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