summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-12-28 02:34:25 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-12-28 02:34:25 +0000
commit0fd5001ed5777a150cdc47b8f712573e949271d3 (patch)
tree0467d9fe54489764dfadd1b7f421406181fc4bed
parent1ab8fed9971824232ee45b2481c667716ac6341f (diff)
parentdf697c65187578c4683afdae4e44fbf17bdd737e (diff)
downloadWallpaperPicker2-android14-qpr2-s1-release.tar.gz
Change-Id: Ib844542afa77aad9c3211651d223112e5a15f8b7
-rw-r--r--src/com/android/wallpaper/picker/customization/ui/binder/ScreenPreviewBinder.kt31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/com/android/wallpaper/picker/customization/ui/binder/ScreenPreviewBinder.kt b/src/com/android/wallpaper/picker/customization/ui/binder/ScreenPreviewBinder.kt
index 46b2c1a9..34f0770e 100644
--- a/src/com/android/wallpaper/picker/customization/ui/binder/ScreenPreviewBinder.kt
+++ b/src/com/android/wallpaper/picker/customization/ui/binder/ScreenPreviewBinder.kt
@@ -163,6 +163,19 @@ object ScreenPreviewBinder {
var disposableHandle: DisposableHandle? = null
+ val cleanupWallpaperConnectionRunnable = Runnable {
+ disposableHandle?.dispose()
+ wallpaperConnection?.destroy()
+ wallpaperConnection = null
+ }
+
+ fun cleanupWallpaperConnection() {
+ // If existing, remove any scheduled cleanups...
+ previewView.removeCallbacks(cleanupWallpaperConnectionRunnable)
+ // ...and cleanup immediately
+ cleanupWallpaperConnectionRunnable.run()
+ }
+
val job =
lifecycleOwner.lifecycleScope.launch {
launch {
@@ -206,9 +219,7 @@ object ScreenPreviewBinder {
override fun onDestroy(owner: LifecycleOwner) {
super.onDestroy(owner)
if (isPageTransitionsFeatureEnabled) {
- disposableHandle?.dispose()
- wallpaperConnection?.destroy()
- wallpaperConnection = null
+ cleanupWallpaperConnection()
}
}
@@ -246,10 +257,12 @@ object ScreenPreviewBinder {
} else null
)
wallpaperIsReadyForReveal = false
- if (!isPageTransitionsFeatureEnabled) {
- disposableHandle?.dispose()
- wallpaperConnection?.destroy()
- wallpaperConnection = null
+ if (isPageTransitionsFeatureEnabled) {
+ // delay cleanup to prevent flicker between onStop and page
+ // transition animation start
+ previewView.postDelayed(cleanupWallpaperConnectionRunnable, 100)
+ } else {
+ cleanupWallpaperConnectionRunnable.run()
}
}
@@ -463,9 +476,7 @@ object ScreenPreviewBinder {
}
(wallpaperInfo as? LiveWallpaperInfo)?.let { liveWallpaperInfo ->
if (isPageTransitionsFeatureEnabled) {
- disposableHandle?.dispose()
- wallpaperConnection?.destroy()
- wallpaperConnection = null
+ cleanupWallpaperConnection()
}
val connection =
wallpaperConnection