|
|
@ -5,6 +5,7 @@ import android.os.Handler |
|
|
|
import android.os.Looper |
|
|
|
import android.os.Looper |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.constant.PreferKey |
|
|
|
import io.legado.app.constant.PreferKey |
|
|
|
|
|
|
|
import io.legado.app.data.appDb |
|
|
|
import io.legado.app.data.entities.Book |
|
|
|
import io.legado.app.data.entities.Book |
|
|
|
import io.legado.app.data.entities.BookProgress |
|
|
|
import io.legado.app.data.entities.BookProgress |
|
|
|
import io.legado.app.exception.NoStackTraceException |
|
|
|
import io.legado.app.exception.NoStackTraceException |
|
|
@ -166,6 +167,13 @@ object AppWebDav { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun getProgressUrl(book: Book): String { |
|
|
|
|
|
|
|
return bookProgressUrl + book.name + "_" + book.author + ".json" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取书籍进度 |
|
|
|
|
|
|
|
*/ |
|
|
|
suspend fun getBookProgress(book: Book): BookProgress? { |
|
|
|
suspend fun getBookProgress(book: Book): BookProgress? { |
|
|
|
if (initWebDav() && NetworkUtils.isAvailable()) { |
|
|
|
if (initWebDav() && NetworkUtils.isAvailable()) { |
|
|
|
val url = getProgressUrl(book) |
|
|
|
val url = getProgressUrl(book) |
|
|
@ -179,7 +187,21 @@ object AppWebDav { |
|
|
|
return null |
|
|
|
return null |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun getProgressUrl(book: Book): String { |
|
|
|
suspend fun downloadAllBookProgress() { |
|
|
|
return bookProgressUrl + book.name + "_" + book.author + ".json" |
|
|
|
appDb.bookDao.all.forEach { book -> |
|
|
|
|
|
|
|
getBookProgress(book)?.let { bookProgress -> |
|
|
|
|
|
|
|
if (bookProgress.durChapterIndex > book.durChapterIndex || |
|
|
|
|
|
|
|
(bookProgress.durChapterIndex == book.durChapterIndex && |
|
|
|
|
|
|
|
bookProgress.durChapterPos > book.durChapterPos) |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
book.durChapterIndex = bookProgress.durChapterIndex |
|
|
|
|
|
|
|
book.durChapterPos = bookProgress.durChapterPos |
|
|
|
|
|
|
|
book.durChapterTitle = bookProgress.durChapterTitle |
|
|
|
|
|
|
|
book.durChapterTime = bookProgress.durChapterTime |
|
|
|
|
|
|
|
appDb.bookDao.update(book) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |