优化
This commit is contained in:
@@ -241,14 +241,36 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
showDialogFragment(ChangeSourceDialog(it.name, it.author))
|
showDialogFragment(ChangeSourceDialog(it.name, it.author))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
R.id.menu_refresh -> {
|
R.id.menu_refresh_dur -> {
|
||||||
if (ReadBook.bookSource == null) {
|
if (ReadBook.bookSource == null) {
|
||||||
upContent()
|
upContent()
|
||||||
} else {
|
} else {
|
||||||
ReadBook.book?.let {
|
ReadBook.book?.let {
|
||||||
ReadBook.curTextChapter = null
|
ReadBook.curTextChapter = null
|
||||||
binding.readView.upContent()
|
binding.readView.upContent()
|
||||||
viewModel.refreshContent(it)
|
viewModel.refreshContentDur(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
R.id.menu_refresh_after -> {
|
||||||
|
if (ReadBook.bookSource == null) {
|
||||||
|
upContent()
|
||||||
|
} else {
|
||||||
|
ReadBook.book?.let {
|
||||||
|
ReadBook.clearTextChapter()
|
||||||
|
binding.readView.upContent()
|
||||||
|
viewModel.refreshContentAfter(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
R.id.menu_refresh_all -> {
|
||||||
|
if (ReadBook.bookSource == null) {
|
||||||
|
upContent()
|
||||||
|
} else {
|
||||||
|
ReadBook.book?.let {
|
||||||
|
ReadBook.clearTextChapter()
|
||||||
|
binding.readView.upContent()
|
||||||
|
viewModel.refreshContentAll(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun refreshContent(book: Book) {
|
fun refreshContentDur(book: Book) {
|
||||||
execute {
|
execute {
|
||||||
appDb.bookChapterDao.getChapter(book.bookUrl, ReadBook.durChapterIndex)
|
appDb.bookChapterDao.getChapter(book.bookUrl, ReadBook.durChapterIndex)
|
||||||
?.let { chapter ->
|
?.let { chapter ->
|
||||||
@@ -263,6 +263,26 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun refreshContentAfter(book: Book) {
|
||||||
|
execute {
|
||||||
|
appDb.bookChapterDao.getChapterList(
|
||||||
|
book.bookUrl,
|
||||||
|
ReadBook.durChapterIndex,
|
||||||
|
book.totalChapterNum
|
||||||
|
).forEach { chapter ->
|
||||||
|
BookHelp.delContent(book, chapter)
|
||||||
|
}
|
||||||
|
ReadBook.loadContent(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun refreshContentAll(book: Book) {
|
||||||
|
execute {
|
||||||
|
BookHelp.clearCache(book)
|
||||||
|
ReadBook.loadContent(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun reverseContent(book: Book) {
|
fun reverseContent(book: Book) {
|
||||||
execute {
|
execute {
|
||||||
appDb.bookChapterDao.getChapter(book.bookUrl, ReadBook.durChapterIndex)
|
appDb.bookChapterDao.getChapter(book.bookUrl, ReadBook.durChapterIndex)
|
||||||
|
|||||||
@@ -15,7 +15,28 @@
|
|||||||
android:id="@+id/menu_refresh"
|
android:id="@+id/menu_refresh"
|
||||||
android:icon="@drawable/ic_refresh_black_24dp"
|
android:icon="@drawable/ic_refresh_black_24dp"
|
||||||
android:title="@string/refresh"
|
android:title="@string/refresh"
|
||||||
app:showAsAction="always" />
|
app:showAsAction="always">
|
||||||
|
|
||||||
|
<menu>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_refresh_dur"
|
||||||
|
android:title="@string/menu_refresh_dur"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_refresh_after"
|
||||||
|
android:title="@string/menu_refresh_after"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_refresh_all"
|
||||||
|
android:title="@string/menu_refresh_all"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
</menu>
|
||||||
|
|
||||||
|
</item>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_download"
|
android:id="@+id/menu_download"
|
||||||
|
|||||||
@@ -934,5 +934,8 @@
|
|||||||
<string name="scope_content">作用于正文</string>
|
<string name="scope_content">作用于正文</string>
|
||||||
<string name="join_qq_channel">加入QQ频道</string>
|
<string name="join_qq_channel">加入QQ频道</string>
|
||||||
<string name="qq_channel_summary">点击加入阅读QQ频道</string>
|
<string name="qq_channel_summary">点击加入阅读QQ频道</string>
|
||||||
|
<string name="menu_refresh_dur">刷新当前章节</string>
|
||||||
|
<string name="menu_refresh_after">刷新之后章节</string>
|
||||||
|
<string name="menu_refresh_all">刷新全部章节</string>
|
||||||
<!-- string end -->
|
<!-- string end -->
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -937,5 +937,8 @@
|
|||||||
<string name="scope_content">作用于正文</string>
|
<string name="scope_content">作用于正文</string>
|
||||||
<string name="join_qq_channel">加入QQ频道</string>
|
<string name="join_qq_channel">加入QQ频道</string>
|
||||||
<string name="qq_channel_summary">点击加入阅读QQ频道</string>
|
<string name="qq_channel_summary">点击加入阅读QQ频道</string>
|
||||||
|
<string name="menu_refresh_dur">刷新当前章节</string>
|
||||||
|
<string name="menu_refresh_after">刷新之后章节</string>
|
||||||
|
<string name="menu_refresh_all">刷新全部章节</string>
|
||||||
<!-- string end -->
|
<!-- string end -->
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -937,5 +937,8 @@
|
|||||||
<string name="scope_content">作用于正文</string>
|
<string name="scope_content">作用于正文</string>
|
||||||
<string name="join_qq_channel">加入QQ频道</string>
|
<string name="join_qq_channel">加入QQ频道</string>
|
||||||
<string name="qq_channel_summary">点击加入阅读QQ频道</string>
|
<string name="qq_channel_summary">点击加入阅读QQ频道</string>
|
||||||
|
<string name="menu_refresh_dur">刷新当前章节</string>
|
||||||
|
<string name="menu_refresh_after">刷新之后章节</string>
|
||||||
|
<string name="menu_refresh_all">刷新全部章节</string>
|
||||||
<!-- string end -->
|
<!-- string end -->
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -934,5 +934,8 @@
|
|||||||
<string name="scope_content">作用于正文</string>
|
<string name="scope_content">作用于正文</string>
|
||||||
<string name="join_qq_channel">加入QQ频道</string>
|
<string name="join_qq_channel">加入QQ频道</string>
|
||||||
<string name="qq_channel_summary">点击加入阅读QQ频道</string>
|
<string name="qq_channel_summary">点击加入阅读QQ频道</string>
|
||||||
|
<string name="menu_refresh_dur">刷新当前章节</string>
|
||||||
|
<string name="menu_refresh_after">刷新之后章节</string>
|
||||||
|
<string name="menu_refresh_all">刷新全部章节</string>
|
||||||
<!-- string end -->
|
<!-- string end -->
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -936,5 +936,8 @@
|
|||||||
<string name="scope_content">作用于正文</string>
|
<string name="scope_content">作用于正文</string>
|
||||||
<string name="join_qq_channel">加入QQ频道</string>
|
<string name="join_qq_channel">加入QQ频道</string>
|
||||||
<string name="qq_channel_summary">点击加入阅读QQ频道</string>
|
<string name="qq_channel_summary">点击加入阅读QQ频道</string>
|
||||||
|
<string name="menu_refresh_dur">刷新当前章节</string>
|
||||||
|
<string name="menu_refresh_after">刷新之后章节</string>
|
||||||
|
<string name="menu_refresh_all">刷新全部章节</string>
|
||||||
<!-- string end -->
|
<!-- string end -->
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -936,5 +936,8 @@
|
|||||||
<string name="scope_content">作用于正文</string>
|
<string name="scope_content">作用于正文</string>
|
||||||
<string name="join_qq_channel">加入QQ频道</string>
|
<string name="join_qq_channel">加入QQ频道</string>
|
||||||
<string name="qq_channel_summary">点击加入阅读QQ频道</string>
|
<string name="qq_channel_summary">点击加入阅读QQ频道</string>
|
||||||
|
<string name="menu_refresh_dur">刷新当前章节</string>
|
||||||
|
<string name="menu_refresh_after">刷新之后章节</string>
|
||||||
|
<string name="menu_refresh_all">刷新全部章节</string>
|
||||||
<!-- string end -->
|
<!-- string end -->
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -937,5 +937,8 @@
|
|||||||
<string name="scope_content">作用于正文</string>
|
<string name="scope_content">作用于正文</string>
|
||||||
<string name="join_qq_channel">Join QQ channel</string>
|
<string name="join_qq_channel">Join QQ channel</string>
|
||||||
<string name="qq_channel_summary">点击加入阅读QQ频道</string>
|
<string name="qq_channel_summary">点击加入阅读QQ频道</string>
|
||||||
|
<string name="menu_refresh_dur">刷新当前章节</string>
|
||||||
|
<string name="menu_refresh_after">刷新之后章节</string>
|
||||||
|
<string name="menu_refresh_all">刷新全部章节</string>
|
||||||
<!-- string end -->
|
<!-- string end -->
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user