Cleanup with bundleOf ext
This commit is contained in:
1 parent
bb3a88813b
commit
2829d081cc
5 files changed
+57
-47
No files matched your search
@@ -35,6 +35,7 @@ import androidx.activity.OnBackPressedCallback
|
||||
import androidx.annotation.IntDef
|
||||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsAnimationCompat
|
||||
@@ -1089,14 +1090,12 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H
|
||||
return R.id.progressScene
|
||||
}
|
||||
|
||||
override fun getArgs(): Bundle {
|
||||
val args = Bundle()
|
||||
args.putString(ProgressScene.KEY_ACTION, ProgressScene.ACTION_GALLERY_TOKEN)
|
||||
args.putLong(ProgressScene.KEY_GID, mGid)
|
||||
args.putString(ProgressScene.KEY_PTOKEN, mPToken)
|
||||
args.putInt(ProgressScene.KEY_PAGE, mPage)
|
||||
return args
|
||||
}
|
||||
override fun getArgs() = bundleOf(
|
||||
ProgressScene.KEY_ACTION to ProgressScene.ACTION_GALLERY_TOKEN,
|
||||
ProgressScene.KEY_GID to mGid,
|
||||
ProgressScene.KEY_PTOKEN to mPToken,
|
||||
ProgressScene.KEY_PAGE to mPage,
|
||||
)
|
||||
}
|
||||
|
||||
private inner class GalleryListAdapter(
|
||||
@@ -1266,12 +1265,10 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H
|
||||
private const val STATE_SEARCH = 2
|
||||
private const val STATE_SEARCH_SHOW_LIST = 3
|
||||
private const val ANIMATE_TIME = 300L
|
||||
fun ListUrlBuilder.toStartArgs(): Bundle {
|
||||
val args = Bundle()
|
||||
args.putString(KEY_ACTION, ACTION_LIST_URL_BUILDER)
|
||||
args.putParcelable(KEY_LIST_URL_BUILDER, this)
|
||||
return args
|
||||
}
|
||||
fun ListUrlBuilder.toStartArgs() = bundleOf(
|
||||
KEY_ACTION to ACTION_LIST_URL_BUILDER,
|
||||
KEY_LIST_URL_BUILDER to this,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ import androidx.compose.ui.res.dimensionResource
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.paging.Pager
|
||||
@@ -199,10 +200,13 @@ class HistoryScene : BaseScene() {
|
||||
}
|
||||
|
||||
private fun onItemClick(gi: GalleryInfo) {
|
||||
val args = Bundle()
|
||||
args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GALLERY_INFO)
|
||||
args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, gi)
|
||||
navAnimated(R.id.galleryDetailScene, args)
|
||||
navAnimated(
|
||||
R.id.galleryDetailScene,
|
||||
bundleOf(
|
||||
GalleryDetailScene.KEY_ACTION to GalleryDetailScene.ACTION_GALLERY_INFO,
|
||||
GalleryDetailScene.KEY_GALLERY_INFO to gi,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
private val cardHeight = (3 * listThumbSize * 3).pxToDp.dp
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.hippo.ehviewer.ui.scene
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import androidx.annotation.MainThread
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.NavOptions
|
||||
@@ -27,33 +28,39 @@ fun NavController.navAnimated(id: Int, args: Bundle?, singleTop: Boolean = false
|
||||
@MainThread
|
||||
fun NavController.navWithUrl(url: String): Boolean {
|
||||
if (url.isEmpty()) return false
|
||||
GalleryListUrlParser.parse(url)?.let { lub ->
|
||||
Bundle().apply {
|
||||
putString(GalleryListScene.KEY_ACTION, GalleryListScene.ACTION_LIST_URL_BUILDER)
|
||||
putParcelable(GalleryListScene.KEY_LIST_URL_BUILDER, lub)
|
||||
navAnimated(R.id.galleryListScene, this)
|
||||
}
|
||||
GalleryListUrlParser.parse(url)?.let {
|
||||
navAnimated(
|
||||
R.id.galleryListScene,
|
||||
bundleOf(
|
||||
GalleryListScene.KEY_ACTION to GalleryListScene.ACTION_LIST_URL_BUILDER,
|
||||
GalleryListScene.KEY_LIST_URL_BUILDER to it,
|
||||
),
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
||||
GalleryDetailUrlParser.parse(url)?.apply {
|
||||
Bundle().apply {
|
||||
putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GID_TOKEN)
|
||||
putLong(GalleryDetailScene.KEY_GID, gid)
|
||||
putString(GalleryDetailScene.KEY_TOKEN, token)
|
||||
navAnimated(R.id.galleryDetailScene, this)
|
||||
}
|
||||
navAnimated(
|
||||
R.id.galleryDetailScene,
|
||||
bundleOf(
|
||||
GalleryDetailScene.KEY_ACTION to GalleryDetailScene.ACTION_GID_TOKEN,
|
||||
GalleryDetailScene.KEY_GID to gid,
|
||||
GalleryDetailScene.KEY_TOKEN to token,
|
||||
),
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
||||
GalleryPageUrlParser.parse(url)?.apply {
|
||||
Bundle().apply {
|
||||
putString(ProgressScene.KEY_ACTION, ProgressScene.ACTION_GALLERY_TOKEN)
|
||||
putLong(ProgressScene.KEY_GID, gid)
|
||||
putString(ProgressScene.KEY_PTOKEN, pToken)
|
||||
putInt(ProgressScene.KEY_PAGE, page)
|
||||
navAnimated(R.id.progressScene, this)
|
||||
}
|
||||
navAnimated(
|
||||
R.id.progressScene,
|
||||
bundleOf(
|
||||
ProgressScene.KEY_ACTION to ProgressScene.ACTION_GALLERY_TOKEN,
|
||||
ProgressScene.KEY_GID to gid,
|
||||
ProgressScene.KEY_PTOKEN to pToken,
|
||||
ProgressScene.KEY_PAGE to page,
|
||||
),
|
||||
)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -24,6 +24,7 @@ import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.hippo.ehviewer.R
|
||||
import com.hippo.ehviewer.client.EhEngine
|
||||
@@ -52,14 +53,17 @@ class ProgressScene : BaseScene() {
|
||||
runSuspendCatching {
|
||||
EhEngine.getGalleryToken(gid, token, page)
|
||||
}.onSuccess {
|
||||
val arg = Bundle()
|
||||
arg.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GID_TOKEN)
|
||||
arg.putLong(GalleryDetailScene.KEY_GID, gid)
|
||||
arg.putString(GalleryDetailScene.KEY_TOKEN, it)
|
||||
arg.putInt(GalleryDetailScene.KEY_PAGE, page)
|
||||
withUIContext {
|
||||
findNavController().popBackStack()
|
||||
navAnimated(R.id.galleryDetailScene, arg)
|
||||
navAnimated(
|
||||
R.id.galleryDetailScene,
|
||||
bundleOf(
|
||||
GalleryDetailScene.KEY_ACTION to GalleryDetailScene.ACTION_GID_TOKEN,
|
||||
GalleryDetailScene.KEY_GID to gid,
|
||||
GalleryDetailScene.KEY_TOKEN to it,
|
||||
GalleryDetailScene.KEY_PAGE to page,
|
||||
),
|
||||
)
|
||||
}
|
||||
}.onFailure {
|
||||
error = ExceptionUtils.getReadableString(it)
|
||||
|
||||
@@ -22,8 +22,8 @@ import android.content.ClipDescription
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.PersistableBundle
|
||||
import android.view.textclassifier.TextClassifier
|
||||
import androidx.core.os.persistableBundleOf
|
||||
import com.hippo.ehviewer.R
|
||||
import com.hippo.ehviewer.ui.MainActivity
|
||||
import com.hippo.ehviewer.ui.scene.BaseScene
|
||||
@@ -42,9 +42,7 @@ fun Context.addTextToClipboard(text: CharSequence?, isSensitive: Boolean, useToa
|
||||
setPrimaryClip(
|
||||
ClipData.newPlainText(null, text).apply {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && isSensitive) {
|
||||
description.extras = PersistableBundle().apply {
|
||||
putBoolean(ClipDescription.EXTRA_IS_SENSITIVE, true)
|
||||
}
|
||||
description.extras = persistableBundleOf(ClipDescription.EXTRA_IS_SENSITIVE to true)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user