Fixed pressing back on settings + reverting recent read changes
This commit is contained in:
parent
580b2a5778
commit
ab7fcd37ba
3 changed files with 18 additions and 28 deletions
|
@ -413,8 +413,8 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
|
||||||
if (drawer.isDrawerOpen(GravityCompat.START) || drawer.isDrawerOpen(GravityCompat.END)) {
|
if (drawer.isDrawerOpen(GravityCompat.START) || drawer.isDrawerOpen(GravityCompat.END)) {
|
||||||
drawer.closeDrawers()
|
drawer.closeDrawers()
|
||||||
} else {
|
} else {
|
||||||
val baseController = router.backstack.last().controller() as BaseController
|
val baseController = router.backstack.last().controller() as? BaseController
|
||||||
if (if (router.backstackSize == 1) !baseController.handleRootBack()
|
if (if (router.backstackSize == 1) !(baseController?.handleRootBack() ?: false)
|
||||||
else !router.handleBack()) {
|
else !router.handleBack()) {
|
||||||
unlocked = false
|
unlocked = false
|
||||||
super.onBackPressed()
|
super.onBackPressed()
|
||||||
|
|
|
@ -16,21 +16,15 @@ import eu.kanade.tachiyomi.data.backup.BackupRestoreService
|
||||||
import eu.kanade.tachiyomi.data.database.models.History
|
import eu.kanade.tachiyomi.data.database.models.History
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||||
import eu.kanade.tachiyomi.ui.catalogue.browse.ProgressItem
|
import eu.kanade.tachiyomi.ui.catalogue.browse.ProgressItem
|
||||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||||
import eu.kanade.tachiyomi.util.system.launchUI
|
import eu.kanade.tachiyomi.util.system.launchUI
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
|
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
|
||||||
import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener
|
import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener
|
||||||
import kotlinx.android.synthetic.main.recently_read_controller.empty_view
|
import kotlinx.android.synthetic.main.recently_read_controller.*
|
||||||
import kotlinx.android.synthetic.main.recently_read_controller.recycler
|
|
||||||
import eu.kanade.tachiyomi.ui.recent_updates.RecentChaptersController
|
|
||||||
import uy.kohesive.injekt.Injekt
|
|
||||||
import uy.kohesive.injekt.api.get
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fragment that shows recently read manga.
|
* Fragment that shows recently read manga.
|
||||||
|
@ -111,18 +105,16 @@ class RecentlyReadController(bundle: Bundle? = null) : BaseController(bundle),
|
||||||
*
|
*
|
||||||
* @param mangaHistory list of manga history
|
* @param mangaHistory list of manga history
|
||||||
*/
|
*/
|
||||||
fun onNextManga(mangaHistory: List<RecentlyReadItem>, freshList:Boolean = false) {
|
fun onNextManga(mangaHistory: List<RecentlyReadItem>) {
|
||||||
val adapter = adapter ?: return
|
val adapter = adapter ?: return
|
||||||
adapter.updateDataSet(mangaHistory)
|
adapter.updateDataSet(mangaHistory)
|
||||||
adapter.onLoadMoreComplete(null)
|
adapter.onLoadMoreComplete(null)
|
||||||
if (recentItems == null || adapter.endlessTargetCount == 1)
|
if (recentItems == null)
|
||||||
resetProgressItem()
|
resetProgressItem()
|
||||||
else if (freshList && mangaHistory.size == recentItems!!.size)
|
|
||||||
onAddPageError()
|
|
||||||
recentItems = mangaHistory.toMutableList()
|
recentItems = mangaHistory.toMutableList()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onAddPageError() {
|
fun onAddPageError() {
|
||||||
adapter?.onLoadMoreComplete(null)
|
adapter?.onLoadMoreComplete(null)
|
||||||
adapter?.endlessTargetCount = 1
|
adapter?.endlessTargetCount = 1
|
||||||
}
|
}
|
||||||
|
@ -213,18 +205,15 @@ class RecentlyReadController(bundle: Bundle? = null) : BaseController(bundle),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fixes problem with the overflow icon showing up in lieu of search
|
// Fixes problem with the overflow icon showing up in lieu of search
|
||||||
searchItem.fixExpand(onExpand = { invalidateMenuOnExpand() })
|
searchItem.setOnActionExpandListener(object : MenuItem.OnActionExpandListener {
|
||||||
}
|
override fun onMenuItemActionExpand(item: MenuItem): Boolean {
|
||||||
|
return true
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
|
||||||
when (item.itemId) {
|
|
||||||
R.id.action_recents -> {
|
|
||||||
router.setRoot(RecentChaptersController().withFadeTransaction()
|
|
||||||
.tag(R.id.nav_drawer_recents.toString()))
|
|
||||||
Injekt.get<PreferencesHelper>().showRecentUpdates().set(true)
|
|
||||||
(activity as? MainActivity)?.updateRecentsIcon()
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return super.onOptionsItemSelected(item)
|
override fun onMenuItemActionCollapse(item: MenuItem): Boolean {
|
||||||
|
activity?.invalidateOptionsMenu()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,13 +55,14 @@ class RecentlyReadPresenter(private val view: RecentlyReadController) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun observe() {
|
fun observe() {
|
||||||
|
readerSubscription?.unsubscribe()
|
||||||
val cal = Calendar.getInstance()
|
val cal = Calendar.getInstance()
|
||||||
cal.time = Date()
|
cal.time = Date()
|
||||||
cal.add(Calendar.YEAR, -50)
|
cal.add(Calendar.YEAR, -50)
|
||||||
db.getRecentMangaLimit(cal.time, lastCount, "").asRxObservable().map {
|
readerSubscription = db.getRecentMangaLimit(cal.time, lastCount, "").asRxObservable().map {
|
||||||
val items = it.map(::RecentlyReadItem)
|
val items = it.map(::RecentlyReadItem)
|
||||||
launchUI {
|
launchUI {
|
||||||
view.onNextManga(items, false)
|
view.onNextManga(items)
|
||||||
}
|
}
|
||||||
}.observeOn(Schedulers.io()).skip(1).take(1).subscribe()
|
}.observeOn(Schedulers.io()).skip(1).take(1).subscribe()
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue