diff --git a/app/src/main/java/com/hippo/ehviewer/Settings.kt b/app/src/main/java/com/hippo/ehviewer/Settings.kt index 661893afa..f50a50b51 100755 --- a/app/src/main/java/com/hippo/ehviewer/Settings.kt +++ b/app/src/main/java/com/hippo/ehviewer/Settings.kt @@ -19,6 +19,8 @@ import android.content.SharedPreferences import android.net.Uri import android.util.Log import androidx.annotation.DimenRes +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp import androidx.preference.PreferenceManager import com.hippo.ehviewer.EhApplication.Companion.application import com.hippo.ehviewer.client.data.FavListUrlBuilder @@ -365,6 +367,9 @@ object Settings { val thumbSize: Int get() = dip2px(getInt(KEY_THUMB_SIZE, DEFAULT_THUMB_SIZE)) + val thumbSizeDp: Dp + get() = getInt(KEY_THUMB_SIZE, DEFAULT_THUMB_SIZE).dp + private fun dip2px(dpValue: Int): Int { val scale = application.resources.displayMetrics.density return (dpValue * scale + 0.5f).toInt() diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.kt index 83243ae82..846757e73 100755 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.kt @@ -379,27 +379,6 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { } else { DownloadInfo.STATE_INVALID } - /* - binding.content.recyclerView.run { - previewsAdapter = GalleryPreviewsAdapter { - mainActivity!!.startReaderActivity(composeBindingGD!!, it.position) - } - footerAdapter = HintAdapter { navigateToPreview(true) } - headerAdapter = HintAdapter { navigateToPreview() } - adapter = ConcatAdapter(headerAdapter, previewsAdapter, footerAdapter) - val columnWidth = Settings.thumbSize - layoutManager = AutoGridLayoutManager(context, columnWidth).apply { - setStrategy(SimpleGridAutoSpanLayout.STRATEGY_SUITABLE_SIZE) - } - val padding = LayoutUtils.dp2pix(context, 8f) - val decoration = MarginItemDecoration(padding, padding, padding, padding, padding) - addItemDecoration(decoration) - val lp = layoutParams - lp.height = resources.displayMetrics.heightPixels * 8 / 7 - layoutParams = lp - } - - */ readButtonText = getString(R.string.read) composeBindingGI?.let { gi -> if (mAction == ACTION_GALLERY_INFO) { @@ -528,8 +507,20 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { galleryDetail: GalleryDetail?, modifier: Modifier ) { + /* + binding.content.recyclerView.run { + previewsAdapter = GalleryPreviewsAdapter { + mainActivity!!.startReaderActivity(composeBindingGD!!, it.position) + } + footerAdapter = HintAdapter { navigateToPreview(true) } + headerAdapter = HintAdapter { navigateToPreview() } + adapter = ConcatAdapter(headerAdapter, previewsAdapter, footerAdapter) + val padding = LayoutUtils.dp2pix(context, 8f) + } + + */ LazyVerticalStaggeredGrid( - columns = StaggeredGridCells.Adaptive(160.dp), + columns = StaggeredGridCells.Adaptive(Settings.thumbSizeDp), modifier = modifier.padding(horizontal = dimensionResource(id = R.dimen.keyline_margin)) ) { item(span = StaggeredGridItemSpan.FullLine) {