mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 13:01:50 +01:00
Format fix + notification feedback
This commit is contained in:
parent
2a4527a8d6
commit
1210691fdd
@ -14,10 +14,7 @@ import eu.kanade.tachiyomi.data.download.DownloadManager
|
|||||||
import eu.kanade.tachiyomi.data.download.ImageNotifier
|
import eu.kanade.tachiyomi.data.download.ImageNotifier
|
||||||
import eu.kanade.tachiyomi.data.mangasync.MangaSyncManager
|
import eu.kanade.tachiyomi.data.mangasync.MangaSyncManager
|
||||||
import eu.kanade.tachiyomi.data.mangasync.UpdateMangaSyncService
|
import eu.kanade.tachiyomi.data.mangasync.UpdateMangaSyncService
|
||||||
import eu.kanade.tachiyomi.data.network.GET
|
|
||||||
import eu.kanade.tachiyomi.data.network.NetworkHelper
|
import eu.kanade.tachiyomi.data.network.NetworkHelper
|
||||||
import eu.kanade.tachiyomi.data.network.ProgressListener
|
|
||||||
import eu.kanade.tachiyomi.data.network.newCallWithProgress
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.source.SourceManager
|
import eu.kanade.tachiyomi.data.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.data.source.model.Page
|
import eu.kanade.tachiyomi.data.source.model.Page
|
||||||
@ -25,9 +22,7 @@ import eu.kanade.tachiyomi.data.source.online.OnlineSource
|
|||||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||||
import eu.kanade.tachiyomi.util.RetryWithDelay
|
import eu.kanade.tachiyomi.util.RetryWithDelay
|
||||||
import eu.kanade.tachiyomi.util.SharedData
|
import eu.kanade.tachiyomi.util.SharedData
|
||||||
import eu.kanade.tachiyomi.util.saveTo
|
|
||||||
import eu.kanade.tachiyomi.util.toast
|
import eu.kanade.tachiyomi.util.toast
|
||||||
import okio.BufferedSource
|
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import rx.Subscription
|
import rx.Subscription
|
||||||
import rx.android.schedulers.AndroidSchedulers
|
import rx.android.schedulers.AndroidSchedulers
|
||||||
@ -35,7 +30,6 @@ import rx.schedulers.Schedulers
|
|||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileInputStream
|
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@ -589,21 +583,28 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
|
|||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
internal fun savePage() {
|
internal fun savePage() {
|
||||||
chapter.pages?.get(chapter.last_page_read)?.let { page ->
|
chapter.pages?.get(chapter.last_page_read)?.let { page ->
|
||||||
|
// Location of image file.
|
||||||
val inputFile = File(page.imagePath)
|
val inputFile = File(page.imagePath)
|
||||||
|
|
||||||
// File where the image will be saved
|
// File where the image will be saved.
|
||||||
val destFile = File(pictureDirectory, manga.title + " - " + chapter.name +
|
val destFile = File(pictureDirectory, manga.title + " - " + chapter.name +
|
||||||
" - " + downloadManager.getImageFilename(page))
|
" - " + downloadManager.getImageFilename(page))
|
||||||
|
|
||||||
|
//Remove the notification if already exist (user feedback)
|
||||||
|
imageNotifier.onClear()
|
||||||
|
|
||||||
|
//Check if file doesn't already exist
|
||||||
if (destFile.exists()) {
|
if (destFile.exists()) {
|
||||||
imageNotifier.onComplete(destFile)
|
imageNotifier.onComplete(destFile)
|
||||||
} else {
|
} else {
|
||||||
if (inputFile.exists()) {
|
if (inputFile.exists()) {
|
||||||
|
// Copy file
|
||||||
Observable.fromCallable { inputFile.copyTo(destFile) }
|
Observable.fromCallable { inputFile.copyTo(destFile) }
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.subscribe(
|
.subscribe(
|
||||||
{ imageNotifier.onComplete(it) }, { error ->
|
{ imageNotifier.onComplete(it) },
|
||||||
|
{ error ->
|
||||||
Timber.e(error.message)
|
Timber.e(error.message)
|
||||||
imageNotifier.onError(error.message)
|
imageNotifier.onError(error.message)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user