Skip to content

Commit 21c967c

Browse files
committed
修复 @Preview 中含有 Prefs 相关代码就无法正常预览
1 parent 593517c commit 21c967c

File tree

1 file changed

+5
-1
lines changed
  • app/shared/src/main/kotlin/dev/aaa1115910/bv/util

1 file changed

+5
-1
lines changed

app/shared/src/main/kotlin/dev/aaa1115910/bv/util/Prefs.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,11 @@ object PrefKeys {
391391
val prefBuvid3Request = PreferenceRequest(prefBuvid3Key, "")
392392
val prefPlayerTypeRequest = PreferenceRequest(prefPlayerTypeKey, PlayerType.Media3.ordinal)
393393
val prefDensityRequest =
394-
PreferenceRequest(prefDensityKey, BVApp.context.resources.displayMetrics.widthPixels / 960f)
394+
PreferenceRequest(
395+
prefDensityKey,
396+
runCatching { BVApp.context.resources.displayMetrics.widthPixels / 960f }
397+
.getOrDefault(2f)
398+
)
395399

396400
@Suppress("KotlinConstantConditions")
397401
val prefAlphaRequest = PreferenceRequest(prefAlphaKey, BuildConfig.BUILD_TYPE == "alpha")

0 commit comments

Comments
 (0)