添加批量换源

pull/1751/head
kunfei 3 years ago
parent bd797476b3
commit ea3fc5a076
  1. 12
      app/src/main/java/io/legado/app/ui/book/arrange/SourcePickerDialog.kt
  2. 20
      app/src/main/res/layout/item_1line_text.xml
  3. 2
      app/src/main/res/layout/item_1line_text_and_del.xml

@ -14,7 +14,7 @@ import io.legado.app.base.adapter.RecyclerAdapter
import io.legado.app.data.appDb import io.legado.app.data.appDb
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.databinding.DialogSourcePickerBinding import io.legado.app.databinding.DialogSourcePickerBinding
import io.legado.app.databinding.Item1lineTextAndDelBinding import io.legado.app.databinding.Item1lineTextBinding
import io.legado.app.lib.theme.primaryColor import io.legado.app.lib.theme.primaryColor
import io.legado.app.lib.theme.primaryTextColor import io.legado.app.lib.theme.primaryTextColor
import io.legado.app.utils.applyTint import io.legado.app.utils.applyTint
@ -81,24 +81,24 @@ class SourcePickerDialog : BaseDialogFragment(R.layout.dialog_source_picker) {
} }
inner class SourceAdapter(context: Context) : inner class SourceAdapter(context: Context) :
RecyclerAdapter<BookSource, Item1lineTextAndDelBinding>(context) { RecyclerAdapter<BookSource, Item1lineTextBinding>(context) {
override fun getViewBinding(parent: ViewGroup): Item1lineTextAndDelBinding { override fun getViewBinding(parent: ViewGroup): Item1lineTextBinding {
return Item1lineTextAndDelBinding.inflate(inflater, parent, false).apply { return Item1lineTextBinding.inflate(inflater, parent, false).apply {
root.setPadding(16.dpToPx()) root.setPadding(16.dpToPx())
} }
} }
override fun convert( override fun convert(
holder: ItemViewHolder, holder: ItemViewHolder,
binding: Item1lineTextAndDelBinding, binding: Item1lineTextBinding,
item: BookSource, item: BookSource,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
binding.textView.text = item.getDisPlayNameGroup() binding.textView.text = item.getDisPlayNameGroup()
} }
override fun registerListener(holder: ItemViewHolder, binding: Item1lineTextAndDelBinding) { override fun registerListener(holder: ItemViewHolder, binding: Item1lineTextBinding) {
binding.root.onClick { binding.root.onClick {
getItemByLayoutPosition(holder.layoutPosition)?.let { getItemByLayoutPosition(holder.layoutPosition)?.let {
callback?.sourceOnClick(it) callback?.sourceOnClick(it)

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="6dp"
android:background="?attr/selectableItemBackground"
tools:ignore="UseCompoundDrawables">
<TextView
android:id="@+id/text_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true"
android:textColor="@color/primaryText" />
</LinearLayout>

@ -6,7 +6,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal"
android:background="?attr/selectableItemBackground"
android:padding="6dp" android:padding="6dp"
tools:ignore="UseCompoundDrawables"> tools:ignore="UseCompoundDrawables">
@ -15,6 +14,7 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:background="?attr/selectableItemBackground"
android:singleLine="true" android:singleLine="true"
android:textColor="@color/primaryText" /> android:textColor="@color/primaryText" />

Loading…
Cancel
Save