Merge pull request #149 from yangyxd/master

分组管理页面调整
pull/172/head
kunfei 5 years ago committed by GitHub
commit 78e6ac5b17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 27
      app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt
  2. 3
      app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt
  3. 3
      app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt
  4. 24
      app/src/main/res/layout/dialog_recycler_view.xml
  5. 35
      app/src/main/res/layout/item_arrange_book.xml
  6. 2
      app/src/main/res/layout/view_select_action_bar.xml

@ -1,11 +1,14 @@
package io.legado.app.ui.book.arrange package io.legado.app.ui.book.arrange
import android.content.Context import android.content.Context
import android.view.View
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.base.adapter.SimpleRecyclerAdapter
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookGroup 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 kotlinx.android.synthetic.main.item_arrange_book.view.*
import org.jetbrains.anko.sdk27.listeners.onClick 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<Any>) { override fun convert(holder: ItemViewHolder, item: Book, payloads: MutableList<Any>) {
with(holder.itemView) { with(holder.itemView) {
tv_name.text = if (item.author.isEmpty()) { tv_name.text = item.name
item.name // tv_name.text = if (item.author.isEmpty()) {
} else { // item.name
"${item.name}(${item.author})" // } else {
} // "${item.name}(${item.author})"
tv_author.text = getGroupName(item.group) // }
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) 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<String> {
val groupNames = arrayListOf<String>() val groupNames = arrayListOf<String>()
callBack.groupList.forEach { callBack.groupList.forEach {
if (it.groupId and groupId > 0) { if (it.groupId and groupId > 0) {
groupNames.add(it.groupName) groupNames.add(it.groupName)
} }
} }
return groupNames;
}
private fun getGroupName(groupId: Int): String {
val groupNames = getGroupList(groupId)
if (groupNames.isEmpty()) { if (groupNames.isEmpty()) {
return context.getString(R.string.no_group) return ""
} }
return groupNames.joinToString(",") return groupNames.joinToString(",")
} }

@ -28,6 +28,7 @@ import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.dialogs.customView import io.legado.app.lib.dialogs.customView
import io.legado.app.lib.dialogs.noButton import io.legado.app.lib.dialogs.noButton
import io.legado.app.lib.dialogs.yesButton 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.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.applyTint import io.legado.app.utils.applyTint
import io.legado.app.utils.getViewModel import io.legado.app.utils.getViewModel
@ -72,6 +73,8 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
recycler_view.layoutManager = LinearLayoutManager(requireContext()) recycler_view.layoutManager = LinearLayoutManager(requireContext())
recycler_view.addItemDecoration(VerticalDivider(requireContext())) recycler_view.addItemDecoration(VerticalDivider(requireContext()))
recycler_view.adapter = adapter recycler_view.adapter = adapter
tv_ok.setTextColor(requireContext().accentColor)
tv_ok.onClick { dismiss() }
App.db.bookGroupDao().liveDataAll().observe(viewLifecycleOwner, Observer { App.db.bookGroupDao().liveDataAll().observe(viewLifecycleOwner, Observer {
val diffResult = val diffResult =
DiffUtil.calculateDiff(GroupDiffCallBack(ArrayList(adapter.getItems()), it)) DiffUtil.calculateDiff(GroupDiffCallBack(ArrayList(adapter.getItems()), it))

@ -22,6 +22,7 @@ import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.dialogs.customView import io.legado.app.lib.dialogs.customView
import io.legado.app.lib.dialogs.noButton import io.legado.app.lib.dialogs.noButton
import io.legado.app.lib.dialogs.yesButton 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.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.applyTint import io.legado.app.utils.applyTint
import io.legado.app.utils.getViewModelOfActivity import io.legado.app.utils.getViewModelOfActivity
@ -66,6 +67,8 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
recycler_view.layoutManager = LinearLayoutManager(requireContext()) recycler_view.layoutManager = LinearLayoutManager(requireContext())
recycler_view.addItemDecoration(VerticalDivider(requireContext())) recycler_view.addItemDecoration(VerticalDivider(requireContext()))
recycler_view.adapter = adapter recycler_view.adapter = adapter
tv_ok.setTextColor(requireContext().accentColor)
tv_ok.onClick { dismiss() }
App.db.rssSourceDao().liveGroup().observe(viewLifecycleOwner, Observer { App.db.rssSourceDao().liveGroup().observe(viewLifecycleOwner, Observer {
val groups = linkedSetOf<String>() val groups = linkedSetOf<String>()
it.map { group -> it.map { group ->

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -14,6 +15,27 @@
android:id="@+id/recycler_view" android:id="@+id/recycler_view"
android:background="@color/background_card" android:background="@color/background_card"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/tv_ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="16dp"
android:padding="12dp"
android:clickable="true"
android:text="@string/ok"
tools:ignore="RtlHardcoded" />
</LinearLayout>
</LinearLayout> </LinearLayout>

@ -19,26 +19,43 @@
<TextView <TextView
android:id="@+id/tv_name" android:id="@+id/tv_name"
android:layout_width="0dp" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="3dp" android:padding="3dp"
android:textSize="16sp" android:textSize="15sp"
android:text="@string/book_name" android:text="@string/book_name"
android:textColor="@color/tv_text_default"
android:singleLine="true" android:singleLine="true"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/tv_author" app:layout_constraintBottom_toTopOf="@id/tv_group_s"
app:layout_constraintLeft_toRightOf="@id/checkbox" app:layout_constraintLeft_toRightOf="@id/checkbox" />
app:layout_constraintRight_toLeftOf="@+id/tv_group" />
<TextView <TextView
android:id="@+id/tv_author" android:id="@+id/tv_author"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="3dp" android:paddingLeft="12dp"
android:paddingRight="8dp"
android:text="@string/author" android:text="@string/author"
android:textColor="@color/tv_text_summary"
android:textSize="12sp"
android:singleLine="true" android:singleLine="true"
app:layout_constraintTop_toTopOf="@+id/tv_name"
app:layout_constraintLeft_toRightOf="@+id/tv_name"
app:layout_constraintBottom_toBottomOf="@+id/tv_name"
app:layout_constraintRight_toRightOf="parent" />
<TextView
android:id="@+id/tv_group_s"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="3dp"
android:hint="@string/no_group"
android:textSize="12sp"
android:singleLine="true"
android:layout_marginTop="8dp"
app:layout_constraintLeft_toRightOf="@+id/checkbox" app:layout_constraintLeft_toRightOf="@+id/checkbox"
app:layout_constraintTop_toBottomOf="@id/tv_name" app:layout_constraintTop_toBottomOf="@id/tv_author"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toLeftOf="@+id/tv_group" /> app:layout_constraintRight_toLeftOf="@+id/tv_group" />
@ -49,7 +66,7 @@
android:background="?attr/selectableItemBackgroundBorderless" android:background="?attr/selectableItemBackgroundBorderless"
android:padding="10dp" android:padding="10dp"
android:text="@string/group" android:text="@string/group"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toBottomOf="@id/tv_author"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toLeftOf="@+id/tv_delete" /> app:layout_constraintRight_toLeftOf="@+id/tv_delete" />
@ -60,7 +77,7 @@
android:background="?attr/selectableItemBackgroundBorderless" android:background="?attr/selectableItemBackgroundBorderless"
android:padding="10dp" android:padding="10dp"
android:text="@string/delete" android:text="@string/delete"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toBottomOf="@id/tv_author"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent" /> app:layout_constraintRight_toRightOf="parent" />

@ -5,7 +5,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="16dp" android:paddingLeft="16dp"
android:paddingRight="16dp" android:paddingRight="8dp"
android:paddingTop="6dp" android:paddingTop="6dp"
android:paddingBottom="6dp" android:paddingBottom="6dp"
android:gravity="center_vertical" android:gravity="center_vertical"

Loading…
Cancel
Save