diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-28 02:34:25 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-28 02:34:25 +0000 |
commit | 0fd5001ed5777a150cdc47b8f712573e949271d3 (patch) | |
tree | 0467d9fe54489764dfadd1b7f421406181fc4bed | |
parent | 1ab8fed9971824232ee45b2481c667716ac6341f (diff) | |
parent | df697c65187578c4683afdae4e44fbf17bdd737e (diff) | |
download | WallpaperPicker2-android14-qpr2-s3-release.tar.gz |
Merge cherrypicks of ['googleplex-android-review.googlesource.com/25702389'] into 24Q1-release.android-14.0.0_r33android-14.0.0_r32android-14.0.0_r31android-14.0.0_r30android-14.0.0_r29android14-qpr2-s3-releaseandroid14-qpr2-s2-releaseandroid14-qpr2-s1-releaseandroid14-qpr2-release
Change-Id: Ib844542afa77aad9c3211651d223112e5a15f8b7
-rw-r--r-- | src/com/android/wallpaper/picker/customization/ui/binder/ScreenPreviewBinder.kt | 31 |
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 |