diff --git a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt index b66a3c911..654eda904 100644 --- a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt @@ -88,7 +88,7 @@ class ArrangeBookActivity : VMBaseActivity(Mode.ToggleAndReverse) { + val dragSelectCallback: DragSelectTouchHelper.Callback = + object : DragSelectTouchHelper.AdvanceCallback(Mode.ToggleAndReverse) { override fun currentSelectedId(): MutableSet { return selectedBooks } @@ -189,7 +189,6 @@ class ArrangeBookAdapter(context: Context, val callBack: CallBack) : return false } } - } interface CallBack { val groupList: List diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt index dbabfd209..0db6df716 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt @@ -237,22 +237,22 @@ class SearchActivity : VMBaseActivity val selectedGroup = getPrefString("searchGroup") ?: "" - menu?.removeGroup(R.id.source_group) - var item = menu?.add(R.id.source_group, Menu.NONE, Menu.NONE, R.string.all_source) + menu.removeGroup(R.id.source_group) + var item = menu.add(R.id.source_group, Menu.NONE, Menu.NONE, R.string.all_source) if (selectedGroup == "") { item?.isChecked = true } groups.sortedWith { o1, o2 -> 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) { item?.isChecked = true } } - menu?.setGroupCheckable(R.id.source_group, true, true) + menu.setGroupCheckable(R.id.source_group, true, true) } /** 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 d82af267a..026f02a4d 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 @@ -152,14 +152,14 @@ class BookSourceActivity : VMBaseActivity + menu.removeGroup(R.id.source_group) groups.sortedWith { o1, o2 -> o1.cnCompare(o2) }.map { - groupMenu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it) + menu.add(R.id.source_group, Menu.NONE, Menu.NONE, it) } } 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 fe090435b..93fc4fdfd 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 @@ -204,8 +204,8 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : } } - fun initDragSelectTouchHelperCallback(): DragSelectTouchHelper.Callback { - return object : DragSelectTouchHelper.AdvanceCallback(Mode.ToggleAndReverse) { + val dragSelectCallback: DragSelectTouchHelper.Callback = + object : DragSelectTouchHelper.AdvanceCallback(Mode.ToggleAndReverse) { override fun currentSelectedId(): MutableSet { return selected } @@ -228,7 +228,6 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : return false } } - } interface CallBack { fun del(bookSource: BookSource) diff --git a/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt b/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt index 0967a106e..e4ea63bd7 100644 --- a/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt @@ -123,14 +123,12 @@ class ExploreFragment : VMBaseFragment(R.layout.fragment_explo }) } - private fun upGroupsMenu() { - groupsMenu?.let { subMenu -> - subMenu.removeGroup(R.id.menu_group_text) - groups.sortedWith { o1, o2 -> - o1.cnCompare(o2) - }.forEach { - subMenu.add(R.id.menu_group_text, Menu.NONE, Menu.NONE, it) - } + private fun upGroupsMenu() = groupsMenu?.let { subMenu -> + subMenu.removeGroup(R.id.menu_group_text) + groups.sortedWith { o1, o2 -> + o1.cnCompare(o2) + }.forEach { + subMenu.add(R.id.menu_group_text, Menu.NONE, Menu.NONE, it) } } diff --git a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt index a24c52943..b527aaade 100644 --- a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt +++ b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt @@ -92,7 +92,7 @@ class ReplaceRuleActivity : VMBaseActivity(Mode.ToggleAndReverse) { + val dragSelectCallback: DragSelectTouchHelper.Callback = + object : DragSelectTouchHelper.AdvanceCallback(Mode.ToggleAndReverse) { override fun currentSelectedId(): MutableSet { return selected } @@ -191,7 +191,6 @@ class ReplaceRuleAdapter(context: Context, var callBack: CallBack) : return false } } - } interface CallBack { fun update(vararg rule: ReplaceRule) 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 8e3c4f78b..01abc2e16 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 @@ -121,13 +121,11 @@ class RssSourceActivity : VMBaseActivity + menu.removeGroup(R.id.source_group) groups.sortedWith { o1, o2 -> o1.cnCompare(o2) }.map { - groupMenu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it) + menu.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 60128fb27..1de2c8ebe 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 @@ -170,8 +170,8 @@ class RssSourceAdapter(context: Context, val callBack: CallBack) : } } - fun initDragSelectTouchHelperCallback(): DragSelectTouchHelper.Callback { - return object : DragSelectTouchHelper.AdvanceCallback(Mode.ToggleAndReverse) { + val dragSelectCallback: DragSelectTouchHelper.Callback = + object : DragSelectTouchHelper.AdvanceCallback(Mode.ToggleAndReverse) { override fun currentSelectedId(): MutableSet { return selected } @@ -194,7 +194,6 @@ class RssSourceAdapter(context: Context, val callBack: CallBack) : return false } } - } interface CallBack { fun del(source: RssSource)