mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 17:11:51 +01:00
Rename recently read / recent updates classes/layouts to match new names
This commit is contained in:
parent
c38026886a
commit
29eb87b7ef
@ -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)
|
||||
}
|
||||
|
@ -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<RecentlyReadItem>(null, controller, true) {
|
||||
class HistoryAdapter(controller: HistoryController) :
|
||||
FlexibleAdapter<HistoryItem>(null, controller, true) {
|
||||
|
||||
val sourceManager by injectLazy<SourceManager>()
|
||||
|
@ -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<RecentlyReadPresenter>(),
|
||||
class HistoryController : NucleusController<HistoryPresenter>(),
|
||||
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<RecentlyReadPresenter>(),
|
||||
|
||||
// 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<RecentlyReadPresenter>(),
|
||||
*
|
||||
* @param mangaHistory list of manga history
|
||||
*/
|
||||
fun onNextManga(mangaHistory: List<RecentlyReadItem>) {
|
||||
fun onNextManga(mangaHistory: List<HistoryItem>) {
|
||||
adapter?.updateDataSet(mangaHistory)
|
||||
}
|
||||
|
@ -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 {
|
@ -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<RecentlyReadHolder>() {
|
||||
class HistoryItem(val mch: MangaChapterHistory) : AbstractFlexibleItem<HistoryHolder>() {
|
||||
|
||||
override fun getLayoutRes(): Int {
|
||||
return R.layout.recently_read_item
|
||||
return R.layout.history_item
|
||||
}
|
||||
|
||||
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): RecentlyReadHolder {
|
||||
return RecentlyReadHolder(view, adapter as RecentlyReadAdapter)
|
||||
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): HistoryHolder {
|
||||
return HistoryHolder(view, adapter as HistoryAdapter)
|
||||
}
|
||||
|
||||
override fun bindViewHolder(
|
||||
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>,
|
||||
holder: RecentlyReadHolder,
|
||||
holder: HistoryHolder,
|
||||
position: Int,
|
||||
payloads: List<Any?>?
|
||||
) {
|
||||
@ -29,7 +29,7 @@ class RecentlyReadItem(val mch: MangaChapterHistory) : AbstractFlexibleItem<Rece
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other is RecentlyReadItem) {
|
||||
if (other is HistoryItem) {
|
||||
return mch.manga.id == other.mch.manga.id
|
||||
}
|
||||
return false
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.recently_read
|
||||
package eu.kanade.tachiyomi.ui.recent.history
|
||||
|
||||
import android.os.Bundle
|
||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
@ -14,11 +14,11 @@ import rx.android.schedulers.AndroidSchedulers
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
/**
|
||||
* Presenter of RecentlyReadFragment.
|
||||
* Presenter of HistoryFragment.
|
||||
* Contains information and data for fragment.
|
||||
* Observable updates should be called from here.
|
||||
*/
|
||||
class RecentlyReadPresenter : BasePresenter<RecentlyReadController>() {
|
||||
class HistoryPresenter : BasePresenter<HistoryController>() {
|
||||
|
||||
/**
|
||||
* Used to connect to database
|
||||
@ -30,21 +30,21 @@ class RecentlyReadPresenter : BasePresenter<RecentlyReadController>() {
|
||||
|
||||
// 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<List<RecentlyReadItem>> {
|
||||
fun getRecentMangaObservable(): Observable<List<HistoryItem>> {
|
||||
// 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())
|
||||
}
|
||||
|
@ -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
|
@ -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<T>(bundle: Bundle? = null) : DialogController(bundle)
|
||||
where T : Controller, T : ConfirmDeleteChaptersDialog.Listener {
|
||||
|
||||
private var chaptersToDelete = emptyList<RecentChapterItem>()
|
||||
private var chaptersToDelete = emptyList<UpdatesItem>()
|
||||
|
||||
constructor(target: T, chaptersToDelete: List<RecentChapterItem>) : this() {
|
||||
constructor(target: T, chaptersToDelete: List<UpdatesItem>) : this() {
|
||||
this.chaptersToDelete = chaptersToDelete
|
||||
targetController = target
|
||||
}
|
||||
@ -29,6 +29,6 @@ class ConfirmDeleteChaptersDialog<T>(bundle: Bundle? = null) : DialogController(
|
||||
}
|
||||
|
||||
interface Listener {
|
||||
fun deleteChapters(chaptersToDelete: List<RecentChapterItem>)
|
||||
fun deleteChapters(chaptersToDelete: List<UpdatesItem>)
|
||||
}
|
||||
}
|
@ -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<DateItem.Holder>() {
|
||||
|
||||
override fun getLayoutRes(): Int {
|
||||
return R.layout.recent_chapters_section_item
|
||||
return R.layout.updates_section_item
|
||||
}
|
||||
|
||||
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): Holder {
|
@ -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
|
@ -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<IFlexible<*>>(null, controller, true) {
|
||||
|
||||
val coverClickListener: OnCoverClickListener = controller
|
@ -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<RecentChaptersPresenter>(),
|
||||
class UpdatesController : NucleusController<UpdatesPresenter>(),
|
||||
RootController,
|
||||
NoToolbarElevationController,
|
||||
ActionMode.Callback,
|
||||
@ -45,7 +45,7 @@ class RecentChaptersController : NucleusController<RecentChaptersPresenter>(),
|
||||
FlexibleAdapter.OnItemLongClickListener,
|
||||
FlexibleAdapter.OnUpdateListener,
|
||||
ConfirmDeleteChaptersDialog.Listener,
|
||||
RecentChaptersAdapter.OnCoverClickListener {
|
||||
UpdatesAdapter.OnCoverClickListener {
|
||||
|
||||
/**
|
||||
* Action mode for multiple selection.
|
||||
@ -55,19 +55,19 @@ class RecentChaptersController : NucleusController<RecentChaptersPresenter>(),
|
||||
/**
|
||||
* 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<RecentChaptersPresenter>(),
|
||||
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<RecentChaptersPresenter>(),
|
||||
* Returns selected chapters
|
||||
* @return list of selected chapters
|
||||
*/
|
||||
fun getSelectedChapters(): List<RecentChapterItem> {
|
||||
fun getSelectedChapters(): List<UpdatesItem> {
|
||||
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<RecentChaptersPresenter>(),
|
||||
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<RecentChaptersPresenter>(),
|
||||
* 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<RecentChaptersPresenter>(),
|
||||
|
||||
/**
|
||||
* Download selected items
|
||||
* @param chapters list of selected [RecentChapter]s
|
||||
* @param chapters list of selected [UpdatesItem]s
|
||||
*/
|
||||
fun downloadChapters(chapters: List<RecentChapterItem>) {
|
||||
fun downloadChapters(chapters: List<UpdatesItem>) {
|
||||
destroyActionModeIfNeeded()
|
||||
presenter.downloadChapters(chapters)
|
||||
}
|
||||
@ -204,22 +204,22 @@ class RecentChaptersController : NucleusController<RecentChaptersPresenter>(),
|
||||
* 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<RecentChapterItem>) {
|
||||
fun markAsRead(chapters: List<UpdatesItem>) {
|
||||
presenter.markChapterRead(chapters, true)
|
||||
if (presenter.preferences.removeAfterMarkedAsRead()) {
|
||||
deleteChapters(chapters)
|
||||
}
|
||||
}
|
||||
|
||||
override fun deleteChapters(chaptersToDelete: List<RecentChapterItem>) {
|
||||
override fun deleteChapters(chaptersToDelete: List<UpdatesItem>) {
|
||||
destroyActionModeIfNeeded()
|
||||
DeletingChaptersDialog().showDialog(router)
|
||||
presenter.deleteChapters(chaptersToDelete)
|
||||
@ -234,9 +234,9 @@ class RecentChaptersController : NucleusController<RecentChaptersPresenter>(),
|
||||
|
||||
/**
|
||||
* Mark chapter as unread
|
||||
* @param chapters list of selected [RecentChapter]
|
||||
* @param chapters list of selected [UpdatesItem]
|
||||
*/
|
||||
fun markAsUnread(chapters: List<RecentChapterItem>) {
|
||||
fun markAsUnread(chapters: List<UpdatesItem>) {
|
||||
presenter.markChapterRead(chapters, false)
|
||||
}
|
||||
|
||||
@ -244,7 +244,7 @@ class RecentChaptersController : NucleusController<RecentChaptersPresenter>(),
|
||||
* 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<RecentChaptersPresenter>(),
|
||||
* 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())
|
||||
}
|
||||
|
@ -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
|
@ -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<RecentChapterHolder, DateItem>(header) {
|
||||
class UpdatesItem(val chapter: Chapter, val manga: Manga, header: DateItem) :
|
||||
AbstractSectionableItem<UpdatesHolder, DateItem>(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<IFlexible<RecyclerView.ViewHolder>>): RecentChapterHolder {
|
||||
return RecentChapterHolder(view, adapter as RecentChaptersAdapter)
|
||||
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): UpdatesHolder {
|
||||
return UpdatesHolder(view, adapter as UpdatesAdapter)
|
||||
}
|
||||
|
||||
override fun bindViewHolder(
|
||||
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>,
|
||||
holder: RecentChapterHolder,
|
||||
holder: UpdatesHolder,
|
||||
position: Int,
|
||||
payloads: List<Any?>?
|
||||
) {
|
||||
@ -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
|
@ -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<RecentChaptersController>() {
|
||||
) : BasePresenter<UpdatesController>() {
|
||||
|
||||
/**
|
||||
* List containing chapter and manga information
|
||||
*/
|
||||
private var chapters: List<RecentChapterItem> = emptyList()
|
||||
private var chapters: List<UpdatesItem> = 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<List<RecentChapterItem>> {
|
||||
private fun getUpdatesObservable(): Observable<List<UpdatesItem>> {
|
||||
// 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<RecentChapterItem>) {
|
||||
private fun setDownloadedChapters(items: List<UpdatesItem>) {
|
||||
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<RecentChapterItem>, read: Boolean) {
|
||||
fun markChapterRead(items: List<UpdatesItem>, 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<RecentChapterItem>) {
|
||||
fun deleteChapters(chapters: List<UpdatesItem>) {
|
||||
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<RecentChapterItem>) {
|
||||
fun downloadChapters(items: List<UpdatesItem>) {
|
||||
items.forEach { downloadManager.downloadChapters(it.manga, listOf(it.chapter)) }
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ class RecentChaptersPresenter(
|
||||
*
|
||||
* @param items chapters selected
|
||||
*/
|
||||
private fun deleteChaptersInternal(chapterItems: List<RecentChapterItem>) {
|
||||
private fun deleteChaptersInternal(chapterItems: List<UpdatesItem>) {
|
||||
val itemsByManga = chapterItems.groupBy { it.manga.id }
|
||||
for ((_, items) in itemsByManga) {
|
||||
val manga = items.first().manga
|
@ -12,7 +12,7 @@
|
||||
android:clipToPadding="false"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingBottom="4dp"
|
||||
tools:listitem="@layout/recently_read_item" />
|
||||
tools:listitem="@layout/history_item" />
|
||||
|
||||
<eu.kanade.tachiyomi.widget.EmptyView
|
||||
android:id="@+id/empty_view"
|
@ -14,7 +14,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
tools:listitem="@layout/recent_chapters_item" />
|
||||
tools:listitem="@layout/updates_item" />
|
||||
|
||||
<eu.kanade.tachiyomi.widget.EmptyView
|
||||
android:id="@+id/empty_view"
|
Loading…
Reference in New Issue
Block a user