Inline launchPageGalleryListSceneAction
This commit is contained in:
1 parent
d9c933bd0a
commit
62d7d09886
2 files changed
+11
-26
No files matched your search
@@ -21,8 +21,6 @@ import android.util.Log
|
||||
import androidx.annotation.DimenRes
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.hippo.ehviewer.client.data.FavListUrlBuilder
|
||||
import com.hippo.ehviewer.ui.scene.GalleryListScene
|
||||
import com.hippo.ehviewer.yorozuya.NumberUtils
|
||||
import com.hippo.unifile.UniFile
|
||||
import splitties.experimental.ExperimentalSplittiesApi
|
||||
import splitties.init.appCtx
|
||||
@@ -128,29 +126,6 @@ object Settings : DefaultPreferences() {
|
||||
sSettingsPre.edit().putString(key, value).apply()
|
||||
}
|
||||
|
||||
private fun getIntFromStr(key: String, defValue: Int): Int {
|
||||
return try {
|
||||
NumberUtils.parseIntSafely(
|
||||
sSettingsPre.getString(key, defValue.toString()),
|
||||
defValue,
|
||||
)
|
||||
} catch (e: ClassCastException) {
|
||||
Log.d(TAG, "Get ClassCastException when get $key value", e)
|
||||
defValue
|
||||
}
|
||||
}
|
||||
|
||||
val launchPageGalleryListSceneAction: String
|
||||
get() {
|
||||
return when (val value = getIntFromStr(KEY_LAUNCH_PAGE, DEFAULT_LAUNCH_PAGE)) {
|
||||
0 -> GalleryListScene.ACTION_HOMEPAGE
|
||||
1 -> GalleryListScene.ACTION_SUBSCRIPTION
|
||||
2 -> GalleryListScene.ACTION_WHATS_HOT
|
||||
3 -> GalleryListScene.ACTION_TOP_LIST
|
||||
else -> throw IllegalStateException("Unexpected value: $value")
|
||||
}
|
||||
}
|
||||
|
||||
@get:DimenRes
|
||||
val detailSizeResId: Int
|
||||
get() = when (detailSize) {
|
||||
@@ -189,6 +164,7 @@ object Settings : DefaultPreferences() {
|
||||
val detailSize by intFromStrPref(KEY_DETAIL_SIZE, 0)
|
||||
val thumbResolution by intFromStrPref(KEY_THUMB_RESOLUTION, 0)
|
||||
val readCacheSize by intFromStrPref(KEY_READ_CACHE_SIZE, 640)
|
||||
var launchPage by intFromStrPref(KEY_LAUNCH_PAGE, DEFAULT_LAUNCH_PAGE)
|
||||
|
||||
val showComments by boolPref("show_gallery_comments", true)
|
||||
val requestNews by boolPref(KEY_REQUEST_NEWS, false)
|
||||
|
||||
@@ -52,6 +52,7 @@ import com.google.android.material.snackbar.Snackbar
|
||||
import com.hippo.ehviewer.AppConfig
|
||||
import com.hippo.ehviewer.R
|
||||
import com.hippo.ehviewer.Settings
|
||||
import com.hippo.ehviewer.Settings.launchPage
|
||||
import com.hippo.ehviewer.client.EhUtils
|
||||
import com.hippo.ehviewer.client.data.ListUrlBuilder
|
||||
import com.hippo.ehviewer.client.parser.GalleryDetailUrlParser
|
||||
@@ -181,7 +182,15 @@ class MainActivity : EhActivity() {
|
||||
private fun setNavGraph() {
|
||||
navController.apply {
|
||||
graph = navInflater.inflate(R.navigation.nav_graph).apply {
|
||||
when (Settings.launchPageGalleryListSceneAction) {
|
||||
when (
|
||||
when (val value = launchPage) {
|
||||
0 -> GalleryListScene.ACTION_HOMEPAGE
|
||||
1 -> GalleryListScene.ACTION_SUBSCRIPTION
|
||||
2 -> GalleryListScene.ACTION_WHATS_HOT
|
||||
3 -> GalleryListScene.ACTION_TOP_LIST
|
||||
else -> throw IllegalStateException("Unexpected value: $value")
|
||||
}
|
||||
) {
|
||||
GalleryListScene.ACTION_HOMEPAGE -> setStartDestination(R.id.nav_homepage)
|
||||
GalleryListScene.ACTION_SUBSCRIPTION -> setStartDestination(R.id.nav_subscription)
|
||||
GalleryListScene.ACTION_WHATS_HOT -> setStartDestination(R.id.nav_whats_hot)
|
||||
|
||||
Reference in new issue
Block a user