From af06cb384e37ec035e63e0e9e8efa797c3c2f420 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 13:13:57 +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 --- .../io/legado/app/ui/book/arrange/ArrangeBookActivity.kt | 9 +++++++++ app/src/main/res/menu/arrange_book_sel.xml | 8 ++++++-- app/src/main/res/values/strings.xml | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt index bc73aed3d..00ee621e4 100644 --- a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt @@ -32,6 +32,7 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi get() = getViewModel(ArrangeBookViewModel::class.java) override val groupList: ArrayList = arrayListOf() private val groupRequestCode = 22 + private val addToGroupRequestCode = 34 private lateinit var adapter: ArrangeBookAdapter private var groupLiveData: LiveData>? = null private var booksLiveData: LiveData>? = null @@ -151,6 +152,7 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi viewModel.upCanUpdate(adapter.selectedBooks.toTypedArray(), true) R.id.menu_update_disable -> viewModel.upCanUpdate(adapter.selectedBooks.toTypedArray(), true) + R.id.menu_add_to_group -> selectGroup(0, addToGroupRequestCode) } return false } @@ -182,6 +184,13 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi viewModel.updateBook(it.copy(group = groupId)) } } + addToGroupRequestCode -> { + val books = arrayListOf() + adapter.selectedBooks.forEach { + books.add(it.copy(group = it.group or groupId)) + } + viewModel.updateBook(*books.toTypedArray()) + } } } diff --git a/app/src/main/res/menu/arrange_book_sel.xml b/app/src/main/res/menu/arrange_book_sel.xml index a4a3dc50d..880569d40 100644 --- a/app/src/main/res/menu/arrange_book_sel.xml +++ b/app/src/main/res/menu/arrange_book_sel.xml @@ -1,6 +1,10 @@ + + @@ -10,7 +14,7 @@ android:title="@string/disable_update" /> + android:id="@+id/menu_add_to_group" + android:title="@string/add_to_group" /> \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 61e09e2a7..9c055c8d5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -638,4 +638,5 @@ 靠左 居中 隐藏 + 加入分组