pull/1705/head
kunfei 3 years ago
parent ff4e37134f
commit 0db277bdfc
  1. 18
      app/src/main/java/io/legado/app/ui/widget/keyboard/KeyboardAssistsConfig.kt
  2. 2
      app/src/main/res/layout/item_1line_text_and_del.xml

@ -6,6 +6,7 @@ import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.core.view.setPadding
import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
@ -23,6 +24,7 @@ import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.widget.recycler.ItemTouchCallback import io.legado.app.ui.widget.recycler.ItemTouchCallback
import io.legado.app.ui.widget.recycler.VerticalDivider import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.applyTint import io.legado.app.utils.applyTint
import io.legado.app.utils.dp
import io.legado.app.utils.setLayout import io.legado.app.utils.setLayout
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
import io.legado.app.utils.visible import io.legado.app.utils.visible
@ -84,8 +86,10 @@ class KeyboardAssistsConfig : BaseDialogFragment(R.layout.dialog_recycler_view),
setTitle("辅助按键") setTitle("辅助按键")
val alertBinding = DialogMultipleEditTextBinding.inflate(layoutInflater).apply { val alertBinding = DialogMultipleEditTextBinding.inflate(layoutInflater).apply {
layout1.hint = "key" layout1.hint = "key"
edit1.setText(keyboardAssist?.key)
layout2.hint = "value" layout2.hint = "value"
layout2.visible() layout2.visible()
edit2.setText(keyboardAssist?.value)
} }
setCustomView(alertBinding.root) setCustomView(alertBinding.root)
cancelButton() cancelButton()
@ -115,7 +119,10 @@ class KeyboardAssistsConfig : BaseDialogFragment(R.layout.dialog_recycler_view),
private var isMoved = false private var isMoved = false
override fun getViewBinding(parent: ViewGroup): Item1lineTextAndDelBinding { override fun getViewBinding(parent: ViewGroup): Item1lineTextAndDelBinding {
return Item1lineTextAndDelBinding.inflate(inflater, parent, false) return Item1lineTextAndDelBinding.inflate(inflater, parent, false).apply {
root.setPadding(16.dp)
ivDelete.visible()
}
} }
override fun convert( override fun convert(
@ -128,11 +135,18 @@ class KeyboardAssistsConfig : BaseDialogFragment(R.layout.dialog_recycler_view),
} }
override fun registerListener(holder: ItemViewHolder, binding: Item1lineTextAndDelBinding) { override fun registerListener(holder: ItemViewHolder, binding: Item1lineTextAndDelBinding) {
binding.ivDelete.setOnClickListener { binding.root.setOnClickListener {
getItemByLayoutPosition(holder.layoutPosition)?.let { keyboardAssist -> getItemByLayoutPosition(holder.layoutPosition)?.let { keyboardAssist ->
editKey(keyboardAssist) editKey(keyboardAssist)
} }
} }
binding.ivDelete.setOnClickListener {
getItemByLayoutPosition(holder.layoutPosition)?.let { keyboardAssist ->
launch(IO) {
appDb.keyboardAssistsDao.delete(keyboardAssist)
}
}
}
} }
override fun swap(srcPosition: Int, targetPosition: Int): Boolean { override fun swap(srcPosition: Int, targetPosition: Int): Boolean {

@ -3,7 +3,7 @@
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" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal"
android:padding="6dp" android:padding="6dp"

Loading…
Cancel
Save