优化中文排序

pull/540/head
gedoor 4 years ago
parent 3c5a190765
commit f8bda2deda
  1. 6
      app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt
  2. 6
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  3. 7
      app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt
  4. 7
      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,8 +244,9 @@ 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)
}.map {
item = menu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it) item = menu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it)
if (it == selectedGroup) { if (it == selectedGroup) {
item?.isChecked = true item?.isChecked = 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,8 +341,9 @@ 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)
}.map {
groupMenu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it) groupMenu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it)
} }
} }

@ -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,8 +126,9 @@ 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)
}.forEach {
subMenu.add(R.id.menu_group_text, Menu.NONE, Menu.NONE, it) 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,8 +195,9 @@ 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)
}.map {
groupMenu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it) groupMenu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it)
} }
} }

Loading…
Cancel
Save