Minor fixes

This commit is contained in:
len 2016-05-26 16:03:55 +02:00
parent 12d6919421
commit 4e784cd7c3
4 changed files with 7 additions and 3 deletions

View file

@ -87,4 +87,8 @@ public class Chapter implements Serializable {
public boolean isDownloaded() {
return status == Download.DOWNLOADED;
}
public boolean isRecognizedNumber() {
return chapter_number >= 0f;
}
}

View file

@ -188,7 +188,7 @@ class ChaptersPresenter : BasePresenter<ChaptersFragment>() {
fun markPreviousChaptersAsRead(selected: Chapter) {
Observable.from(chapters)
.filter { it.chapter_number > -1 && it.chapter_number < selected.chapter_number }
.filter { it.isRecognizedNumber && it.chapter_number < selected.chapter_number }
.doOnNext { it.read = true }
.toList()
.flatMap { db.updateChaptersProgress(it).asRxObservable() }

View file

@ -260,7 +260,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
page_seekbar.max = numPages - 1
page_seekbar.progress = currentPage
setToolbarSubtitle(if (chapter.chapter_number != -1f)
setToolbarSubtitle(if (chapter.isRecognizedNumber)
getString(R.string.chapter_subtitle, decimalFormat.format(chapter.chapter_number.toDouble()))
else
chapter.name)

View file

@ -71,7 +71,7 @@ fun syncChaptersWithSource(db: DatabaseHelper,
val c = toAdd[i]
c.date_fetch = now++
// Try to mark already read chapters as read when the source deletes them
if (c.chapter_number != -1f && c.chapter_number in deletedReadChapterNumbers) {
if (c.isRecognizedNumber && c.chapter_number in deletedReadChapterNumbers) {
c.read = true
readded++
}