pull/90/head^2
kunfei 5 years ago
parent 1aac80df4e
commit b82e65b561
  1. 25
      app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt
  2. 4
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt
  3. 18
      app/src/main/res/layout/activity_arrange_book.xml

@ -2,22 +2,41 @@ package io.legado.app.ui.book.arrange
import android.os.Bundle import android.os.Bundle
import androidx.lifecycle.LiveData 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.R
import io.legado.app.base.VMBaseActivity import io.legado.app.base.VMBaseActivity
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.lib.theme.ATH
import io.legado.app.utils.getViewModel import io.legado.app.utils.getViewModel
import kotlinx.android.synthetic.main.activity_arrange_book.*
class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activity_arrange_book) { class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activity_arrange_book) {
override val viewModel: ArrangeBookViewModel override val viewModel: ArrangeBookViewModel
get() = getViewModel(ArrangeBookViewModel::class.java) get() = getViewModel(ArrangeBookViewModel::class.java)
private lateinit var adapter: ArrangeBookAdapter
private var booksLiveData: LiveData<Book>? = null private var booksLiveData: LiveData<List<Book>>? = null
override fun onActivityCreated(savedInstanceState: Bundle?) { 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 {
})
}
} }

@ -21,6 +21,7 @@ import io.legado.app.lib.dialogs.*
import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.accentColor import io.legado.app.lib.theme.accentColor
import io.legado.app.lib.theme.view.ATEAutoCompleteTextView 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.book.search.SearchActivity
import io.legado.app.ui.download.DownloadActivity import io.legado.app.ui.download.DownloadActivity
import io.legado.app.ui.importbook.ImportBookActivity import io.legado.app.ui.importbook.ImportBookActivity
@ -64,8 +65,7 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
.show(childFragmentManager, "groupManageDialog") .show(childFragmentManager, "groupManageDialog")
R.id.menu_add_local -> startActivity<ImportBookActivity>() R.id.menu_add_local -> startActivity<ImportBookActivity>()
R.id.menu_add_url -> addBookByUrl() R.id.menu_add_url -> addBookByUrl()
R.id.menu_arrange_bookshelf -> { R.id.menu_arrange_bookshelf -> startActivity<ArrangeBookActivity>()
}
R.id.menu_download -> startActivity<DownloadActivity>() R.id.menu_download -> startActivity<DownloadActivity>()
} }
} }

@ -1,7 +1,25 @@
<?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:app="http://schemas.android.com/apk/res-auto"
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">
<io.legado.app.ui.widget.TitleBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/arrange_bookshelf" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
</LinearLayout> </LinearLayout>
Loading…
Cancel
Save