pull/737/head
Robot 4 years ago
commit 2fcc327aa1
  1. 5
      app/src/main/assets/updateLog.md
  2. 12
      app/src/main/java/io/legado/app/service/help/ReadBook.kt
  3. 19
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  4. 19
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt
  5. 1
      app/src/main/res/values-zh-rHK/strings.xml
  6. 1
      app/src/main/res/values-zh-rTW/strings.xml
  7. 1
      app/src/main/res/values-zh/strings.xml
  8. 1
      app/src/main/res/values/strings.xml

@ -6,10 +6,7 @@
**2020/12/12**
* 修复bug
* 网络访问框架修改为RxHttp, 有bug及时反馈
**2020/12/11**
* 修复bug
* 网络访问框架修改为RxHttp, 有bug及时反馈
* 优化进度同步
**2020/12/11**
* 修复因修改进度同步导致的bug

@ -4,10 +4,7 @@ import androidx.lifecycle.MutableLiveData
import com.hankcs.hanlp.HanLP
import io.legado.app.App
import io.legado.app.constant.BookType
import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter
import io.legado.app.data.entities.BookSource
import io.legado.app.data.entities.ReadRecord
import io.legado.app.data.entities.*
import io.legado.app.help.*
import io.legado.app.help.coroutine.Coroutine
import io.legado.app.model.webBook.WebBook
@ -78,6 +75,13 @@ object ReadBook {
}
}
fun upProgress(progress: BookProgress) {
durChapterIndex = progress.durChapterIndex
durChapterPos = progress.durChapterPos
clearTextChapter()
loadContent(resetPageOffset = true)
}
fun clearTextChapter() {
prevTextChapter = null
curTextChapter = null

@ -20,6 +20,7 @@ import io.legado.app.constant.PreferKey
import io.legado.app.constant.Status
import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter
import io.legado.app.data.entities.BookProgress
import io.legado.app.help.ReadBookConfig
import io.legado.app.help.ReadTipConfig
import io.legado.app.help.storage.Backup
@ -108,6 +109,9 @@ class ReadBookActivity : ReadBookBaseActivity(),
upMenu()
upView()
}
viewModel.processLiveData.observe(this) {
sureSyncProgress(it)
}
viewModel.initData(intent)
}
@ -218,10 +222,7 @@ class ReadBookActivity : ReadBookBaseActivity(),
binding.readView.upPageAnim()
}
R.id.menu_book_info -> ReadBook.book?.let {
startActivity<BookInfoActivity>(
Pair("name", it.name),
Pair("author", it.author)
)
startActivity<BookInfoActivity>(Pair("name", it.name), Pair("author", it.author))
}
R.id.menu_toc_regex -> TocRegexDialog.show(
supportFragmentManager,
@ -730,6 +731,16 @@ class ReadBookActivity : ReadBookBaseActivity(),
}
}
private fun sureSyncProgress(progress: BookProgress) {
alert(R.string.get_book_progress) {
message = getString(R.string.current_progress_exceeds_cloud)
okButton {
ReadBook.upProgress(progress)
}
noButton()
}.show()
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode == Activity.RESULT_OK) {

@ -2,11 +2,13 @@ package io.legado.app.ui.book.read
import android.app.Application
import android.content.Intent
import androidx.lifecycle.MutableLiveData
import io.legado.app.App
import io.legado.app.R
import io.legado.app.base.BaseViewModel
import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter
import io.legado.app.data.entities.BookProgress
import io.legado.app.data.entities.SearchBook
import io.legado.app.help.AppConfig
import io.legado.app.help.BookHelp
@ -22,9 +24,9 @@ import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.withContext
class ReadBookViewModel(application: Application) : BaseViewModel(application) {
var isInitFinish = false
var searchContentQuery = ""
val processLiveData = MutableLiveData<BookProgress>()
fun initData(intent: Intent) {
execute {
@ -162,13 +164,14 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
fun syncBookProgress(book: Book) {
execute {
BookWebDav.getBookProgress(book)?.let {
book.durChapterIndex = it.durChapterIndex
book.durChapterPos = it.durChapterPos
book.durChapterTime = it.durChapterTime
book.durChapterTitle = it.durChapterTitle
ReadBook.clearTextChapter()
ReadBook.loadContent(resetPageOffset = true)
BookWebDav.getBookProgress(book)?.let { progress ->
if (progress.durChapterIndex < book.durChapterIndex ||
(progress.durChapterIndex == book.durChapterIndex && progress.durChapterPos < book.durChapterPos)
) {
processLiveData.postValue(progress)
} else {
ReadBook.upProgress(progress)
}
}
}
}

@ -789,5 +789,6 @@
<string name="rule_subscription">规则订阅</string>
<string name="rule_sub_empty_msg">添加大佬们提供的规则导入地址\n添加后点击可导入规则</string>
<string name="get_book_progress">拉取云端进度</string>
<string name="current_progress_exceeds_cloud">当前进度超过云端进度,是否同步?</string>
</resources>

@ -790,5 +790,6 @@
<string name="rule_subscription">规则订阅</string>
<string name="rule_sub_empty_msg">添加大佬们提供的规则导入地址\n添加后点击可导入规则</string>
<string name="get_book_progress">拉取云端进度</string>
<string name="current_progress_exceeds_cloud">当前进度超过云端进度,是否同步?</string>
</resources>

@ -793,5 +793,6 @@
<string name="rule_subscription">规则订阅</string>
<string name="rule_sub_empty_msg">添加大佬们提供的规则导入地址\n添加后点击可导入规则</string>
<string name="get_book_progress">拉取云端进度</string>
<string name="current_progress_exceeds_cloud">当前进度超过云端进度,是否同步?</string>
</resources>

@ -796,5 +796,6 @@
<string name="rule_subscription">规则订阅</string>
<string name="rule_sub_empty_msg">添加大佬们提供的规则导入地址\n添加后点击可导入规则</string>
<string name="get_book_progress">拉取云端进度</string>
<string name="current_progress_exceeds_cloud">当前进度超过云端进度,是否同步?</string>
</resources>

Loading…
Cancel
Save