|
|
@ -168,20 +168,24 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
book: Book, |
|
|
|
book: Book, |
|
|
|
alertSync: ((progress: BookProgress) -> Unit)? = null |
|
|
|
alertSync: ((progress: BookProgress) -> Unit)? = null |
|
|
|
) { |
|
|
|
) { |
|
|
|
if (AppWebDav.syncBookProgress) |
|
|
|
execute { |
|
|
|
execute { |
|
|
|
if (AppWebDav.syncBookProgress) { |
|
|
|
AppWebDav.getBookProgress(book) |
|
|
|
AppWebDav.getBookProgress(book) |
|
|
|
}.onSuccess { |
|
|
|
?: throw NoStackTraceException("没有进度") |
|
|
|
it?.let { progress -> |
|
|
|
} else { |
|
|
|
if (progress.durChapterIndex < book.durChapterIndex || |
|
|
|
throw NoStackTraceException("进度同步未启用") |
|
|
|
(progress.durChapterIndex == book.durChapterIndex && progress.durChapterPos < book.durChapterPos) |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
alertSync?.invoke(progress) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
ReadBook.setProgress(progress) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}.onSuccess { progress -> |
|
|
|
|
|
|
|
if (progress.durChapterIndex < book.durChapterIndex || |
|
|
|
|
|
|
|
(progress.durChapterIndex == book.durChapterIndex |
|
|
|
|
|
|
|
&& progress.durChapterPos < book.durChapterPos) |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
alertSync?.invoke(progress) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
ReadBook.setProgress(progress) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|