feat: 优化代码

pull/149/head
kunfei 5 years ago
parent f4bbe3ad6e
commit 853d970642
  1. 19
      app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt

@ -151,15 +151,16 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac
*/ */
@RequiresApi(Build.VERSION_CODES.M) @RequiresApi(Build.VERSION_CODES.M)
private fun onInitializeMenu(menu: Menu) { private fun onInitializeMenu(menu: Menu) {
// Start with a menu Item order value that is high enough try {
// so that your "PROCESS_TEXT" menu items appear after the var menuItemOrder = 100
// standard selection menu items like Cut, Copy, Paste. for (resolveInfo in getSupportedActivities()) {
var menuItemOrder = 100 menu.add(
for (resolveInfo in getSupportedActivities()) { Menu.NONE, Menu.NONE,
menu.add( menuItemOrder++, resolveInfo.loadLabel(context.packageManager)
Menu.NONE, Menu.NONE, ).intent = createProcessTextIntentForResolveInfo(resolveInfo)
menuItemOrder++, resolveInfo.loadLabel(context.packageManager) }
).intent = createProcessTextIntentForResolveInfo(resolveInfo) } catch (e: Exception) {
context.toast("获取文字操作菜单出错:${e.localizedMessage}")
} }
} }

Loading…
Cancel
Save