diff --git a/app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt b/app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt index ea37c7b00..e611ac728 100644 --- a/app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt +++ b/app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt @@ -123,6 +123,13 @@ val Fragment.primaryDisabledTextColor: Int val Fragment.secondaryDisabledTextColor: Int get() = getSecondaryDisabledTextColor(isDarkTheme) +val Context.buttonDisabledColor: Int + get() = if (isDarkTheme) { + ContextCompat.getColor(this, R.color.ate_button_disabled_dark) + } else { + ContextCompat.getColor(this, R.color.ate_button_disabled_light) + } + val Context.isDarkTheme: Boolean get() = ColorUtils.isColorLight(ThemeStore.primaryColor(this)) diff --git a/app/src/main/java/io/legado/app/ui/chapterlist/BookmarkFragment.kt b/app/src/main/java/io/legado/app/ui/chapterlist/BookmarkFragment.kt index 43c583e7f..0d42b5600 100644 --- a/app/src/main/java/io/legado/app/ui/chapterlist/BookmarkFragment.kt +++ b/app/src/main/java/io/legado/app/ui/chapterlist/BookmarkFragment.kt @@ -2,10 +2,12 @@ package io.legado.app.ui.chapterlist import android.os.Bundle import android.view.View +import android.widget.LinearLayout import androidx.lifecycle.LiveData import androidx.lifecycle.Observer import androidx.paging.LivePagedListBuilder import androidx.paging.PagedList +import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.App import io.legado.app.R @@ -32,6 +34,12 @@ class BookmarkFragment : VMBaseFragment(R.layout.fragment_ ATH.applyEdgeEffectColor(recycler_view) adapter = BookmarkAdapter() recycler_view.layoutManager = LinearLayoutManager(requireContext()) + recycler_view.addItemDecoration( + DividerItemDecoration( + requireContext(), + LinearLayout.VERTICAL + ) + ) recycler_view.adapter = adapter } diff --git a/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListAdapter.kt b/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListAdapter.kt index 5dc8d27f2..581bf3c01 100644 --- a/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListAdapter.kt @@ -8,10 +8,13 @@ import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView import io.legado.app.R import io.legado.app.data.entities.BookChapter +import io.legado.app.lib.theme.accentColor +import io.legado.app.utils.getCompatColor import kotlinx.android.synthetic.main.item_bookmark.view.* import org.jetbrains.anko.sdk27.listeners.onClick -class ChapterListAdapter : PagedListAdapter(DIFF_CALLBACK) { +class ChapterListAdapter(val callback: Callback) : + PagedListAdapter(DIFF_CALLBACK) { companion object { @@ -26,8 +29,6 @@ class ChapterListAdapter : PagedListAdapter(R.layout.fragment_chapter_list) { +class ChapterListFragment : VMBaseFragment(R.layout.fragment_chapter_list), + ChapterListAdapter.Callback { override val viewModel: ChapterListViewModel get() = getViewModelOfActivity(ChapterListViewModel::class.java) lateinit var adapter: ChapterListAdapter private var liveData: LiveData>? = null + private var durChapterIndex = 0 override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -30,8 +35,14 @@ class ChapterListFragment : VMBaseFragment(R.layout.fragme } private fun initRecyclerView() { - adapter = ChapterListAdapter() + adapter = ChapterListAdapter(this) recycler_view.layoutManager = LinearLayoutManager(requireContext()) + recycler_view.addItemDecoration( + DividerItemDecoration( + requireContext(), + LinearLayout.VERTICAL + ) + ) recycler_view.adapter = adapter } @@ -43,9 +54,9 @@ class ChapterListFragment : VMBaseFragment(R.layout.fragme private fun initView() { viewModel.bookDate.value?.let { - tv_current_chapter_info.text = it.durChapterTitle + loadBookFinish(it) } ?: viewModel.bookDate.observe(viewLifecycleOwner, Observer { - tv_current_chapter_info.text = it.durChapterTitle + loadBookFinish(it) }) iv_chapter_top.onClick { recycler_view.scrollToPosition(0) } iv_chapter_bottom.onClick { @@ -59,4 +70,18 @@ class ChapterListFragment : VMBaseFragment(R.layout.fragme } } } + + private fun loadBookFinish(book: Book) { + durChapterIndex = book.durChapterIndex + tv_current_chapter_info.text = book.durChapterTitle + recycler_view.scrollToPosition(durChapterIndex) + } + + override fun durChapterIndex(): Int { + return durChapterIndex + } + + override fun openChapter() { + + } } \ No newline at end of file