@@ -42,6 +42,31 @@ object ReadBook : CoroutineScope by MainScope() {
|
|||||||
private val loadingChapters = arrayListOf<Int>()
|
private val loadingChapters = arrayListOf<Int>()
|
||||||
private val readRecord = ReadRecord()
|
private val readRecord = ReadRecord()
|
||||||
var readStartTime: Long = System.currentTimeMillis()
|
var readStartTime: Long = System.currentTimeMillis()
|
||||||
|
/* 跳转历史记录 */
|
||||||
|
var bookProgressHistory: List<BookProgress>? = null
|
||||||
|
/* 跳转进度前进度记录 */
|
||||||
|
var lastBookPress: BookProgress? = null
|
||||||
|
|
||||||
|
//暂时保存跳转前进度
|
||||||
|
fun saveCurrentBookProcess() {
|
||||||
|
if (lastBookPress != null) return //避免进度条连续跳转不能覆盖最初的进度记录
|
||||||
|
lastBookPress = book?.let { BookProgress(it) }
|
||||||
|
}
|
||||||
|
//恢复跳转前进度
|
||||||
|
fun restoreLastBookProcess() {
|
||||||
|
lastBookPress?.let {
|
||||||
|
durChapterPos = it.durChapterPos
|
||||||
|
if (durChapterIndex != it.durChapterIndex) {
|
||||||
|
clearTextChapter()
|
||||||
|
durChapterIndex = it.durChapterIndex
|
||||||
|
}
|
||||||
|
callBack?.upContent()
|
||||||
|
saveRead()
|
||||||
|
loadContent(resetPageOffset = true) {
|
||||||
|
lastBookPress = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun resetData(book: Book) {
|
fun resetData(book: Book) {
|
||||||
ReadBook.book = book
|
ReadBook.book = book
|
||||||
@@ -55,6 +80,7 @@ object ReadBook : CoroutineScope by MainScope() {
|
|||||||
callBack?.upMenuView()
|
callBack?.upMenuView()
|
||||||
callBack?.upPageAnim()
|
callBack?.upPageAnim()
|
||||||
upWebBook(book)
|
upWebBook(book)
|
||||||
|
lastBookPress = null
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
loadingChapters.clear()
|
loadingChapters.clear()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
viewModel.searchResultIndex = index
|
viewModel.searchResultIndex = index
|
||||||
binding.searchMenu.updateSearchResultIndex(index)
|
binding.searchMenu.updateSearchResultIndex(index)
|
||||||
binding.searchMenu.selectedSearchResult?.let { currentResult ->
|
binding.searchMenu.selectedSearchResult?.let { currentResult ->
|
||||||
|
ReadBook.saveCurrentBookProcess() //退出全文搜索恢复此时进度
|
||||||
skipToSearch(currentResult)
|
skipToSearch(currentResult)
|
||||||
showActionMenu()
|
showActionMenu()
|
||||||
}
|
}
|
||||||
@@ -493,6 +494,11 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
keyCode == KeyEvent.KEYCODE_BACK -> {
|
keyCode == KeyEvent.KEYCODE_BACK -> {
|
||||||
if (isShowingSearchResult) {
|
if (isShowingSearchResult) {
|
||||||
exitSearchMenu()
|
exitSearchMenu()
|
||||||
|
restoreLastBookProcess()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (ReadBook.lastBookPress != null) {
|
||||||
|
restoreLastBookProcess()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -926,13 +932,6 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 跳转到指定章节
|
|
||||||
*/
|
|
||||||
override fun skipToChapter(index: Int) {
|
|
||||||
viewModel.openChapter(index)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打开搜索界面
|
* 打开搜索界面
|
||||||
*/
|
*/
|
||||||
@@ -984,6 +983,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
upNavigationBarColor()
|
upNavigationBarColor()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 退出全文搜索
|
||||||
override fun exitSearchMenu() {
|
override fun exitSearchMenu() {
|
||||||
if (isShowingSearchResult) {
|
if (isShowingSearchResult) {
|
||||||
isShowingSearchResult = false
|
isShowingSearchResult = false
|
||||||
@@ -994,6 +994,20 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 恢复到 全文搜索/进度条跳转前的位置 */
|
||||||
|
private fun restoreLastBookProcess() {
|
||||||
|
// 默认提示恢复
|
||||||
|
alert(R.string.draw) {
|
||||||
|
setMessage(R.string.restore_last_book_process)
|
||||||
|
yesButton {
|
||||||
|
ReadBook.restoreLastBookProcess() //恢复启动全文搜索前的进度
|
||||||
|
}
|
||||||
|
noButton {
|
||||||
|
ReadBook.lastBookPress = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun showLogin() {
|
override fun showLogin() {
|
||||||
ReadBook.bookSource?.let {
|
ReadBook.bookSource?.let {
|
||||||
startActivity<SourceLoginActivity> {
|
startActivity<SourceLoginActivity> {
|
||||||
@@ -1141,11 +1155,18 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 进度条跳转到指定章节 */
|
||||||
|
override fun skipToChapter(index: Int) {
|
||||||
|
viewModel.openChapter(index)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 全文搜索跳转 */
|
||||||
override fun navigateToSearch(searchResult: SearchResult, index: Int) {
|
override fun navigateToSearch(searchResult: SearchResult, index: Int) {
|
||||||
viewModel.searchResultIndex = index
|
viewModel.searchResultIndex = index
|
||||||
skipToSearch(searchResult)
|
skipToSearch(searchResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 全文搜索跳转 */
|
||||||
private fun skipToSearch(searchResult: SearchResult) {
|
private fun skipToSearch(searchResult: SearchResult) {
|
||||||
val previousResult = binding.searchMenu.previousSearchResult
|
val previousResult = binding.searchMenu.previousSearchResult
|
||||||
|
|
||||||
|
|||||||
@@ -375,11 +375,13 @@ class ReadMenu @JvmOverloads constructor(
|
|||||||
"page" -> ReadBook.skipToPage(seekBar.progress)
|
"page" -> ReadBook.skipToPage(seekBar.progress)
|
||||||
"chapter" -> {
|
"chapter" -> {
|
||||||
if (confirmSkipToChapter) {
|
if (confirmSkipToChapter) {
|
||||||
|
ReadBook.saveCurrentBookProcess()
|
||||||
callBack.skipToChapter(seekBar.progress)
|
callBack.skipToChapter(seekBar.progress)
|
||||||
} else {
|
} else {
|
||||||
context.alert("章节跳转确认", "确定要跳转章节吗?") {
|
context.alert("章节跳转确认", "确定要跳转章节吗?") {
|
||||||
yesButton {
|
yesButton {
|
||||||
confirmSkipToChapter = true
|
confirmSkipToChapter = true
|
||||||
|
ReadBook.saveCurrentBookProcess()
|
||||||
callBack.skipToChapter(seekBar.progress)
|
callBack.skipToChapter(seekBar.progress)
|
||||||
}
|
}
|
||||||
noButton {
|
noButton {
|
||||||
|
|||||||
@@ -1039,4 +1039,5 @@
|
|||||||
<string name="progress_bar_behavior">进度条行为</string>
|
<string name="progress_bar_behavior">进度条行为</string>
|
||||||
<string name="source_edit_text_max_line">源编辑框最大行数</string>
|
<string name="source_edit_text_max_line">源编辑框最大行数</string>
|
||||||
<string name="source_edit_max_line_summary">%s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑</string>
|
<string name="source_edit_max_line_summary">%s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑</string>
|
||||||
|
<string name="restore_last_book_process">是否恢复到跳转前的阅读进度?</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1042,4 +1042,5 @@
|
|||||||
<string name="progress_bar_behavior">进度条行为</string>
|
<string name="progress_bar_behavior">进度条行为</string>
|
||||||
<string name="source_edit_text_max_line">源编辑框最大行数</string>
|
<string name="source_edit_text_max_line">源编辑框最大行数</string>
|
||||||
<string name="source_edit_max_line_summary">%s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑</string>
|
<string name="source_edit_max_line_summary">%s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑</string>
|
||||||
|
<string name="restore_last_book_process">是否恢复到跳转前的阅读进度?</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1042,4 +1042,5 @@
|
|||||||
<string name="progress_bar_behavior">进度条行为</string>
|
<string name="progress_bar_behavior">进度条行为</string>
|
||||||
<string name="source_edit_text_max_line">源编辑框最大行数</string>
|
<string name="source_edit_text_max_line">源编辑框最大行数</string>
|
||||||
<string name="source_edit_max_line_summary">%s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑</string>
|
<string name="source_edit_max_line_summary">%s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑</string>
|
||||||
|
<string name="restore_last_book_process">是否恢复到跳转前的阅读进度?</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1039,4 +1039,5 @@
|
|||||||
<string name="progress_bar_behavior">进度条行为</string>
|
<string name="progress_bar_behavior">进度条行为</string>
|
||||||
<string name="source_edit_text_max_line">源编辑框最大行数</string>
|
<string name="source_edit_text_max_line">源编辑框最大行数</string>
|
||||||
<string name="source_edit_max_line_summary">%s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑</string>
|
<string name="source_edit_max_line_summary">%s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑</string>
|
||||||
|
<string name="restore_last_book_process">是否恢复到跳转前的阅读进度?</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1041,4 +1041,5 @@
|
|||||||
<string name="progress_bar_behavior">进度条行为</string>
|
<string name="progress_bar_behavior">进度条行为</string>
|
||||||
<string name="source_edit_text_max_line">源编辑框最大行数</string>
|
<string name="source_edit_text_max_line">源编辑框最大行数</string>
|
||||||
<string name="source_edit_max_line_summary">%s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑</string>
|
<string name="source_edit_max_line_summary">%s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑</string>
|
||||||
|
<string name="restore_last_book_process">是否恢复到跳转前的阅读进度?</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1041,4 +1041,5 @@
|
|||||||
<string name="progress_bar_behavior">进度条行为</string>
|
<string name="progress_bar_behavior">进度条行为</string>
|
||||||
<string name="source_edit_text_max_line">源编辑框最大行数</string>
|
<string name="source_edit_text_max_line">源编辑框最大行数</string>
|
||||||
<string name="source_edit_max_line_summary">%s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑</string>
|
<string name="source_edit_max_line_summary">%s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑</string>
|
||||||
|
<string name="restore_last_book_process">是否恢复到跳转前的阅读进度?</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1042,4 +1042,5 @@
|
|||||||
<string name="progress_bar_behavior">进度条行为</string>
|
<string name="progress_bar_behavior">进度条行为</string>
|
||||||
<string name="source_edit_text_max_line">源编辑框最大行数</string>
|
<string name="source_edit_text_max_line">源编辑框最大行数</string>
|
||||||
<string name="source_edit_max_line_summary">%s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑</string>
|
<string name="source_edit_max_line_summary">%s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑</string>
|
||||||
|
<string name="restore_last_book_process">是否恢复到跳转前的阅读进度?</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user