mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-11 05:50:48 +01: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)
|
toast(error.message)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onChapterAppendError() {
|
|
||||||
// Ignore
|
|
||||||
}
|
|
||||||
|
|
||||||
fun onLongPress(page: Page) {
|
fun onLongPress(page: Page) {
|
||||||
MaterialDialog.Builder(this)
|
MaterialDialog.Builder(this)
|
||||||
.title(getString(R.string.options))
|
.title(getString(R.string.options))
|
||||||
.items(R.array.reader_image_options)
|
.items(R.array.reader_image_options)
|
||||||
.itemsIds(R.array.reader_image_options_values)
|
.itemsIds(R.array.reader_image_options_values)
|
||||||
.itemsCallback { materialDialog, view, i, charSequence ->
|
.itemsCallback { materialDialog, view, i, charSequence ->
|
||||||
when (i) {
|
when (i) {
|
||||||
0 -> presenter.setCover(page)
|
0 -> presenter.setCover(page)
|
||||||
1 -> shareImage(page)
|
1 -> shareImage(page)
|
||||||
2 -> presenter.savePage(page)
|
2 -> presenter.savePage(page)
|
||||||
}
|
}
|
||||||
}.show()
|
}.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onChapterAppendError() {
|
||||||
|
// Ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -408,16 +408,16 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||||
|
|
||||||
private fun setRotation(rotation: Int) {
|
private fun setRotation(rotation: Int) {
|
||||||
when (rotation) {
|
when (rotation) {
|
||||||
// Rotation free
|
// Rotation free
|
||||||
1 -> requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
1 -> requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
||||||
// Lock in current rotation
|
// Lock in current rotation
|
||||||
2 -> {
|
2 -> {
|
||||||
val currentOrientation = resources.configuration.orientation
|
val currentOrientation = resources.configuration.orientation
|
||||||
setRotation(if (currentOrientation == Configuration.ORIENTATION_PORTRAIT) 3 else 4)
|
setRotation(if (currentOrientation == Configuration.ORIENTATION_PORTRAIT) 3 else 4)
|
||||||
}
|
}
|
||||||
// Lock in portrait
|
// Lock in portrait
|
||||||
3 -> requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
|
3 -> requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
|
||||||
// Lock in landscape
|
// Lock in landscape
|
||||||
4 -> requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
|
4 -> requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -476,6 +476,9 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||||
* @param page page object containing image information.
|
* @param page page object containing image information.
|
||||||
*/
|
*/
|
||||||
fun shareImage(page: Page) {
|
fun shareImage(page: Page) {
|
||||||
|
if (page.status != Page.READY)
|
||||||
|
return
|
||||||
|
|
||||||
val shareIntent = Intent().apply {
|
val shareIntent = Intent().apply {
|
||||||
action = Intent.ACTION_SEND
|
action = Intent.ACTION_SEND
|
||||||
putExtra(Intent.EXTRA_STREAM, Uri.parse(page.imagePath))
|
putExtra(Intent.EXTRA_STREAM, Uri.parse(page.imagePath))
|
||||||
|
|
|
@ -383,11 +383,13 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
|
||||||
if (chapter.read) {
|
if (chapter.read) {
|
||||||
val removeAfterReadSlots = prefs.removeAfterReadSlots()
|
val removeAfterReadSlots = prefs.removeAfterReadSlots()
|
||||||
when (removeAfterReadSlots) {
|
when (removeAfterReadSlots) {
|
||||||
// Setting disabled
|
// Setting disabled
|
||||||
-1 -> { /**Empty function**/ }
|
-1 -> {
|
||||||
// Remove current read chapter
|
/**Empty function**/
|
||||||
|
}
|
||||||
|
// Remove current read chapter
|
||||||
0 -> deleteChapter(chapter, manga)
|
0 -> deleteChapter(chapter, manga)
|
||||||
// Remove previous chapter specified by user in settings.
|
// Remove previous chapter specified by user in settings.
|
||||||
else -> getAdjacentChaptersStrategy(chapter, removeAfterReadSlots)
|
else -> getAdjacentChaptersStrategy(chapter, removeAfterReadSlots)
|
||||||
.first?.let { deleteChapter(it, manga) }
|
.first?.let { deleteChapter(it, manga) }
|
||||||
}
|
}
|
||||||
|
@ -531,6 +533,9 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
|
||||||
* Update cover with page file.
|
* Update cover with page file.
|
||||||
*/
|
*/
|
||||||
internal fun setCover(page: Page) {
|
internal fun setCover(page: Page) {
|
||||||
|
if (page.status != Page.READY)
|
||||||
|
return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (manga.favorite) {
|
if (manga.favorite) {
|
||||||
if (manga.thumbnail_url != null) {
|
if (manga.thumbnail_url != null) {
|
||||||
|
@ -554,6 +559,9 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
|
||||||
*/
|
*/
|
||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
internal fun savePage(page: Page) {
|
internal fun savePage(page: Page) {
|
||||||
|
if (page.status != Page.READY)
|
||||||
|
return
|
||||||
|
|
||||||
// Used to show image notification
|
// Used to show image notification
|
||||||
val imageNotifier = ImageNotifier(context)
|
val imageNotifier = ImageNotifier(context)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue