pull/32/head
kunfei 5 years ago
parent d11e58315b
commit 83cfc65455
  1. 6
      app/src/main/java/io/legado/app/ui/chapterlist/BookmarkFragment.kt
  2. 28
      app/src/main/java/io/legado/app/ui/chapterlist/ChapterListFragment.kt
  3. 2
      app/src/main/res/layout/fragment_bookmark.xml
  4. 2
      app/src/main/res/layout/fragment_chapter_list.xml

@ -28,10 +28,10 @@ class BookmarkFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragment_
}
private fun initRecyclerView() {
ATH.applyEdgeEffectColor(rv_list)
ATH.applyEdgeEffectColor(recycler_view)
adapter = BookmarkAdapter()
rv_list.layoutManager = LinearLayoutManager(requireContext())
rv_list.adapter = adapter
recycler_view.layoutManager = LinearLayoutManager(requireContext())
recycler_view.adapter = adapter
}
private fun initData() {

@ -1,13 +1,41 @@
package io.legado.app.ui.chapterlist
import android.os.Bundle
import android.view.View
import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.paging.LivePagedListBuilder
import androidx.paging.PagedList
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.App
import io.legado.app.R
import io.legado.app.base.VMBaseFragment
import io.legado.app.data.entities.BookChapter
import io.legado.app.utils.getViewModelOfActivity
import kotlinx.android.synthetic.main.fragment_chapter_list.*
class ChapterListFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragment_chapter_list) {
override val viewModel: ChapterListViewModel
get() = getViewModelOfActivity(ChapterListViewModel::class.java)
lateinit var adapter: ChapterListAdapter
var liveData: LiveData<PagedList<BookChapter>>? = null
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initRecyclerView()
initData()
}
private fun initRecyclerView() {
adapter = ChapterListAdapter()
recycler_view.layoutManager = LinearLayoutManager(requireContext())
recycler_view.adapter = adapter
}
private fun initData() {
liveData?.removeObservers(viewLifecycleOwner)
liveData = LivePagedListBuilder(App.db.bookChapterDao().observeByBook(""), 30).build()
liveData?.observe(viewLifecycleOwner, Observer { adapter.submitList(it) })
}
}

@ -5,7 +5,7 @@
android:descendantFocusability="blocksDescendants">
<io.legado.app.ui.widget.recycler.scroller.FastScrollRecyclerView
android:id="@+id/rv_list"
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never" />

@ -6,7 +6,7 @@
android:descendantFocusability="blocksDescendants">
<io.legado.app.ui.widget.recycler.scroller.FastScrollRecyclerView
android:id="@+id/rv_list"
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:overScrollMode="never"

Loading…
Cancel
Save