优化中文排序

pull/540/head
gedoor 4 years ago
parent 3c5a190765
commit f8bda2deda
  1. 14
      app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt
  2. 10
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  3. 11
      app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt
  4. 11
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt

@ -30,7 +30,6 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.sdk27.listeners.onClick
import org.jetbrains.anko.startActivity import org.jetbrains.anko.startActivity
import java.text.Collator
class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel>(), class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel>(),
@ -245,13 +244,14 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
if (selectedGroup == "") { if (selectedGroup == "") {
item?.isChecked = true item?.isChecked = true
} }
groups.sortedWith(Collator.getInstance(java.util.Locale.CHINESE)) groups.sortedWith { o1, o2 ->
.map { o1.cnCompare(o2)
item = menu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it) }.map {
if (it == selectedGroup) { item = menu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it)
item?.isChecked = true if (it == selectedGroup) {
} item?.isChecked = true
} }
}
menu?.setGroupCheckable(R.id.source_group, true, true) menu?.setGroupCheckable(R.id.source_group, true, true)
} }

@ -44,7 +44,6 @@ import org.jetbrains.anko.startActivity
import org.jetbrains.anko.startActivityForResult import org.jetbrains.anko.startActivityForResult
import org.jetbrains.anko.toast import org.jetbrains.anko.toast
import java.io.File import java.io.File
import java.text.Collator
class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceViewModel>(), class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceViewModel>(),
PopupMenu.OnMenuItemClickListener, PopupMenu.OnMenuItemClickListener,
@ -342,10 +341,11 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
private fun upGroupMenu() { private fun upGroupMenu() {
groupMenu?.removeGroup(R.id.source_group) groupMenu?.removeGroup(R.id.source_group)
groups.sortedWith(Collator.getInstance(java.util.Locale.CHINESE)) groups.sortedWith { o1, o2 ->
.map { o1.cnCompare(o2)
groupMenu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it) }.map {
} groupMenu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it)
}
} }
@SuppressLint("InflateParams") @SuppressLint("InflateParams")

@ -22,11 +22,11 @@ import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.primaryTextColor import io.legado.app.lib.theme.primaryTextColor
import io.legado.app.ui.book.explore.ExploreShowActivity import io.legado.app.ui.book.explore.ExploreShowActivity
import io.legado.app.ui.book.source.edit.BookSourceEditActivity import io.legado.app.ui.book.source.edit.BookSourceEditActivity
import io.legado.app.utils.cnCompare
import io.legado.app.utils.getViewModel import io.legado.app.utils.getViewModel
import io.legado.app.utils.splitNotBlank import io.legado.app.utils.splitNotBlank
import io.legado.app.utils.startActivity import io.legado.app.utils.startActivity
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
import java.text.Collator
/** /**
* 发现界面 * 发现界面
@ -126,10 +126,11 @@ class ExploreFragment : VMBaseFragment<ExploreViewModel>(R.layout.fragment_explo
private fun upGroupsMenu() { private fun upGroupsMenu() {
groupsMenu?.let { subMenu -> groupsMenu?.let { subMenu ->
subMenu.removeGroup(R.id.menu_group_text) subMenu.removeGroup(R.id.menu_group_text)
groups.sortedWith(Collator.getInstance(java.util.Locale.CHINESE)) groups.sortedWith { o1, o2 ->
.forEach { o1.cnCompare(o2)
subMenu.add(R.id.menu_group_text, Menu.NONE, Menu.NONE, it) }.forEach {
} subMenu.add(R.id.menu_group_text, Menu.NONE, Menu.NONE, it)
}
} }
} }

@ -40,8 +40,6 @@ import org.jetbrains.anko.startActivity
import org.jetbrains.anko.startActivityForResult import org.jetbrains.anko.startActivityForResult
import org.jetbrains.anko.toast import org.jetbrains.anko.toast
import java.io.File import java.io.File
import java.text.Collator
import java.util.*
class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceViewModel>(), class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceViewModel>(),
@ -197,10 +195,11 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView
private fun upGroupMenu() { private fun upGroupMenu() {
groupMenu?.removeGroup(R.id.source_group) groupMenu?.removeGroup(R.id.source_group)
groups.sortedWith(Collator.getInstance(Locale.CHINESE)) groups.sortedWith { o1, o2 ->
.map { o1.cnCompare(o2)
groupMenu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it) }.map {
} groupMenu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it)
}
} }
private fun initLiveDataSource(key: String? = null) { private fun initLiveDataSource(key: String? = null) {

Loading…
Cancel
Save