diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index c23261157d..3f10225d64 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -144,17 +144,11 @@ open class MainActivity : BaseActivity(), DownloadServiceListener { preferences.lastTab().set(item.itemId) val currentRoot = router.backstack.firstOrNull() if (currentRoot?.tag()?.toIntOrNull() != id) { - when (id) { - R.id.nav_library -> setRoot(LibraryListController(), id) - R.id.nav_recents -> { - setRoot(RecentsController(), id) -// if (preferences.showRecentUpdates().getOrDefault()) setRoot( -// RecentChaptersController(), id -// ) -// else setRoot(RecentlyReadController(), id) - } - R.id.nav_catalogues -> setRoot(CatalogueController(), id) - } + setRoot(when (id) { + R.id.nav_library -> LibraryListController() + R.id.nav_recents -> RecentsController() + else -> CatalogueController() + }, id) } else if (currentRoot.tag()?.toIntOrNull() == id) { if (router.backstackSize == 1) { when (id) { @@ -163,7 +157,6 @@ open class MainActivity : BaseActivity(), DownloadServiceListener { if (!showRecents) setRoot(RecentChaptersController(), id) else setRoot(RecentlyReadController(), id) preferences.showRecentUpdates().set(!showRecents) - updateRecentsIcon() }*/ R.id.nav_library -> { val controller = @@ -188,7 +181,6 @@ open class MainActivity : BaseActivity(), DownloadServiceListener { View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION container.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - // updateRecentsIcon() supportActionBar?.setDisplayShowCustomEnabled(true) @@ -209,10 +201,6 @@ open class MainActivity : BaseActivity(), DownloadServiceListener { top = insets.systemWindowInsetTop ) bottom_nav.updatePadding(bottom = insets.systemWindowInsetBottom) - - /*insets.replaceSystemWindowInsets( - 0, insets.systemWindowInsetTop, 0, insets.systemWindowInsetBottom - )*/ } router = Conductor.attachRouter(this, container, savedInstanceState) @@ -306,16 +294,6 @@ open class MainActivity : BaseActivity(), DownloadServiceListener { } } - /*fun updateRecentsIcon() { - bottom_nav.menu.findItem(R.id.nav_recents).icon = AppCompatResources.getDrawable( - this, - if (preferences.showRecentUpdates() - .getOrDefault() - ) R.drawable.recent_updates_selector_24dp - else R.drawable.recent_read_selector_24dp - ) - }*/ - override fun startSupportActionMode(callback: androidx.appcompat.view.ActionMode.Callback): androidx.appcompat.view.ActionMode? { window?.statusBarColor = getResourceColor(R.attr.colorPrimaryVariant) return super.startSupportActionMode(callback) @@ -356,6 +334,11 @@ open class MainActivity : BaseActivity(), DownloadServiceListener { DownloadService.callListeners() } + override fun onPause() { + super.onPause() + snackBar?.dismiss() + } + private fun getExtensionUpdates() { if (Date().time >= preferences.lastExtCheck().getOrDefault() + TimeUnit.HOURS.toMillis(1)) { GlobalScope.launch(Dispatchers.IO) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaAdapter.kt index d521718538..7beffcf690 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaAdapter.kt @@ -1,9 +1,7 @@ package eu.kanade.tachiyomi.ui.recents -import android.widget.ImageView import androidx.recyclerview.widget.ItemTouchHelper import eu.davidea.flexibleadapter.items.IFlexible -import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.ui.manga.chapter.BaseChapterAdapter import java.text.DecimalFormat import java.text.DecimalFormatSymbols @@ -21,10 +19,8 @@ class RecentMangaAdapter(val delegate: RecentsInterface) : interface RecentsInterface : RecentMangaInterface, DownloadInterface interface RecentMangaInterface { - fun onHeaderClick(position: Int) fun onCoverClick(position: Int) fun markAsRead(position: Int) - fun setCover(manga: Manga, view: ImageView) fun isSearching(): Boolean } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHeaderItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHeaderItem.kt index 7c9790b19c..781155d743 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHeaderItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHeaderItem.kt @@ -58,11 +58,17 @@ class RecentMangaHeaderItem(val recentsType: Int) : fun bind(recentsType: Int) { title.setText(when (recentsType) { - RecentsItem.CONTINUE_READING -> R.string.continue_reading - RecentsItem.NEW_CHAPTERS -> R.string.new_chapters - RecentsItem.NEWLY_ADDED -> R.string.new_additions + CONTINUE_READING -> R.string.continue_reading + NEW_CHAPTERS -> R.string.new_chapters + NEWLY_ADDED -> R.string.new_additions else -> R.string.continue_reading }) } } + + companion object { + const val CONTINUE_READING = 0 + const val NEW_CHAPTERS = 1 + const val NEWLY_ADDED = 2 + } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHolder.kt index a940243030..b8df783533 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHolder.kt @@ -2,8 +2,12 @@ package eu.kanade.tachiyomi.ui.recents import android.text.format.DateUtils import android.view.View +import com.bumptech.glide.load.engine.DiskCacheStrategy +import com.bumptech.glide.signature.ObjectKey import eu.kanade.tachiyomi.R +import eu.kanade.tachiyomi.data.database.models.MangaImpl import eu.kanade.tachiyomi.data.download.model.Download +import eu.kanade.tachiyomi.data.glide.GlideApp import eu.kanade.tachiyomi.source.LocalSource import eu.kanade.tachiyomi.ui.manga.chapter.BaseChapterHolder import eu.kanade.tachiyomi.util.view.visibleIf @@ -22,10 +26,10 @@ class RecentMangaHolder( fun bind(recentsType: Int) { when (recentsType) { - RecentsItem.CONTINUE_READING -> { + RecentMangaHeaderItem.CONTINUE_READING -> { title.setText(R.string.view_history) } - RecentsItem.NEW_CHAPTERS -> { + RecentMangaHeaderItem.NEW_CHAPTERS -> { title.setText(R.string.view_all_updates) } } @@ -68,7 +72,10 @@ class RecentMangaHolder( ) else -> "" } - adapter.delegate.setCover(item.mch.manga, cover_thumbnail) + GlideApp.with(itemView.context).load(item.mch.manga).diskCacheStrategy(DiskCacheStrategy + .AUTOMATIC) + .signature(ObjectKey(MangaImpl.getLastCoverFetch(item.mch.manga.id!!).toString())).into(cover_thumbnail) + // adapter.delegate.setCover(item.mch.manga, cover_thumbnail) notifyStatus( if (adapter.isSelected(adapterPosition)) Download.CHECKED else item.status, item.progress diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsAdapter.kt deleted file mode 100644 index ce706e3c24..0000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsAdapter.kt +++ /dev/null @@ -1,21 +0,0 @@ -package eu.kanade.tachiyomi.ui.recents - -import android.widget.ImageView -import eu.davidea.flexibleadapter.FlexibleAdapter -import eu.davidea.flexibleadapter.items.IFlexible -import eu.kanade.tachiyomi.data.database.models.Chapter -import eu.kanade.tachiyomi.data.database.models.Manga - -class RecentsAdapter(val delegate: RecentsInterface) : - FlexibleAdapter>(null, delegate, true) { - - interface RecentsInterface { - fun resumeManga(manga: Manga, chapter: Chapter) - fun showManga(manga: Manga) - fun markAsRead(manga: Manga, chapter: Chapter) - fun downloadChapter(item: RecentMangaItem) - fun downloadChapterNow(chapter: Chapter) - fun setCover(manga: Manga, view: ImageView) - fun viewAll(position: Int) - } -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt index 10f5ce8ed4..41724c95e9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt @@ -8,25 +8,18 @@ import android.view.MenuInflater import android.view.MenuItem import android.view.View import android.view.ViewGroup -import android.widget.ImageView import androidx.appcompat.widget.SearchView import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.LinearLayoutManager import com.bluelinelabs.conductor.Controller import com.bluelinelabs.conductor.ControllerChangeHandler import com.bluelinelabs.conductor.ControllerChangeType -import com.bumptech.glide.load.engine.DiskCacheStrategy -import com.bumptech.glide.signature.ObjectKey import com.google.android.material.snackbar.BaseTransientBottomBar import com.google.android.material.snackbar.Snackbar import eu.davidea.flexibleadapter.FlexibleAdapter import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.data.database.models.Chapter -import eu.kanade.tachiyomi.data.database.models.Manga -import eu.kanade.tachiyomi.data.database.models.MangaImpl import eu.kanade.tachiyomi.data.download.DownloadService import eu.kanade.tachiyomi.data.download.model.Download -import eu.kanade.tachiyomi.data.glide.GlideApp import eu.kanade.tachiyomi.data.library.LibraryUpdateService import eu.kanade.tachiyomi.ui.base.controller.BaseController import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction @@ -50,7 +43,6 @@ import kotlinx.android.synthetic.main.recently_read_controller.* */ class RecentsController(bundle: Bundle? = null) : BaseController(bundle), RecentMangaAdapter.RecentsInterface, - RecentsAdapter.RecentsInterface, FlexibleAdapter.OnItemClickListener, RootSearchInterface { @@ -61,7 +53,6 @@ class RecentsController(bundle: Bundle? = null) : BaseController(bundle), /** * Adapter containing the recent manga. */ - // private val adapter = RecentsAdapter(this) private var adapter = RecentMangaAdapter(this) private var presenter = RecentsPresenter(this) @@ -92,11 +83,6 @@ class RecentsController(bundle: Bundle? = null) : BaseController(bundle), recycler.setHasFixedSize(true) recycler.recycledViewPool.setMaxRecycledViews(0, 0) adapter.isSwipeEnabled = true - /*recycler.addItemDecoration( - DividerItemDecoration( - recycler.context, DividerItemDecoration.VERTICAL - ) - )*/ adapter.itemTouchHelperCallback.setSwipeFlags( ItemTouchHelper.LEFT ) @@ -128,7 +114,6 @@ class RecentsController(bundle: Bundle? = null) : BaseController(bundle), refreshItem(lastChapterId ?: 0L) lastChapterId = null } - // recycler.removeItemDecorationAt(0) } fun updateChapterDownload(download: Download) { @@ -136,10 +121,6 @@ class RecentsController(bundle: Bundle? = null) : BaseController(bundle), val id = download.chapter.id ?: return val holder = recycler.findViewHolderForItemId(id) as? RecentMangaHolder ?: return holder.notifyStatus(download.status, download.progress) - /* (i in 0 until adapter.itemCount) { - val holder = recycler.findViewHolderForAdapterPosition(i) as? RecentsHolder ?: continue - if (holder.updateChapterDownload(download)) break - }*/ } private fun refreshItem(chapterId: Long) { @@ -147,20 +128,11 @@ class RecentsController(bundle: Bundle? = null) : BaseController(bundle), it is RecentMangaItem && it.mch.chapter.id == chapterId } if (recentItemPos > -1) adapter.notifyItemChanged(recentItemPos) - /*holder.notifyStatus(download.status, download.progress) - for (i in 0 until adapter.itemCount) { - val holder = recycler.findViewHolderForAdapterPosition(i) as? RecentsHolder ?: continue - holder.refreshChapter(chapterId) - }*/ } override fun downloadChapter(position: Int) { - val item = adapter.getItem(position) as? RecentMangaItem ?: return - downloadChapter(item) - } - - override fun downloadChapter(item: RecentMangaItem) { val view = view ?: return + val item = adapter.getItem(position) as? RecentMangaItem ?: return val chapter = item.chapter val manga = item.mch.manga if (item.status != Download.NOT_DOWNLOADED && item.status != Download.ERROR) { @@ -176,67 +148,56 @@ class RecentsController(bundle: Bundle? = null) : BaseController(bundle), presenter.startDownloadChapterNow(chapter) } - override fun downloadChapterNow(chapter: Chapter) { - presenter.startDownloadChapterNow(chapter) - } - override fun onCoverClick(position: Int) { val manga = (adapter.getItem(position) as? RecentMangaItem)?.mch?.manga ?: return router.pushController(MangaDetailsController(manga).withFadeTransaction()) } - override fun showManga(manga: Manga) = router.pushController(MangaDetailsController(manga).withFadeTransaction()) - override fun onItemClick(view: View?, position: Int): Boolean { val item = adapter.getItem(position) ?: return false if (item is RecentMangaItem) { if (item.mch.manga.id == null) { val headerItem = adapter.getHeaderOf(item) as? RecentMangaHeaderItem val controller: Controller = when (headerItem?.recentsType) { - RecentsItem.NEW_CHAPTERS -> RecentChaptersController() - RecentsItem.CONTINUE_READING -> RecentlyReadController() + RecentMangaHeaderItem.NEW_CHAPTERS -> RecentChaptersController() + RecentMangaHeaderItem.CONTINUE_READING -> RecentlyReadController() else -> return false } router.pushController(controller.withFadeTransaction()) - } else resumeManga(item.mch.manga, item.chapter) - } else if (item is RecentMangaHeaderItem) return false // onHeaderClick(position) + } else { + val activity = activity ?: return false + val intent = ReaderActivity.newIntent(activity, item.mch.manga, item.chapter) + startActivity(intent) + } + } else if (item is RecentMangaHeaderItem) return false return true } - override fun resumeManga(manga: Manga, chapter: Chapter) { - val activity = activity ?: return - val intent = ReaderActivity.newIntent(activity, manga, chapter) - startActivity(intent) - } - override fun markAsRead(position: Int) { val item = adapter.getItem(position) as? RecentMangaItem ?: return - markAsRead(item.mch.manga, item.chapter) - } - - override fun markAsRead(manga: Manga, chapter: Chapter) { + val chapter = item.chapter + val manga = item.mch.manga val lastRead = chapter.last_page_read val pagesLeft = chapter.pages_left lastChapterId = chapter.id presenter.markChapterRead(chapter, true) - snack = - view?.snack(R.string.marked_as_read, Snackbar.LENGTH_INDEFINITE) { - anchorView = activity?.bottom_nav - var undoing = false - setAction(R.string.action_undo) { - presenter.markChapterRead(chapter, false, lastRead, pagesLeft) - undoing = true - } - addCallback(object : BaseTransientBottomBar.BaseCallback() { - override fun onDismissed(transientBottomBar: Snackbar?, event: Int) { - super.onDismissed(transientBottomBar, event) - if (!undoing && presenter.preferences.removeAfterMarkedAsRead()) { - lastChapterId = chapter.id - presenter.deleteChapter(chapter, manga) - } - } - }) + snack = view?.snack(R.string.marked_as_read, Snackbar.LENGTH_INDEFINITE) { + anchorView = activity?.bottom_nav + var undoing = false + setAction(R.string.action_undo) { + presenter.markChapterRead(chapter, false, lastRead, pagesLeft) + undoing = true } + addCallback(object : BaseTransientBottomBar.BaseCallback() { + override fun onDismissed(transientBottomBar: Snackbar?, event: Int) { + super.onDismissed(transientBottomBar, event) + if (!undoing && presenter.preferences.removeAfterMarkedAsRead()) { + lastChapterId = chapter.id + presenter.deleteChapter(chapter, manga) + } + } + }) + } (activity as? MainActivity)?.setUndoSnackBar(snack) } @@ -274,33 +235,6 @@ class RecentsController(bundle: Bundle? = null) : BaseController(bundle), } } - override fun setCover(manga: Manga, view: ImageView) { - val activity = activity ?: return - GlideApp.with(activity).load(manga).diskCacheStrategy(DiskCacheStrategy.AUTOMATIC) - .signature(ObjectKey(MangaImpl.getLastCoverFetch(manga.id!!).toString())).into(view) - } - - override fun onHeaderClick(position: Int) { - val recentsType = (adapter.getItem(position) as? RecentMangaHeaderItem)?.recentsType - ?: return - val controller: Controller = when (recentsType) { - RecentsItem.NEW_CHAPTERS -> RecentChaptersController() - RecentsItem.CONTINUE_READING -> RecentlyReadController() - else -> return - } - router.pushController(controller.withFadeTransaction()) - } - - override fun viewAll(position: Int) { - /*val recentsType = (adapter.getItem(position) as? RecentsItem)?.recentType ?: return - val controller: Controller = when (recentsType) { - RecentsItem.NEW_CHAPTERS -> RecentChaptersController() - RecentsItem.CONTINUE_READING -> RecentlyReadController() - else -> return - } - router.pushController(controller.withFadeTransaction())*/ - } - override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { R.id.action_refresh -> { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsHolder.kt deleted file mode 100644 index b9f4e5c11f..0000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsHolder.kt +++ /dev/null @@ -1,136 +0,0 @@ -package eu.kanade.tachiyomi.ui.recents - -import android.view.View -import android.view.ViewGroup -import android.widget.ImageView -import androidx.recyclerview.widget.DividerItemDecoration -import androidx.recyclerview.widget.ItemTouchHelper -import androidx.recyclerview.widget.LinearLayoutManager -import eu.davidea.flexibleadapter.FlexibleAdapter -import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.data.database.models.Chapter -import eu.kanade.tachiyomi.data.database.models.Manga -import eu.kanade.tachiyomi.data.download.model.Download -import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder -import eu.kanade.tachiyomi.util.system.dpToPx -import eu.kanade.tachiyomi.util.view.updateLayoutParams -import eu.kanade.tachiyomi.util.view.visibleIf -import kotlinx.android.synthetic.main.recents_item.* - -class RecentsHolder( - view: View, - val adapter: RecentsAdapter -) : BaseFlexibleViewHolder(view, adapter), - FlexibleAdapter.OnItemClickListener, - FlexibleAdapter.OnUpdateListener, - RecentMangaAdapter.RecentsInterface { - - private val subAdapter = RecentMangaAdapter(this) - - init { - recycler.adapter = subAdapter - subAdapter.isSwipeEnabled = true - val manager = LinearLayoutManager(view.context) - recycler.layoutManager = manager - recycler.addItemDecoration( - DividerItemDecoration( - recycler.context, DividerItemDecoration.VERTICAL - ) - ) - recycler.setHasFixedSize(true) - view_all.setOnClickListener { adapter.delegate.viewAll(adapterPosition) } - subAdapter.itemTouchHelperCallback.setSwipeFlags( - ItemTouchHelper.LEFT - ) - } - - fun bind(item: RecentsItem) { - when (item.recentType) { - RecentsItem.CONTINUE_READING -> { - title.setText(R.string.continue_reading) - view_all.setText(R.string.view_history) - } - RecentsItem.NEW_CHAPTERS -> { - title.setText(R.string.new_chapters) - view_all.setText(R.string.view_all_updates) - } - RecentsItem.NEWLY_ADDED -> { - title.setText(R.string.new_additions) - } - } - title.visibleIf(item.recentType != RecentsItem.SEARCH) - view_all.visibleIf(item.recentType == RecentsItem.CONTINUE_READING || item.recentType == RecentsItem.NEW_CHAPTERS) - recycler.updateLayoutParams { - bottomMargin = if (adapterPosition == adapter.itemCount - 1) 0 else 12.dpToPx - } - subAdapter.updateDataSet(item.mangaList) - } - - override fun downloadChapter(position: Int) { - val item = (subAdapter.getItem(position) as? RecentMangaItem) ?: return - adapter.delegate.downloadChapter(item) - } - - override fun startDownloadNow(position: Int) { - val chapter = (subAdapter.getItem(position) as? RecentMangaItem)?.chapter ?: return - adapter.delegate.downloadChapterNow(chapter) - } - - override fun onCoverClick(position: Int) { - val manga = (subAdapter.getItem(position) as? RecentMangaItem)?.mch?.manga ?: return - adapter.delegate.showManga(manga) - } - - override fun onItemClick(view: View?, position: Int): Boolean { - val item = (subAdapter.getItem(position) as? RecentMangaItem) ?: return false - adapter.delegate.resumeManga(item.mch.manga, item.chapter) - return true - } - - fun updateChapterDownload(download: Download): Boolean { - val holder = getHolder(download.chapter) ?: return false - holder.notifyStatus(download.status, download.progress) - return true - } - - fun refreshChapter(chapterId: Long) { - val item = (adapter.getItem(adapterPosition) as? RecentsItem) ?: return - val recentItemPos = item.mangaList.indexOfFirst { it.mch.chapter.id == chapterId } - if (recentItemPos > -1) subAdapter.notifyItemChanged(recentItemPos) - } - - override fun onUpdateEmptyView(size: Int) { - if (size > 0) { - empty_view?.hide() - } else { - val recentsType = (adapter.getItem(adapterPosition) as? RecentsItem)?.recentType ?: return - when (recentsType) { - RecentsItem.CONTINUE_READING -> - empty_view?.show(R.drawable.ic_history_white_128dp, R.string.information_no_recent_manga) - RecentsItem.NEW_CHAPTERS -> - empty_view?.show(R.drawable.ic_update_black_128dp, R.string.information_no_recent) - RecentsItem.NEWLY_ADDED -> - empty_view?.show(R.drawable.recent_read_outline_128dp, R.string.information_no_recent) - RecentsItem.SEARCH -> - empty_view?.show(R.drawable.search_128dp, R.string.no_search_result) - } - } - } - - private fun getHolder(chapter: Chapter): RecentMangaHolder? { - return recycler?.findViewHolderForItemId(chapter.id!!) as? RecentMangaHolder - } - - override fun setCover(manga: Manga, view: ImageView) { - adapter.delegate.setCover(manga, view) - } - - override fun markAsRead(position: Int) { - val item = (subAdapter.getItem(position) as RecentMangaItem) - adapter.delegate.markAsRead(item.mch.manga, item.chapter) - } - - override fun onHeaderClick(position: Int) { - } - override fun isSearching() = false -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsItem.kt deleted file mode 100644 index 224fac1dde..0000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsItem.kt +++ /dev/null @@ -1,51 +0,0 @@ -package eu.kanade.tachiyomi.ui.recents - -import android.view.View -import androidx.recyclerview.widget.RecyclerView -import eu.davidea.flexibleadapter.FlexibleAdapter -import eu.davidea.flexibleadapter.items.AbstractFlexibleItem -import eu.davidea.flexibleadapter.items.IFlexible -import eu.kanade.tachiyomi.R - -class RecentsItem(val recentType: Int, val mangaList: List) : - AbstractFlexibleItem() { - - override fun getLayoutRes(): Int { - return R.layout.recents_item - } - - override fun createViewHolder( - view: View, - adapter: FlexibleAdapter> - ): RecentsHolder { - return RecentsHolder(view, adapter as RecentsAdapter) - } - - override fun bindViewHolder( - adapter: FlexibleAdapter>, - holder: RecentsHolder, - position: Int, - payloads: MutableList? - ) { - - holder.bind(this) - } - - override fun equals(other: Any?): Boolean { - if (other is RecentsItem) { - return recentType == other.recentType - } - return false - } - - override fun hashCode(): Int { - return recentType.hashCode() - } - - companion object { - const val CONTINUE_READING = 0 - const val NEW_CHAPTERS = 1 - const val NEWLY_ADDED = 2 - const val SEARCH = 3 - } -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsPresenter.kt index 2f1cfdd4fc..5ef3f436f0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsPresenter.kt @@ -32,12 +32,12 @@ class RecentsPresenter( private var scope = CoroutineScope(Job() + Dispatchers.Default) - var recentItems = listOf() - // var groupedRecentItems = listOf() + private var recentItems = listOf() var query = "" - var newAdditionsHeader = RecentMangaHeaderItem(RecentsItem.NEWLY_ADDED) - var newChaptersHeader = RecentMangaHeaderItem(RecentsItem.NEW_CHAPTERS) - var continueReadingHeader = RecentMangaHeaderItem(RecentsItem.CONTINUE_READING) + private val newAdditionsHeader = RecentMangaHeaderItem(RecentMangaHeaderItem.NEWLY_ADDED) + private val newChaptersHeader = RecentMangaHeaderItem(RecentMangaHeaderItem.NEW_CHAPTERS) + private val continueReadingHeader = RecentMangaHeaderItem(RecentMangaHeaderItem + .CONTINUE_READING) fun onCreate() { downloadManager.addListener(this)