mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Added page.ready check
This commit is contained in:
parent
7d3d0999f3
commit
13954ffe01
2 changed files with 33 additions and 22 deletions
|
@ -225,22 +225,22 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
|||
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<ReaderPresenter>() {
|
|||
|
||||
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<ReaderPresenter>() {
|
|||
* @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))
|
||||
|
|
|
@ -383,11 +383,13 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
|
|||
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<ReaderActivity>() {
|
|||
* 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<ReaderActivity>() {
|
|||
*/
|
||||
@Throws(IOException::class)
|
||||
internal fun savePage(page: Page) {
|
||||
if (page.status != Page.READY)
|
||||
return
|
||||
|
||||
// Used to show image notification
|
||||
val imageNotifier = ImageNotifier(context)
|
||||
|
||||
|
|
Loading…
Reference in a new issue