pull/32/head
GKF 6 years ago
parent fc28ac232a
commit 510bf82283
  1. 38
      app/src/main/java/io/legado/app/ui/main/booksource/BookSourceAdapter.kt
  2. 73
      app/src/main/res/layout/item_book_source.xml

@ -1,2 +1,40 @@
package io.legado.app.ui.main.booksource
import android.view.View
import android.view.ViewGroup
import androidx.paging.PagedListAdapter
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import io.legado.app.data.entities.Source
class BookSourceAdapter : PagedListAdapter<Source, BookSourceAdapter.MyViewHolder>(DIFF_CALLBACK) {
companion object {
@JvmField
val DIFF_CALLBACK = object : DiffUtil.ItemCallback<Source>() {
override fun areItemsTheSame(oldItem: Source, newItem: Source): Boolean =
oldItem.id == newItem.id
override fun areContentsTheSame(oldItem: Source, newItem: Source): Boolean =
oldItem.id == newItem.id
&& oldItem.name == newItem.name
&& oldItem.group == newItem.group
&& oldItem.isEnabled == newItem.isEnabled
}
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
}
class MyViewHolder(view: View) : RecyclerView.ViewHolder(view) {
}
}

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="16dp">
<com.kunfei.bookshelf.widget.views.ATECheckBox
android:id="@+id/cb_book_source"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:singleLine="true"
android:text=""
android:textColor="@color/tv_text_default"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_edit_source"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/bg_ib_pre_round"
android:contentDescription="@string/edit"
android:padding="8dp"
android:src="@drawable/ic_edit"
app:tint="@color/tv_text_default"/>
<ImageView
android:id="@+id/iv_top_source"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/bg_ib_pre_round"
android:contentDescription="@string/to_top"
android:padding="8dp"
android:src="@drawable/ic_top_source"
app:tint="@color/tv_text_default"/>
<ImageView
android:id="@+id/iv_del_source"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/bg_ib_pre_round"
android:contentDescription="@string/delete"
android:padding="8dp"
android:src="@drawable/ic_clear_all"
app:tint="@color/tv_text_default"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@color/btn_bg_press"/>
</LinearLayout>
Loading…
Cancel
Save