From b82e65b5618489e11838bf86f7be44102e1895d7 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 5 Feb 2020 21:46:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/book/arrange/ArrangeBookActivity.kt | 25 ++++++++++++++++--- .../ui/main/bookshelf/BookshelfFragment.kt | 4 +-- .../main/res/layout/activity_arrange_book.xml | 18 +++++++++++++ 3 files changed, 42 insertions(+), 5 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 1e5cedde4..ce614f24d 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 @@ -2,22 +2,41 @@ package io.legado.app.ui.book.arrange import android.os.Bundle import androidx.lifecycle.LiveData +import androidx.lifecycle.Observer +import androidx.recyclerview.widget.LinearLayoutManager +import io.legado.app.App import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.data.entities.Book +import io.legado.app.lib.theme.ATH import io.legado.app.utils.getViewModel +import kotlinx.android.synthetic.main.activity_arrange_book.* class ArrangeBookActivity : VMBaseActivity(R.layout.activity_arrange_book) { override val viewModel: ArrangeBookViewModel get() = getViewModel(ArrangeBookViewModel::class.java) - - private var booksLiveData: LiveData? = null + private lateinit var adapter: ArrangeBookAdapter + private var booksLiveData: LiveData>? = null override fun onActivityCreated(savedInstanceState: Bundle?) { + initView() + initData() + } - + private fun initView() { + ATH.applyEdgeEffectColor(recycler_view) + recycler_view.layoutManager = LinearLayoutManager(this) + adapter = ArrangeBookAdapter(this) + recycler_view.adapter = adapter } + private fun initData() { + booksLiveData?.removeObservers(this) + booksLiveData = App.db.bookDao().observeAll() + booksLiveData?.observe(this, Observer { + + }) + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt index a5fbb8bd5..e3c68dcaa 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt @@ -21,6 +21,7 @@ import io.legado.app.lib.dialogs.* import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.accentColor import io.legado.app.lib.theme.view.ATEAutoCompleteTextView +import io.legado.app.ui.book.arrange.ArrangeBookActivity import io.legado.app.ui.book.search.SearchActivity import io.legado.app.ui.download.DownloadActivity import io.legado.app.ui.importbook.ImportBookActivity @@ -64,8 +65,7 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b .show(childFragmentManager, "groupManageDialog") R.id.menu_add_local -> startActivity() R.id.menu_add_url -> addBookByUrl() - R.id.menu_arrange_bookshelf -> { - } + R.id.menu_arrange_bookshelf -> startActivity() R.id.menu_download -> startActivity() } } diff --git a/app/src/main/res/layout/activity_arrange_book.xml b/app/src/main/res/layout/activity_arrange_book.xml index d829e291c..fb728237a 100644 --- a/app/src/main/res/layout/activity_arrange_book.xml +++ b/app/src/main/res/layout/activity_arrange_book.xml @@ -1,7 +1,25 @@ + + + + + + + + \ No newline at end of file