From faf287fc1a06874015ce9bade7a99dc4901e899a Mon Sep 17 00:00:00 2001 From: yangyxd Date: Tue, 10 Mar 2020 18:21:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=BB=84=E7=AE=A1=E7=90=86=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/arrange/ArrangeBookAdapter.kt | 27 +++++++++----- .../app/ui/book/group/GroupManageDialog.kt | 3 ++ .../ui/rss/source/manage/GroupManageDialog.kt | 3 ++ .../main/res/layout/dialog_recycler_view.xml | 24 ++++++++++++- app/src/main/res/layout/item_arrange_book.xml | 35 ++++++++++++++----- .../res/layout/view_select_action_bar.xml | 4 +-- 6 files changed, 76 insertions(+), 20 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 96fe1344e..fd51e3a3d 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 @@ -1,11 +1,14 @@ package io.legado.app.ui.book.arrange import android.content.Context +import android.view.View import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookGroup +import io.legado.app.utils.gone +import io.legado.app.utils.visible import kotlinx.android.synthetic.main.item_arrange_book.view.* import org.jetbrains.anko.sdk27.listeners.onClick @@ -52,12 +55,15 @@ class ArrangeBookAdapter(context: Context, val callBack: CallBack) : override fun convert(holder: ItemViewHolder, item: Book, payloads: MutableList) { with(holder.itemView) { - tv_name.text = if (item.author.isEmpty()) { - item.name - } else { - "${item.name}(${item.author})" - } - tv_author.text = getGroupName(item.group) + tv_name.text = item.name +// tv_name.text = if (item.author.isEmpty()) { +// item.name +// } else { +// "${item.name}(${item.author})" +// } + tv_author.text = item.author // resources.getString(R.string.author_show, item.author) + tv_author.visibility = if (item.author.isEmpty()) View.GONE else View.VISIBLE + tv_group_s.text = getGroupName(item.group) checkbox.isChecked = selectedBooks.contains(item) } } @@ -102,15 +108,20 @@ class ArrangeBookAdapter(context: Context, val callBack: CallBack) : } } - private fun getGroupName(groupId: Int): String { + private fun getGroupList(groupId: Int): List { val groupNames = arrayListOf() callBack.groupList.forEach { if (it.groupId and groupId > 0) { groupNames.add(it.groupName) } } + return groupNames; + } + + private fun getGroupName(groupId: Int): String { + val groupNames = getGroupList(groupId) if (groupNames.isEmpty()) { - return context.getString(R.string.no_group) + return "" } return groupNames.joinToString(",") } diff --git a/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt b/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt index ea4d2b61e..1086f0416 100644 --- a/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt @@ -28,6 +28,7 @@ import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.customView import io.legado.app.lib.dialogs.noButton import io.legado.app.lib.dialogs.yesButton +import io.legado.app.lib.theme.accentColor import io.legado.app.ui.widget.recycler.VerticalDivider import io.legado.app.utils.applyTint import io.legado.app.utils.getViewModel @@ -72,6 +73,8 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { recycler_view.layoutManager = LinearLayoutManager(requireContext()) recycler_view.addItemDecoration(VerticalDivider(requireContext())) recycler_view.adapter = adapter + tv_ok.setTextColor(requireContext().accentColor) + tv_ok.onClick { dismiss() } App.db.bookGroupDao().liveDataAll().observe(viewLifecycleOwner, Observer { val diffResult = DiffUtil.calculateDiff(GroupDiffCallBack(ArrayList(adapter.getItems()), it)) diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt index 391281a4e..ed09cec93 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt @@ -22,6 +22,7 @@ import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.customView import io.legado.app.lib.dialogs.noButton import io.legado.app.lib.dialogs.yesButton +import io.legado.app.lib.theme.accentColor import io.legado.app.ui.widget.recycler.VerticalDivider import io.legado.app.utils.applyTint import io.legado.app.utils.getViewModelOfActivity @@ -66,6 +67,8 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { recycler_view.layoutManager = LinearLayoutManager(requireContext()) recycler_view.addItemDecoration(VerticalDivider(requireContext())) recycler_view.adapter = adapter + tv_ok.setTextColor(requireContext().accentColor) + tv_ok.onClick { dismiss() } App.db.rssSourceDao().liveGroup().observe(viewLifecycleOwner, Observer { val groups = linkedSetOf() it.map { group -> diff --git a/app/src/main/res/layout/dialog_recycler_view.xml b/app/src/main/res/layout/dialog_recycler_view.xml index 1fce14eef..98f67043f 100644 --- a/app/src/main/res/layout/dialog_recycler_view.xml +++ b/app/src/main/res/layout/dialog_recycler_view.xml @@ -1,5 +1,6 @@ @@ -14,6 +15,27 @@ android:id="@+id/recycler_view" android:background="@color/background_card" android:layout_width="match_parent" - android:layout_height="match_parent" /> + android:layout_height="match_parent" + android:layout_weight="1" /> + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_arrange_book.xml b/app/src/main/res/layout/item_arrange_book.xml index 0ce5072d6..4fdd7a19c 100644 --- a/app/src/main/res/layout/item_arrange_book.xml +++ b/app/src/main/res/layout/item_arrange_book.xml @@ -19,26 +19,43 @@ + app:layout_constraintBottom_toTopOf="@id/tv_group_s" + app:layout_constraintLeft_toRightOf="@id/checkbox" /> + + @@ -49,7 +66,7 @@ android:background="?attr/selectableItemBackgroundBorderless" android:padding="10dp" android:text="@string/group" - app:layout_constraintTop_toTopOf="parent" + app:layout_constraintTop_toBottomOf="@id/tv_author" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintRight_toLeftOf="@+id/tv_delete" /> @@ -60,7 +77,7 @@ android:background="?attr/selectableItemBackgroundBorderless" android:padding="10dp" android:text="@string/delete" - app:layout_constraintTop_toTopOf="parent" + app:layout_constraintTop_toBottomOf="@id/tv_author" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintRight_toRightOf="parent" /> diff --git a/app/src/main/res/layout/view_select_action_bar.xml b/app/src/main/res/layout/view_select_action_bar.xml index e725a57b7..2e8d733ab 100644 --- a/app/src/main/res/layout/view_select_action_bar.xml +++ b/app/src/main/res/layout/view_select_action_bar.xml @@ -5,11 +5,11 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingLeft="16dp" - android:paddingRight="16dp" + android:paddingRight="8dp" android:paddingTop="6dp" android:paddingBottom="6dp" android:gravity="center_vertical" - android:elevation="2dp"> + android:elevation="2dp" >