书架刷新设置 #128
This commit is contained in:
@@ -206,4 +206,5 @@ object PreferKey {
|
||||
const val labelVisibilityMode = "labelVisibilityMode"
|
||||
const val menuAlpha = "menuAlpha"
|
||||
const val colorImage = "colorImage"
|
||||
const val bookshelfRefreshingLimit = "bookshelfRefreshingLimit"
|
||||
}
|
||||
|
||||
@@ -831,5 +831,11 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
set(value) {
|
||||
appCtx.putPrefString(PreferKey.readSliderMode, value)
|
||||
}
|
||||
|
||||
var bookshelfRefreshingLimit: Int
|
||||
get() = appCtx.getPrefInt(PreferKey.bookshelfRefreshingLimit, 0)
|
||||
set(value) {
|
||||
appCtx.putPrefInt(PreferKey.bookshelfRefreshingLimit, value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import io.legato.kazusa.constant.EventBus
|
||||
import io.legato.kazusa.databinding.DialogBookshelfConfigBinding
|
||||
import io.legato.kazusa.help.config.AppConfig
|
||||
import io.legato.kazusa.ui.main.MainViewModel
|
||||
import io.legato.kazusa.ui.widget.number.NumberPickerDialog
|
||||
import io.legato.kazusa.utils.bookshelfLayoutGrid
|
||||
import io.legato.kazusa.utils.postEvent
|
||||
import io.legato.kazusa.utils.viewbindingdelegate.viewBinding
|
||||
@@ -38,7 +39,6 @@ class BookshelfConfigBottomSheet : BaseBottomSheetDialogFragment(R.layout.dialog
|
||||
|
||||
val columnCount = requireContext().bookshelfLayoutGrid.takeIf { it > 0 } ?: 1
|
||||
|
||||
|
||||
val bookshelfSort = AppConfig.bookshelfSort
|
||||
|
||||
binding.apply {
|
||||
@@ -79,8 +79,22 @@ class BookshelfConfigBottomSheet : BaseBottomSheetDialogFragment(R.layout.dialog
|
||||
chipGrid.isChecked = isGrid
|
||||
chipGridCompact.isChecked = isGridCompact
|
||||
chipGridCover.isChecked = isGridCover
|
||||
sliderGridCount.value = columnCount.toFloat()
|
||||
sliderGridCount.progress = columnCount
|
||||
|
||||
binding.tvValue.text = if (AppConfig.bookshelfRefreshingLimit <= 0) "无限制"
|
||||
else "${AppConfig.bookshelfRefreshingLimit} 本"
|
||||
|
||||
binding.layoutRefreshLimit.setOnClickListener {
|
||||
NumberPickerDialog(requireContext())
|
||||
.setTitle("书架更新数量限制")
|
||||
.setMinValue(0) // 0 表示无限制
|
||||
.setMaxValue(500) // 可根据需求设定最大值
|
||||
.setValue(AppConfig.bookshelfRefreshingLimit)
|
||||
.show { selected ->
|
||||
AppConfig.bookshelfRefreshingLimit = selected
|
||||
tvValue.text = if (selected <= 0) "无限制" else "$selected 本"
|
||||
}
|
||||
}
|
||||
|
||||
when (AppConfig.bookshelfSortOrder) {
|
||||
0 -> binding.chipGroupOrder.check(binding.chipAsc.id)
|
||||
@@ -120,7 +134,7 @@ class BookshelfConfigBottomSheet : BaseBottomSheetDialogFragment(R.layout.dialog
|
||||
(requireParentFragment() as? BaseBookshelfFragment)?.upSort()
|
||||
}
|
||||
|
||||
val selectedColumn = sliderGridCount.value.toInt()
|
||||
val selectedColumn = sliderGridCount.progress
|
||||
val newLayout = when {
|
||||
chipList.isChecked -> 0
|
||||
chipGrid.isChecked -> 1
|
||||
|
||||
@@ -129,8 +129,14 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
||||
upFastScrollerBar()
|
||||
//binding.refreshLayout.setColorSchemeColors(accentColor)
|
||||
binding.refreshLayout.setOnRefreshListener {
|
||||
val books = booksAdapter.getItems()
|
||||
val refreshList = if (AppConfig.bookshelfRefreshingLimit > 0) {
|
||||
books.take(AppConfig.bookshelfRefreshingLimit)
|
||||
} else {
|
||||
books
|
||||
}
|
||||
binding.refreshLayout.isRefreshing = false
|
||||
activityViewModel.upToc(booksAdapter.getItems())
|
||||
activityViewModel.upToc(refreshList)
|
||||
}
|
||||
binding.rvBookshelf.layoutManager = GridLayoutManager(context, bookshelfLayoutGrid)
|
||||
binding.rvBookshelf.setRecycledViewPool(activityViewModel.booksGridRecycledViewPool)
|
||||
|
||||
@@ -121,10 +121,21 @@ class BookshelfFragment2() : BaseBookshelfFragment(R.layout.fragment_bookshelf2)
|
||||
initBooksData()
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun BaseBooksAdapter<*>.getBookItems(): List<Book> {
|
||||
return getItems() as List<Book>
|
||||
}
|
||||
|
||||
private fun initRecyclerView() {
|
||||
binding.refreshLayout.setOnRefreshListener {
|
||||
val books = booksAdapter.getBookItems()
|
||||
val refreshList = if (AppConfig.bookshelfRefreshingLimit > 0) {
|
||||
books.take(AppConfig.bookshelfRefreshingLimit)
|
||||
} else {
|
||||
books
|
||||
}
|
||||
binding.refreshLayout.isRefreshing = false
|
||||
activityViewModel.upToc(books)
|
||||
activityViewModel.upToc(refreshList)
|
||||
}
|
||||
|
||||
binding.rvBookshelf.layoutManager = GridLayoutManager(context, bookshelfLayoutGrid)
|
||||
|
||||
@@ -61,6 +61,7 @@ class DetailSeekBar @JvmOverloads constructor(
|
||||
TooltipCompat.setTooltipText(this, title)
|
||||
}
|
||||
|
||||
binding.slider.valueFrom = typedArray.getInteger(R.styleable.DetailSeekBar_min, 0).toFloat()
|
||||
binding.slider.valueTo = typedArray.getInteger(R.styleable.DetailSeekBar_max, 0).toFloat()
|
||||
typedArray.recycle()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user