mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-14 04:45:07 +01:00
Renaming SourceSearch classes to GlobalSearch
This commit is contained in:
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.manga.MangaDetailsController
|
||||||
import eu.kanade.tachiyomi.ui.migration.manga.design.PreMigrationController
|
import eu.kanade.tachiyomi.ui.migration.manga.design.PreMigrationController
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
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.dpToPx
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import eu.kanade.tachiyomi.util.system.launchUI
|
import eu.kanade.tachiyomi.util.system.launchUI
|
||||||
@ -944,7 +944,7 @@ class LibraryController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun globalSearch(query: String) {
|
override fun globalSearch(query: String) {
|
||||||
router.pushController(SourceSearchController(query).withFadeTransaction())
|
router.pushController(GlobalSearchController(query).withFadeTransaction())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActionStateChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int) {
|
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.data.notification.NotificationReceiver
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||||
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
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.gone
|
||||||
import eu.kanade.tachiyomi.util.view.withFadeTransaction
|
import eu.kanade.tachiyomi.util.view.withFadeTransaction
|
||||||
import kotlinx.android.synthetic.main.main_activity.*
|
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.
|
// Get the search query provided in extras, and if not null, perform a global search with it.
|
||||||
val query = intent.getStringExtra(SearchManager.QUERY)
|
val query = intent.getStringExtra(SearchManager.QUERY)
|
||||||
if (query != null && query.isNotEmpty()) {
|
if (query != null && query.isNotEmpty()) {
|
||||||
router.replaceTopController(SourceSearchController(query).withFadeTransaction())
|
router.replaceTopController(GlobalSearchController(query).withFadeTransaction())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
INTENT_SEARCH -> {
|
INTENT_SEARCH -> {
|
||||||
@ -77,7 +77,7 @@ class SearchActivity : MainActivity() {
|
|||||||
if (router.backstackSize > 1) {
|
if (router.backstackSize > 1) {
|
||||||
router.popToRoot()
|
router.popToRoot()
|
||||||
}
|
}
|
||||||
router.replaceTopController(SourceSearchController(query, filter).withFadeTransaction())
|
router.replaceTopController(GlobalSearchController(query, filter).withFadeTransaction())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> return false
|
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.reader.ReaderActivity
|
||||||
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
||||||
import eu.kanade.tachiyomi.ui.source.SourceController
|
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.ui.webview.WebViewActivity
|
||||||
import eu.kanade.tachiyomi.util.storage.getUriCompat
|
import eu.kanade.tachiyomi.util.storage.getUriCompat
|
||||||
import eu.kanade.tachiyomi.util.system.ThemeUtil
|
import eu.kanade.tachiyomi.util.system.ThemeUtil
|
||||||
@ -1011,7 +1011,7 @@ class MangaDetailsController : BaseController,
|
|||||||
|
|
||||||
override fun globalSearch(text: String) {
|
override fun globalSearch(text: String) {
|
||||||
if (isNotOnline()) return
|
if (isNotOnline()) return
|
||||||
router.pushController(SourceSearchController(text).withFadeTransaction())
|
router.pushController(GlobalSearchController(text).withFadeTransaction())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showChapterFilter() {
|
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.data.preference.getOrDefault
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
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.GlobalSearchController
|
||||||
import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchPresenter
|
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchPresenter
|
||||||
import eu.kanade.tachiyomi.ui.main.BottomNavBarInterface
|
import eu.kanade.tachiyomi.ui.main.BottomNavBarInterface
|
||||||
import eu.kanade.tachiyomi.ui.migration.manga.process.MigrationListController
|
import eu.kanade.tachiyomi.ui.migration.manga.process.MigrationListController
|
||||||
import eu.kanade.tachiyomi.util.view.withFadeTransaction
|
import eu.kanade.tachiyomi.util.view.withFadeTransaction
|
||||||
@ -24,7 +24,7 @@ import uy.kohesive.injekt.injectLazy
|
|||||||
|
|
||||||
class SearchController(
|
class SearchController(
|
||||||
private var manga: Manga? = null
|
private var manga: Manga? = null
|
||||||
) : SourceSearchController(manga?.title), BottomNavBarInterface {
|
) : GlobalSearchController(manga?.title), BottomNavBarInterface {
|
||||||
|
|
||||||
private var newManga: Manga? = null
|
private var newManga: Manga? = null
|
||||||
private var progress = 1
|
private var progress = 1
|
||||||
@ -44,7 +44,7 @@ class SearchController(
|
|||||||
return super.getTitle()
|
return super.getTitle()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createPresenter(): SourceSearchPresenter {
|
override fun createPresenter(): GlobalSearchPresenter {
|
||||||
return SearchPresenter(initialQuery, manga!!)
|
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.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||||
import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchCardItem
|
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchMangaItem
|
||||||
import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchItem
|
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchItem
|
||||||
import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchPresenter
|
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchPresenter
|
||||||
|
|
||||||
class SearchPresenter(
|
class SearchPresenter(
|
||||||
initialQuery: String? = "",
|
initialQuery: String? = "",
|
||||||
private val manga: Manga
|
private val manga: Manga
|
||||||
) : SourceSearchPresenter(initialQuery) {
|
) : GlobalSearchPresenter(initialQuery) {
|
||||||
|
|
||||||
override fun getEnabledSources(): List<CatalogueSource> {
|
override fun getEnabledSources(): List<CatalogueSource> {
|
||||||
// Put the source of the selected manga at the top
|
// Put the source of the selected manga at the top
|
||||||
@ -17,8 +17,8 @@ class SearchPresenter(
|
|||||||
.sortedByDescending { it.id == manga.source }
|
.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
|
// 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.main.RootSearchInterface
|
||||||
import eu.kanade.tachiyomi.ui.setting.SettingsSourcesController
|
import eu.kanade.tachiyomi.ui.setting.SettingsSourcesController
|
||||||
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController
|
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.ui.source.latest.LatestUpdatesController
|
||||||
import eu.kanade.tachiyomi.util.view.applyWindowInsetsForRootController
|
import eu.kanade.tachiyomi.util.view.applyWindowInsetsForRootController
|
||||||
import eu.kanade.tachiyomi.util.view.collapse
|
import eu.kanade.tachiyomi.util.view.collapse
|
||||||
@ -333,7 +333,7 @@ class SourceController : NucleusController<SourcePresenter>(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun performGlobalSearch(query: String) {
|
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.
|
* Adapter that holds the search cards.
|
||||||
*
|
*
|
||||||
* @param controller instance of [SourceSearchController].
|
* @param controller instance of [GlobalSearchController].
|
||||||
*/
|
*/
|
||||||
class SourceSearchAdapter(val controller: SourceSearchController) :
|
class GlobalSearchAdapter(val controller: GlobalSearchController) :
|
||||||
FlexibleAdapter<SourceSearchItem>(null, controller, true) {
|
FlexibleAdapter<GlobalSearchItem>(null, controller, true) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bundle where the view state of the holders is saved.
|
* 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.
|
* Adapter that holds the manga items from search results.
|
||||||
*
|
*
|
||||||
* @param controller instance of [SourceSearchController].
|
* @param controller instance of [GlobalSearchController].
|
||||||
*/
|
*/
|
||||||
class SourceSearchCardAdapter(controller: SourceSearchController) :
|
class GlobalSearchCardAdapter(controller: GlobalSearchController) :
|
||||||
FlexibleAdapter<SourceSearchCardItem>(null, controller, true) {
|
FlexibleAdapter<GlobalSearchMangaItem>(null, controller, true) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listen for browse item clicks.
|
* Listen for browse item clicks.
|
||||||
@ -18,7 +18,7 @@ class SourceSearchCardAdapter(controller: SourceSearchController) :
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Listener which should be called when user clicks browse.
|
* 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 {
|
interface OnMangaClickListener {
|
||||||
fun onMangaClick(manga: Manga)
|
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 shows and manages the different search result in global search.
|
||||||
* This controller should only handle UI actions, IO actions should be done by [SourceSearchPresenter]
|
* This controller should only handle UI actions, IO actions should be done by [GlobalSearchPresenter]
|
||||||
* [SourceSearchCardAdapter.OnMangaClickListener] called when manga is clicked in global search
|
* [GlobalSearchCardAdapter.OnMangaClickListener] called when manga is clicked in global search
|
||||||
*/
|
*/
|
||||||
open class SourceSearchController(
|
open class GlobalSearchController(
|
||||||
protected val initialQuery: String? = null,
|
protected val initialQuery: String? = null,
|
||||||
protected val extensionFilter: String? = null
|
protected val extensionFilter: String? = null
|
||||||
) : NucleusController<SourceSearchPresenter>(),
|
) : NucleusController<GlobalSearchPresenter>(),
|
||||||
SourceSearchCardAdapter.OnMangaClickListener {
|
GlobalSearchCardAdapter.OnMangaClickListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter containing search results grouped by lang.
|
* Adapter containing search results grouped by lang.
|
||||||
*/
|
*/
|
||||||
protected var adapter: SourceSearchAdapter? = null
|
protected var adapter: GlobalSearchAdapter? = null
|
||||||
|
|
||||||
private var customTitle: String? = 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 {
|
override fun createPresenter(): GlobalSearchPresenter {
|
||||||
return SourceSearchPresenter(initialQuery, extensionFilter)
|
return GlobalSearchPresenter(initialQuery, extensionFilter)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -137,7 +137,7 @@ open class SourceSearchController(
|
|||||||
*/
|
*/
|
||||||
override fun onViewCreated(view: View) {
|
override fun onViewCreated(view: View) {
|
||||||
super.onViewCreated(view)
|
super.onViewCreated(view)
|
||||||
adapter = SourceSearchAdapter(this)
|
adapter = GlobalSearchAdapter(this)
|
||||||
|
|
||||||
recycler.updatePaddingRelative(
|
recycler.updatePaddingRelative(
|
||||||
top = (activity?.toolbar?.height ?: 0) +
|
top = (activity?.toolbar?.height ?: 0) +
|
||||||
@ -175,13 +175,13 @@ open class SourceSearchController(
|
|||||||
* @param source used to find holder containing source
|
* @param source used to find holder containing source
|
||||||
* @return the holder of the manga or null if it's not bound.
|
* @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
|
val adapter = adapter ?: return null
|
||||||
|
|
||||||
adapter.allBoundViewHolders.forEach { holder ->
|
adapter.allBoundViewHolders.forEach { holder ->
|
||||||
val item = adapter.getItem(holder.adapterPosition)
|
val item = adapter.getItem(holder.adapterPosition)
|
||||||
if (item != null && source.id == item.source.id) {
|
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.
|
* @param searchResult result of search.
|
||||||
*/
|
*/
|
||||||
fun setItems(searchResult: List<SourceSearchItem>) {
|
fun setItems(searchResult: List<GlobalSearchItem>) {
|
||||||
if (extensionFilter != null) {
|
if (extensionFilter != null) {
|
||||||
val results = searchResult.first().results
|
val results = searchResult.first().results
|
||||||
if (results != null && results.size == 1) {
|
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.*
|
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 view view of [GlobalSearchItem]
|
||||||
* @param adapter instance of [SourceSearchAdapter]
|
* @param adapter instance of [GlobalSearchAdapter]
|
||||||
*/
|
*/
|
||||||
class SourceSearchHolder(view: View, val adapter: SourceSearchAdapter) :
|
class GlobalSearchHolder(view: View, val adapter: GlobalSearchAdapter) :
|
||||||
BaseFlexibleViewHolder(view, adapter) {
|
BaseFlexibleViewHolder(view, adapter) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter containing manga from search results.
|
* 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 {
|
init {
|
||||||
// Set layout horizontal.
|
// Set layout horizontal.
|
||||||
@ -35,7 +35,7 @@ class SourceSearchHolder(view: View, val adapter: SourceSearchAdapter) :
|
|||||||
*
|
*
|
||||||
* @param item item of card.
|
* @param item item of card.
|
||||||
*/
|
*/
|
||||||
fun bind(item: SourceSearchItem) {
|
fun bind(item: GlobalSearchItem) {
|
||||||
val source = item.source
|
val source = item.source
|
||||||
val results = item.results
|
val results = item.results
|
||||||
|
|
||||||
@ -81,11 +81,11 @@ class SourceSearchHolder(view: View, val adapter: SourceSearchAdapter) :
|
|||||||
* @param manga the manga to find.
|
* @param manga the manga to find.
|
||||||
* @return the holder of the manga or null if it's not bound.
|
* @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 ->
|
mangaAdapter.allBoundViewHolders.forEach { holder ->
|
||||||
val item = mangaAdapter.getItem(holder.adapterPosition)
|
val item = mangaAdapter.getItem(holder.adapterPosition)
|
||||||
if (item != null && item.manga.id!! == manga.id!!) {
|
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 results the search results.
|
||||||
* @param highlighted whether this search item should be highlighted/marked in the catalogue search view.
|
* @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) :
|
class GlobalSearchItem(val source: CatalogueSource, val results: List<GlobalSearchMangaItem>?, val highlighted: Boolean = false) :
|
||||||
AbstractFlexibleItem<SourceSearchHolder>() {
|
AbstractFlexibleItem<GlobalSearchHolder>() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set view.
|
* 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.
|
* @return holder of view.
|
||||||
*/
|
*/
|
||||||
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): SourceSearchHolder {
|
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): GlobalSearchHolder {
|
||||||
return SourceSearchHolder(view, adapter as SourceSearchAdapter)
|
return GlobalSearchHolder(view, adapter as GlobalSearchAdapter)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,7 +41,7 @@ class SourceSearchItem(val source: CatalogueSource, val results: List<SourceSear
|
|||||||
*/
|
*/
|
||||||
override fun bindViewHolder(
|
override fun bindViewHolder(
|
||||||
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>,
|
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>,
|
||||||
holder: SourceSearchHolder,
|
holder: GlobalSearchHolder,
|
||||||
position: Int,
|
position: Int,
|
||||||
payloads: MutableList<Any?>?
|
payloads: MutableList<Any?>?
|
||||||
) {
|
) {
|
||||||
@ -54,7 +54,7 @@ class SourceSearchItem(val source: CatalogueSource, val results: List<SourceSear
|
|||||||
* @return items are equal?
|
* @return items are equal?
|
||||||
*/
|
*/
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
if (other is SourceSearchItem) {
|
if (other is GlobalSearchItem) {
|
||||||
return source.id == other.source.id
|
return source.id == other.source.id
|
||||||
}
|
}
|
||||||
return false
|
return false
|
@ -9,7 +9,7 @@ import eu.kanade.tachiyomi.util.view.visibleIf
|
|||||||
import eu.kanade.tachiyomi.widget.StateImageViewTarget
|
import eu.kanade.tachiyomi.widget.StateImageViewTarget
|
||||||
import kotlinx.android.synthetic.main.source_global_search_controller_card_item.*
|
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) {
|
BaseFlexibleViewHolder(view, adapter) {
|
||||||
|
|
||||||
init {
|
init {
|
@ -8,19 +8,19 @@ import eu.davidea.flexibleadapter.items.IFlexible
|
|||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
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 {
|
override fun getLayoutRes(): Int {
|
||||||
return R.layout.source_global_search_controller_card_item
|
return R.layout.source_global_search_controller_card_item
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): SourceSearchCardHolder {
|
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): GlobalSearchMangaHolder {
|
||||||
return SourceSearchCardHolder(view, adapter as SourceSearchCardAdapter)
|
return GlobalSearchMangaHolder(view, adapter as GlobalSearchCardAdapter)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun bindViewHolder(
|
override fun bindViewHolder(
|
||||||
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>,
|
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>,
|
||||||
holder: SourceSearchCardHolder,
|
holder: GlobalSearchMangaHolder,
|
||||||
position: Int,
|
position: Int,
|
||||||
payloads: MutableList<Any?>?
|
payloads: MutableList<Any?>?
|
||||||
) {
|
) {
|
||||||
@ -28,7 +28,7 @@ class SourceSearchCardItem(val manga: Manga) : AbstractFlexibleItem<SourceSearch
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
if (other is SourceSearchCardItem) {
|
if (other is GlobalSearchMangaItem) {
|
||||||
return manga.id == other.manga.id
|
return manga.id == other.manga.id
|
||||||
}
|
}
|
||||||
return false
|
return false
|
@ -25,20 +25,20 @@ import uy.kohesive.injekt.api.get
|
|||||||
import uy.kohesive.injekt.injectLazy
|
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.
|
* Function calls should be done from here. UI calls should be done from the controller.
|
||||||
*
|
*
|
||||||
* @param sourceManager manages the different sources.
|
* @param sourceManager manages the different sources.
|
||||||
* @param db manages the database calls.
|
* @param db manages the database calls.
|
||||||
* @param preferencesHelper manages the preference calls.
|
* @param preferencesHelper manages the preference calls.
|
||||||
*/
|
*/
|
||||||
open class SourceSearchPresenter(
|
open class GlobalSearchPresenter(
|
||||||
private val initialQuery: String? = "",
|
private val initialQuery: String? = "",
|
||||||
private val initialExtensionFilter: String? = null,
|
private val initialExtensionFilter: String? = null,
|
||||||
val sourceManager: SourceManager = Injekt.get(),
|
val sourceManager: SourceManager = Injekt.get(),
|
||||||
val db: DatabaseHelper = Injekt.get(),
|
val db: DatabaseHelper = Injekt.get(),
|
||||||
private val preferencesHelper: PreferencesHelper = Injekt.get()
|
private val preferencesHelper: PreferencesHelper = Injekt.get()
|
||||||
) : BasePresenter<SourceSearchController>() {
|
) : BasePresenter<GlobalSearchController>() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enabled sources.
|
* Enabled sources.
|
||||||
@ -73,7 +73,7 @@ open class SourceSearchPresenter(
|
|||||||
override fun onCreate(savedState: Bundle?) {
|
override fun onCreate(savedState: Bundle?) {
|
||||||
super.onCreate(savedState)
|
super.onCreate(savedState)
|
||||||
|
|
||||||
extensionFilter = savedState?.getString(SourceSearchPresenter::extensionFilter.name)
|
extensionFilter = savedState?.getString(GlobalSearchPresenter::extensionFilter.name)
|
||||||
?: initialExtensionFilter
|
?: initialExtensionFilter
|
||||||
|
|
||||||
// Perform a search with previous or initial state
|
// Perform a search with previous or initial state
|
||||||
@ -90,7 +90,7 @@ open class SourceSearchPresenter(
|
|||||||
|
|
||||||
override fun onSave(state: Bundle) {
|
override fun onSave(state: Bundle) {
|
||||||
state.putString(BrowseSourcePresenter::query.name, query)
|
state.putString(BrowseSourcePresenter::query.name, query)
|
||||||
state.putString(SourceSearchPresenter::extensionFilter.name, extensionFilter)
|
state.putString(GlobalSearchPresenter::extensionFilter.name, extensionFilter)
|
||||||
super.onSave(state)
|
super.onSave(state)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,9 +134,9 @@ open class SourceSearchPresenter(
|
|||||||
*/
|
*/
|
||||||
protected open fun createCatalogueSearchItem(
|
protected open fun createCatalogueSearchItem(
|
||||||
source: CatalogueSource,
|
source: CatalogueSource,
|
||||||
results: List<SourceSearchCardItem>?
|
results: List<GlobalSearchMangaItem>?
|
||||||
): SourceSearchItem {
|
): GlobalSearchItem {
|
||||||
return SourceSearchItem(source, results)
|
return GlobalSearchItem(source, results)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -180,7 +180,7 @@ open class SourceSearchPresenter(
|
|||||||
.map {
|
.map {
|
||||||
createCatalogueSearchItem(
|
createCatalogueSearchItem(
|
||||||
source,
|
source,
|
||||||
it.map { SourceSearchCardItem(it) })
|
it.map { GlobalSearchMangaItem(it) })
|
||||||
}
|
}
|
||||||
}, 5).observeOn(AndroidSchedulers.mainThread())
|
}, 5).observeOn(AndroidSchedulers.mainThread())
|
||||||
// Update matching source with the obtained results
|
// Update matching source with the obtained results
|
Loading…
Reference in New Issue
Block a user