修改bookshelf grid显示效果

pull/69/head
Administrator 5 years ago
parent f41d6373d6
commit 1bfd273ee7
  1. 7
      app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt
  2. 2
      app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt
  3. 38
      app/src/main/res/layout/item_bookshelf_grid.xml
  4. 2
      app/src/main/res/values/arrays.xml

@ -12,15 +12,18 @@ import kotlinx.android.synthetic.main.item_bookshelf_grid.view.*
import org.jetbrains.anko.sdk27.listeners.onClick
import org.jetbrains.anko.sdk27.listeners.onLongClick
class BooksAdapterGrid(context: Context, private val callBack: CallBack) :
class BooksAdapterGrid(context: Context, private val span: Int, private val callBack: CallBack) :
BooksAdapter(context, R.layout.item_bookshelf_grid) {
override fun convert(holder: ItemViewHolder, item: Book, payloads: MutableList<Any>) {
with(holder.itemView) {
if (payloads.isEmpty()) {
ATH.applyBackgroundTint(this)
tv_name.textSize = (16 - span).toFloat()
bv_author.textSize = (10 - span).toFloat()
bv_unread.textSize = (10 - span).toFloat()
tv_name.text = item.name
tv_author.text = item.author
bv_author.text = item.author
item.getDisplayCover()?.let {
ImageLoader.load(context, it)//Glide自动识别http://和file://
.placeholder(R.drawable.image_cover_default)

@ -71,7 +71,7 @@ class BooksFragment : BaseFragment(R.layout.fragment_books),
booksAdapter = BooksAdapterList(requireContext(), this)
} else {
rv_bookshelf.layoutManager = GridLayoutManager(context, bookshelfLayout + 2)
booksAdapter = BooksAdapterGrid(requireContext(), this)
booksAdapter = BooksAdapterGrid(requireContext(), bookshelfLayout, this)
}
rv_bookshelf.adapter = booksAdapter
}

@ -49,13 +49,33 @@
tools:ignore="RtlHardcoded" />
</FrameLayout>
<FrameLayout
android:id="@+id/fl_author"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="@id/iv_cover"
app:layout_constraintBottom_toBottomOf="@id/iv_cover">
<io.legado.app.ui.widget.BadgeView
android:id="@+id/bv_author"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|bottom"
android:includeFontPadding="false"
android:layout_margin="5dp"
android:singleLine="true"
tools:ignore="RtlHardcoded" />
</FrameLayout>
<TextView
android:id="@+id/tv_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:gravity="center"
android:singleLine="true"
android:lines="2"
android:ellipsize="end"
android:text="@string/book_name"
android:textColor="@color/tv_text_default"
android:textSize="16sp"
@ -64,20 +84,4 @@
app:layout_constraintTop_toBottomOf="@+id/iv_cover"
tools:ignore="RtlHardcoded,RtlSymmetry" />
<TextView
android:id="@+id/tv_author"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:gravity="center"
android:maxLines="1"
android:text="@string/author"
android:textColor="@color/tv_text_secondary"
android:textSize="13sp"
app:layout_constraintLeft_toLeftOf="@+id/iv_cover"
app:layout_constraintRight_toRightOf="@+id/iv_cover"
app:layout_constraintTop_toBottomOf="@+id/tv_name"
app:layout_constraintBottom_toBottomOf="parent"
tools:ignore="RtlSymmetry" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -40,7 +40,7 @@
<item>@string/layout_grid3</item>
<item>@string/layout_grid4</item>
<item>@string/layout_grid5</item>
<item>@string/layout_grid6</item>
<!-- <item>@string/layout_grid6</item> -->
</string-array>
<string-array name="indent">

Loading…
Cancel
Save