From 13954ffe0100c50d691127aef659816a53636b21 Mon Sep 17 00:00:00 2001 From: Bram van de Kerkhof Date: Sun, 13 Nov 2016 14:07:20 +0100 Subject: [PATCH] Added page.ready check --- .../tachiyomi/ui/reader/ReaderActivity.kt | 39 ++++++++++--------- .../tachiyomi/ui/reader/ReaderPresenter.kt | 16 ++++++-- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index fe3104f701..488669a1f6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -225,22 +225,22 @@ class ReaderActivity : BaseRxActivity() { toast(error.message) } - fun onChapterAppendError() { - // Ignore - } - fun onLongPress(page: Page) { MaterialDialog.Builder(this) - .title(getString(R.string.options)) - .items(R.array.reader_image_options) - .itemsIds(R.array.reader_image_options_values) - .itemsCallback { materialDialog, view, i, charSequence -> - when (i) { - 0 -> presenter.setCover(page) - 1 -> shareImage(page) - 2 -> presenter.savePage(page) - } - }.show() + .title(getString(R.string.options)) + .items(R.array.reader_image_options) + .itemsIds(R.array.reader_image_options_values) + .itemsCallback { materialDialog, view, i, charSequence -> + when (i) { + 0 -> presenter.setCover(page) + 1 -> shareImage(page) + 2 -> presenter.savePage(page) + } + }.show() + } + + fun onChapterAppendError() { + // Ignore } /** @@ -408,16 +408,16 @@ class ReaderActivity : BaseRxActivity() { private fun setRotation(rotation: Int) { when (rotation) { - // Rotation free + // Rotation free 1 -> requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED - // Lock in current rotation + // Lock in current rotation 2 -> { val currentOrientation = resources.configuration.orientation setRotation(if (currentOrientation == Configuration.ORIENTATION_PORTRAIT) 3 else 4) } - // Lock in portrait + // Lock in portrait 3 -> requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT - // Lock in landscape + // Lock in landscape 4 -> requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE } } @@ -476,6 +476,9 @@ class ReaderActivity : BaseRxActivity() { * @param page page object containing image information. */ fun shareImage(page: Page) { + if (page.status != Page.READY) + return + val shareIntent = Intent().apply { action = Intent.ACTION_SEND putExtra(Intent.EXTRA_STREAM, Uri.parse(page.imagePath)) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt index 1dd62da5f7..cddcf0e23e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt @@ -383,11 +383,13 @@ class ReaderPresenter : BasePresenter() { if (chapter.read) { val removeAfterReadSlots = prefs.removeAfterReadSlots() when (removeAfterReadSlots) { - // Setting disabled - -1 -> { /**Empty function**/ } - // Remove current read chapter + // Setting disabled + -1 -> { + /**Empty function**/ + } + // Remove current read chapter 0 -> deleteChapter(chapter, manga) - // Remove previous chapter specified by user in settings. + // Remove previous chapter specified by user in settings. else -> getAdjacentChaptersStrategy(chapter, removeAfterReadSlots) .first?.let { deleteChapter(it, manga) } } @@ -531,6 +533,9 @@ class ReaderPresenter : BasePresenter() { * Update cover with page file. */ internal fun setCover(page: Page) { + if (page.status != Page.READY) + return + try { if (manga.favorite) { if (manga.thumbnail_url != null) { @@ -554,6 +559,9 @@ class ReaderPresenter : BasePresenter() { */ @Throws(IOException::class) internal fun savePage(page: Page) { + if (page.status != Page.READY) + return + // Used to show image notification val imageNotifier = ImageNotifier(context)