Fix #636. Minor improvements. Dependency updates
This commit is contained in:
@@ -171,11 +171,11 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||
.content(getString(R.string.confirm_update_manga_sync, chapterToUpdate))
|
||||
.positiveText(android.R.string.yes)
|
||||
.negativeText(android.R.string.no)
|
||||
.onPositive { dialog, which -> presenter.updateTrackLastChapterRead() }
|
||||
.onPositive { dialog, which -> presenter.updateTrackLastChapterRead(chapterToUpdate) }
|
||||
.onAny { dialog1, which1 -> super.onBackPressed() }
|
||||
.show()
|
||||
} else {
|
||||
presenter.updateTrackLastChapterRead()
|
||||
presenter.updateTrackLastChapterRead(chapterToUpdate)
|
||||
super.onBackPressed()
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -14,7 +14,6 @@ import eu.kanade.tachiyomi.data.database.models.Track
|
||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||
import eu.kanade.tachiyomi.data.track.TrackUpdateService
|
||||
import eu.kanade.tachiyomi.source.LocalSource
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
@@ -452,27 +451,31 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
|
||||
Math.floor(chapter.chapter_number.toDouble()).toInt()
|
||||
else if (prevChapter != null && prevChapter.read)
|
||||
Math.floor(prevChapter.chapter_number.toDouble()).toInt()
|
||||
else
|
||||
return 0
|
||||
|
||||
return if (trackList.any { lastChapterRead > it.last_chapter_read })
|
||||
lastChapterRead
|
||||
else
|
||||
0
|
||||
|
||||
trackList.forEach { sync ->
|
||||
if (lastChapterRead > sync.last_chapter_read) {
|
||||
sync.last_chapter_read = lastChapterRead
|
||||
sync.update = true
|
||||
}
|
||||
}
|
||||
|
||||
return if (trackList.any { it.update }) lastChapterRead else 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the service that updates the last chapter read in sync services
|
||||
*/
|
||||
fun updateTrackLastChapterRead() {
|
||||
trackList?.forEach { sync ->
|
||||
val service = trackManager.getService(sync.sync_id)
|
||||
if (service != null && service.isLogged && sync.update) {
|
||||
TrackUpdateService.start(context, sync)
|
||||
fun updateTrackLastChapterRead(lastChapterRead: Int) {
|
||||
trackList?.forEach { track ->
|
||||
val service = trackManager.getService(track.sync_id)
|
||||
if (service != null && service.isLogged && lastChapterRead > track.last_chapter_read) {
|
||||
track.last_chapter_read = lastChapterRead
|
||||
|
||||
// We wan't these to execute even if the presenter is destroyed and leaks for a
|
||||
// while. The view can still be garbage collected.
|
||||
Observable.defer { service.update(track) }
|
||||
.map { db.insertTrack(track).executeAsBlocking() }
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({}, { Timber.e(it) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user