From 29eb87b7efada58420bc2536abaa79fcfc59b111 Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 6 Mar 2020 22:55:44 -0500 Subject: [PATCH] Rename recently read / recent updates classes/layouts to match new names --- .../kanade/tachiyomi/ui/main/MainActivity.kt | 8 +-- .../history/HistoryAdapter.kt} | 10 ++-- .../history/HistoryController.kt} | 26 ++++----- .../history/HistoryHolder.kt} | 18 +++--- .../history/HistoryItem.kt} | 14 ++--- .../history/HistoryPresenter.kt} | 12 ++-- .../history}/RemoveHistoryDialog.kt | 2 +- .../updates}/ConfirmDeleteChaptersDialog.kt | 8 +-- .../updates}/DateItem.kt | 4 +- .../updates}/DeletingChaptersDialog.kt | 2 +- .../updates/UpdatesAdapter.kt} | 4 +- .../updates/UpdatesController.kt} | 56 +++++++++---------- .../updates/UpdatesHolder.kt} | 18 +++--- .../updates/UpdatesItem.kt} | 16 +++--- .../updates/UpdatesPresenter.kt} | 30 +++++----- ..._controller.xml => history_controller.xml} | 2 +- ...ecently_read_item.xml => history_item.xml} | 0 ..._controller.xml => updates_controller.xml} | 2 +- ...ent_chapters_item.xml => updates_item.xml} | 0 ...tion_item.xml => updates_section_item.xml} | 0 20 files changed, 116 insertions(+), 116 deletions(-) rename app/src/main/java/eu/kanade/tachiyomi/ui/{recently_read/RecentlyReadAdapter.kt => recent/history/HistoryAdapter.kt} (83%) rename app/src/main/java/eu/kanade/tachiyomi/ui/{recently_read/RecentlyReadController.kt => recent/history/HistoryController.kt} (80%) rename app/src/main/java/eu/kanade/tachiyomi/ui/{recently_read/RecentlyReadHolder.kt => recent/history/HistoryHolder.kt} (81%) rename app/src/main/java/eu/kanade/tachiyomi/ui/{recently_read/RecentlyReadItem.kt => recent/history/HistoryItem.kt} (68%) rename app/src/main/java/eu/kanade/tachiyomi/ui/{recently_read/RecentlyReadPresenter.kt => recent/history/HistoryPresenter.kt} (90%) rename app/src/main/java/eu/kanade/tachiyomi/ui/{recently_read => recent/history}/RemoveHistoryDialog.kt (97%) rename app/src/main/java/eu/kanade/tachiyomi/ui/{recent_updates => recent/updates}/ConfirmDeleteChaptersDialog.kt (78%) rename app/src/main/java/eu/kanade/tachiyomi/ui/{recent_updates => recent/updates}/DateItem.kt (93%) rename app/src/main/java/eu/kanade/tachiyomi/ui/{recent_updates => recent/updates}/DeletingChaptersDialog.kt (93%) rename app/src/main/java/eu/kanade/tachiyomi/ui/{recent_updates/RecentChaptersAdapter.kt => recent/updates/UpdatesAdapter.kt} (77%) rename app/src/main/java/eu/kanade/tachiyomi/ui/{recent_updates/RecentChaptersController.kt => recent/updates/UpdatesController.kt} (85%) rename app/src/main/java/eu/kanade/tachiyomi/ui/{recent_updates/RecentChapterHolder.kt => recent/updates/UpdatesHolder.kt} (88%) rename app/src/main/java/eu/kanade/tachiyomi/ui/{recent_updates/RecentChapterItem.kt => recent/updates/UpdatesItem.kt} (73%) rename app/src/main/java/eu/kanade/tachiyomi/ui/{recent_updates/RecentChaptersPresenter.kt => recent/updates/UpdatesPresenter.kt} (86%) rename app/src/main/res/layout/{recently_read_controller.xml => history_controller.xml} (93%) rename app/src/main/res/layout/{recently_read_item.xml => history_item.xml} (100%) rename app/src/main/res/layout/{recent_chapters_controller.xml => updates_controller.xml} (94%) rename app/src/main/res/layout/{recent_chapters_item.xml => updates_item.xml} (100%) rename app/src/main/res/layout/{recent_chapters_section_item.xml => updates_section_item.xml} (100%) 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 9ff314ac5d..41951bea2d 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 @@ -26,8 +26,8 @@ import eu.kanade.tachiyomi.ui.download.DownloadController import eu.kanade.tachiyomi.ui.library.LibraryController import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.more.MoreController -import eu.kanade.tachiyomi.ui.recent_updates.RecentChaptersController -import eu.kanade.tachiyomi.ui.recently_read.RecentlyReadController +import eu.kanade.tachiyomi.ui.recent.history.HistoryController +import eu.kanade.tachiyomi.ui.recent.updates.UpdatesController import kotlinx.android.synthetic.main.main_activity.appbar import kotlinx.android.synthetic.main.main_activity.bottom_nav import kotlinx.android.synthetic.main.main_activity.drawer @@ -75,8 +75,8 @@ class MainActivity : BaseActivity() { if (currentRoot?.tag()?.toIntOrNull() != id) { when (id) { R.id.nav_library -> setRoot(LibraryController(), id) - R.id.nav_updates -> setRoot(RecentChaptersController(), id) - R.id.nav_history -> setRoot(RecentlyReadController(), id) + R.id.nav_updates -> setRoot(UpdatesController(), id) + R.id.nav_history -> setRoot(HistoryController(), id) R.id.nav_catalogues -> setRoot(CatalogueController(), id) R.id.nav_more -> setRoot(MoreController(), id) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryAdapter.kt similarity index 83% rename from app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadAdapter.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryAdapter.kt index 67d09ff2d4..a4889a17bf 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryAdapter.kt @@ -1,4 +1,4 @@ -package eu.kanade.tachiyomi.ui.recently_read +package eu.kanade.tachiyomi.ui.recent.history import eu.davidea.flexibleadapter.FlexibleAdapter import eu.kanade.tachiyomi.data.preference.PreferencesHelper @@ -10,15 +10,15 @@ import java.text.DecimalFormatSymbols import uy.kohesive.injekt.injectLazy /** - * Adapter of RecentlyReadHolder. + * Adapter of HistoryHolder. * Connection between Fragment and Holder * Holder updates should be called from here. * - * @param controller a RecentlyReadController object + * @param controller a HistoryController object * @constructor creates an instance of the adapter. */ -class RecentlyReadAdapter(controller: RecentlyReadController) : - FlexibleAdapter(null, controller, true) { +class HistoryAdapter(controller: HistoryController) : + FlexibleAdapter(null, controller, true) { val sourceManager by injectLazy() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt similarity index 80% rename from app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadController.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt index 677b2212e0..167cb16f26 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt @@ -1,4 +1,4 @@ -package eu.kanade.tachiyomi.ui.recently_read +package eu.kanade.tachiyomi.ui.recent.history import android.view.LayoutInflater import android.view.View @@ -14,38 +14,38 @@ import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.reader.ReaderActivity import eu.kanade.tachiyomi.util.system.toast -import kotlinx.android.synthetic.main.recently_read_controller.empty_view -import kotlinx.android.synthetic.main.recently_read_controller.recycler +import kotlinx.android.synthetic.main.history_controller.empty_view +import kotlinx.android.synthetic.main.history_controller.recycler /** * Fragment that shows recently read manga. * Uses R.layout.fragment_recently_read. * UI related actions should be called from here. */ -class RecentlyReadController : NucleusController(), +class HistoryController : NucleusController(), RootController, FlexibleAdapter.OnUpdateListener, - RecentlyReadAdapter.OnRemoveClickListener, - RecentlyReadAdapter.OnResumeClickListener, - RecentlyReadAdapter.OnCoverClickListener, + HistoryAdapter.OnRemoveClickListener, + HistoryAdapter.OnResumeClickListener, + HistoryAdapter.OnCoverClickListener, RemoveHistoryDialog.Listener { /** * Adapter containing the recent manga. */ - var adapter: RecentlyReadAdapter? = null + var adapter: HistoryAdapter? = null private set override fun getTitle(): String? { return resources?.getString(R.string.label_recent_manga) } - override fun createPresenter(): RecentlyReadPresenter { - return RecentlyReadPresenter() + override fun createPresenter(): HistoryPresenter { + return HistoryPresenter() } override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View { - return inflater.inflate(R.layout.recently_read_controller, container, false) + return inflater.inflate(R.layout.history_controller, container, false) } /** @@ -58,7 +58,7 @@ class RecentlyReadController : NucleusController(), // Initialize adapter recycler.layoutManager = LinearLayoutManager(view.context) - adapter = RecentlyReadAdapter(this@RecentlyReadController) + adapter = HistoryAdapter(this@HistoryController) recycler.setHasFixedSize(true) recycler.adapter = adapter } @@ -73,7 +73,7 @@ class RecentlyReadController : NucleusController(), * * @param mangaHistory list of manga history */ - fun onNextManga(mangaHistory: List) { + fun onNextManga(mangaHistory: List) { adapter?.updateDataSet(mangaHistory) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryHolder.kt similarity index 81% rename from app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadHolder.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryHolder.kt index 990fafd3a9..d096d0d23a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryHolder.kt @@ -1,4 +1,4 @@ -package eu.kanade.tachiyomi.ui.recently_read +package eu.kanade.tachiyomi.ui.recent.history import android.view.View import com.bumptech.glide.load.engine.DiskCacheStrategy @@ -8,12 +8,12 @@ import eu.kanade.tachiyomi.data.glide.GlideApp import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder import eu.kanade.tachiyomi.util.lang.toTimestampString import java.util.Date -import kotlinx.android.synthetic.main.recently_read_item.cover -import kotlinx.android.synthetic.main.recently_read_item.last_read -import kotlinx.android.synthetic.main.recently_read_item.manga_source -import kotlinx.android.synthetic.main.recently_read_item.manga_title -import kotlinx.android.synthetic.main.recently_read_item.remove -import kotlinx.android.synthetic.main.recently_read_item.resume +import kotlinx.android.synthetic.main.history_item.cover +import kotlinx.android.synthetic.main.history_item.last_read +import kotlinx.android.synthetic.main.history_item.manga_source +import kotlinx.android.synthetic.main.history_item.manga_title +import kotlinx.android.synthetic.main.history_item.remove +import kotlinx.android.synthetic.main.history_item.resume /** * Holder that contains recent manga item @@ -24,9 +24,9 @@ import kotlinx.android.synthetic.main.recently_read_item.resume * @param adapter the adapter handling this holder. * @constructor creates a new recent chapter holder. */ -class RecentlyReadHolder( +class HistoryHolder( view: View, - val adapter: RecentlyReadAdapter + val adapter: HistoryAdapter ) : BaseFlexibleViewHolder(view, adapter) { init { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryItem.kt similarity index 68% rename from app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadItem.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryItem.kt index 7ab671ee6a..a13f2dbfb0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryItem.kt @@ -1,4 +1,4 @@ -package eu.kanade.tachiyomi.ui.recently_read +package eu.kanade.tachiyomi.ui.recent.history 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.MangaChapterHistory -class RecentlyReadItem(val mch: MangaChapterHistory) : AbstractFlexibleItem() { +class HistoryItem(val mch: MangaChapterHistory) : AbstractFlexibleItem() { override fun getLayoutRes(): Int { - return R.layout.recently_read_item + return R.layout.history_item } - override fun createViewHolder(view: View, adapter: FlexibleAdapter>): RecentlyReadHolder { - return RecentlyReadHolder(view, adapter as RecentlyReadAdapter) + override fun createViewHolder(view: View, adapter: FlexibleAdapter>): HistoryHolder { + return HistoryHolder(view, adapter as HistoryAdapter) } override fun bindViewHolder( adapter: FlexibleAdapter>, - holder: RecentlyReadHolder, + holder: HistoryHolder, position: Int, payloads: List? ) { @@ -29,7 +29,7 @@ class RecentlyReadItem(val mch: MangaChapterHistory) : AbstractFlexibleItem() { +class HistoryPresenter : BasePresenter() { /** * Used to connect to database @@ -30,21 +30,21 @@ class RecentlyReadPresenter : BasePresenter() { // Used to get a list of recently read manga getRecentMangaObservable() - .subscribeLatestCache(RecentlyReadController::onNextManga) + .subscribeLatestCache(HistoryController::onNextManga) } /** * Get recent manga observable * @return list of history */ - fun getRecentMangaObservable(): Observable> { + fun getRecentMangaObservable(): Observable> { // Set date for recent manga val cal = Calendar.getInstance() cal.time = Date() cal.add(Calendar.MONTH, -1) return db.getRecentManga(cal.time).asRxObservable() - .map { recents -> recents.map(::RecentlyReadItem) } + .map { recents -> recents.map(::HistoryItem) } .observeOn(AndroidSchedulers.mainThread()) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RemoveHistoryDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/RemoveHistoryDialog.kt similarity index 97% rename from app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RemoveHistoryDialog.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/RemoveHistoryDialog.kt index 320bbc6618..086fb7257a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RemoveHistoryDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/RemoveHistoryDialog.kt @@ -1,4 +1,4 @@ -package eu.kanade.tachiyomi.ui.recently_read +package eu.kanade.tachiyomi.ui.recent.history import android.app.Dialog import android.os.Bundle diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/ConfirmDeleteChaptersDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/ConfirmDeleteChaptersDialog.kt similarity index 78% rename from app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/ConfirmDeleteChaptersDialog.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/ConfirmDeleteChaptersDialog.kt index bb8f5c47df..022893a0ff 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/ConfirmDeleteChaptersDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/ConfirmDeleteChaptersDialog.kt @@ -1,4 +1,4 @@ -package eu.kanade.tachiyomi.ui.recent_updates +package eu.kanade.tachiyomi.ui.recent.updates import android.app.Dialog import android.os.Bundle @@ -10,9 +10,9 @@ import eu.kanade.tachiyomi.ui.base.controller.DialogController class ConfirmDeleteChaptersDialog(bundle: Bundle? = null) : DialogController(bundle) where T : Controller, T : ConfirmDeleteChaptersDialog.Listener { - private var chaptersToDelete = emptyList() + private var chaptersToDelete = emptyList() - constructor(target: T, chaptersToDelete: List) : this() { + constructor(target: T, chaptersToDelete: List) : this() { this.chaptersToDelete = chaptersToDelete targetController = target } @@ -29,6 +29,6 @@ class ConfirmDeleteChaptersDialog(bundle: Bundle? = null) : DialogController( } interface Listener { - fun deleteChapters(chaptersToDelete: List) + fun deleteChapters(chaptersToDelete: List) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/DateItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/DateItem.kt similarity index 93% rename from app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/DateItem.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/DateItem.kt index 378c0729d2..913e93f28b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/DateItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/DateItem.kt @@ -1,4 +1,4 @@ -package eu.kanade.tachiyomi.ui.recent_updates +package eu.kanade.tachiyomi.ui.recent.updates import android.text.format.DateUtils import android.view.View @@ -14,7 +14,7 @@ import java.util.Date class DateItem(val date: Date) : AbstractHeaderItem() { override fun getLayoutRes(): Int { - return R.layout.recent_chapters_section_item + return R.layout.updates_section_item } override fun createViewHolder(view: View, adapter: FlexibleAdapter>): Holder { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/DeletingChaptersDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/DeletingChaptersDialog.kt similarity index 93% rename from app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/DeletingChaptersDialog.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/DeletingChaptersDialog.kt index 8d03dce65e..b62633c060 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/DeletingChaptersDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/DeletingChaptersDialog.kt @@ -1,4 +1,4 @@ -package eu.kanade.tachiyomi.ui.recent_updates +package eu.kanade.tachiyomi.ui.recent.updates import android.app.Dialog import android.os.Bundle diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/RecentChaptersAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesAdapter.kt similarity index 77% rename from app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/RecentChaptersAdapter.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesAdapter.kt index e829a71356..f12b440b51 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/RecentChaptersAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesAdapter.kt @@ -1,9 +1,9 @@ -package eu.kanade.tachiyomi.ui.recent_updates +package eu.kanade.tachiyomi.ui.recent.updates import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.items.IFlexible -class RecentChaptersAdapter(val controller: RecentChaptersController) : +class UpdatesAdapter(val controller: UpdatesController) : FlexibleAdapter>(null, controller, true) { val coverClickListener: OnCoverClickListener = controller diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/RecentChaptersController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt similarity index 85% rename from app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/RecentChaptersController.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt index ec95e113fe..4c8ebca1fd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/RecentChaptersController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt @@ -1,4 +1,4 @@ -package eu.kanade.tachiyomi.ui.recent_updates +package eu.kanade.tachiyomi.ui.recent.updates import android.view.LayoutInflater import android.view.Menu @@ -27,17 +27,17 @@ import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.reader.ReaderActivity import eu.kanade.tachiyomi.util.system.notificationManager import eu.kanade.tachiyomi.util.system.toast -import kotlinx.android.synthetic.main.recent_chapters_controller.empty_view -import kotlinx.android.synthetic.main.recent_chapters_controller.recycler -import kotlinx.android.synthetic.main.recent_chapters_controller.swipe_refresh +import kotlinx.android.synthetic.main.updates_controller.empty_view +import kotlinx.android.synthetic.main.updates_controller.recycler +import kotlinx.android.synthetic.main.updates_controller.swipe_refresh import timber.log.Timber /** * Fragment that shows recent chapters. - * Uses [R.layout.recent_chapters_controller]. + * Uses [R.layout.updates_controller]. * UI related actions should be called from here. */ -class RecentChaptersController : NucleusController(), +class UpdatesController : NucleusController(), RootController, NoToolbarElevationController, ActionMode.Callback, @@ -45,7 +45,7 @@ class RecentChaptersController : NucleusController(), FlexibleAdapter.OnItemLongClickListener, FlexibleAdapter.OnUpdateListener, ConfirmDeleteChaptersDialog.Listener, - RecentChaptersAdapter.OnCoverClickListener { + UpdatesAdapter.OnCoverClickListener { /** * Action mode for multiple selection. @@ -55,19 +55,19 @@ class RecentChaptersController : NucleusController(), /** * Adapter containing the recent chapters. */ - var adapter: RecentChaptersAdapter? = null + var adapter: UpdatesAdapter? = null private set override fun getTitle(): String? { return resources?.getString(R.string.label_recent_updates) } - override fun createPresenter(): RecentChaptersPresenter { - return RecentChaptersPresenter() + override fun createPresenter(): UpdatesPresenter { + return UpdatesPresenter() } override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View { - return inflater.inflate(R.layout.recent_chapters_controller, container, false) + return inflater.inflate(R.layout.updates_controller, container, false) } /** @@ -82,7 +82,7 @@ class RecentChaptersController : NucleusController(), recycler.layoutManager = layoutManager recycler.addItemDecoration(DividerItemDecoration(view.context, DividerItemDecoration.VERTICAL)) recycler.setHasFixedSize(true) - adapter = RecentChaptersAdapter(this@RecentChaptersController) + adapter = UpdatesAdapter(this@UpdatesController) recycler.adapter = adapter recycler.scrollStateChanges().subscribeUntilDestroy { @@ -112,9 +112,9 @@ class RecentChaptersController : NucleusController(), * Returns selected chapters * @return list of selected chapters */ - fun getSelectedChapters(): List { + fun getSelectedChapters(): List { val adapter = adapter ?: return emptyList() - return adapter.selectedPositions.mapNotNull { adapter.getItem(it) as? RecentChapterItem } + return adapter.selectedPositions.mapNotNull { adapter.getItem(it) as? UpdatesItem } } /** @@ -125,7 +125,7 @@ class RecentChaptersController : NucleusController(), val adapter = adapter ?: return false // Get item from position - val item = adapter.getItem(position) as? RecentChapterItem ?: return false + val item = adapter.getItem(position) as? UpdatesItem ?: return false if (actionMode != null && adapter.mode == SelectableAdapter.Mode.MULTI) { toggleSelection(position) return true @@ -160,7 +160,7 @@ class RecentChaptersController : NucleusController(), * Open chapter in reader * @param chapter selected chapter */ - private fun openChapter(item: RecentChapterItem) { + private fun openChapter(item: UpdatesItem) { val activity = activity ?: return val intent = ReaderActivity.newIntent(activity, item.manga, item.chapter) startActivity(intent) @@ -168,9 +168,9 @@ class RecentChaptersController : NucleusController(), /** * Download selected items - * @param chapters list of selected [RecentChapter]s + * @param chapters list of selected [UpdatesItem]s */ - fun downloadChapters(chapters: List) { + fun downloadChapters(chapters: List) { destroyActionModeIfNeeded() presenter.downloadChapters(chapters) } @@ -204,22 +204,22 @@ class RecentChaptersController : NucleusController(), * Returns holder belonging to chapter * @param download [Download] object containing download progress. */ - private fun getHolder(download: Download): RecentChapterHolder? { - return recycler?.findViewHolderForItemId(download.chapter.id!!) as? RecentChapterHolder + private fun getHolder(download: Download): UpdatesHolder? { + return recycler?.findViewHolderForItemId(download.chapter.id!!) as? UpdatesHolder } /** * Mark chapter as read * @param chapters list of chapters */ - fun markAsRead(chapters: List) { + fun markAsRead(chapters: List) { presenter.markChapterRead(chapters, true) if (presenter.preferences.removeAfterMarkedAsRead()) { deleteChapters(chapters) } } - override fun deleteChapters(chaptersToDelete: List) { + override fun deleteChapters(chaptersToDelete: List) { destroyActionModeIfNeeded() DeletingChaptersDialog().showDialog(router) presenter.deleteChapters(chaptersToDelete) @@ -234,9 +234,9 @@ class RecentChaptersController : NucleusController(), /** * Mark chapter as unread - * @param chapters list of selected [RecentChapter] + * @param chapters list of selected [UpdatesItem] */ - fun markAsUnread(chapters: List) { + fun markAsUnread(chapters: List) { presenter.markChapterRead(chapters, false) } @@ -244,7 +244,7 @@ class RecentChaptersController : NucleusController(), * Start downloading chapter * @param chapter selected chapter with manga */ - fun downloadChapter(chapter: RecentChapterItem) { + fun downloadChapter(chapter: UpdatesItem) { presenter.downloadChapters(listOf(chapter)) } @@ -252,17 +252,17 @@ class RecentChaptersController : NucleusController(), * Start deleting chapter * @param chapter selected chapter with manga */ - fun deleteChapter(chapter: RecentChapterItem) { + fun deleteChapter(chapter: UpdatesItem) { DeletingChaptersDialog().showDialog(router) presenter.deleteChapters(listOf(chapter)) } override fun onCoverClick(position: Int) { - val chapterClicked = adapter?.getItem(position) as? RecentChapterItem ?: return + val chapterClicked = adapter?.getItem(position) as? UpdatesItem ?: return openManga(chapterClicked) } - fun openManga(chapter: RecentChapterItem) { + fun openManga(chapter: UpdatesItem) { router.pushController(MangaController(chapter.manga).withFadeTransaction()) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/RecentChapterHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesHolder.kt similarity index 88% rename from app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/RecentChapterHolder.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesHolder.kt index efaf7aeaf4..fcb5e04ecc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/RecentChapterHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesHolder.kt @@ -1,4 +1,4 @@ -package eu.kanade.tachiyomi.ui.recent_updates +package eu.kanade.tachiyomi.ui.recent.updates import android.view.View import android.widget.PopupMenu @@ -8,11 +8,11 @@ import eu.kanade.tachiyomi.data.download.model.Download import eu.kanade.tachiyomi.data.glide.GlideApp import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder import eu.kanade.tachiyomi.util.system.getResourceColor -import kotlinx.android.synthetic.main.recent_chapters_item.chapter_menu -import kotlinx.android.synthetic.main.recent_chapters_item.chapter_title -import kotlinx.android.synthetic.main.recent_chapters_item.download_text -import kotlinx.android.synthetic.main.recent_chapters_item.manga_cover -import kotlinx.android.synthetic.main.recent_chapters_item.manga_title +import kotlinx.android.synthetic.main.updates_item.chapter_menu +import kotlinx.android.synthetic.main.updates_item.chapter_title +import kotlinx.android.synthetic.main.updates_item.download_text +import kotlinx.android.synthetic.main.updates_item.manga_cover +import kotlinx.android.synthetic.main.updates_item.manga_title /** * Holder that contains chapter item @@ -24,7 +24,7 @@ import kotlinx.android.synthetic.main.recent_chapters_item.manga_title * @param listener a listener to react to single tap and long tap events. * @constructor creates a new recent chapter holder. */ -class RecentChapterHolder(private val view: View, private val adapter: RecentChaptersAdapter) : +class UpdatesHolder(private val view: View, private val adapter: UpdatesAdapter) : BaseFlexibleViewHolder(view, adapter) { /** @@ -40,7 +40,7 @@ class RecentChapterHolder(private val view: View, private val adapter: RecentCha /** * Currently bound item. */ - private var item: RecentChapterItem? = null + private var item: UpdatesItem? = null init { // We need to post a Runnable to show the popup to make sure that the PopupMenu is @@ -57,7 +57,7 @@ class RecentChapterHolder(private val view: View, private val adapter: RecentCha * * @param item item containing chapter information */ - fun bind(item: RecentChapterItem) { + fun bind(item: UpdatesItem) { this.item = item // Set chapter title diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/RecentChapterItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesItem.kt similarity index 73% rename from app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/RecentChapterItem.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesItem.kt index d801940ce1..0925d039b2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/RecentChapterItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesItem.kt @@ -1,4 +1,4 @@ -package eu.kanade.tachiyomi.ui.recent_updates +package eu.kanade.tachiyomi.ui.recent.updates import android.view.View import androidx.recyclerview.widget.RecyclerView @@ -10,8 +10,8 @@ import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.download.model.Download -class RecentChapterItem(val chapter: Chapter, val manga: Manga, header: DateItem) : - AbstractSectionableItem(header) { +class UpdatesItem(val chapter: Chapter, val manga: Manga, header: DateItem) : + AbstractSectionableItem(header) { private var _status: Int = 0 @@ -28,16 +28,16 @@ class RecentChapterItem(val chapter: Chapter, val manga: Manga, header: DateItem get() = status == Download.DOWNLOADED override fun getLayoutRes(): Int { - return R.layout.recent_chapters_item + return R.layout.updates_item } - override fun createViewHolder(view: View, adapter: FlexibleAdapter>): RecentChapterHolder { - return RecentChapterHolder(view, adapter as RecentChaptersAdapter) + override fun createViewHolder(view: View, adapter: FlexibleAdapter>): UpdatesHolder { + return UpdatesHolder(view, adapter as UpdatesAdapter) } override fun bindViewHolder( adapter: FlexibleAdapter>, - holder: RecentChapterHolder, + holder: UpdatesHolder, position: Int, payloads: List? ) { @@ -47,7 +47,7 @@ class RecentChapterItem(val chapter: Chapter, val manga: Manga, header: DateItem override fun equals(other: Any?): Boolean { if (this === other) return true - if (other is RecentChapterItem) { + if (other is UpdatesItem) { return chapter.id!! == other.chapter.id!! } return false diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/RecentChaptersPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt similarity index 86% rename from app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/RecentChaptersPresenter.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt index 1da0c38030..39ebbbccdb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/RecentChaptersPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt @@ -1,4 +1,4 @@ -package eu.kanade.tachiyomi.ui.recent_updates +package eu.kanade.tachiyomi.ui.recent.updates import android.os.Bundle import eu.kanade.tachiyomi.data.database.DatabaseHelper @@ -18,27 +18,27 @@ import timber.log.Timber import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -class RecentChaptersPresenter( +class UpdatesPresenter( val preferences: PreferencesHelper = Injekt.get(), private val db: DatabaseHelper = Injekt.get(), private val downloadManager: DownloadManager = Injekt.get(), private val sourceManager: SourceManager = Injekt.get() -) : BasePresenter() { +) : BasePresenter() { /** * List containing chapter and manga information */ - private var chapters: List = emptyList() + private var chapters: List = emptyList() override fun onCreate(savedState: Bundle?) { super.onCreate(savedState) - getRecentChaptersObservable() + getUpdatesObservable() .observeOn(AndroidSchedulers.mainThread()) - .subscribeLatestCache(RecentChaptersController::onNextRecentChapters) + .subscribeLatestCache(UpdatesController::onNextRecentChapters) getChapterStatusObservable() - .subscribeLatestCache(RecentChaptersController::onChapterStatusChange) { _, error -> + .subscribeLatestCache(UpdatesController::onChapterStatusChange) { _, error -> Timber.e(error) } } @@ -48,7 +48,7 @@ class RecentChaptersPresenter( * * @return observable containing recent chapters and date */ - fun getRecentChaptersObservable(): Observable> { + private fun getUpdatesObservable(): Observable> { // Set date limit for recent chapters val cal = Calendar.getInstance().apply { time = Date() @@ -65,7 +65,7 @@ class RecentChaptersPresenter( val dateItem = DateItem(it.key) it.value .sortedWith(compareBy({ it.chapter.date_fetch }, { it.chapter.chapter_number })).asReversed() - .map { RecentChapterItem(it.chapter, it.manga, dateItem) } + .map { UpdatesItem(it.chapter, it.manga, dateItem) } } } .doOnNext { @@ -116,7 +116,7 @@ class RecentChaptersPresenter( * * @param items the list of chapter from the database. */ - private fun setDownloadedChapters(items: List) { + private fun setDownloadedChapters(items: List) { for (item in items) { val manga = item.manga val chapter = item.chapter @@ -148,7 +148,7 @@ class RecentChaptersPresenter( * @param items list of selected chapters * @param read read status */ - fun markChapterRead(items: List, read: Boolean) { + fun markChapterRead(items: List, read: Boolean) { val chapters = items.map { it.chapter } chapters.forEach { it.read = read @@ -167,21 +167,21 @@ class RecentChaptersPresenter( * * @param chapters list of chapters */ - fun deleteChapters(chapters: List) { + fun deleteChapters(chapters: List) { Observable.just(chapters) .doOnNext { deleteChaptersInternal(it) } .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribeFirst({ view, _ -> view.onChaptersDeleted() - }, RecentChaptersController::onChaptersDeletedError) + }, UpdatesController::onChaptersDeletedError) } /** * Download selected chapters * @param items list of recent chapters seleted. */ - fun downloadChapters(items: List) { + fun downloadChapters(items: List) { items.forEach { downloadManager.downloadChapters(it.manga, listOf(it.chapter)) } } @@ -190,7 +190,7 @@ class RecentChaptersPresenter( * * @param items chapters selected */ - private fun deleteChaptersInternal(chapterItems: List) { + private fun deleteChaptersInternal(chapterItems: List) { val itemsByManga = chapterItems.groupBy { it.manga.id } for ((_, items) in itemsByManga) { val manga = items.first().manga diff --git a/app/src/main/res/layout/recently_read_controller.xml b/app/src/main/res/layout/history_controller.xml similarity index 93% rename from app/src/main/res/layout/recently_read_controller.xml rename to app/src/main/res/layout/history_controller.xml index 6fae21c749..f43124068f 100644 --- a/app/src/main/res/layout/recently_read_controller.xml +++ b/app/src/main/res/layout/history_controller.xml @@ -12,7 +12,7 @@ android:clipToPadding="false" android:paddingTop="4dp" android:paddingBottom="4dp" - tools:listitem="@layout/recently_read_item" /> + tools:listitem="@layout/history_item" /> + tools:listitem="@layout/updates_item" />