diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index e36a350ff..b69dc9d11 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,6 +5,7 @@ **2020/05/10** * 添加识别rss分组中的频道信息,在菜单中可以切换频道 from yangyxd +* 书源添加批量置顶 **2020/05/04** * 优化txt文件目录解析 diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index d3cb63af3..088d6855b 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -203,6 +203,7 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity R.id.menu_disable_explore -> viewModel.disableSelectExplore(adapter.getSelection()) R.id.menu_export_selection -> FilePicker.selectFolder(this, exportRequestCode) R.id.menu_check_source -> CheckSource.start(this, adapter.getSelection()) + R.id.menu_top_sel -> viewModel.topSource(*adapter.getSelection().toTypedArray()) } return true } diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt index 5857fe8ef..e3ea49495 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt @@ -19,10 +19,13 @@ import java.io.File class BookSourceViewModel(application: Application) : BaseViewModel(application) { - fun topSource(bookSource: BookSource) { + fun topSource(vararg sources: BookSource) { execute { - bookSource.customOrder = App.db.bookSourceDao().minOrder - 1 - App.db.bookSourceDao().insert(bookSource) + val minOrder = App.db.bookSourceDao().minOrder - 1 + sources.forEachIndexed { index, bookSource -> + bookSource.customOrder = minOrder - index + } + App.db.bookSourceDao().update(*sources) } } diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt index 1f7503e47..f945dcc15 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt @@ -106,8 +106,7 @@ class RssSourceActivity : VMBaseActivity(R.layout.activity_r R.id.menu_disable_selection -> viewModel.disableSelection(adapter.getSelection()) R.id.menu_del_selection -> viewModel.delSelection(adapter.getSelection()) R.id.menu_export_selection -> FilePicker.selectFolder(this, exportRequestCode) - R.id.menu_check_source -> { - } + R.id.menu_top_sel -> viewModel.topSource(*adapter.getSelection().toTypedArray()) } return true } diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt index 65c5bc093..723710c7d 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt @@ -17,10 +17,13 @@ import java.io.File class RssSourceViewModel(application: Application) : BaseViewModel(application) { - fun topSource(rssSource: RssSource) { + fun topSource(vararg sources: RssSource) { execute { - rssSource.customOrder = App.db.rssSourceDao().minOrder - 1 - App.db.rssSourceDao().insert(rssSource) + val minOrder = App.db.rssSourceDao().minOrder - 1 + sources.forEachIndexed { index, rssSource -> + rssSource.customOrder = minOrder - index + } + App.db.rssSourceDao().update(*sources) } } diff --git a/app/src/main/res/menu/book_source_sel.xml b/app/src/main/res/menu/book_source_sel.xml index 456bf4645..dd245cd43 100644 --- a/app/src/main/res/menu/book_source_sel.xml +++ b/app/src/main/res/menu/book_source_sel.xml @@ -22,6 +22,11 @@ android:title="@string/disable_explore" app:showAsAction="never" /> + +