From 6d00fe65a0779698a957064ef922c16d8c437125 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 13 Feb 2020 20:37:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/arrange/ArrangeBookAdapter.kt | 19 +++++++++++++------ app/src/main/res/layout/item_arrange_book.xml | 2 ++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt index 7b3345917..67589e9ad 100644 --- a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt @@ -42,9 +42,12 @@ class ArrangeBookAdapter(context: Context, val callBack: CallBack) : override fun convert(holder: ItemViewHolder, item: Book, payloads: MutableList) { with(holder.itemView) { - tv_name.text = item.name - tv_author.text = context.getString(R.string.author_show, item.author) - tv_group.text = getGroupName(item.group) + tv_name.text = if (item.author.isEmpty()) { + item.name + } else { + "${item.name}(${item.author})" + } + tv_author.text = getGroupName(item.group) checkbox.isChecked = selectedBooks.contains(item) checkbox.onClick { if (checkbox.isChecked) { @@ -74,12 +77,16 @@ class ArrangeBookAdapter(context: Context, val callBack: CallBack) : } private fun getGroupName(groupId: Int): String { + val groupNames = arrayListOf() callBack.groupList.forEach { - if (it.groupId == groupId) { - return it.groupName + if (it.groupId and groupId > 0) { + groupNames.add(it.groupName) } } - return context.getString(R.string.group) + if (groupNames.isEmpty()) { + return context.getString(R.string.no_group) + } + return groupNames.joinToString(",") } interface CallBack { diff --git a/app/src/main/res/layout/item_arrange_book.xml b/app/src/main/res/layout/item_arrange_book.xml index 5406a08d5..0ce5072d6 100644 --- a/app/src/main/res/layout/item_arrange_book.xml +++ b/app/src/main/res/layout/item_arrange_book.xml @@ -24,6 +24,7 @@ android:padding="3dp" android:textSize="16sp" android:text="@string/book_name" + android:singleLine="true" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toTopOf="@id/tv_author" app:layout_constraintLeft_toRightOf="@id/checkbox" @@ -35,6 +36,7 @@ android:layout_height="wrap_content" android:padding="3dp" android:text="@string/author" + android:singleLine="true" app:layout_constraintLeft_toRightOf="@+id/checkbox" app:layout_constraintTop_toBottomOf="@id/tv_name" app:layout_constraintBottom_toBottomOf="parent"