feat: 优化代码

pull/103/head
kunfei 5 years ago
parent f60b6ac2e9
commit 2ddfd65dd9
  1. 7
      app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt
  2. 26
      app/src/main/res/layout/item_group_select.xml

@ -33,7 +33,7 @@ import io.legado.app.utils.getViewModel
import io.legado.app.utils.requestInputMethod
import kotlinx.android.synthetic.main.dialog_edit_text.view.*
import kotlinx.android.synthetic.main.dialog_recycler_view.*
import kotlinx.android.synthetic.main.item_group_manage.view.*
import kotlinx.android.synthetic.main.item_group_select.*
import org.jetbrains.anko.sdk27.listeners.onClick
import java.util.*
@ -151,16 +151,15 @@ class GroupSelectDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
}
private inner class GroupAdapter(context: Context) :
SimpleRecyclerAdapter<BookGroup>(context, R.layout.item_group_manage),
SimpleRecyclerAdapter<BookGroup>(context, R.layout.item_group_select),
ItemTouchCallback.OnItemTouchCallbackListener {
private var isMoved: Boolean = false
override fun convert(holder: ItemViewHolder, item: BookGroup, payloads: MutableList<Any>) {
with(holder.itemView) {
tv_group.text = item.groupName
cb_group.text = item.groupName
tv_edit.onClick { editGroup(item) }
tv_del.onClick { viewModel.delGroup(item) }
this.onClick {
callBack?.upGroup(requestCode, item)
dismiss()

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background"
android:padding="8dp"
android:orientation="horizontal">
<io.legado.app.lib.theme.view.ATECheckBox
android:id="@+id/cb_group"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:singleLine="true"
android:textColor="@color/tv_text_default" />
<TextView
android:id="@+id/tv_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:padding="8dp"
android:text="@string/edit" />
</LinearLayout>
Loading…
Cancel
Save