Purify Settings
This commit is contained in:
1 parent
c46c386fea
commit
c97974eb72
3 files changed
+18
-12
No files matched your search
@@ -2,7 +2,6 @@
|
||||
|
||||
package com.hippo.ehviewer
|
||||
|
||||
import androidx.annotation.DimenRes
|
||||
import com.hippo.ehviewer.client.data.FavListUrlBuilder
|
||||
import splitties.preferences.DefaultPreferences
|
||||
import splitties.preferences.edit
|
||||
@@ -53,14 +52,6 @@ object Settings : DefaultPreferences() {
|
||||
}
|
||||
}
|
||||
|
||||
@get:DimenRes
|
||||
val detailSizeResId: Int
|
||||
get() = when (detailSize) {
|
||||
0 -> R.dimen.gallery_list_column_width_long
|
||||
1 -> R.dimen.gallery_list_column_width_short
|
||||
else -> throw IllegalStateException("Unexpected value: $detailSize")
|
||||
}
|
||||
|
||||
var downloadScheme by stringOrNullPref("image_scheme", null)
|
||||
var downloadAuthority by stringOrNullPref("image_authority", null)
|
||||
var downloadPath by stringOrNullPref("image_path", null)
|
||||
|
||||
@@ -60,6 +60,7 @@ import com.hippo.ehviewer.EhApplication.Companion.imageCache
|
||||
import com.hippo.ehviewer.EhDB
|
||||
import com.hippo.ehviewer.R
|
||||
import com.hippo.ehviewer.Settings
|
||||
import com.hippo.ehviewer.Settings.detailSize
|
||||
import com.hippo.ehviewer.Settings.listThumbSize
|
||||
import com.hippo.ehviewer.client.EhUtils
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo
|
||||
@@ -262,7 +263,15 @@ class DownloadsScene :
|
||||
mAdapter!!.setHasStableIds(true)
|
||||
recyclerView.adapter = mAdapter
|
||||
val layoutManager = AutoStaggeredGridLayoutManager(0, StaggeredGridLayoutManager.VERTICAL)
|
||||
layoutManager.setColumnSize(resources.getDimensionPixelOffset(Settings.detailSizeResId))
|
||||
layoutManager.setColumnSize(
|
||||
resources.getDimensionPixelOffset(
|
||||
when (detailSize) {
|
||||
0 -> R.dimen.gallery_list_column_width_long
|
||||
1 -> R.dimen.gallery_list_column_width_short
|
||||
else -> throw IllegalStateException("Unexpected value: $detailSize")
|
||||
},
|
||||
),
|
||||
)
|
||||
layoutManager.setStrategy(STRATEGY_MIN_SIZE)
|
||||
layoutManager.supportsPredictiveItemAnimations = false
|
||||
recyclerView.layoutManager = layoutManager
|
||||
|
||||
@@ -25,7 +25,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.RecyclerView.ItemDecoration
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
import com.hippo.ehviewer.R
|
||||
import com.hippo.ehviewer.Settings
|
||||
import com.hippo.ehviewer.Settings.detailSize
|
||||
import com.hippo.ehviewer.Settings.thumbSizeDp
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo
|
||||
import com.hippo.ehviewer.ui.legacy.easyrecyclerview.MarginItemDecoration
|
||||
@@ -58,7 +58,13 @@ abstract class GalleryAdapter(
|
||||
val recyclerView = mRecyclerView
|
||||
when (type) {
|
||||
TYPE_LIST -> {
|
||||
val columnWidth = mResources.getDimensionPixelOffset(Settings.detailSizeResId)
|
||||
val columnWidth = mResources.getDimensionPixelOffset(
|
||||
when (detailSize) {
|
||||
0 -> R.dimen.gallery_list_column_width_long
|
||||
1 -> R.dimen.gallery_list_column_width_short
|
||||
else -> throw IllegalStateException("Unexpected value: $detailSize")
|
||||
},
|
||||
)
|
||||
mLayoutManager.setColumnSize(columnWidth)
|
||||
mLayoutManager.setStrategy(STRATEGY_MIN_SIZE)
|
||||
if (null != mGirdDecoration) {
|
||||
|
||||
Reference in new issue
Block a user