搜索与发现项优化 #146
This commit is contained in:
@@ -43,7 +43,6 @@ class ExploreShowActivity : VMBaseActivity<ActivityExploreShowBinding, ExploreSh
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun initRecyclerView() {
|
private fun initRecyclerView() {
|
||||||
binding.recyclerView.addItemDecoration(VerticalDivider(this))
|
|
||||||
binding.recyclerView.adapter = adapter
|
binding.recyclerView.adapter = adapter
|
||||||
binding.recyclerView.applyNavigationBarPadding()
|
binding.recyclerView.applyNavigationBarPadding()
|
||||||
adapter.addFooterView {
|
adapter.addFooterView {
|
||||||
|
|||||||
@@ -53,10 +53,13 @@ class ExploreShowAdapter(context: Context, val callBack: CallBack) :
|
|||||||
tvIntroduce.text = item.trimIntro(context)
|
tvIntroduce.text = item.trimIntro(context)
|
||||||
val kinds = item.getKindList()
|
val kinds = item.getKindList()
|
||||||
if (kinds.isEmpty()) {
|
if (kinds.isEmpty()) {
|
||||||
llKind.gone()
|
tvKind.gone()
|
||||||
|
tvAuthorKind.gone()
|
||||||
} else {
|
} else {
|
||||||
llKind.visible()
|
tvAuthorKind.visible()
|
||||||
llKind.setLabels(kinds) {}
|
tvKind.visible()
|
||||||
|
val kindText = kinds.joinToString(" • ")
|
||||||
|
tvKind.text = kindText
|
||||||
}
|
}
|
||||||
ivCover.load(
|
ivCover.load(
|
||||||
item.coverUrl,
|
item.coverUrl,
|
||||||
@@ -80,7 +83,7 @@ class ExploreShowAdapter(context: Context, val callBack: CallBack) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun registerListener(holder: ItemViewHolder, binding: ItemSearchBinding) {
|
override fun registerListener(holder: ItemViewHolder, binding: ItemSearchBinding) {
|
||||||
holder.itemView.setOnClickListener {
|
binding.llContent.setOnClickListener {
|
||||||
getItem(holder.layoutPosition)?.let {
|
getItem(holder.layoutPosition)?.let {
|
||||||
callBack.showBookInfo(it.toBook())
|
callBack.showBookInfo(it.toBook())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class SearchAdapter(context: Context, val callBack: CallBack) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun registerListener(holder: ItemViewHolder, binding: ItemSearchBinding) {
|
override fun registerListener(holder: ItemViewHolder, binding: ItemSearchBinding) {
|
||||||
binding.root.setOnClickListener {
|
binding.llContent.setOnClickListener {
|
||||||
getItem(holder.layoutPosition)?.let {
|
getItem(holder.layoutPosition)?.let {
|
||||||
callBack.showBookInfo(it.name, it.author, it.bookUrl)
|
callBack.showBookInfo(it.name, it.author, it.bookUrl)
|
||||||
}
|
}
|
||||||
@@ -135,12 +135,13 @@ class SearchAdapter(context: Context, val callBack: CallBack) :
|
|||||||
|
|
||||||
private fun upKind(binding: ItemSearchBinding, kinds: List<String>) = binding.run {
|
private fun upKind(binding: ItemSearchBinding, kinds: List<String>) = binding.run {
|
||||||
if (kinds.isEmpty()) {
|
if (kinds.isEmpty()) {
|
||||||
llKind.gone()
|
tvKind.gone()
|
||||||
|
tvAuthorKind.gone()
|
||||||
} else {
|
} else {
|
||||||
llKind.visible()
|
tvAuthorKind.visible()
|
||||||
llKind.setLabels(kinds) { chips ->
|
tvKind.visible()
|
||||||
chips.textSize = 12f
|
val kindText = kinds.joinToString(" • ")
|
||||||
}
|
tvKind.text = kindText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,159 +1,197 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
app:strokeWidth="0dp"
|
||||||
|
app:cardBackgroundColor="?attr/colorSurfaceContainerLow"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:paddingHorizontal="16dp"
|
android:layout_marginHorizontal="8dp"
|
||||||
android:paddingVertical="8dp"
|
android:layout_marginVertical="6dp">
|
||||||
android:background="?attr/selectableItemBackground"
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:id="@+id/ll_content"
|
||||||
android:scrollbars="none">
|
android:layout_width="match_parent"
|
||||||
|
|
||||||
<!-- 封面图片 -->
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:cardCornerRadius="8dp"
|
android:padding="8dp"
|
||||||
app:strokeWidth="0dp">
|
android:clickable="true"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:scrollbars="none">
|
||||||
|
|
||||||
<io.legato.kazusa.ui.widget.image.CoverImageView
|
<!-- 封面图片 -->
|
||||||
android:id="@+id/iv_cover"
|
|
||||||
android:layout_width="80dp"
|
|
||||||
android:layout_height="110dp"
|
|
||||||
android:contentDescription="@string/img_cover"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:src="@drawable/image_cover_default"
|
|
||||||
android:transitionName="img_cover"
|
|
||||||
tools:ignore="UnusedAttribute" />
|
|
||||||
|
|
||||||
<!-- 书架内标记 -->
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
<com.google.android.material.card.MaterialCardView
|
||||||
android:id="@+id/iv_in_bookshelf"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentStart="true"
|
app:cardCornerRadius="8dp"
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:layout_margin="4dp"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:visibility="visible"
|
|
||||||
app:cardBackgroundColor="?attr/colorTertiaryContainer"
|
|
||||||
app:cardCornerRadius="4dp"
|
|
||||||
app:strokeWidth="0dp">
|
app:strokeWidth="0dp">
|
||||||
|
|
||||||
<TextView
|
<io.legato.kazusa.ui.widget.image.CoverImageView
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/iv_cover"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="80dp"
|
||||||
android:paddingHorizontal="4dp"
|
android:layout_height="110dp"
|
||||||
android:paddingVertical="2dp"
|
android:contentDescription="@string/img_cover"
|
||||||
android:text="@string/remove_from_bookshelf"
|
android:scaleType="centerCrop"
|
||||||
android:textColor="?attr/colorTertiary"
|
android:src="@drawable/image_cover_default"
|
||||||
android:textStyle="bold"
|
android:transitionName="img_cover"
|
||||||
android:textSize="10sp"
|
tools:ignore="UnusedAttribute" />
|
||||||
tools:ignore="SmallSp" />
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- 右侧内容区域 -->
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<!-- 标题行 -->
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tv_name"
|
|
||||||
style="@style/ChapterNameText"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginEnd="4dp"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:text="@string/app_name"
|
|
||||||
app:layout_constraintEnd_toStartOf="@id/cd_count"
|
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
|
<!-- 书架内标记 -->
|
||||||
<com.google.android.material.card.MaterialCardView
|
<com.google.android.material.card.MaterialCardView
|
||||||
android:id="@+id/cd_count"
|
android:id="@+id/iv_in_bookshelf"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_marginVertical="4dp"
|
android:layout_centerVertical="true"
|
||||||
app:cardBackgroundColor="?attr/colorSurfaceContainer"
|
android:layout_margin="4dp"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:visibility="visible"
|
||||||
|
app:cardBackgroundColor="?attr/colorTertiaryContainer"
|
||||||
app:cardCornerRadius="4dp"
|
app:cardCornerRadius="4dp"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/tv_name"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="@id/tv_name"
|
|
||||||
app:strokeWidth="0dp">
|
app:strokeWidth="0dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/bv_originCount"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingHorizontal="4dp"
|
android:paddingHorizontal="4dp"
|
||||||
android:paddingVertical="2dp"
|
android:paddingVertical="2dp"
|
||||||
android:text="@string/text"
|
android:text="@string/remove_from_bookshelf"
|
||||||
android:textColor="?attr/colorPrimary"
|
android:textColor="?attr/colorTertiary"
|
||||||
android:textSize="10sp"
|
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
|
android:textSize="10sp"
|
||||||
tools:ignore="SmallSp" />
|
tools:ignore="SmallSp" />
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
<!-- 作者 -->
|
|
||||||
<TextView
|
<!-- 右侧内容区域 -->
|
||||||
android:id="@+id/tv_author"
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:ellipsize="end"
|
android:layout_weight="1"
|
||||||
android:lines="1"
|
android:layout_marginStart="8dp"
|
||||||
android:text="@string/author"
|
android:layout_gravity="center"
|
||||||
android:textSize="12sp" />
|
android:orientation="vertical">
|
||||||
|
|
||||||
<!-- 分类标签 -->
|
<!-- 标题行 -->
|
||||||
<HorizontalScrollView
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:scrollbars="none">
|
|
||||||
|
|
||||||
<io.legato.kazusa.ui.widget.LabelsBar
|
<TextView
|
||||||
android:id="@+id/ll_kind"
|
android:id="@+id/tv_name"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="wrap_content"
|
||||||
app:chipSpacingHorizontal="4dp"
|
android:layout_marginTop="4dp"
|
||||||
android:orientation="horizontal" />
|
android:singleLine="true"
|
||||||
|
android:text="@string/app_name"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintEnd_toStartOf="@id/cd_count"
|
||||||
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
</HorizontalScrollView>
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
android:id="@+id/cd_count"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_marginVertical="4dp"
|
||||||
|
app:cardBackgroundColor="?attr/colorSurfaceContainer"
|
||||||
|
app:cardCornerRadius="4dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/tv_name"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/tv_name"
|
||||||
|
app:strokeWidth="0dp">
|
||||||
|
|
||||||
<!-- 最后阅读 -->
|
<TextView
|
||||||
<TextView
|
android:id="@+id/bv_originCount"
|
||||||
android:id="@+id/tv_lasted"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:paddingHorizontal="4dp"
|
||||||
android:ellipsize="end"
|
android:paddingVertical="2dp"
|
||||||
android:lines="1"
|
android:text="@string/text"
|
||||||
android:text="@string/last_read"
|
android:textColor="?attr/colorPrimary"
|
||||||
android:textSize="12sp" />
|
android:textSize="10sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:ignore="SmallSp" />
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
<!-- 简介 -->
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
<io.legato.kazusa.ui.widget.text.MultilineTextView
|
|
||||||
android:id="@+id/tv_introduce"
|
<HorizontalScrollView
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/horizontal_scroll"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:ellipsize="end"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/book_intro"
|
android:layout_marginTop="2dp"
|
||||||
android:textSize="12sp" />
|
android:layout_gravity="center_vertical"
|
||||||
|
android:scrollbars="none"
|
||||||
|
android:overScrollMode="never">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_author"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="?attr/colorSecondary"
|
||||||
|
android:lines="1"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="@string/author"
|
||||||
|
android:textSize="12sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_author_kind"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingHorizontal="4dp"
|
||||||
|
android:textColor="?attr/colorSecondary"
|
||||||
|
android:text=" | "
|
||||||
|
android:textSize="12sp"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_kind"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:lines="1"
|
||||||
|
android:paddingEnd="32dp"
|
||||||
|
android:textColor="?attr/colorSecondary"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:singleLine="true"
|
||||||
|
tools:ignore="RtlSymmetry" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</HorizontalScrollView>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 最后阅读 -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_lasted"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="3dp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:lines="1"
|
||||||
|
android:text="@string/last_read"
|
||||||
|
android:textSize="12sp" />
|
||||||
|
|
||||||
|
<!-- 简介 -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_introduce"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginVertical="3dp"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:text="@string/book_intro"
|
||||||
|
android:textSize="12sp" />
|
||||||
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
Reference in New Issue
Block a user