优化书架显示

pull/981/head
gedoor 4 years ago
parent e894038271
commit acbd2b11d1
  1. 3
      app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt
  2. 3
      app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt
  3. 121
      app/src/main/res/layout/item_bookshelf_grid.xml
  4. 9
      app/src/main/res/layout/item_bookshelf_list.xml

@ -7,8 +7,6 @@ import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.constant.BookType import io.legado.app.constant.BookType
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.databinding.ItemBookshelfGridBinding import io.legado.app.databinding.ItemBookshelfGridBinding
import io.legado.app.lib.theme.backgroundColor
import io.legado.app.utils.ColorUtils
import io.legado.app.utils.invisible import io.legado.app.utils.invisible
import splitties.views.onLongClick import splitties.views.onLongClick
@ -27,7 +25,6 @@ class BooksAdapterGrid(context: Context, private val callBack: CallBack) :
) = with(binding) { ) = with(binding) {
val bundle = payloads.getOrNull(0) as? Bundle val bundle = payloads.getOrNull(0) as? Bundle
if (bundle == null) { if (bundle == null) {
root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))
tvName.text = item.name tvName.text = item.name
ivCover.load(item.getDisplayCover(), item.name, item.author) ivCover.load(item.getDisplayCover(), item.name, item.author)
upRefresh(binding, item) upRefresh(binding, item)

@ -7,8 +7,6 @@ import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.constant.BookType import io.legado.app.constant.BookType
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.databinding.ItemBookshelfListBinding import io.legado.app.databinding.ItemBookshelfListBinding
import io.legado.app.lib.theme.backgroundColor
import io.legado.app.utils.ColorUtils
import io.legado.app.utils.invisible import io.legado.app.utils.invisible
import splitties.views.onLongClick import splitties.views.onLongClick
@ -27,7 +25,6 @@ class BooksAdapterList(context: Context, private val callBack: CallBack) :
) = with(binding) { ) = with(binding) {
val bundle = payloads.getOrNull(0) as? Bundle val bundle = payloads.getOrNull(0) as? Bundle
if (bundle == null) { if (bundle == null) {
root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))
tvName.text = item.name tvName.text = item.name
tvAuthor.text = item.author tvAuthor.text = item.author
tvRead.text = item.durChapterTitle tvRead.text = item.durChapterTitle

@ -1,67 +1,90 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
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:id="@+id/cv_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:clickable="true"
android:paddingTop="8dp" android:focusable="true"
android:paddingLeft="8dp" tools:ignore="UnusedAttribute">
android:paddingRight="8dp">
<androidx.constraintlayout.widget.ConstraintLayout
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
app:layout_constraintTop_toTopOf="parent">
<io.legado.app.ui.widget.image.CoverImageView <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/iv_cover"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:layout_margin="8dp"
android:scaleType="centerCrop" <io.legado.app.ui.widget.image.CoverImageView
android:src="@drawable/image_cover_default" android:id="@+id/iv_cover"
android:transitionName="img_cover" android:layout_width="match_parent"
app:layout_constraintTop_toTopOf="parent" android:layout_height="wrap_content"
tools:ignore="UnusedAttribute" /> android:layout_margin="8dp"
android:scaleType="centerCrop"
android:src="@drawable/image_cover_default"
android:transitionName="img_cover"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="UnusedAttribute" />
<io.legado.app.ui.widget.text.BadgeView
android:id="@+id/bv_unread"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:includeFontPadding="false"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="RtlHardcoded" />
<io.legado.app.ui.widget.anima.RotateLoading
android:id="@+id/rl_loading"
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_gravity="right"
android:visibility="invisible"
app:hide_mode="invisible"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:loading_width="2dp"
tools:ignore="RtlHardcoded" />
<io.legado.app.ui.widget.text.BadgeView </androidx.constraintlayout.widget.ConstraintLayout>
android:id="@+id/bv_unread"
android:layout_width="wrap_content" <TextView
android:id="@+id/tv_name"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="right" android:layout_marginTop="6dp"
android:ellipsize="end"
android:gravity="top|center_horizontal"
android:includeFontPadding="false" android:includeFontPadding="false"
app:layout_constraintRight_toRightOf="parent" android:lines="2"
app:layout_constraintTop_toTopOf="parent" android:text="@string/book_name"
tools:ignore="RtlHardcoded" /> android:textColor="@color/primaryText"
android:textSize="12sp"
<io.legado.app.ui.widget.anima.RotateLoading tools:ignore="RtlHardcoded,RtlSymmetry" />
android:id="@+id/rl_loading"
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_gravity="right"
android:visibility="invisible"
app:hide_mode="invisible"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:loading_width="2dp"
tools:ignore="RtlHardcoded" />
</androidx.constraintlayout.widget.ConstraintLayout> </LinearLayout>
<TextView <View
android:id="@+id/tv_name" android:id="@+id/vw_foreground"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="0dp"
android:layout_marginTop="6dp" android:background="?android:attr/selectableItemBackground"
android:ellipsize="end" app:layout_constraintBottom_toBottomOf="parent"
android:gravity="top|center_horizontal" app:layout_constraintTop_toTopOf="parent"
android:includeFontPadding="false" app:layout_constraintVertical_bias="0.0"
android:lines="2" tools:layout_editor_absoluteX="0dp" />
android:text="@string/book_name"
android:textColor="@color/primaryText" </androidx.constraintlayout.widget.ConstraintLayout>
android:textSize="12sp"
tools:ignore="RtlHardcoded,RtlSymmetry" />
</LinearLayout>

@ -167,13 +167,4 @@
app:layout_constraintVertical_bias="0.0" app:layout_constraintVertical_bias="0.0"
tools:layout_editor_absoluteX="0dp" /> tools:layout_editor_absoluteX="0dp" />
<View
android:id="@+id/vw_select"
android:layout_width="match_parent"
android:layout_height="0dp"
android:visibility="gone"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
Loading…
Cancel
Save