summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTaesu Lee <taesu82.lee@samsung.com>2020-03-06 17:38:15 +0900
committerLuca Stefani <luca.stefani.ge1@gmail.com>2020-03-16 16:29:45 +0100
commit34a9b021a67e973f84a00ba37599cfcf73d4e9f3 (patch)
tree9a112e758a30e520666e20551336de362d6a1d78
parent0249cb0164a86fbe4e7be65f8e9b18446db638ea (diff)
downloadpackages_apps_Messaging-34a9b021a67e973f84a00ba37599cfcf73d4e9f3.tar.gz
packages_apps_Messaging-34a9b021a67e973f84a00ba37599cfcf73d4e9f3.tar.bz2
packages_apps_Messaging-34a9b021a67e973f84a00ba37599cfcf73d4e9f3.zip
Fix WindowLeaked issue on AttachmentPreview
Stop attaching animation before removal attachment views and hiding the AttachmentPreview. Test: Long-press to attach a media from GalleryGridView and uncheck the media to detach immediately. Change-Id: Ia1014609c056c9f35e428f8968b58dc2c1b704f9 Signed-off-by: Taesu Lee <taesu82.lee@samsung.com>
-rw-r--r--src/com/android/messaging/ui/AttachmentPreview.java16
-rw-r--r--src/com/android/messaging/ui/MultiAttachmentLayout.java7
2 files changed, 20 insertions, 3 deletions
diff --git a/src/com/android/messaging/ui/AttachmentPreview.java b/src/com/android/messaging/ui/AttachmentPreview.java
index 7eea14b..f4465c4 100644
--- a/src/com/android/messaging/ui/AttachmentPreview.java
+++ b/src/com/android/messaging/ui/AttachmentPreview.java
@@ -57,6 +57,8 @@ public class AttachmentPreview extends ScrollView implements OnAttachmentClickLi
private Runnable mHideRunnable;
private boolean mPendingHideCanceled;
+ private PopupTransitionAnimation mPopupTransitionAnimation;
+
private static final int CLOSE_BUTTON_REVEAL_STAGGER_MILLIS = 300;
public AttachmentPreview(final Context context, final AttributeSet attrs) {
@@ -132,6 +134,7 @@ public class AttachmentPreview extends ScrollView implements OnAttachmentClickLi
public void run() {
// Only hide if we are didn't get overruled by showing
if (!mPendingHideCanceled) {
+ stopPopupAnimation();
mAttachmentView.removeAllViews();
setVisibility(GONE);
}
@@ -280,10 +283,19 @@ public class AttachmentPreview extends ScrollView implements OnAttachmentClickLi
mHideRunnable.run();
}
- static void tryAnimateViewIn(final MessagePartData attachmentData, final View view) {
+ private void tryAnimateViewIn(final MessagePartData attachmentData, final View view) {
if (attachmentData instanceof MediaPickerMessagePartData) {
final Rect startRect = ((MediaPickerMessagePartData) attachmentData).getStartRect();
- new PopupTransitionAnimation(startRect, view).startAfterLayoutComplete();
+ stopPopupAnimation();
+ mPopupTransitionAnimation = new PopupTransitionAnimation(startRect, view);
+ mPopupTransitionAnimation.startAfterLayoutComplete();
+ }
+ }
+
+ private void stopPopupAnimation() {
+ if (mPopupTransitionAnimation != null) {
+ mPopupTransitionAnimation.cancel();
+ mPopupTransitionAnimation = null;
}
}
diff --git a/src/com/android/messaging/ui/MultiAttachmentLayout.java b/src/com/android/messaging/ui/MultiAttachmentLayout.java
index f620245..5bae8a5 100644
--- a/src/com/android/messaging/ui/MultiAttachmentLayout.java
+++ b/src/com/android/messaging/ui/MultiAttachmentLayout.java
@@ -33,6 +33,7 @@ import com.android.messaging.datamodel.data.MessagePartData;
import com.android.messaging.datamodel.data.PendingAttachmentData;
import com.android.messaging.datamodel.media.ImageRequestDescriptor;
import com.android.messaging.ui.AsyncImageView.AsyncImageViewDelayLoader;
+import com.android.messaging.ui.animation.PopupTransitionAnimation;
import com.android.messaging.util.AccessibilityUtil;
import com.android.messaging.util.Assert;
import com.android.messaging.util.UiUtils;
@@ -275,7 +276,11 @@ public class MultiAttachmentLayout extends FrameLayout {
// views will slide from their previous position to their new position within the
// layout
if (i == 0) {
- AttachmentPreview.tryAnimateViewIn(attachment, attachmentWrapper.view);
+ if (attachment instanceof MediaPickerMessagePartData) {
+ final Rect startRect = ((MediaPickerMessagePartData) attachment).getStartRect();
+ new PopupTransitionAnimation(startRect, attachmentWrapper.view)
+ .startAfterLayoutComplete();
+ }
}
attachmentWrapper.needsSlideAnimation = i > 0;
}