From e1a3ee1b81d1fe79d7715059cfda619aa4f82e67 Mon Sep 17 00:00:00 2001 From: len Date: Sun, 18 Dec 2016 16:35:39 +0100 Subject: [PATCH] Bugfixes --- .../tachiyomi/data/download/DownloadProvider.kt | 6 +++++- .../tachiyomi/ui/base/activity/BaseActivity.kt | 12 ++++++++++++ .../tachiyomi/ui/base/activity/BaseRxActivity.kt | 12 ++++++++++++ .../kanade/tachiyomi/ui/download/DownloadHolder.kt | 6 ++++-- .../eu/kanade/tachiyomi/ui/main/MainActivity.kt | 4 +++- .../eu/kanade/tachiyomi/ui/manga/MangaActivity.kt | 14 +++++++++++--- .../tachiyomi/ui/manga/chapter/ChaptersFragment.kt | 3 ++- app/src/main/res/values/strings.xml | 3 +++ 8 files changed, 52 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadProvider.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadProvider.kt index 79eabc70b0..018126b900 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadProvider.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadProvider.kt @@ -6,6 +6,7 @@ import com.hippo.unifile.UniFile import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.preference.PreferencesHelper +import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.data.source.Source import eu.kanade.tachiyomi.util.DiskUtil import uy.kohesive.injekt.injectLazy @@ -26,10 +27,13 @@ class DownloadProvider(private val context: Context) { /** * The root directory for downloads. */ - private lateinit var downloadsDir: UniFile + private var downloadsDir = preferences.downloadsDirectory().getOrDefault().let { + UniFile.fromUri(context, Uri.parse(it)) + } init { preferences.downloadsDirectory().asObservable() + .skip(1) .subscribe { downloadsDir = UniFile.fromUri(context, Uri.parse(it)) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt index 751818c82e..cb36629478 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt @@ -11,4 +11,16 @@ abstract class BaseActivity : AppCompatActivity(), ActivityMixin { override fun getActivity() = this + var isResumed = false + + override fun onResume() { + super.onResume() + isResumed = true + } + + override fun onPause() { + isResumed = false + super.onPause() + } + } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseRxActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseRxActivity.kt index 59aa6b961d..0b480cd41e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseRxActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseRxActivity.kt @@ -25,4 +25,16 @@ abstract class BaseRxActivity

> : NucleusAppCompatActivity

() { val fromLauncher = intent.getBooleanExtra(FROM_LAUNCHER_EXTRA, false) - //Remove any current manga if we are launching from launcher - if(fromLauncher) SharedData.remove(MangaEvent::class.java) + // Remove any current manga if we are launching from launcher + if (fromLauncher) SharedData.remove(MangaEvent::class.java) presenter.setMangaEvent(SharedData.getOrPut(MangaEvent::class.java) { val id = intent.getLongExtra(MANGA_EXTRA, 0) - MangaEvent(presenter.db.getManga(id).executeAsBlocking()!!) + val dbManga = presenter.db.getManga(id).executeAsBlocking() + if (dbManga != null) { + MangaEvent(dbManga) + } else { + toast(R.string.manga_not_in_db) + finish() + return + } }) setupToolbar(toolbar) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt index 2fe17d0526..04cb5bac0f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt @@ -394,7 +394,8 @@ class ChaptersFragment : BaseRxFragment(), ActionMode.Callbac } fun dismissDeletingDialog() { - (childFragmentManager.findFragmentByTag(DeletingChaptersDialog.TAG) as? DialogFragment)?.dismiss() + (childFragmentManager.findFragmentByTag(DeletingChaptersDialog.TAG) as? DialogFragment) + ?.dismissAllowingStateLoss() } override fun onListItemClick(position: Int): Boolean { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 66e9110da3..3a856f25eb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -226,6 +226,9 @@ Select a source Please enable at least one valid source + + This manga was removed from the database! + Info Description