mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 22:59:18 +01:00
Rename catalogue classes/layouts -> source
This commit is contained in:
parent
c784d24fa6
commit
a1e7592bd8
@ -1,3 +0,0 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.browse
|
||||
|
||||
class NoResultsException : Exception()
|
@ -6,15 +6,15 @@ import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.kanade.tachiyomi.data.glide.GlideApp
|
||||
import eu.kanade.tachiyomi.source.LocalSource
|
||||
import eu.kanade.tachiyomi.util.view.visibleIf
|
||||
import kotlinx.android.synthetic.main.catalogue_grid_item.download_text
|
||||
import kotlinx.android.synthetic.main.catalogue_grid_item.local_text
|
||||
import kotlinx.android.synthetic.main.catalogue_grid_item.thumbnail
|
||||
import kotlinx.android.synthetic.main.catalogue_grid_item.title
|
||||
import kotlinx.android.synthetic.main.catalogue_grid_item.unread_text
|
||||
import kotlinx.android.synthetic.main.source_grid_item.download_text
|
||||
import kotlinx.android.synthetic.main.source_grid_item.local_text
|
||||
import kotlinx.android.synthetic.main.source_grid_item.thumbnail
|
||||
import kotlinx.android.synthetic.main.source_grid_item.title
|
||||
import kotlinx.android.synthetic.main.source_grid_item.unread_text
|
||||
|
||||
/**
|
||||
* Class used to hold the displayed data of a manga in the library, like the cover or the title.
|
||||
* All the elements from the layout file "item_catalogue_grid" are available in this class.
|
||||
* All the elements from the layout file "item_source_grid" are available in this class.
|
||||
*
|
||||
* @param view the inflated view for this holder.
|
||||
* @param adapter the adapter handling this holder.
|
||||
|
@ -15,8 +15,8 @@ import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
||||
import kotlinx.android.synthetic.main.catalogue_grid_item.view.card
|
||||
import kotlinx.android.synthetic.main.catalogue_grid_item.view.gradient
|
||||
import kotlinx.android.synthetic.main.source_grid_item.view.card
|
||||
import kotlinx.android.synthetic.main.source_grid_item.view.gradient
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
@ -29,9 +29,9 @@ class LibraryItem(val manga: LibraryManga, private val libraryAsList: Preference
|
||||
|
||||
override fun getLayoutRes(): Int {
|
||||
return if (libraryAsList.getOrDefault())
|
||||
R.layout.catalogue_list_item
|
||||
R.layout.source_list_item
|
||||
else
|
||||
R.layout.catalogue_grid_item
|
||||
R.layout.source_grid_item
|
||||
}
|
||||
|
||||
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): LibraryHolder {
|
||||
|
@ -6,11 +6,11 @@ import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.kanade.tachiyomi.data.glide.GlideApp
|
||||
import eu.kanade.tachiyomi.source.LocalSource
|
||||
import eu.kanade.tachiyomi.util.view.visibleIf
|
||||
import kotlinx.android.synthetic.main.catalogue_list_item.download_text
|
||||
import kotlinx.android.synthetic.main.catalogue_list_item.local_text
|
||||
import kotlinx.android.synthetic.main.catalogue_list_item.thumbnail
|
||||
import kotlinx.android.synthetic.main.catalogue_list_item.title
|
||||
import kotlinx.android.synthetic.main.catalogue_list_item.unread_text
|
||||
import kotlinx.android.synthetic.main.source_list_item.download_text
|
||||
import kotlinx.android.synthetic.main.source_list_item.local_text
|
||||
import kotlinx.android.synthetic.main.source_list_item.thumbnail
|
||||
import kotlinx.android.synthetic.main.source_list_item.title
|
||||
import kotlinx.android.synthetic.main.source_list_item.unread_text
|
||||
|
||||
/**
|
||||
* Class used to hold the displayed data of a manga in the library, like the cover or the title.
|
||||
|
@ -21,8 +21,6 @@ import eu.kanade.tachiyomi.ui.base.controller.NoToolbarElevationController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.RootController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.TabbedController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||
import eu.kanade.tachiyomi.ui.catalogue.CatalogueController
|
||||
import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchController
|
||||
import eu.kanade.tachiyomi.ui.download.DownloadController
|
||||
import eu.kanade.tachiyomi.ui.extension.ExtensionController
|
||||
import eu.kanade.tachiyomi.ui.library.LibraryController
|
||||
@ -30,6 +28,8 @@ import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.ui.more.MoreController
|
||||
import eu.kanade.tachiyomi.ui.recent.history.HistoryController
|
||||
import eu.kanade.tachiyomi.ui.recent.updates.UpdatesController
|
||||
import eu.kanade.tachiyomi.ui.source.SourceController
|
||||
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController
|
||||
import java.util.Date
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@ -83,7 +83,7 @@ class MainActivity : BaseActivity() {
|
||||
R.id.nav_library -> setRoot(LibraryController(), id)
|
||||
R.id.nav_updates -> setRoot(UpdatesController(), id)
|
||||
R.id.nav_history -> setRoot(HistoryController(), id)
|
||||
R.id.nav_sources -> setRoot(CatalogueController(), id)
|
||||
R.id.nav_sources -> setRoot(SourceController(), id)
|
||||
R.id.nav_more -> setRoot(MoreController(), id)
|
||||
}
|
||||
} else if (!isHandlingShortcut) {
|
||||
@ -228,7 +228,7 @@ class MainActivity : BaseActivity() {
|
||||
if (router.backstackSize > 1) {
|
||||
router.popToRoot()
|
||||
}
|
||||
router.pushController(CatalogueSearchController(query).withFadeTransaction())
|
||||
router.pushController(GlobalSearchController(query).withFadeTransaction())
|
||||
}
|
||||
}
|
||||
INTENT_SEARCH -> {
|
||||
@ -238,7 +238,7 @@ class MainActivity : BaseActivity() {
|
||||
if (router.backstackSize > 1) {
|
||||
router.popToRoot()
|
||||
}
|
||||
router.pushController(CatalogueSearchController(query, filter).withFadeTransaction())
|
||||
router.pushController(GlobalSearchController(query, filter).withFadeTransaction())
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
|
@ -44,12 +44,12 @@ import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||
import eu.kanade.tachiyomi.ui.catalogue.browse.BrowseCatalogueController
|
||||
import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchController
|
||||
import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog
|
||||
import eu.kanade.tachiyomi.ui.library.LibraryController
|
||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController
|
||||
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController
|
||||
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
||||
import eu.kanade.tachiyomi.util.lang.truncateCenter
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
@ -549,7 +549,7 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
||||
*/
|
||||
private fun performGlobalSearch(query: String) {
|
||||
val router = parentController?.router ?: return
|
||||
router.pushController(CatalogueSearchController(query).withFadeTransaction())
|
||||
router.pushController(GlobalSearchController(query).withFadeTransaction())
|
||||
}
|
||||
|
||||
/**
|
||||
@ -570,7 +570,7 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
||||
router.handleBack()
|
||||
previousController.search(query)
|
||||
}
|
||||
is BrowseCatalogueController -> {
|
||||
is BrowseSourceController -> {
|
||||
router.handleBack()
|
||||
previousController.searchWithQuery(query)
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.kanade.tachiyomi.data.glide.GlideApp
|
||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||
import kotlinx.android.synthetic.main.catalogue_list_item.thumbnail
|
||||
import kotlinx.android.synthetic.main.catalogue_list_item.title
|
||||
import kotlinx.android.synthetic.main.source_list_item.thumbnail
|
||||
import kotlinx.android.synthetic.main.source_list_item.title
|
||||
|
||||
class MangaHolder(
|
||||
private val view: View,
|
||||
|
@ -11,7 +11,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
class MangaItem(val manga: Manga) : AbstractFlexibleItem<MangaHolder>() {
|
||||
|
||||
override fun getLayoutRes(): Int {
|
||||
return R.layout.catalogue_list_item
|
||||
return R.layout.source_list_item
|
||||
}
|
||||
|
||||
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): MangaHolder {
|
||||
|
@ -9,17 +9,17 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.popControllerWithTag
|
||||
import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchController
|
||||
import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchPresenter
|
||||
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController
|
||||
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchPresenter
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class SearchController(
|
||||
private var manga: Manga? = null
|
||||
) : CatalogueSearchController(manga?.title) {
|
||||
) : GlobalSearchController(manga?.title) {
|
||||
|
||||
private var newManga: Manga? = null
|
||||
|
||||
override fun createPresenter(): CatalogueSearchPresenter {
|
||||
override fun createPresenter(): GlobalSearchPresenter {
|
||||
return SearchPresenter(initialQuery, manga!!)
|
||||
}
|
||||
|
||||
|
@ -9,9 +9,9 @@ import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchCardItem
|
||||
import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchItem
|
||||
import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchPresenter
|
||||
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchCardItem
|
||||
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchItem
|
||||
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchPresenter
|
||||
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
|
||||
import rx.Observable
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
@ -20,7 +20,7 @@ import rx.schedulers.Schedulers
|
||||
class SearchPresenter(
|
||||
initialQuery: String? = "",
|
||||
private val manga: Manga
|
||||
) : CatalogueSearchPresenter(initialQuery) {
|
||||
) : GlobalSearchPresenter(initialQuery) {
|
||||
|
||||
private val replacingMangaRelay = BehaviorRelay.create<Boolean>()
|
||||
|
||||
@ -36,9 +36,9 @@ class SearchPresenter(
|
||||
.sortedByDescending { it.id == manga.source }
|
||||
}
|
||||
|
||||
override fun createCatalogueSearchItem(source: CatalogueSource, results: List<CatalogueSearchCardItem>?): CatalogueSearchItem {
|
||||
override fun createCatalogueSearchItem(source: CatalogueSource, results: List<GlobalSearchCardItem>?): GlobalSearchItem {
|
||||
// Set the catalogue search item as highlighted if the source matches that of the selected manga
|
||||
return CatalogueSearchItem(source, results, source.id == manga.source)
|
||||
return GlobalSearchItem(source, results, source.id == manga.source)
|
||||
}
|
||||
|
||||
override fun networkToLocalManga(sManga: SManga, sourceId: Long): Manga {
|
||||
|
@ -7,7 +7,7 @@ import eu.davidea.flexibleadapter.items.AbstractHeaderItem
|
||||
import eu.davidea.flexibleadapter.items.IFlexible
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||
import kotlinx.android.synthetic.main.catalogue_main_controller_card.title
|
||||
import kotlinx.android.synthetic.main.source_main_controller_card.title
|
||||
|
||||
/**
|
||||
* Item that contains the selection header.
|
||||
@ -18,7 +18,7 @@ class SelectionHeader : AbstractHeaderItem<SelectionHeader.Holder>() {
|
||||
* Returns the layout resource of this item.
|
||||
*/
|
||||
override fun getLayoutRes(): Int {
|
||||
return R.layout.catalogue_main_controller_card
|
||||
return R.layout.source_main_controller_card
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -8,11 +8,11 @@ import eu.kanade.tachiyomi.ui.base.holder.SlicedHolder
|
||||
import eu.kanade.tachiyomi.util.view.gone
|
||||
import eu.kanade.tachiyomi.util.view.roundTextIcon
|
||||
import io.github.mthli.slice.Slice
|
||||
import kotlinx.android.synthetic.main.catalogue_main_controller_card_item.card
|
||||
import kotlinx.android.synthetic.main.catalogue_main_controller_card_item.image
|
||||
import kotlinx.android.synthetic.main.catalogue_main_controller_card_item.source_browse
|
||||
import kotlinx.android.synthetic.main.catalogue_main_controller_card_item.source_latest
|
||||
import kotlinx.android.synthetic.main.catalogue_main_controller_card_item.title
|
||||
import kotlinx.android.synthetic.main.source_main_controller_card_item.card
|
||||
import kotlinx.android.synthetic.main.source_main_controller_card_item.image
|
||||
import kotlinx.android.synthetic.main.source_main_controller_card_item.source_browse
|
||||
import kotlinx.android.synthetic.main.source_main_controller_card_item.source_latest
|
||||
import kotlinx.android.synthetic.main.source_main_controller_card_item.title
|
||||
|
||||
class SourceHolder(view: View, override val adapter: SourceAdapter) :
|
||||
BaseFlexibleViewHolder(view, adapter),
|
||||
|
@ -21,7 +21,7 @@ data class SourceItem(val source: Source, val header: SelectionHeader? = null) :
|
||||
* Returns the layout resource of this item.
|
||||
*/
|
||||
override fun getLayoutRes(): Int {
|
||||
return R.layout.catalogue_main_controller_card_item
|
||||
return R.layout.source_main_controller_card_item
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,10 +1,10 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue
|
||||
package eu.kanade.tachiyomi.ui.source
|
||||
|
||||
import android.view.View
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||
import kotlinx.android.synthetic.main.catalogue_main_controller_card.title
|
||||
import kotlinx.android.synthetic.main.source_main_controller_card.title
|
||||
|
||||
class LangHolder(view: View, adapter: FlexibleAdapter<*>) :
|
||||
BaseFlexibleViewHolder(view, adapter) {
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue
|
||||
package eu.kanade.tachiyomi.ui.source
|
||||
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
@ -18,7 +18,7 @@ data class LangItem(val code: String) : AbstractHeaderItem<LangHolder>() {
|
||||
* Returns the layout resource of this item.
|
||||
*/
|
||||
override fun getLayoutRes(): Int {
|
||||
return R.layout.catalogue_main_controller_card
|
||||
return R.layout.source_main_controller_card
|
||||
}
|
||||
|
||||
/**
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue
|
||||
package eu.kanade.tachiyomi.ui.source
|
||||
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.davidea.flexibleadapter.items.IFlexible
|
||||
@ -8,9 +8,9 @@ import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
/**
|
||||
* Adapter that holds the catalogue cards.
|
||||
*
|
||||
* @param controller instance of [CatalogueController].
|
||||
* @param controller instance of [SourceController].
|
||||
*/
|
||||
class CatalogueAdapter(val controller: CatalogueController) :
|
||||
class SourceAdapter(val controller: SourceController) :
|
||||
FlexibleAdapter<IFlexible<*>>(null, controller, true) {
|
||||
|
||||
val cardBackground = controller.activity!!.getResourceColor(R.attr.colorSurface)
|
||||
@ -31,7 +31,7 @@ class CatalogueAdapter(val controller: CatalogueController) :
|
||||
|
||||
/**
|
||||
* Listener which should be called when user clicks browse.
|
||||
* Note: Should only be handled by [CatalogueController]
|
||||
* Note: Should only be handled by [SourceController]
|
||||
*/
|
||||
interface OnBrowseClickListener {
|
||||
fun onBrowseClick(position: Int)
|
||||
@ -39,7 +39,7 @@ class CatalogueAdapter(val controller: CatalogueController) :
|
||||
|
||||
/**
|
||||
* Listener which should be called when user clicks latest.
|
||||
* Note: Should only be handled by [CatalogueController]
|
||||
* Note: Should only be handled by [SourceController]
|
||||
*/
|
||||
interface OnLatestClickListener {
|
||||
fun onLatestClick(position: Int)
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue
|
||||
package eu.kanade.tachiyomi.ui.source
|
||||
|
||||
import android.Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
import android.view.LayoutInflater
|
||||
@ -20,41 +20,41 @@ import eu.davidea.flexibleadapter.items.IFlexible
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.databinding.CatalogueMainControllerBinding
|
||||
import eu.kanade.tachiyomi.databinding.SourceMainControllerBinding
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.RootController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.requestPermissionsSafe
|
||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||
import eu.kanade.tachiyomi.ui.catalogue.browse.BrowseCatalogueController
|
||||
import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchController
|
||||
import eu.kanade.tachiyomi.ui.catalogue.latest.LatestUpdatesController
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsSourcesController
|
||||
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController
|
||||
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController
|
||||
import eu.kanade.tachiyomi.ui.source.latest.LatestUpdatesController
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
/**
|
||||
* This controller shows and manages the different catalogues enabled by the user.
|
||||
* This controller should only handle UI actions, IO actions should be done by [CataloguePresenter]
|
||||
* [CatalogueAdapter.OnBrowseClickListener] call function data on browse item click.
|
||||
* [CatalogueAdapter.OnLatestClickListener] call function data on latest item click
|
||||
* This controller should only handle UI actions, IO actions should be done by [SourcePresenter]
|
||||
* [SourceAdapter.OnBrowseClickListener] call function data on browse item click.
|
||||
* [SourceAdapter.OnLatestClickListener] call function data on latest item click
|
||||
*/
|
||||
class CatalogueController : NucleusController<CataloguePresenter>(),
|
||||
class SourceController : NucleusController<SourcePresenter>(),
|
||||
RootController,
|
||||
FlexibleAdapter.OnItemClickListener,
|
||||
FlexibleAdapter.OnItemLongClickListener,
|
||||
CatalogueAdapter.OnBrowseClickListener,
|
||||
CatalogueAdapter.OnLatestClickListener {
|
||||
SourceAdapter.OnBrowseClickListener,
|
||||
SourceAdapter.OnLatestClickListener {
|
||||
|
||||
private val preferences: PreferencesHelper = Injekt.get()
|
||||
|
||||
/**
|
||||
* Adapter containing sources.
|
||||
*/
|
||||
private var adapter: CatalogueAdapter? = null
|
||||
private var adapter: SourceAdapter? = null
|
||||
|
||||
private lateinit var binding: CatalogueMainControllerBinding
|
||||
private lateinit var binding: SourceMainControllerBinding
|
||||
|
||||
init {
|
||||
setHasOptionsMenu(true)
|
||||
@ -64,26 +64,26 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
|
||||
return applicationContext?.getString(R.string.label_sources)
|
||||
}
|
||||
|
||||
override fun createPresenter(): CataloguePresenter {
|
||||
return CataloguePresenter()
|
||||
override fun createPresenter(): SourcePresenter {
|
||||
return SourcePresenter()
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiate the view with [R.layout.catalogue_main_controller].
|
||||
* Initiate the view with [R.layout.source_main_controller].
|
||||
*
|
||||
* @param inflater used to load the layout xml.
|
||||
* @param container containing parent views.
|
||||
* @return inflated view.
|
||||
*/
|
||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||
binding = CatalogueMainControllerBinding.inflate(inflater)
|
||||
binding = SourceMainControllerBinding.inflate(inflater)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View) {
|
||||
super.onViewCreated(view)
|
||||
|
||||
adapter = CatalogueAdapter(this)
|
||||
adapter = SourceAdapter(this)
|
||||
|
||||
// Create recycler and set adapter.
|
||||
binding.recycler.layoutManager = LinearLayoutManager(view.context)
|
||||
@ -109,7 +109,7 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
|
||||
override fun onItemClick(view: View, position: Int): Boolean {
|
||||
val item = adapter?.getItem(position) as? SourceItem ?: return false
|
||||
val source = item.source
|
||||
openCatalogue(source, BrowseCatalogueController(source))
|
||||
openCatalogue(source, BrowseSourceController(source))
|
||||
return false
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
|
||||
val activity = activity ?: return
|
||||
val item = adapter?.getItem(position) as? SourceItem ?: return
|
||||
|
||||
val isPinned = item.header?.code?.equals(CataloguePresenter.PINNED_KEY) ?: false
|
||||
val isPinned = item.header?.code?.equals(SourcePresenter.PINNED_KEY) ?: false
|
||||
|
||||
MaterialDialog.Builder(activity)
|
||||
.title(item.source.name)
|
||||
@ -152,14 +152,14 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when browse is clicked in [CatalogueAdapter]
|
||||
* Called when browse is clicked in [SourceAdapter]
|
||||
*/
|
||||
override fun onBrowseClick(position: Int) {
|
||||
onItemClick(view!!, position)
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when latest is clicked in [CatalogueAdapter]
|
||||
* Called when latest is clicked in [SourceAdapter]
|
||||
*/
|
||||
override fun onLatestClick(position: Int) {
|
||||
val item = adapter?.getItem(position) as? SourceItem ?: return
|
||||
@ -169,7 +169,7 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
|
||||
/**
|
||||
* Opens a catalogue with the given controller.
|
||||
*/
|
||||
private fun openCatalogue(source: CatalogueSource, controller: BrowseCatalogueController) {
|
||||
private fun openCatalogue(source: CatalogueSource, controller: BrowseSourceController) {
|
||||
preferences.lastUsedCatalogueSource().set(source.id)
|
||||
router.pushController(controller.withFadeTransaction())
|
||||
}
|
||||
@ -182,7 +182,7 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
|
||||
*/
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
// Inflate menu
|
||||
inflater.inflate(R.menu.catalogue_main, menu)
|
||||
inflater.inflate(R.menu.source_main, menu)
|
||||
|
||||
// Initialize search option.
|
||||
val searchItem = menu.findItem(R.id.action_search)
|
||||
@ -198,7 +198,7 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
|
||||
}
|
||||
|
||||
fun performGlobalSearch(query: String) {
|
||||
router.pushController(CatalogueSearchController(query).withFadeTransaction())
|
||||
router.pushController(GlobalSearchController(query).withFadeTransaction())
|
||||
}
|
||||
|
||||
/**
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue
|
||||
package eu.kanade.tachiyomi.ui.source
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Canvas
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue
|
||||
package eu.kanade.tachiyomi.ui.source
|
||||
|
||||
import android.view.View
|
||||
import eu.kanade.tachiyomi.R
|
||||
@ -9,13 +9,13 @@ import eu.kanade.tachiyomi.util.view.gone
|
||||
import eu.kanade.tachiyomi.util.view.roundTextIcon
|
||||
import eu.kanade.tachiyomi.util.view.visible
|
||||
import io.github.mthli.slice.Slice
|
||||
import kotlinx.android.synthetic.main.catalogue_main_controller_card_item.card
|
||||
import kotlinx.android.synthetic.main.catalogue_main_controller_card_item.image
|
||||
import kotlinx.android.synthetic.main.catalogue_main_controller_card_item.source_browse
|
||||
import kotlinx.android.synthetic.main.catalogue_main_controller_card_item.source_latest
|
||||
import kotlinx.android.synthetic.main.catalogue_main_controller_card_item.title
|
||||
import kotlinx.android.synthetic.main.source_main_controller_card_item.card
|
||||
import kotlinx.android.synthetic.main.source_main_controller_card_item.image
|
||||
import kotlinx.android.synthetic.main.source_main_controller_card_item.source_browse
|
||||
import kotlinx.android.synthetic.main.source_main_controller_card_item.source_latest
|
||||
import kotlinx.android.synthetic.main.source_main_controller_card_item.title
|
||||
|
||||
class SourceHolder(view: View, override val adapter: CatalogueAdapter) :
|
||||
class SourceHolder(view: View, override val adapter: SourceAdapter) :
|
||||
BaseFlexibleViewHolder(view, adapter),
|
||||
SlicedHolder {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue
|
||||
package eu.kanade.tachiyomi.ui.source
|
||||
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
@ -21,14 +21,14 @@ data class SourceItem(val source: CatalogueSource, val header: LangItem? = null)
|
||||
* Returns the layout resource of this item.
|
||||
*/
|
||||
override fun getLayoutRes(): Int {
|
||||
return R.layout.catalogue_main_controller_card_item
|
||||
return R.layout.source_main_controller_card_item
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new view holder for this item.
|
||||
*/
|
||||
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): SourceHolder {
|
||||
return SourceHolder(view, adapter as CatalogueAdapter)
|
||||
return SourceHolder(view, adapter as SourceAdapter)
|
||||
}
|
||||
|
||||
/**
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue
|
||||
package eu.kanade.tachiyomi.ui.source
|
||||
|
||||
import android.os.Bundle
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
@ -16,16 +16,16 @@ import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
/**
|
||||
* Presenter of [CatalogueController]
|
||||
* Presenter of [SourceController]
|
||||
* Function calls should be done from here. UI calls should be done from the controller.
|
||||
*
|
||||
* @param sourceManager manages the different sources.
|
||||
* @param preferences application preferences.
|
||||
*/
|
||||
class CataloguePresenter(
|
||||
class SourcePresenter(
|
||||
val sourceManager: SourceManager = Injekt.get(),
|
||||
private val preferences: PreferencesHelper = Injekt.get()
|
||||
) : BasePresenter<CatalogueController>() {
|
||||
) : BasePresenter<SourceController>() {
|
||||
|
||||
var sources = getEnabledSources()
|
||||
|
||||
@ -76,7 +76,7 @@ class CataloguePresenter(
|
||||
}
|
||||
|
||||
sourceSubscription = Observable.just(sourceItems)
|
||||
.subscribeLatestCache(CatalogueController::setSources)
|
||||
.subscribeLatestCache(SourceController::setSources)
|
||||
}
|
||||
|
||||
private fun loadLastUsedSource() {
|
||||
@ -88,7 +88,7 @@ class CataloguePresenter(
|
||||
sharedObs.skip(1).delay(500, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread()))
|
||||
.distinctUntilChanged()
|
||||
.map { (sourceManager.get(it) as? CatalogueSource)?.let { SourceItem(it) } }
|
||||
.subscribeLatestCache(CatalogueController::setLastUsedSource)
|
||||
.subscribeLatestCache(SourceController::setLastUsedSource)
|
||||
}
|
||||
|
||||
fun updateSources() {
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.browse
|
||||
package eu.kanade.tachiyomi.ui.source.browse
|
||||
|
||||
import android.content.res.Configuration
|
||||
import android.os.Bundle
|
||||
@ -23,7 +23,7 @@ import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Category
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.databinding.CatalogueControllerBinding
|
||||
import eu.kanade.tachiyomi.databinding.SourceControllerBinding
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
@ -51,8 +51,8 @@ import uy.kohesive.injekt.injectLazy
|
||||
/**
|
||||
* Controller to manage the catalogues available in the app.
|
||||
*/
|
||||
open class BrowseCatalogueController(bundle: Bundle) :
|
||||
NucleusController<BrowseCataloguePresenter>(bundle),
|
||||
open class BrowseSourceController(bundle: Bundle) :
|
||||
NucleusController<BrowseSourcePresenter>(bundle),
|
||||
FlexibleAdapter.OnItemClickListener,
|
||||
FlexibleAdapter.OnItemLongClickListener,
|
||||
FlexibleAdapter.EndlessScrollListener,
|
||||
@ -77,7 +77,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
||||
/**
|
||||
* Sheet containing filter items.
|
||||
*/
|
||||
private var filterSheet: CatalogueFilterSheet? = null
|
||||
private var filterSheet: SourceFilterSheet? = null
|
||||
|
||||
/**
|
||||
* Recycler view with the list of results.
|
||||
@ -99,7 +99,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
||||
*/
|
||||
private var progressItem: ProgressItem? = null
|
||||
|
||||
private lateinit var binding: CatalogueControllerBinding
|
||||
private lateinit var binding: SourceControllerBinding
|
||||
|
||||
init {
|
||||
setHasOptionsMenu(true)
|
||||
@ -109,12 +109,12 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
||||
return presenter.source.name
|
||||
}
|
||||
|
||||
override fun createPresenter(): BrowseCataloguePresenter {
|
||||
return BrowseCataloguePresenter(args.getLong(SOURCE_ID_KEY))
|
||||
override fun createPresenter(): BrowseSourcePresenter {
|
||||
return BrowseSourcePresenter(args.getLong(SOURCE_ID_KEY))
|
||||
}
|
||||
|
||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||
binding = CatalogueControllerBinding.inflate(inflater)
|
||||
binding = SourceControllerBinding.inflate(inflater)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
||||
return
|
||||
}
|
||||
|
||||
filterSheet = CatalogueFilterSheet(
|
||||
filterSheet = SourceFilterSheet(
|
||||
activity!!,
|
||||
onSearchClicked = {
|
||||
val allDefault = presenter.sourceFilters == presenter.source.getFilterList()
|
||||
@ -188,17 +188,17 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
||||
addItemDecoration(DividerItemDecoration(context, DividerItemDecoration.VERTICAL))
|
||||
}
|
||||
} else {
|
||||
(binding.catalogueView.inflate(R.layout.catalogue_recycler_autofit) as AutofitRecyclerView).apply {
|
||||
(binding.catalogueView.inflate(R.layout.source_recycler_autofit) as AutofitRecyclerView).apply {
|
||||
numColumnsSubscription = getColumnsPreferenceForCurrentOrientation().asObservable()
|
||||
.doOnNext { spanCount = it }
|
||||
.skip(1)
|
||||
// Set again the adapter to recalculate the covers height
|
||||
.subscribe { adapter = this@BrowseCatalogueController.adapter }
|
||||
.subscribe { adapter = this@BrowseSourceController.adapter }
|
||||
|
||||
(layoutManager as GridLayoutManager).spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
|
||||
override fun getSpanSize(position: Int): Int {
|
||||
return when (adapter?.getItemViewType(position)) {
|
||||
R.layout.catalogue_grid_item, null -> 1
|
||||
R.layout.source_grid_item, null -> 1
|
||||
else -> spanCount
|
||||
}
|
||||
}
|
||||
@ -231,7 +231,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
inflater.inflate(R.menu.catalogue_list, menu)
|
||||
inflater.inflate(R.menu.source_browse, menu)
|
||||
|
||||
// Initialize search menu
|
||||
val searchItem = menu.findItem(R.id.action_search)
|
||||
@ -246,7 +246,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
||||
|
||||
val searchEventsObservable = searchView.queryTextChangeEvents()
|
||||
.skip(1)
|
||||
.filter { router.backstack.lastOrNull()?.controller() == this@BrowseCatalogueController }
|
||||
.filter { router.backstack.lastOrNull()?.controller() == this@BrowseSourceController }
|
||||
.share()
|
||||
val writingObservable = searchEventsObservable
|
||||
.filter { !it.isSubmitted }
|
||||
@ -323,7 +323,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
||||
* @param page the current page.
|
||||
* @param mangas the list of manga of the page.
|
||||
*/
|
||||
fun onAddPage(page: Int, mangas: List<CatalogueItem>) {
|
||||
fun onAddPage(page: Int, mangas: List<SourceItem>) {
|
||||
val adapter = adapter ?: return
|
||||
hideProgressBar()
|
||||
if (page == 1) {
|
||||
@ -434,7 +434,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
||||
if (!isListMode || !view.context.connectivityManager.isActiveNetworkMetered) {
|
||||
// Initialize mangas if going to grid view or if over wifi when going to list view
|
||||
val mangas = (0 until adapter.itemCount).mapNotNull {
|
||||
(adapter.getItem(it) as? CatalogueItem)?.manga
|
||||
(adapter.getItem(it) as? SourceItem)?.manga
|
||||
}
|
||||
presenter.initializeMangas(mangas)
|
||||
}
|
||||
@ -458,13 +458,13 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
||||
* @param manga the manga to find.
|
||||
* @return the holder of the manga or null if it's not bound.
|
||||
*/
|
||||
private fun getHolder(manga: Manga): CatalogueHolder? {
|
||||
private fun getHolder(manga: Manga): SourceHolder? {
|
||||
val adapter = adapter ?: return null
|
||||
|
||||
adapter.allBoundViewHolders.forEach { holder ->
|
||||
val item = adapter.getItem(holder.adapterPosition) as? CatalogueItem
|
||||
val item = adapter.getItem(holder.adapterPosition) as? SourceItem
|
||||
if (item != null && item.manga.id!! == manga.id!!) {
|
||||
return holder as CatalogueHolder
|
||||
return holder as SourceHolder
|
||||
}
|
||||
}
|
||||
|
||||
@ -495,7 +495,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
||||
* @return true if the item should be selected, false otherwise.
|
||||
*/
|
||||
override fun onItemClick(view: View, position: Int): Boolean {
|
||||
val item = adapter?.getItem(position) as? CatalogueItem ?: return false
|
||||
val item = adapter?.getItem(position) as? SourceItem ?: return false
|
||||
router.pushController(MangaController(item.manga, true).withFadeTransaction())
|
||||
|
||||
return false
|
||||
@ -512,7 +512,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
||||
*/
|
||||
override fun onItemLongClick(position: Int) {
|
||||
val activity = activity ?: return
|
||||
val manga = (adapter?.getItem(position) as? CatalogueItem?)?.manga ?: return
|
||||
val manga = (adapter?.getItem(position) as? SourceItem?)?.manga ?: return
|
||||
|
||||
if (manga.favorite) {
|
||||
MaterialDialog.Builder(activity)
|
||||
@ -576,7 +576,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
||||
presenter.changeMangaFavorite(manga)
|
||||
presenter.updateMangaCategories(manga, categories)
|
||||
|
||||
val position = adapter?.currentItems?.indexOfFirst { it -> (it as CatalogueItem).manga.id == manga.id }
|
||||
val position = adapter?.currentItems?.indexOfFirst { it -> (it as SourceItem).manga.id == manga.id }
|
||||
if (position != null) {
|
||||
adapter?.notifyItemChanged(position)
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.browse
|
||||
package eu.kanade.tachiyomi.ui.source.browse
|
||||
|
||||
import android.os.Bundle
|
||||
import eu.davidea.flexibleadapter.items.IFlexible
|
||||
@ -15,19 +15,19 @@ import eu.kanade.tachiyomi.source.model.Filter
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||
import eu.kanade.tachiyomi.ui.catalogue.filter.CheckboxItem
|
||||
import eu.kanade.tachiyomi.ui.catalogue.filter.CheckboxSectionItem
|
||||
import eu.kanade.tachiyomi.ui.catalogue.filter.GroupItem
|
||||
import eu.kanade.tachiyomi.ui.catalogue.filter.HeaderItem
|
||||
import eu.kanade.tachiyomi.ui.catalogue.filter.SelectItem
|
||||
import eu.kanade.tachiyomi.ui.catalogue.filter.SelectSectionItem
|
||||
import eu.kanade.tachiyomi.ui.catalogue.filter.SeparatorItem
|
||||
import eu.kanade.tachiyomi.ui.catalogue.filter.SortGroup
|
||||
import eu.kanade.tachiyomi.ui.catalogue.filter.SortItem
|
||||
import eu.kanade.tachiyomi.ui.catalogue.filter.TextItem
|
||||
import eu.kanade.tachiyomi.ui.catalogue.filter.TextSectionItem
|
||||
import eu.kanade.tachiyomi.ui.catalogue.filter.TriStateItem
|
||||
import eu.kanade.tachiyomi.ui.catalogue.filter.TriStateSectionItem
|
||||
import eu.kanade.tachiyomi.ui.source.filter.CheckboxItem
|
||||
import eu.kanade.tachiyomi.ui.source.filter.CheckboxSectionItem
|
||||
import eu.kanade.tachiyomi.ui.source.filter.GroupItem
|
||||
import eu.kanade.tachiyomi.ui.source.filter.HeaderItem
|
||||
import eu.kanade.tachiyomi.ui.source.filter.SelectItem
|
||||
import eu.kanade.tachiyomi.ui.source.filter.SelectSectionItem
|
||||
import eu.kanade.tachiyomi.ui.source.filter.SeparatorItem
|
||||
import eu.kanade.tachiyomi.ui.source.filter.SortGroup
|
||||
import eu.kanade.tachiyomi.ui.source.filter.SortItem
|
||||
import eu.kanade.tachiyomi.ui.source.filter.TextItem
|
||||
import eu.kanade.tachiyomi.ui.source.filter.TextSectionItem
|
||||
import eu.kanade.tachiyomi.ui.source.filter.TriStateItem
|
||||
import eu.kanade.tachiyomi.ui.source.filter.TriStateSectionItem
|
||||
import rx.Observable
|
||||
import rx.Subscription
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
@ -38,15 +38,15 @@ import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
/**
|
||||
* Presenter of [BrowseCatalogueController].
|
||||
* Presenter of [BrowseSourceController].
|
||||
*/
|
||||
open class BrowseCataloguePresenter(
|
||||
open class BrowseSourcePresenter(
|
||||
sourceId: Long,
|
||||
sourceManager: SourceManager = Injekt.get(),
|
||||
private val db: DatabaseHelper = Injekt.get(),
|
||||
private val prefs: PreferencesHelper = Injekt.get(),
|
||||
private val coverCache: CoverCache = Injekt.get()
|
||||
) : BasePresenter<BrowseCatalogueController>() {
|
||||
) : BasePresenter<BrowseSourceController>() {
|
||||
|
||||
/**
|
||||
* Selected source.
|
||||
@ -151,7 +151,7 @@ open class BrowseCataloguePresenter(
|
||||
.observeOn(Schedulers.io())
|
||||
.map { it.first to it.second.map { networkToLocalManga(it, sourceId) } }
|
||||
.doOnNext { initializeMangas(it.second) }
|
||||
.map { it.first to it.second.map { CatalogueItem(it, catalogueAsList) } }
|
||||
.map { it.first to it.second.map { SourceItem(it, catalogueAsList) } }
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeReplay({ view, (page, mangas) ->
|
||||
view.onAddPage(page, mangas)
|
||||
@ -173,7 +173,7 @@ open class BrowseCataloguePresenter(
|
||||
pageSubscription = Observable.defer { pager.requestNext() }
|
||||
.subscribeFirst({ _, _ ->
|
||||
// Nothing to do when onNext is emitted.
|
||||
}, BrowseCatalogueController::onAddPageError)
|
||||
}, BrowseSourceController::onAddPageError)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -288,7 +288,7 @@ open class BrowseCataloguePresenter(
|
||||
}
|
||||
|
||||
open fun createPager(query: String, filters: FilterList): Pager {
|
||||
return CataloguePager(source, query, filters)
|
||||
return SourcePager(source, query, filters)
|
||||
}
|
||||
|
||||
private fun FilterList.toItems(): List<IFlexible<*>> {
|
@ -0,0 +1,3 @@
|
||||
package eu.kanade.tachiyomi.ui.source.browse
|
||||
|
||||
class NoResultsException : Exception()
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.browse
|
||||
package eu.kanade.tachiyomi.ui.source.browse
|
||||
|
||||
import com.jakewharton.rxrelay.PublishRelay
|
||||
import eu.kanade.tachiyomi.source.model.MangasPage
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.browse
|
||||
package eu.kanade.tachiyomi.ui.source.browse
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ProgressBar
|
||||
@ -17,7 +17,7 @@ class ProgressItem : AbstractFlexibleItem<ProgressItem.Holder>() {
|
||||
private var loadMore = true
|
||||
|
||||
override fun getLayoutRes(): Int {
|
||||
return R.layout.catalogue_progress_item
|
||||
return R.layout.source_progress_item
|
||||
}
|
||||
|
||||
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): Holder {
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.browse
|
||||
package eu.kanade.tachiyomi.ui.source.browse
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
@ -10,10 +10,10 @@ import eu.davidea.flexibleadapter.items.IFlexible
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.util.view.inflate
|
||||
import eu.kanade.tachiyomi.widget.SimpleNavigationView
|
||||
import kotlinx.android.synthetic.main.catalogue_drawer_content.view.reset_btn
|
||||
import kotlinx.android.synthetic.main.catalogue_drawer_content.view.search_btn
|
||||
import kotlinx.android.synthetic.main.source_filter_sheet.view.reset_btn
|
||||
import kotlinx.android.synthetic.main.source_filter_sheet.view.search_btn
|
||||
|
||||
class CatalogueFilterSheet(
|
||||
class SourceFilterSheet(
|
||||
activity: Activity,
|
||||
onSearchClicked: () -> Unit,
|
||||
onResetClicked: () -> Unit
|
||||
@ -49,7 +49,7 @@ class CatalogueFilterSheet(
|
||||
init {
|
||||
recycler.adapter = adapter
|
||||
recycler.setHasFixedSize(true)
|
||||
val view = inflate(R.layout.catalogue_drawer_content)
|
||||
val view = inflate(R.layout.source_filter_sheet)
|
||||
((view as ViewGroup).getChildAt(1) as ViewGroup).addView(recycler)
|
||||
addView(view)
|
||||
search_btn.setOnClickListener { onSearchClicked() }
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.browse
|
||||
package eu.kanade.tachiyomi.ui.source.browse
|
||||
|
||||
import android.view.View
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
@ -6,20 +6,20 @@ import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.glide.GlideApp
|
||||
import eu.kanade.tachiyomi.widget.StateImageViewTarget
|
||||
import kotlinx.android.synthetic.main.catalogue_grid_item.progress
|
||||
import kotlinx.android.synthetic.main.catalogue_grid_item.thumbnail
|
||||
import kotlinx.android.synthetic.main.catalogue_grid_item.title
|
||||
import kotlinx.android.synthetic.main.source_grid_item.progress
|
||||
import kotlinx.android.synthetic.main.source_grid_item.thumbnail
|
||||
import kotlinx.android.synthetic.main.source_grid_item.title
|
||||
|
||||
/**
|
||||
* Class used to hold the displayed data of a manga in the catalogue, like the cover or the title.
|
||||
* All the elements from the layout file "item_catalogue_grid" are available in this class.
|
||||
* All the elements from the layout file "item_source_grid" are available in this class.
|
||||
*
|
||||
* @param view the inflated view for this holder.
|
||||
* @param adapter the adapter handling this holder.
|
||||
* @constructor creates a new catalogue holder.
|
||||
*/
|
||||
class CatalogueGridHolder(private val view: View, private val adapter: FlexibleAdapter<*>) :
|
||||
CatalogueHolder(view, adapter) {
|
||||
class SourceGridHolder(private val view: View, private val adapter: FlexibleAdapter<*>) :
|
||||
SourceHolder(view, adapter) {
|
||||
|
||||
/**
|
||||
* Method called from [CatalogueAdapter.onBindViewHolder]. It updates the data for this
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.browse
|
||||
package eu.kanade.tachiyomi.ui.source.browse
|
||||
|
||||
import android.view.View
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
@ -11,7 +11,7 @@ import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||
* @param view the inflated view for this holder.
|
||||
* @param adapter the adapter handling this holder.
|
||||
*/
|
||||
abstract class CatalogueHolder(view: View, adapter: FlexibleAdapter<*>) :
|
||||
abstract class SourceHolder(view: View, adapter: FlexibleAdapter<*>) :
|
||||
BaseFlexibleViewHolder(view, adapter) {
|
||||
|
||||
/**
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.browse
|
||||
package eu.kanade.tachiyomi.ui.source.browse
|
||||
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
@ -13,23 +13,23 @@ import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
||||
import kotlinx.android.synthetic.main.catalogue_grid_item.view.card
|
||||
import kotlinx.android.synthetic.main.catalogue_grid_item.view.gradient
|
||||
import kotlinx.android.synthetic.main.source_grid_item.view.card
|
||||
import kotlinx.android.synthetic.main.source_grid_item.view.gradient
|
||||
|
||||
class CatalogueItem(val manga: Manga, private val catalogueAsList: Preference<Boolean>) :
|
||||
AbstractFlexibleItem<CatalogueHolder>() {
|
||||
class SourceItem(val manga: Manga, private val catalogueAsList: Preference<Boolean>) :
|
||||
AbstractFlexibleItem<SourceHolder>() {
|
||||
|
||||
override fun getLayoutRes(): Int {
|
||||
return if (catalogueAsList.getOrDefault())
|
||||
R.layout.catalogue_list_item
|
||||
R.layout.source_list_item
|
||||
else
|
||||
R.layout.catalogue_grid_item
|
||||
R.layout.source_grid_item
|
||||
}
|
||||
|
||||
override fun createViewHolder(
|
||||
view: View,
|
||||
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>
|
||||
): CatalogueHolder {
|
||||
): SourceHolder {
|
||||
val parent = adapter.recyclerView
|
||||
return if (parent is AutofitRecyclerView) {
|
||||
view.apply {
|
||||
@ -38,15 +38,15 @@ class CatalogueItem(val manga: Manga, private val catalogueAsList: Preference<Bo
|
||||
gradient.layoutParams = FrameLayout.LayoutParams(
|
||||
MATCH_PARENT, parent.itemWidth / 3 * 4 / 2, Gravity.BOTTOM)
|
||||
}
|
||||
CatalogueGridHolder(view, adapter)
|
||||
SourceGridHolder(view, adapter)
|
||||
} else {
|
||||
CatalogueListHolder(view, adapter)
|
||||
SourceListHolder(view, adapter)
|
||||
}
|
||||
}
|
||||
|
||||
override fun bindViewHolder(
|
||||
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>,
|
||||
holder: CatalogueHolder,
|
||||
holder: SourceHolder,
|
||||
position: Int,
|
||||
payloads: List<Any?>?
|
||||
) {
|
||||
@ -55,7 +55,7 @@ class CatalogueItem(val manga: Manga, private val catalogueAsList: Preference<Bo
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other is CatalogueItem) {
|
||||
if (other is SourceItem) {
|
||||
return manga.id!! == other.manga.id!!
|
||||
}
|
||||
return false
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.browse
|
||||
package eu.kanade.tachiyomi.ui.source.browse
|
||||
|
||||
import android.view.View
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
@ -6,8 +6,8 @@ import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.glide.GlideApp
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import kotlinx.android.synthetic.main.catalogue_list_item.thumbnail
|
||||
import kotlinx.android.synthetic.main.catalogue_list_item.title
|
||||
import kotlinx.android.synthetic.main.source_list_item.thumbnail
|
||||
import kotlinx.android.synthetic.main.source_list_item.title
|
||||
|
||||
/**
|
||||
* Class used to hold the displayed data of a manga in the catalogue, like the cover or the title.
|
||||
@ -17,8 +17,8 @@ import kotlinx.android.synthetic.main.catalogue_list_item.title
|
||||
* @param adapter the adapter handling this holder.
|
||||
* @constructor creates a new catalogue holder.
|
||||
*/
|
||||
class CatalogueListHolder(private val view: View, adapter: FlexibleAdapter<*>) :
|
||||
CatalogueHolder(view, adapter) {
|
||||
class SourceListHolder(private val view: View, adapter: FlexibleAdapter<*>) :
|
||||
SourceHolder(view, adapter) {
|
||||
|
||||
private val favoriteColor = view.context.getResourceColor(android.R.attr.textColorHint)
|
||||
private val unfavoriteColor = view.context.getResourceColor(android.R.attr.textColorPrimary)
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.browse
|
||||
package eu.kanade.tachiyomi.ui.source.browse
|
||||
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
@ -7,7 +7,7 @@ import rx.Observable
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.schedulers.Schedulers
|
||||
|
||||
open class CataloguePager(val source: CatalogueSource, val query: String, val filters: FilterList) : Pager() {
|
||||
open class SourcePager(val source: CatalogueSource, val query: String, val filters: FilterList) : Pager() {
|
||||
|
||||
override fun requestNext(): Observable<MangasPage> {
|
||||
val page = currentPage
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.filter
|
||||
package eu.kanade.tachiyomi.ui.source.filter
|
||||
|
||||
import android.view.View
|
||||
import android.widget.CheckBox
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.filter
|
||||
package eu.kanade.tachiyomi.ui.source.filter
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.filter
|
||||
package eu.kanade.tachiyomi.ui.source.filter
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.View
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.filter
|
||||
package eu.kanade.tachiyomi.ui.source.filter
|
||||
|
||||
import eu.davidea.flexibleadapter.items.ISectionable
|
||||
import eu.kanade.tachiyomi.source.model.Filter
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.filter
|
||||
package eu.kanade.tachiyomi.ui.source.filter
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ArrayAdapter
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.filter
|
||||
package eu.kanade.tachiyomi.ui.source.filter
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.View
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.filter
|
||||
package eu.kanade.tachiyomi.ui.source.filter
|
||||
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.filter
|
||||
package eu.kanade.tachiyomi.ui.source.filter
|
||||
|
||||
import android.view.View
|
||||
import android.widget.CheckedTextView
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.filter
|
||||
package eu.kanade.tachiyomi.ui.source.filter
|
||||
|
||||
import android.view.View
|
||||
import android.widget.EditText
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.filter
|
||||
package eu.kanade.tachiyomi.ui.source.filter
|
||||
|
||||
import android.view.View
|
||||
import android.widget.CheckedTextView
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.global_search
|
||||
package eu.kanade.tachiyomi.ui.source.global_search
|
||||
|
||||
import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
@ -9,10 +9,10 @@ import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
/**
|
||||
* Adapter that holds the search cards.
|
||||
*
|
||||
* @param controller instance of [CatalogueSearchController].
|
||||
* @param controller instance of [GlobalSearchController].
|
||||
*/
|
||||
class CatalogueSearchAdapter(val controller: CatalogueSearchController) :
|
||||
FlexibleAdapter<CatalogueSearchItem>(null, controller, true) {
|
||||
class GlobalSearchAdapter(val controller: GlobalSearchController) :
|
||||
FlexibleAdapter<GlobalSearchItem>(null, controller, true) {
|
||||
|
||||
/**
|
||||
* Bundle where the view state of the holders is saved.
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.global_search
|
||||
package eu.kanade.tachiyomi.ui.source.global_search
|
||||
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
@ -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 [CatalogueSearchController].
|
||||
* @param controller instance of [GlobalSearchController].
|
||||
*/
|
||||
class CatalogueSearchCardAdapter(controller: CatalogueSearchController) :
|
||||
FlexibleAdapter<CatalogueSearchCardItem>(null, controller, true) {
|
||||
class GlobalSearchCardAdapter(controller: GlobalSearchController) :
|
||||
FlexibleAdapter<GlobalSearchCardItem>(null, controller, true) {
|
||||
|
||||
/**
|
||||
* Listen for browse item clicks.
|
||||
@ -18,7 +18,7 @@ class CatalogueSearchCardAdapter(controller: CatalogueSearchController) :
|
||||
|
||||
/**
|
||||
* Listener which should be called when user clicks browse.
|
||||
* Note: Should only be handled by [CatalogueSearchController]
|
||||
* Note: Should only be handled by [GlobalSearchController]
|
||||
*/
|
||||
interface OnMangaClickListener {
|
||||
fun onMangaClick(manga: Manga)
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.global_search
|
||||
package eu.kanade.tachiyomi.ui.source.global_search
|
||||
|
||||
import android.view.View
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
@ -6,11 +6,11 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.glide.GlideApp
|
||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||
import eu.kanade.tachiyomi.widget.StateImageViewTarget
|
||||
import kotlinx.android.synthetic.main.catalogue_global_search_controller_card_item.itemImage
|
||||
import kotlinx.android.synthetic.main.catalogue_global_search_controller_card_item.progress
|
||||
import kotlinx.android.synthetic.main.catalogue_global_search_controller_card_item.tvTitle
|
||||
import kotlinx.android.synthetic.main.global_search_controller_card_item.itemImage
|
||||
import kotlinx.android.synthetic.main.global_search_controller_card_item.progress
|
||||
import kotlinx.android.synthetic.main.global_search_controller_card_item.tvTitle
|
||||
|
||||
class CatalogueSearchCardHolder(view: View, adapter: CatalogueSearchCardAdapter) :
|
||||
class GlobalSearchCardHolder(view: View, adapter: GlobalSearchCardAdapter) :
|
||||
BaseFlexibleViewHolder(view, adapter) {
|
||||
|
||||
init {
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.global_search
|
||||
package eu.kanade.tachiyomi.ui.source.global_search
|
||||
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
@ -8,19 +8,19 @@ import eu.davidea.flexibleadapter.items.IFlexible
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
|
||||
class CatalogueSearchCardItem(val manga: Manga) : AbstractFlexibleItem<CatalogueSearchCardHolder>() {
|
||||
class GlobalSearchCardItem(val manga: Manga) : AbstractFlexibleItem<GlobalSearchCardHolder>() {
|
||||
|
||||
override fun getLayoutRes(): Int {
|
||||
return R.layout.catalogue_global_search_controller_card_item
|
||||
return R.layout.global_search_controller_card_item
|
||||
}
|
||||
|
||||
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): CatalogueSearchCardHolder {
|
||||
return CatalogueSearchCardHolder(view, adapter as CatalogueSearchCardAdapter)
|
||||
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): GlobalSearchCardHolder {
|
||||
return GlobalSearchCardHolder(view, adapter as GlobalSearchCardAdapter)
|
||||
}
|
||||
|
||||
override fun bindViewHolder(
|
||||
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>,
|
||||
holder: CatalogueSearchCardHolder,
|
||||
holder: GlobalSearchCardHolder,
|
||||
position: Int,
|
||||
payloads: List<Any?>?
|
||||
) {
|
||||
@ -28,7 +28,7 @@ class CatalogueSearchCardItem(val manga: Manga) : AbstractFlexibleItem<Catalogue
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other is CatalogueSearchCardItem) {
|
||||
if (other is GlobalSearchCardItem) {
|
||||
return manga.id == other.manga.id
|
||||
}
|
||||
return false
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.global_search
|
||||
package eu.kanade.tachiyomi.ui.source.global_search
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
@ -12,7 +12,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.jakewharton.rxbinding.support.v7.widget.queryTextChangeEvents
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.databinding.CatalogueGlobalSearchControllerBinding
|
||||
import eu.kanade.tachiyomi.databinding.GlobalSearchControllerBinding
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||
@ -20,21 +20,21 @@ import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
|
||||
/**
|
||||
* 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 [CatalogueSearchPresenter]
|
||||
* [CatalogueSearchCardAdapter.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 CatalogueSearchController(
|
||||
open class GlobalSearchController(
|
||||
protected val initialQuery: String? = null,
|
||||
protected val extensionFilter: String? = null
|
||||
) : NucleusController<CatalogueSearchPresenter>(),
|
||||
CatalogueSearchCardAdapter.OnMangaClickListener {
|
||||
) : NucleusController<GlobalSearchPresenter>(),
|
||||
GlobalSearchCardAdapter.OnMangaClickListener {
|
||||
|
||||
/**
|
||||
* Adapter containing search results grouped by lang.
|
||||
*/
|
||||
protected var adapter: CatalogueSearchAdapter? = null
|
||||
protected var adapter: GlobalSearchAdapter? = null
|
||||
|
||||
private lateinit var binding: CatalogueGlobalSearchControllerBinding
|
||||
private lateinit var binding: GlobalSearchControllerBinding
|
||||
|
||||
/**
|
||||
* Called when controller is initialized.
|
||||
@ -44,14 +44,14 @@ open class CatalogueSearchController(
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiate the view with [R.layout.catalogue_global_search_controller].
|
||||
* Initiate the view with [R.layout.global_search_controller].
|
||||
*
|
||||
* @param inflater used to load the layout xml.
|
||||
* @param container containing parent views.
|
||||
* @return inflated view
|
||||
*/
|
||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||
binding = CatalogueGlobalSearchControllerBinding.inflate(inflater)
|
||||
binding = GlobalSearchControllerBinding.inflate(inflater)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
@ -65,12 +65,12 @@ open class CatalogueSearchController(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the [CatalogueSearchPresenter] used in controller.
|
||||
* Create the [GlobalSearchPresenter] used in controller.
|
||||
*
|
||||
* @return instance of [CatalogueSearchPresenter]
|
||||
* @return instance of [GlobalSearchPresenter]
|
||||
*/
|
||||
override fun createPresenter(): CatalogueSearchPresenter {
|
||||
return CatalogueSearchPresenter(initialQuery, extensionFilter)
|
||||
override fun createPresenter(): GlobalSearchPresenter {
|
||||
return GlobalSearchPresenter(initialQuery, extensionFilter)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,7 +101,7 @@ open class CatalogueSearchController(
|
||||
*/
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
// Inflate menu.
|
||||
inflater.inflate(R.menu.catalogue_new_list, menu)
|
||||
inflater.inflate(R.menu.global_search, menu)
|
||||
|
||||
// Initialize search menu
|
||||
val searchItem = menu.findItem(R.id.action_search)
|
||||
@ -136,7 +136,7 @@ open class CatalogueSearchController(
|
||||
override fun onViewCreated(view: View) {
|
||||
super.onViewCreated(view)
|
||||
|
||||
adapter = CatalogueSearchAdapter(this)
|
||||
adapter = GlobalSearchAdapter(this)
|
||||
|
||||
// Create recycler and set adapter.
|
||||
binding.recycler.layoutManager = LinearLayoutManager(view.context)
|
||||
@ -164,13 +164,13 @@ open class CatalogueSearchController(
|
||||
* @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): CatalogueSearchHolder? {
|
||||
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 CatalogueSearchHolder
|
||||
return holder as GlobalSearchHolder
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ open class CatalogueSearchController(
|
||||
*
|
||||
* @param searchResult result of search.
|
||||
*/
|
||||
fun setItems(searchResult: List<CatalogueSearchItem>) {
|
||||
fun setItems(searchResult: List<GlobalSearchItem>) {
|
||||
adapter?.updateDataSet(searchResult)
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.global_search
|
||||
package eu.kanade.tachiyomi.ui.source.global_search
|
||||
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
@ -6,26 +6,26 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||
import eu.kanade.tachiyomi.util.view.gone
|
||||
import eu.kanade.tachiyomi.util.view.visible
|
||||
import kotlinx.android.synthetic.main.catalogue_global_search_controller_card.progress
|
||||
import kotlinx.android.synthetic.main.catalogue_global_search_controller_card.recycler
|
||||
import kotlinx.android.synthetic.main.catalogue_global_search_controller_card.source_card
|
||||
import kotlinx.android.synthetic.main.catalogue_global_search_controller_card.title
|
||||
import kotlinx.android.synthetic.main.global_search_controller_card.progress
|
||||
import kotlinx.android.synthetic.main.global_search_controller_card.recycler
|
||||
import kotlinx.android.synthetic.main.global_search_controller_card.source_card
|
||||
import kotlinx.android.synthetic.main.global_search_controller_card.title
|
||||
|
||||
/**
|
||||
* Holder that binds the [CatalogueSearchItem] containing catalogue cards.
|
||||
* Holder that binds the [GlobalSearchItem] containing catalogue cards.
|
||||
*
|
||||
* @param view view of [CatalogueSearchItem]
|
||||
* @param adapter instance of [CatalogueSearchAdapter]
|
||||
* @param view view of [GlobalSearchItem]
|
||||
* @param adapter instance of [GlobalSearchAdapter]
|
||||
*/
|
||||
class CatalogueSearchHolder(view: View, val adapter: CatalogueSearchAdapter) :
|
||||
class GlobalSearchHolder(view: View, val adapter: GlobalSearchAdapter) :
|
||||
BaseFlexibleViewHolder(view, adapter) {
|
||||
|
||||
/**
|
||||
* Adapter containing manga from search results.
|
||||
*/
|
||||
private val mangaAdapter = CatalogueSearchCardAdapter(adapter.controller)
|
||||
private val mangaAdapter = GlobalSearchCardAdapter(adapter.controller)
|
||||
|
||||
private var lastBoundResults: List<CatalogueSearchCardItem>? = null
|
||||
private var lastBoundResults: List<GlobalSearchCardItem>? = null
|
||||
|
||||
init {
|
||||
// Set layout horizontal.
|
||||
@ -38,7 +38,7 @@ class CatalogueSearchHolder(view: View, val adapter: CatalogueSearchAdapter) :
|
||||
*
|
||||
* @param item item of card.
|
||||
*/
|
||||
fun bind(item: CatalogueSearchItem) {
|
||||
fun bind(item: GlobalSearchItem) {
|
||||
val source = item.source
|
||||
val results = item.results
|
||||
|
||||
@ -83,11 +83,11 @@ class CatalogueSearchHolder(view: View, val adapter: CatalogueSearchAdapter) :
|
||||
* @param manga the manga to find.
|
||||
* @return the holder of the manga or null if it's not bound.
|
||||
*/
|
||||
private fun getHolder(manga: Manga): CatalogueSearchCardHolder? {
|
||||
private fun getHolder(manga: Manga): GlobalSearchCardHolder? {
|
||||
mangaAdapter.allBoundViewHolders.forEach { holder ->
|
||||
val item = mangaAdapter.getItem(holder.adapterPosition)
|
||||
if (item != null && item.manga.id!! == manga.id!!) {
|
||||
return holder as CatalogueSearchCardHolder
|
||||
return holder as GlobalSearchCardHolder
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.global_search
|
||||
package eu.kanade.tachiyomi.ui.source.global_search
|
||||
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
@ -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 CatalogueSearchItem(val source: CatalogueSource, val results: List<CatalogueSearchCardItem>?, val highlighted: Boolean = false) :
|
||||
AbstractFlexibleItem<CatalogueSearchHolder>() {
|
||||
class GlobalSearchItem(val source: CatalogueSource, val results: List<GlobalSearchCardItem>?, val highlighted: Boolean = false) :
|
||||
AbstractFlexibleItem<GlobalSearchHolder>() {
|
||||
|
||||
/**
|
||||
* Set view.
|
||||
@ -24,16 +24,16 @@ class CatalogueSearchItem(val source: CatalogueSource, val results: List<Catalog
|
||||
* @return id of view
|
||||
*/
|
||||
override fun getLayoutRes(): Int {
|
||||
return R.layout.catalogue_global_search_controller_card
|
||||
return R.layout.global_search_controller_card
|
||||
}
|
||||
|
||||
/**
|
||||
* Create view holder (see [CatalogueSearchAdapter].
|
||||
* Create view holder (see [GlobalSearchAdapter].
|
||||
*
|
||||
* @return holder of view.
|
||||
*/
|
||||
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): CatalogueSearchHolder {
|
||||
return CatalogueSearchHolder(view, adapter as CatalogueSearchAdapter)
|
||||
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): GlobalSearchHolder {
|
||||
return GlobalSearchHolder(view, adapter as GlobalSearchAdapter)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,7 +41,7 @@ class CatalogueSearchItem(val source: CatalogueSource, val results: List<Catalog
|
||||
*/
|
||||
override fun bindViewHolder(
|
||||
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>,
|
||||
holder: CatalogueSearchHolder,
|
||||
holder: GlobalSearchHolder,
|
||||
position: Int,
|
||||
payloads: List<Any?>?
|
||||
) {
|
||||
@ -54,7 +54,7 @@ class CatalogueSearchItem(val source: CatalogueSource, val results: List<Catalog
|
||||
* @return items are equal?
|
||||
*/
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other is CatalogueSearchItem) {
|
||||
if (other is GlobalSearchItem) {
|
||||
return source.id == other.source.id
|
||||
}
|
||||
return false
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.global_search
|
||||
package eu.kanade.tachiyomi.ui.source.global_search
|
||||
|
||||
import android.os.Bundle
|
||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import eu.kanade.tachiyomi.source.model.MangasPage
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||
import eu.kanade.tachiyomi.ui.catalogue.browse.BrowseCataloguePresenter
|
||||
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourcePresenter
|
||||
import rx.Observable
|
||||
import rx.Subscription
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
@ -25,20 +25,20 @@ import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
/**
|
||||
* Presenter of [CatalogueSearchController]
|
||||
* 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 preferences manages the preference calls.
|
||||
*/
|
||||
open class CatalogueSearchPresenter(
|
||||
open class GlobalSearchPresenter(
|
||||
val initialQuery: String? = "",
|
||||
val initialExtensionFilter: String? = null,
|
||||
val sourceManager: SourceManager = Injekt.get(),
|
||||
val db: DatabaseHelper = Injekt.get(),
|
||||
val preferences: PreferencesHelper = Injekt.get()
|
||||
) : BasePresenter<CatalogueSearchController>() {
|
||||
) : BasePresenter<GlobalSearchController>() {
|
||||
|
||||
/**
|
||||
* Enabled sources.
|
||||
@ -73,11 +73,11 @@ open class CatalogueSearchPresenter(
|
||||
override fun onCreate(savedState: Bundle?) {
|
||||
super.onCreate(savedState)
|
||||
|
||||
extensionFilter = savedState?.getString(CatalogueSearchPresenter::extensionFilter.name)
|
||||
extensionFilter = savedState?.getString(GlobalSearchPresenter::extensionFilter.name)
|
||||
?: initialExtensionFilter
|
||||
|
||||
// Perform a search with previous or initial state
|
||||
search(savedState?.getString(BrowseCataloguePresenter::query.name)
|
||||
search(savedState?.getString(BrowseSourcePresenter::query.name)
|
||||
?: initialQuery.orEmpty())
|
||||
}
|
||||
|
||||
@ -88,8 +88,8 @@ open class CatalogueSearchPresenter(
|
||||
}
|
||||
|
||||
override fun onSave(state: Bundle) {
|
||||
state.putString(BrowseCataloguePresenter::query.name, query)
|
||||
state.putString(CatalogueSearchPresenter::extensionFilter.name, extensionFilter)
|
||||
state.putString(BrowseSourcePresenter::query.name, query)
|
||||
state.putString(GlobalSearchPresenter::extensionFilter.name, extensionFilter)
|
||||
super.onSave(state)
|
||||
}
|
||||
|
||||
@ -133,8 +133,8 @@ open class CatalogueSearchPresenter(
|
||||
/**
|
||||
* Creates a catalogue search item
|
||||
*/
|
||||
protected open fun createCatalogueSearchItem(source: CatalogueSource, results: List<CatalogueSearchCardItem>?): CatalogueSearchItem {
|
||||
return CatalogueSearchItem(source, results)
|
||||
protected open fun createCatalogueSearchItem(source: CatalogueSource, results: List<GlobalSearchCardItem>?): GlobalSearchItem {
|
||||
return GlobalSearchItem(source, results)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -165,7 +165,7 @@ open class CatalogueSearchPresenter(
|
||||
.map { it.mangas.take(10) } // Get at most 10 manga from search result.
|
||||
.map { it.map { networkToLocalManga(it, source.id) } } // Convert to local manga.
|
||||
.doOnNext { fetchImage(it, source) } // Load manga covers.
|
||||
.map { createCatalogueSearchItem(source, it.map { CatalogueSearchCardItem(it) }) }
|
||||
.map { createCatalogueSearchItem(source, it.map { GlobalSearchCardItem(it) }) }
|
||||
}, 5)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
// Update matching source with the obtained results
|
@ -1,22 +1,22 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.latest
|
||||
package eu.kanade.tachiyomi.ui.source.latest
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.ui.catalogue.browse.BrowseCatalogueController
|
||||
import eu.kanade.tachiyomi.ui.catalogue.browse.BrowseCataloguePresenter
|
||||
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController
|
||||
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourcePresenter
|
||||
|
||||
/**
|
||||
* Controller that shows the latest manga from the catalogue. Inherit [BrowseCatalogueController].
|
||||
* Controller that shows the latest manga from the catalogue. Inherit [BrowseSourceController].
|
||||
*/
|
||||
class LatestUpdatesController(bundle: Bundle) : BrowseCatalogueController(bundle) {
|
||||
class LatestUpdatesController(bundle: Bundle) : BrowseSourceController(bundle) {
|
||||
|
||||
constructor(source: CatalogueSource) : this(Bundle().apply {
|
||||
putLong(SOURCE_ID_KEY, source.id)
|
||||
})
|
||||
|
||||
override fun createPresenter(): BrowseCataloguePresenter {
|
||||
override fun createPresenter(): BrowseSourcePresenter {
|
||||
return LatestUpdatesPresenter(args.getLong(SOURCE_ID_KEY))
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.latest
|
||||
package eu.kanade.tachiyomi.ui.source.latest
|
||||
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.model.MangasPage
|
||||
import eu.kanade.tachiyomi.ui.catalogue.browse.Pager
|
||||
import eu.kanade.tachiyomi.ui.source.browse.Pager
|
||||
import rx.Observable
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.schedulers.Schedulers
|
@ -1,13 +1,13 @@
|
||||
package eu.kanade.tachiyomi.ui.catalogue.latest
|
||||
package eu.kanade.tachiyomi.ui.source.latest
|
||||
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import eu.kanade.tachiyomi.ui.catalogue.browse.BrowseCataloguePresenter
|
||||
import eu.kanade.tachiyomi.ui.catalogue.browse.Pager
|
||||
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourcePresenter
|
||||
import eu.kanade.tachiyomi.ui.source.browse.Pager
|
||||
|
||||
/**
|
||||
* Presenter of [LatestUpdatesController]. Inherit BrowseCataloguePresenter.
|
||||
*/
|
||||
class LatestUpdatesPresenter(sourceId: Long) : BrowseCataloguePresenter(sourceId) {
|
||||
class LatestUpdatesPresenter(sourceId: Long) : BrowseSourcePresenter(sourceId) {
|
||||
|
||||
override fun createPager(query: String, filters: FilterList): Pager {
|
||||
return LatestUpdatesPager(source)
|
@ -7,7 +7,7 @@ import android.os.Build
|
||||
import android.view.ContextThemeWrapper
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.ui.catalogue.CataloguePresenter
|
||||
import eu.kanade.tachiyomi.ui.source.SourcePresenter
|
||||
import java.util.Locale
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
@ -51,7 +51,7 @@ object LocaleHelper {
|
||||
return when (lang) {
|
||||
null -> ""
|
||||
"" -> context.getString(R.string.other_source)
|
||||
CataloguePresenter.PINNED_KEY -> context.getString(R.string.pinned_sources)
|
||||
SourcePresenter.PINNED_KEY -> context.getString(R.string.pinned_sources)
|
||||
"all" -> context.getString(R.string.all_lang)
|
||||
else -> {
|
||||
val locale = getLocale(lang)
|
||||
|
@ -5,7 +5,7 @@
|
||||
android:id="@id/swipe_refresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="eu.kanade.tachiyomi.ui.catalogue.browse.BrowseCatalogueController">
|
||||
tools:context="eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -11,6 +11,6 @@
|
||||
android:clipToPadding="false"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingBottom="4dp"
|
||||
tools:listitem="@layout/catalogue_global_search_controller_card" />
|
||||
tools:listitem="@layout/global_search_controller_card" />
|
||||
|
||||
</FrameLayout>
|
@ -43,7 +43,7 @@
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingEnd="4dp"
|
||||
tools:listitem="@layout/catalogue_global_search_controller_card_item" />
|
||||
tools:listitem="@layout/global_search_controller_card_item" />
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
@ -2,9 +2,9 @@
|
||||
<eu.kanade.tachiyomi.widget.AutofitRecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/library_grid"
|
||||
style="@style/Theme.Widget.GridView.Catalogue"
|
||||
style="@style/Theme.Widget.GridView.Source"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:columnWidth="140dp"
|
||||
tools:listitem="@layout/catalogue_grid_item" />
|
||||
tools:listitem="@layout/source_grid_item" />
|
||||
|
@ -4,4 +4,4 @@
|
||||
android:id="@+id/library_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:listitem="@layout/catalogue_list_item" />
|
||||
tools:listitem="@layout/source_list_item" />
|
||||
|
@ -5,7 +5,7 @@
|
||||
android:id="@id/swipe_refresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="eu.kanade.tachiyomi.ui.catalogue.browse.BrowseCatalogueController">
|
||||
tools:context="eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -14,7 +14,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context="eu.kanade.tachiyomi.ui.catalogue.browse.BrowseCatalogueController">
|
||||
tools:context="eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress"
|
@ -9,7 +9,7 @@
|
||||
android:id="@+id/recycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:listitem="@layout/catalogue_main_controller_card" />
|
||||
tools:listitem="@layout/source_main_controller_card" />
|
||||
|
||||
<eu.davidea.fastscroller.FastScroller
|
||||
android:id="@+id/fast_scroller"
|
@ -1,10 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<eu.kanade.tachiyomi.widget.AutofitRecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/catalogue_grid"
|
||||
style="@style/Theme.Widget.GridView.Catalogue"
|
||||
android:id="@+id/source_grid"
|
||||
style="@style/Theme.Widget.GridView.Source"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:columnWidth="140dp"
|
||||
tools:listitem="@layout/catalogue_grid_item" />
|
||||
tools:listitem="@layout/source_grid_item" />
|
@ -1,7 +1,5 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context=".CatalogueListActivity">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_search"
|
@ -1,7 +1,5 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context=".CatalogueListActivity">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_search"
|
@ -1,7 +1,5 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context=".CatalogueListActivity">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_search"
|
@ -176,7 +176,7 @@
|
||||
<item name="android:scrollbarStyle">outsideOverlay</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Widget.GridView.Catalogue">
|
||||
<style name="Theme.Widget.GridView.Source">
|
||||
<item name="android:padding">5dp</item>
|
||||
<item name="android:gravity">top|left</item>
|
||||
<item name="android:smoothScrollbar">true</item>
|
||||
|
Loading…
Reference in New Issue
Block a user