Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -35,6 +35,7 @@ object ReadBook : CoroutineScope by MainScope() {
|
|||||||
var durChapterIndex = 0
|
var durChapterIndex = 0
|
||||||
var durChapterPos = 0
|
var durChapterPos = 0
|
||||||
var isLocalBook = true
|
var isLocalBook = true
|
||||||
|
var chapterChanged = false
|
||||||
var prevTextChapter: TextChapter? = null
|
var prevTextChapter: TextChapter? = null
|
||||||
var curTextChapter: TextChapter? = null
|
var curTextChapter: TextChapter? = null
|
||||||
var nextTextChapter: TextChapter? = null
|
var nextTextChapter: TextChapter? = null
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ class BookInfoActivity :
|
|||||||
withContext(IO) {
|
withContext(IO) {
|
||||||
book.durChapterIndex = it.first
|
book.durChapterIndex = it.first
|
||||||
book.durChapterPos = it.second
|
book.durChapterPos = it.second
|
||||||
|
chapterChanged = it.third
|
||||||
appDb.bookDao.update(book)
|
appDb.bookDao.update(book)
|
||||||
}
|
}
|
||||||
viewModel.chapterListData.value?.let { chapterList ->
|
viewModel.chapterListData.value?.let { chapterList ->
|
||||||
@@ -103,6 +104,7 @@ class BookInfoActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private var tocChanged = false
|
private var tocChanged = false
|
||||||
|
private var chapterChanged = false
|
||||||
private val waitDialog by lazy { WaitDialog(this) }
|
private val waitDialog by lazy { WaitDialog(this) }
|
||||||
private var editMenuItem: MenuItem? = null
|
private var editMenuItem: MenuItem? = null
|
||||||
|
|
||||||
@@ -620,6 +622,7 @@ class BookInfoActivity :
|
|||||||
.putExtra("bookUrl", book.bookUrl)
|
.putExtra("bookUrl", book.bookUrl)
|
||||||
.putExtra("inBookshelf", viewModel.inBookshelf)
|
.putExtra("inBookshelf", viewModel.inBookshelf)
|
||||||
.putExtra("tocChanged", tocChanged)
|
.putExtra("tocChanged", tocChanged)
|
||||||
|
.putExtra("chapterChanged", chapterChanged)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
tocChanged = false
|
tocChanged = false
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
|
|||||||
execute {
|
execute {
|
||||||
ReadBook.inBookshelf = intent.getBooleanExtra("inBookshelf", true)
|
ReadBook.inBookshelf = intent.getBooleanExtra("inBookshelf", true)
|
||||||
ReadBook.tocChanged = intent.getBooleanExtra("tocChanged", false)
|
ReadBook.tocChanged = intent.getBooleanExtra("tocChanged", false)
|
||||||
|
ReadBook.chapterChanged = intent.getBooleanExtra("chapterChanged", false)
|
||||||
val bookUrl = intent.getStringExtra("bookUrl")
|
val bookUrl = intent.getStringExtra("bookUrl")
|
||||||
val book = when {
|
val book = when {
|
||||||
bookUrl.isNullOrEmpty() -> appDb.bookDao.lastReadBook
|
bookUrl.isNullOrEmpty() -> appDb.bookDao.lastReadBook
|
||||||
@@ -104,7 +105,10 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
|
|||||||
}
|
}
|
||||||
ReadBook.loadContent(resetPageOffset = false)
|
ReadBook.loadContent(resetPageOffset = false)
|
||||||
}
|
}
|
||||||
if (!isSameBook || !BaseReadAloudService.isRun) {
|
if (ReadBook.chapterChanged) {
|
||||||
|
// 有章节跳转不同步阅读进度
|
||||||
|
ReadBook.chapterChanged = false
|
||||||
|
} else if (!isSameBook || !BaseReadAloudService.isRun) {
|
||||||
syncBookProgress(book)
|
syncBookProgress(book)
|
||||||
}
|
}
|
||||||
if (!book.isLocal && ReadBook.bookSource == null) {
|
if (!book.isLocal && ReadBook.bookSource == null) {
|
||||||
|
|||||||
@@ -202,10 +202,10 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
searchView.setOnQueryTextFocusChangeListener { _, hasFocus ->
|
searchView.setOnQueryTextFocusChangeListener { _, hasFocus ->
|
||||||
if (!hasFocus && searchView.query.toString().trim().isEmpty()) {
|
if (binding.refreshProgressBar.isAutoLoading || (!hasFocus && adapter.isNotEmpty() && searchView.query.isNotBlank())){
|
||||||
finish()
|
visibleInputHelp(false)
|
||||||
} else {
|
} else {
|
||||||
visibleInputHelp(hasFocus)
|
visibleInputHelp(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
visibleInputHelp(true)
|
visibleInputHelp(true)
|
||||||
|
|||||||
@@ -162,7 +162,10 @@ class ChapterListFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_chapt
|
|||||||
|
|
||||||
override fun openChapter(bookChapter: BookChapter) {
|
override fun openChapter(bookChapter: BookChapter) {
|
||||||
activity?.run {
|
activity?.run {
|
||||||
setResult(RESULT_OK, Intent().putExtra("index", bookChapter.index))
|
setResult(RESULT_OK, Intent()
|
||||||
|
.putExtra("index", bookChapter.index)
|
||||||
|
.putExtra("chapterChanged", bookChapter.index != durChapterIndex)
|
||||||
|
)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,19 +5,20 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import androidx.activity.result.contract.ActivityResultContract
|
import androidx.activity.result.contract.ActivityResultContract
|
||||||
|
|
||||||
class TocActivityResult : ActivityResultContract<String, Pair<Int, Int>?>() {
|
class TocActivityResult : ActivityResultContract<String, Triple<Int, Int, Boolean>?>() {
|
||||||
|
|
||||||
override fun createIntent(context: Context, input: String): Intent {
|
override fun createIntent(context: Context, input: String): Intent {
|
||||||
return Intent(context, TocActivity::class.java)
|
return Intent(context, TocActivity::class.java)
|
||||||
.putExtra("bookUrl", input)
|
.putExtra("bookUrl", input)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun parseResult(resultCode: Int, intent: Intent?): Pair<Int, Int>? {
|
override fun parseResult(resultCode: Int, intent: Intent?): Triple<Int, Int, Boolean>? {
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
intent?.let {
|
intent?.let {
|
||||||
return Pair(
|
return Triple(
|
||||||
it.getIntExtra("index", 0),
|
it.getIntExtra("index", 0),
|
||||||
it.getIntExtra("chapterPos", 0)
|
it.getIntExtra("chapterPos", 0),
|
||||||
|
it.getBooleanExtra("chapterChanged", false)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user