|
@@ -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)
|
|
|
}
|