mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
优化
This commit is contained in:
parent
3d77019c07
commit
0ff22a12a3
@ -76,11 +76,13 @@ class DictRuleActivity : VMBaseActivity<ActivityDictRuleBinding, DictRuleViewMod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onContextItemSelected(item: MenuItem): Boolean {
|
override fun onCompatOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.menu_create -> showDialogFragment<DictRuleEditDialog>()
|
R.id.menu_create -> showDialogFragment<DictRuleEditDialog>()
|
||||||
|
R.id.menu_import_default -> viewModel.importDefault()
|
||||||
|
R.id.menu_help -> {}
|
||||||
}
|
}
|
||||||
return super.onContextItemSelected(item)
|
return super.onCompatOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMenuItemClick(item: MenuItem): Boolean {
|
override fun onMenuItemClick(item: MenuItem): Boolean {
|
||||||
|
@ -4,6 +4,7 @@ import android.app.Application
|
|||||||
import io.legado.app.base.BaseViewModel
|
import io.legado.app.base.BaseViewModel
|
||||||
import io.legado.app.data.appDb
|
import io.legado.app.data.appDb
|
||||||
import io.legado.app.data.entities.DictRule
|
import io.legado.app.data.entities.DictRule
|
||||||
|
import io.legado.app.help.DefaultData
|
||||||
|
|
||||||
class DictRuleViewModel(application: Application) : BaseViewModel(application) {
|
class DictRuleViewModel(application: Application) : BaseViewModel(application) {
|
||||||
|
|
||||||
@ -30,4 +31,10 @@ class DictRuleViewModel(application: Application) : BaseViewModel(application) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun importDefault() {
|
||||||
|
execute {
|
||||||
|
DefaultData.importDefaultDictRules()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -11,8 +11,6 @@
|
|||||||
android:id="@+id/title_bar"
|
android:id="@+id/title_bar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:contentInsetStartWithNavigation="0dp"
|
|
||||||
app:contentLayout="@layout/view_search"
|
|
||||||
app:title="@string/dict_rule" />
|
app:title="@string/dict_rule" />
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
tools:ignore="AlwaysShowAction">
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_create"
|
android:id="@+id/menu_create"
|
||||||
android:icon="@drawable/ic_add"
|
android:icon="@drawable/ic_add"
|
||||||
android:title="@string/create"
|
android:title="@string/create"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="always" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_import_local"
|
android:id="@+id/menu_import_local"
|
||||||
@ -26,6 +28,12 @@
|
|||||||
android:title="@string/import_by_qr_code"
|
android:title="@string/import_by_qr_code"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_import_default"
|
||||||
|
android:icon="@drawable/ic_import"
|
||||||
|
android:title="@string/import_default_rule"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_help"
|
android:id="@+id/menu_help"
|
||||||
android:icon="@drawable/ic_help"
|
android:icon="@drawable/ic_help"
|
||||||
|
Loading…
Reference in New Issue
Block a user