Renaming SourceSearch classes to GlobalSearch

pull/3372/head
Jay 4 years ago
parent b809f57950
commit f046f12311

@ -58,7 +58,7 @@ import eu.kanade.tachiyomi.ui.main.RootSearchInterface
import eu.kanade.tachiyomi.ui.manga.MangaDetailsController
import eu.kanade.tachiyomi.ui.migration.manga.design.PreMigrationController
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchController
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController
import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.launchUI
@ -944,7 +944,7 @@ class LibraryController(
}
override fun globalSearch(query: String) {
router.pushController(SourceSearchController(query).withFadeTransaction())
router.pushController(GlobalSearchController(query).withFadeTransaction())
}
override fun onActionStateChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int) {

@ -7,7 +7,7 @@ import com.bluelinelabs.conductor.Controller
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
import eu.kanade.tachiyomi.ui.base.controller.DialogController
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchController
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.withFadeTransaction
import kotlinx.android.synthetic.main.main_activity.*
@ -67,7 +67,7 @@ class SearchActivity : MainActivity() {
// Get the search query provided in extras, and if not null, perform a global search with it.
val query = intent.getStringExtra(SearchManager.QUERY)
if (query != null && query.isNotEmpty()) {
router.replaceTopController(SourceSearchController(query).withFadeTransaction())
router.replaceTopController(GlobalSearchController(query).withFadeTransaction())
}
}
INTENT_SEARCH -> {
@ -77,7 +77,7 @@ class SearchActivity : MainActivity() {
if (router.backstackSize > 1) {
router.popToRoot()
}
router.replaceTopController(SourceSearchController(query, filter).withFadeTransaction())
router.replaceTopController(GlobalSearchController(query, filter).withFadeTransaction())
}
}
else -> return false

@ -88,7 +88,7 @@ import eu.kanade.tachiyomi.ui.migration.manga.design.PreMigrationController
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
import eu.kanade.tachiyomi.ui.source.SourceController
import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchController
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
import eu.kanade.tachiyomi.util.storage.getUriCompat
import eu.kanade.tachiyomi.util.system.ThemeUtil
@ -1011,7 +1011,7 @@ class MangaDetailsController : BaseController,
override fun globalSearch(text: String) {
if (isNotOnline()) return
router.pushController(SourceSearchController(text).withFadeTransaction())
router.pushController(GlobalSearchController(text).withFadeTransaction())
}
override fun showChapterFilter() {

@ -15,8 +15,8 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.ui.base.controller.DialogController
import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchController
import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchPresenter
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchPresenter
import eu.kanade.tachiyomi.ui.main.BottomNavBarInterface
import eu.kanade.tachiyomi.ui.migration.manga.process.MigrationListController
import eu.kanade.tachiyomi.util.view.withFadeTransaction
@ -24,7 +24,7 @@ import uy.kohesive.injekt.injectLazy
class SearchController(
private var manga: Manga? = null
) : SourceSearchController(manga?.title), BottomNavBarInterface {
) : GlobalSearchController(manga?.title), BottomNavBarInterface {
private var newManga: Manga? = null
private var progress = 1
@ -44,7 +44,7 @@ class SearchController(
return super.getTitle()
}
override fun createPresenter(): SourceSearchPresenter {
override fun createPresenter(): GlobalSearchPresenter {
return SearchPresenter(initialQuery, manga!!)
}

@ -2,14 +2,14 @@ package eu.kanade.tachiyomi.ui.migration
import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchCardItem
import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchItem
import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchPresenter
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchMangaItem
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchItem
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchPresenter
class SearchPresenter(
initialQuery: String? = "",
private val manga: Manga
) : SourceSearchPresenter(initialQuery) {
) : GlobalSearchPresenter(initialQuery) {
override fun getEnabledSources(): List<CatalogueSource> {
// Put the source of the selected manga at the top
@ -17,8 +17,8 @@ class SearchPresenter(
.sortedByDescending { it.id == manga.source }
}
override fun createCatalogueSearchItem(source: CatalogueSource, results: List<SourceSearchCardItem>?): SourceSearchItem {
override fun createCatalogueSearchItem(source: CatalogueSource, results: List<GlobalSearchMangaItem>?): GlobalSearchItem {
// Set the catalogue search item as highlighted if the source matches that of the selected manga
return SourceSearchItem(source, results, source.id == manga.source)
return GlobalSearchItem(source, results, source.id == manga.source)
}
}

@ -30,7 +30,7 @@ import eu.kanade.tachiyomi.ui.main.MainActivity
import eu.kanade.tachiyomi.ui.main.RootSearchInterface
import eu.kanade.tachiyomi.ui.setting.SettingsSourcesController
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController
import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchController
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController
import eu.kanade.tachiyomi.ui.source.latest.LatestUpdatesController
import eu.kanade.tachiyomi.util.view.applyWindowInsetsForRootController
import eu.kanade.tachiyomi.util.view.collapse
@ -333,7 +333,7 @@ class SourceController : NucleusController<SourcePresenter>(),
}
private fun performGlobalSearch(query: String) {
router.pushController(SourceSearchController(query).withFadeTransaction())
router.pushController(GlobalSearchController(query).withFadeTransaction())
}
/**

@ -8,10 +8,10 @@ import eu.davidea.flexibleadapter.FlexibleAdapter
/**
* Adapter that holds the search cards.
*
* @param controller instance of [SourceSearchController].
* @param controller instance of [GlobalSearchController].
*/
class SourceSearchAdapter(val controller: SourceSearchController) :
FlexibleAdapter<SourceSearchItem>(null, controller, true) {
class GlobalSearchAdapter(val controller: GlobalSearchController) :
FlexibleAdapter<GlobalSearchItem>(null, controller, true) {
/**
* Bundle where the view state of the holders is saved.

@ -6,10 +6,10 @@ import eu.kanade.tachiyomi.data.database.models.Manga
/**
* Adapter that holds the manga items from search results.
*
* @param controller instance of [SourceSearchController].
* @param controller instance of [GlobalSearchController].
*/
class SourceSearchCardAdapter(controller: SourceSearchController) :
FlexibleAdapter<SourceSearchCardItem>(null, controller, true) {
class GlobalSearchCardAdapter(controller: GlobalSearchController) :
FlexibleAdapter<GlobalSearchMangaItem>(null, controller, true) {
/**
* Listen for browse item clicks.
@ -18,7 +18,7 @@ class SourceSearchCardAdapter(controller: SourceSearchController) :
/**
* Listener which should be called when user clicks browse.
* Note: Should only be handled by [SourceSearchController]
* Note: Should only be handled by [GlobalSearchController]
*/
interface OnMangaClickListener {
fun onMangaClick(manga: Manga)

@ -22,19 +22,19 @@ import kotlinx.android.synthetic.main.source_global_search_controller.*
/**
* This controller shows and manages the different search result in global search.
* This controller should only handle UI actions, IO actions should be done by [SourceSearchPresenter]
* [SourceSearchCardAdapter.OnMangaClickListener] called when manga is clicked in global search
* This controller should only handle UI actions, IO actions should be done by [GlobalSearchPresenter]
* [GlobalSearchCardAdapter.OnMangaClickListener] called when manga is clicked in global search
*/
open class SourceSearchController(
open class GlobalSearchController(
protected val initialQuery: String? = null,
protected val extensionFilter: String? = null
) : NucleusController<SourceSearchPresenter>(),
SourceSearchCardAdapter.OnMangaClickListener {
) : NucleusController<GlobalSearchPresenter>(),
GlobalSearchCardAdapter.OnMangaClickListener {
/**
* Adapter containing search results grouped by lang.
*/
protected var adapter: SourceSearchAdapter? = null
protected var adapter: GlobalSearchAdapter? = null
private var customTitle: String? = null
@ -66,12 +66,12 @@ open class SourceSearchController(
}
/**
* Create the [SourceSearchPresenter] used in controller.
* Create the [GlobalSearchPresenter] used in controller.
*
* @return instance of [SourceSearchPresenter]
* @return instance of [GlobalSearchPresenter]
*/
override fun createPresenter(): SourceSearchPresenter {
return SourceSearchPresenter(initialQuery, extensionFilter)
override fun createPresenter(): GlobalSearchPresenter {
return GlobalSearchPresenter(initialQuery, extensionFilter)
}
/**
@ -137,7 +137,7 @@ open class SourceSearchController(
*/
override fun onViewCreated(view: View) {
super.onViewCreated(view)
adapter = SourceSearchAdapter(this)
adapter = GlobalSearchAdapter(this)
recycler.updatePaddingRelative(
top = (activity?.toolbar?.height ?: 0) +
@ -175,13 +175,13 @@ open class SourceSearchController(
* @param source used to find holder containing source
* @return the holder of the manga or null if it's not bound.
*/
private fun getHolder(source: CatalogueSource): SourceSearchHolder? {
private fun getHolder(source: CatalogueSource): GlobalSearchHolder? {
val adapter = adapter ?: return null
adapter.allBoundViewHolders.forEach { holder ->
val item = adapter.getItem(holder.adapterPosition)
if (item != null && source.id == item.source.id) {
return holder as SourceSearchHolder
return holder as GlobalSearchHolder
}
}
@ -193,7 +193,7 @@ open class SourceSearchController(
*
* @param searchResult result of search.
*/
fun setItems(searchResult: List<SourceSearchItem>) {
fun setItems(searchResult: List<GlobalSearchItem>) {
if (extensionFilter != null) {
val results = searchResult.first().results
if (results != null && results.size == 1) {

@ -8,20 +8,20 @@ import eu.kanade.tachiyomi.util.view.visible
import kotlinx.android.synthetic.main.source_global_search_controller_card.*
/**
* Holder that binds the [SourceSearchItem] containing catalogue cards.
* Holder that binds the [GlobalSearchItem] containing catalogue cards.
*
* @param view view of [SourceSearchItem]
* @param adapter instance of [SourceSearchAdapter]
* @param view view of [GlobalSearchItem]
* @param adapter instance of [GlobalSearchAdapter]
*/
class SourceSearchHolder(view: View, val adapter: SourceSearchAdapter) :
class GlobalSearchHolder(view: View, val adapter: GlobalSearchAdapter) :
BaseFlexibleViewHolder(view, adapter) {
/**
* Adapter containing manga from search results.
*/
private val mangaAdapter = SourceSearchCardAdapter(adapter.controller)
private val mangaAdapter = GlobalSearchCardAdapter(adapter.controller)
private var lastBoundResults: List<SourceSearchCardItem>? = null
private var lastBoundResults: List<GlobalSearchMangaItem>? = null
init {
// Set layout horizontal.
@ -35,7 +35,7 @@ class SourceSearchHolder(view: View, val adapter: SourceSearchAdapter) :
*
* @param item item of card.
*/
fun bind(item: SourceSearchItem) {
fun bind(item: GlobalSearchItem) {
val source = item.source
val results = item.results
@ -81,11 +81,11 @@ class SourceSearchHolder(view: View, val adapter: SourceSearchAdapter) :
* @param manga the manga to find.
* @return the holder of the manga or null if it's not bound.
*/
private fun getHolder(manga: Manga): SourceSearchCardHolder? {
private fun getHolder(manga: Manga): GlobalSearchMangaHolder? {
mangaAdapter.allBoundViewHolders.forEach { holder ->
val item = mangaAdapter.getItem(holder.adapterPosition)
if (item != null && item.manga.id!! == manga.id!!) {
return holder as SourceSearchCardHolder
return holder as GlobalSearchMangaHolder
}
}

@ -15,8 +15,8 @@ import eu.kanade.tachiyomi.source.CatalogueSource
* @param results the search results.
* @param highlighted whether this search item should be highlighted/marked in the catalogue search view.
*/
class SourceSearchItem(val source: CatalogueSource, val results: List<SourceSearchCardItem>?, val highlighted: Boolean = false) :
AbstractFlexibleItem<SourceSearchHolder>() {
class GlobalSearchItem(val source: CatalogueSource, val results: List<GlobalSearchMangaItem>?, val highlighted: Boolean = false) :
AbstractFlexibleItem<GlobalSearchHolder>() {
/**
* Set view.
@ -28,12 +28,12 @@ class SourceSearchItem(val source: CatalogueSource, val results: List<SourceSear
}
/**
* Create view holder (see [SourceSearchAdapter].
* Create view holder (see [GlobalSearchAdapter].
*
* @return holder of view.
*/
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): SourceSearchHolder {
return SourceSearchHolder(view, adapter as SourceSearchAdapter)
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): GlobalSearchHolder {
return GlobalSearchHolder(view, adapter as GlobalSearchAdapter)
}
/**
@ -41,7 +41,7 @@ class SourceSearchItem(val source: CatalogueSource, val results: List<SourceSear
*/
override fun bindViewHolder(
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>,
holder: SourceSearchHolder,
holder: GlobalSearchHolder,
position: Int,
payloads: MutableList<Any?>?
) {
@ -54,7 +54,7 @@ class SourceSearchItem(val source: CatalogueSource, val results: List<SourceSear
* @return items are equal?
*/
override fun equals(other: Any?): Boolean {
if (other is SourceSearchItem) {
if (other is GlobalSearchItem) {
return source.id == other.source.id
}
return false

@ -9,7 +9,7 @@ import eu.kanade.tachiyomi.util.view.visibleIf
import eu.kanade.tachiyomi.widget.StateImageViewTarget
import kotlinx.android.synthetic.main.source_global_search_controller_card_item.*
class SourceSearchCardHolder(view: View, adapter: SourceSearchCardAdapter) :
class GlobalSearchMangaHolder(view: View, adapter: GlobalSearchCardAdapter) :
BaseFlexibleViewHolder(view, adapter) {
init {

@ -8,19 +8,19 @@ import eu.davidea.flexibleadapter.items.IFlexible
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Manga
class SourceSearchCardItem(val manga: Manga) : AbstractFlexibleItem<SourceSearchCardHolder>() {
class GlobalSearchMangaItem(val manga: Manga) : AbstractFlexibleItem<GlobalSearchMangaHolder>() {
override fun getLayoutRes(): Int {
return R.layout.source_global_search_controller_card_item
}
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): SourceSearchCardHolder {
return SourceSearchCardHolder(view, adapter as SourceSearchCardAdapter)
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): GlobalSearchMangaHolder {
return GlobalSearchMangaHolder(view, adapter as GlobalSearchCardAdapter)
}
override fun bindViewHolder(
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>,
holder: SourceSearchCardHolder,
holder: GlobalSearchMangaHolder,
position: Int,
payloads: MutableList<Any?>?
) {
@ -28,7 +28,7 @@ class SourceSearchCardItem(val manga: Manga) : AbstractFlexibleItem<SourceSearch
}
override fun equals(other: Any?): Boolean {
if (other is SourceSearchCardItem) {
if (other is GlobalSearchMangaItem) {
return manga.id == other.manga.id
}
return false

@ -25,20 +25,20 @@ import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy
/**
* Presenter of [SourceSearchController]
* Presenter of [GlobalSearchController]
* Function calls should be done from here. UI calls should be done from the controller.
*
* @param sourceManager manages the different sources.
* @param db manages the database calls.
* @param preferencesHelper manages the preference calls.
*/
open class SourceSearchPresenter(
open class GlobalSearchPresenter(
private val initialQuery: String? = "",
private val initialExtensionFilter: String? = null,
val sourceManager: SourceManager = Injekt.get(),
val db: DatabaseHelper = Injekt.get(),
private val preferencesHelper: PreferencesHelper = Injekt.get()
) : BasePresenter<SourceSearchController>() {
) : BasePresenter<GlobalSearchController>() {
/**
* Enabled sources.
@ -73,7 +73,7 @@ open class SourceSearchPresenter(
override fun onCreate(savedState: Bundle?) {
super.onCreate(savedState)
extensionFilter = savedState?.getString(SourceSearchPresenter::extensionFilter.name)
extensionFilter = savedState?.getString(GlobalSearchPresenter::extensionFilter.name)
?: initialExtensionFilter
// Perform a search with previous or initial state
@ -90,7 +90,7 @@ open class SourceSearchPresenter(
override fun onSave(state: Bundle) {
state.putString(BrowseSourcePresenter::query.name, query)
state.putString(SourceSearchPresenter::extensionFilter.name, extensionFilter)
state.putString(GlobalSearchPresenter::extensionFilter.name, extensionFilter)
super.onSave(state)
}
@ -134,9 +134,9 @@ open class SourceSearchPresenter(
*/
protected open fun createCatalogueSearchItem(
source: CatalogueSource,
results: List<SourceSearchCardItem>?
): SourceSearchItem {
return SourceSearchItem(source, results)
results: List<GlobalSearchMangaItem>?
): GlobalSearchItem {
return GlobalSearchItem(source, results)
}
/**
@ -180,7 +180,7 @@ open class SourceSearchPresenter(
.map {
createCatalogueSearchItem(
source,
it.map { SourceSearchCardItem(it) })
it.map { GlobalSearchMangaItem(it) })
}
}, 5).observeOn(AndroidSchedulers.mainThread())
// Update matching source with the obtained results
Loading…
Cancel
Save