From 408720e25b2c5a2d081f4ad1dbc8fa440367d60d Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 10 May 2020 10:18:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/service/help/CheckSource.kt | 2 +- .../app/ui/book/source/manage/BookSourceAdapter.kt | 6 +++--- .../ui/book/source/manage/BookSourceViewModel.kt | 14 +++++++------- .../app/ui/rss/source/manage/RssSourceActivity.kt | 2 +- .../app/ui/rss/source/manage/RssSourceAdapter.kt | 6 +++--- .../app/ui/rss/source/manage/RssSourceViewModel.kt | 10 +++++----- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/help/CheckSource.kt b/app/src/main/java/io/legado/app/service/help/CheckSource.kt index 1f13723a2..b0a33953b 100644 --- a/app/src/main/java/io/legado/app/service/help/CheckSource.kt +++ b/app/src/main/java/io/legado/app/service/help/CheckSource.kt @@ -10,7 +10,7 @@ import org.jetbrains.anko.toast object CheckSource { - fun start(context: Context, sources: LinkedHashSet) { + fun start(context: Context, sources: List) { if (sources.isEmpty()) { context.toast(R.string.non_select) return diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt index c420284f8..a035341ee 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt @@ -46,14 +46,14 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : callBack.upCountView() } - fun getSelection(): LinkedHashSet { - val selection = linkedSetOf() + fun getSelection(): List { + val selection = arrayListOf() getItems().map { if (selected.contains(it)) { selection.add(it) } } - return selection + return selection.sortedBy { it.customOrder } } override fun convert(holder: ItemViewHolder, item: BookSource, payloads: MutableList) { 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 3ffd37543..5077a71cf 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 @@ -57,7 +57,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) } } - fun enableSelection(sources: LinkedHashSet) { + fun enableSelection(sources: List) { execute { val list = arrayListOf() sources.forEach { @@ -67,7 +67,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) } } - fun disableSelection(sources: LinkedHashSet) { + fun disableSelection(sources: List) { execute { val list = arrayListOf() sources.forEach { @@ -77,7 +77,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) } } - fun enableSelectExplore(sources: LinkedHashSet) { + fun enableSelectExplore(sources: List) { execute { val list = arrayListOf() sources.forEach { @@ -87,7 +87,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) } } - fun disableSelectExplore(sources: LinkedHashSet) { + fun disableSelectExplore(sources: List) { execute { val list = arrayListOf() sources.forEach { @@ -97,13 +97,13 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) } } - fun delSelection(sources: LinkedHashSet) { + fun delSelection(sources: List) { execute { App.db.bookSourceDao().delete(*sources.toTypedArray()) } } - fun exportSelection(sources: LinkedHashSet, file: File) { + fun exportSelection(sources: List, file: File) { execute { val json = GSON.toJson(sources) FileUtils.createFileIfNotExist(file, "exportBookSource.json") @@ -115,7 +115,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) } } - fun exportSelection(sources: LinkedHashSet, doc: DocumentFile) { + fun exportSelection(sources: List, doc: DocumentFile) { execute { val json = GSON.toJson(sources) doc.findFile("exportBookSource.json")?.delete() 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 13f270d6a..be9866ef2 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 @@ -204,7 +204,7 @@ class RssSourceActivity : VMBaseActivity(R.layout.activity_r private fun upGroupMenu() { groupMenu?.removeGroup(R.id.source_group) - groups.sortedWith(Collator.getInstance(java.util.Locale.CHINESE)) + groups.sortedWith(Collator.getInstance(Locale.CHINESE)) .map { groupMenu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it) } diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt index 28ee9b48c..156dc1610 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt @@ -40,14 +40,14 @@ class RssSourceAdapter(context: Context, val callBack: CallBack) : callBack.upCountView() } - fun getSelection(): LinkedHashSet { - val selection = linkedSetOf() + fun getSelection(): List { + val selection = arrayListOf() getItems().forEach { if (selected.contains(it)) { selection.add(it) } } - return selection + return selection.sortedBy { it.customOrder } } override fun convert(holder: ItemViewHolder, item: RssSource, payloads: MutableList) { 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 a506bad24..1ee781220 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 @@ -55,7 +55,7 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application) } } - fun enableSelection(sources: LinkedHashSet) { + fun enableSelection(sources: List) { execute { val list = arrayListOf() sources.forEach { @@ -65,7 +65,7 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application) } } - fun disableSelection(sources: LinkedHashSet) { + fun disableSelection(sources: List) { execute { val list = arrayListOf() sources.forEach { @@ -75,13 +75,13 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application) } } - fun delSelection(sources: LinkedHashSet) { + fun delSelection(sources: List) { execute { App.db.rssSourceDao().delete(*sources.toTypedArray()) } } - fun exportSelection(sources: LinkedHashSet, file: File) { + fun exportSelection(sources: List, file: File) { execute { val json = GSON.toJson(sources) FileUtils.createFileIfNotExist(file, "exportRssSource.json") @@ -93,7 +93,7 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application) } } - fun exportSelection(sources: LinkedHashSet, doc: DocumentFile) { + fun exportSelection(sources: List, doc: DocumentFile) { execute { val json = GSON.toJson(sources) doc.findFile("exportRssSource.json")?.delete()