From 9e1e49ba66b2074888e0e4cc82359d9023ceee68 Mon Sep 17 00:00:00 2001 From: gedoor Date: Mon, 10 Jun 2019 22:19:47 +0800 Subject: [PATCH] up --- .../legado/app/ui/bookshelf/BookshelfActivity.kt | 8 +++++++- .../legado/app/ui/bookshelf/BookshelfViewModel.kt | 3 +++ .../app/ui/main/bookshelf/BookGroupAdapter.kt | 14 ++++++-------- .../app/ui/main/bookshelf/BookshelfFragment.kt | 7 +++++-- app/src/main/res/layout/activity_bookshelf.xml | 5 +++++ app/src/main/res/layout/item_book_group.xml | 1 + 6 files changed, 27 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/bookshelf/BookshelfActivity.kt b/app/src/main/java/io/legado/app/ui/bookshelf/BookshelfActivity.kt index a1862417f..445abca97 100644 --- a/app/src/main/java/io/legado/app/ui/bookshelf/BookshelfActivity.kt +++ b/app/src/main/java/io/legado/app/ui/bookshelf/BookshelfActivity.kt @@ -4,6 +4,7 @@ import android.os.Bundle import io.legado.app.R import io.legado.app.base.BaseActivity import io.legado.app.utils.getViewModel +import kotlinx.android.synthetic.main.activity_bookshelf.* class BookshelfActivity : BaseActivity() { override val viewModel: BookshelfViewModel @@ -12,7 +13,12 @@ class BookshelfActivity : BaseActivity() { get() = R.layout.activity_bookshelf override fun onViewModelCreated(viewModel: BookshelfViewModel, savedInstanceState: Bundle?) { - + if (viewModel.bookGroup == null) { + viewModel.bookGroup = intent.getParcelableExtra("data") + } + viewModel.bookGroup?.let { + title_bar.title = it.groupName + } } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/bookshelf/BookshelfViewModel.kt b/app/src/main/java/io/legado/app/ui/bookshelf/BookshelfViewModel.kt index 717663d89..3948465ac 100644 --- a/app/src/main/java/io/legado/app/ui/bookshelf/BookshelfViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/bookshelf/BookshelfViewModel.kt @@ -2,7 +2,10 @@ package io.legado.app.ui.bookshelf import android.app.Application import io.legado.app.base.BaseViewModel +import io.legado.app.data.entities.BookGroup class BookshelfViewModel(application: Application) : BaseViewModel(application) { + var bookGroup: BookGroup? = null + } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookGroupAdapter.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookGroupAdapter.kt index f0416bd67..bb3adbf8f 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookGroupAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookGroupAdapter.kt @@ -46,12 +46,10 @@ class BookGroupAdapter : PagedListAdapter holder.bind(defaultGroups[position], callBack) + position == itemCount - 1 -> holder.bind(addBookGroup, callBack) + else -> currentList?.get(position - defaultGroups.size)?.let { holder.bind(it, callBack) } } @@ -61,11 +59,11 @@ class BookGroupAdapter : PagedListAdapter context?.let { MaterialDialog(it).show { window?.decorView?.disableAutoFill() @@ -69,6 +71,7 @@ class BookshelfFragment : BaseFragment(R.layout.fragment_bookshelf) { positiveButton(R.string.ok) } } + else -> context?.startActivity(Pair("data", bookGroup)) } } } diff --git a/app/src/main/res/layout/activity_bookshelf.xml b/app/src/main/res/layout/activity_bookshelf.xml index d829e291c..49c8c9d5d 100644 --- a/app/src/main/res/layout/activity_bookshelf.xml +++ b/app/src/main/res/layout/activity_bookshelf.xml @@ -4,4 +4,9 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_book_group.xml b/app/src/main/res/layout/item_book_group.xml index 687e0c65a..1fd1e0d0e 100644 --- a/app/src/main/res/layout/item_book_group.xml +++ b/app/src/main/res/layout/item_book_group.xml @@ -3,5 +3,6 @@ android:id="@+id/tv_group" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:background="@drawable/bg_ib_pre" android:layout_margin="5dp" android:padding="5dp" /> \ No newline at end of file