搜索与发现项优化 #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,11 +1,19 @@
|
|||||||
<?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">
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/ll_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:clickable="true"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:scrollbars="none">
|
android:scrollbars="none">
|
||||||
@@ -60,7 +68,7 @@
|
|||||||
<!-- 右侧内容区域 -->
|
<!-- 右侧内容区域 -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
@@ -73,12 +81,13 @@
|
|||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_name"
|
android:id="@+id/tv_name"
|
||||||
style="@style/ChapterNameText"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="4dp"
|
android:layout_marginTop="4dp"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:text="@string/app_name"
|
android:text="@string/app_name"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold"
|
||||||
app:layout_constraintEnd_toStartOf="@id/cd_count"
|
app:layout_constraintEnd_toStartOf="@id/cd_count"
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
@@ -112,48 +121,77 @@
|
|||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<!-- 作者 -->
|
<HorizontalScrollView
|
||||||
<TextView
|
android:id="@+id/horizontal_scroll"
|
||||||
android:id="@+id/tv_author"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:ellipsize="end"
|
android:layout_marginTop="2dp"
|
||||||
|
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:lines="1"
|
||||||
|
android:singleLine="true"
|
||||||
android:text="@string/author"
|
android:text="@string/author"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
<!-- 分类标签 -->
|
<TextView
|
||||||
<HorizontalScrollView
|
android:id="@+id/tv_author_kind"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:scrollbars="none">
|
|
||||||
|
|
||||||
<io.legato.kazusa.ui.widget.LabelsBar
|
|
||||||
android:id="@+id/ll_kind"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="40dp"
|
android:layout_height="wrap_content"
|
||||||
app:chipSpacingHorizontal="4dp"
|
android:paddingHorizontal="4dp"
|
||||||
android:orientation="horizontal" />
|
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>
|
</HorizontalScrollView>
|
||||||
|
|
||||||
|
|
||||||
<!-- 最后阅读 -->
|
<!-- 最后阅读 -->
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_lasted"
|
android:id="@+id/tv_lasted"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="3dp"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:lines="1"
|
android:lines="1"
|
||||||
android:text="@string/last_read"
|
android:text="@string/last_read"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
<!-- 简介 -->
|
<!-- 简介 -->
|
||||||
<io.legato.kazusa.ui.widget.text.MultilineTextView
|
<TextView
|
||||||
android:id="@+id/tv_introduce"
|
android:id="@+id/tv_introduce"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginVertical="3dp"
|
||||||
|
android:maxLines="2"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:text="@string/book_intro"
|
android:text="@string/book_intro"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
Reference in New Issue
Block a user