Fix WindowLeaked issue on AttachmentPreview am: 1412b40ec6 am: 7ad96ef75f am: 994ef53939
Change-Id: I5576b0085b7af9922fb76467048c1691f849646e
This commit is contained in:
@@ -57,6 +57,8 @@ public class AttachmentPreview extends ScrollView implements OnAttachmentClickLi
|
|||||||
private Runnable mHideRunnable;
|
private Runnable mHideRunnable;
|
||||||
private boolean mPendingHideCanceled;
|
private boolean mPendingHideCanceled;
|
||||||
|
|
||||||
|
private PopupTransitionAnimation mPopupTransitionAnimation;
|
||||||
|
|
||||||
private static final int CLOSE_BUTTON_REVEAL_STAGGER_MILLIS = 300;
|
private static final int CLOSE_BUTTON_REVEAL_STAGGER_MILLIS = 300;
|
||||||
|
|
||||||
public AttachmentPreview(final Context context, final AttributeSet attrs) {
|
public AttachmentPreview(final Context context, final AttributeSet attrs) {
|
||||||
@@ -132,6 +134,7 @@ public class AttachmentPreview extends ScrollView implements OnAttachmentClickLi
|
|||||||
public void run() {
|
public void run() {
|
||||||
// Only hide if we are didn't get overruled by showing
|
// Only hide if we are didn't get overruled by showing
|
||||||
if (!mPendingHideCanceled) {
|
if (!mPendingHideCanceled) {
|
||||||
|
stopPopupAnimation();
|
||||||
mAttachmentView.removeAllViews();
|
mAttachmentView.removeAllViews();
|
||||||
setVisibility(GONE);
|
setVisibility(GONE);
|
||||||
}
|
}
|
||||||
@@ -280,10 +283,19 @@ public class AttachmentPreview extends ScrollView implements OnAttachmentClickLi
|
|||||||
mHideRunnable.run();
|
mHideRunnable.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tryAnimateViewIn(final MessagePartData attachmentData, final View view) {
|
private void tryAnimateViewIn(final MessagePartData attachmentData, final View view) {
|
||||||
if (attachmentData instanceof MediaPickerMessagePartData) {
|
if (attachmentData instanceof MediaPickerMessagePartData) {
|
||||||
final Rect startRect = ((MediaPickerMessagePartData) attachmentData).getStartRect();
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import com.android.messaging.datamodel.data.MessagePartData;
|
|||||||
import com.android.messaging.datamodel.data.PendingAttachmentData;
|
import com.android.messaging.datamodel.data.PendingAttachmentData;
|
||||||
import com.android.messaging.datamodel.media.ImageRequestDescriptor;
|
import com.android.messaging.datamodel.media.ImageRequestDescriptor;
|
||||||
import com.android.messaging.ui.AsyncImageView.AsyncImageViewDelayLoader;
|
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.AccessibilityUtil;
|
||||||
import com.android.messaging.util.Assert;
|
import com.android.messaging.util.Assert;
|
||||||
import com.android.messaging.util.UiUtils;
|
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
|
// views will slide from their previous position to their new position within the
|
||||||
// layout
|
// layout
|
||||||
if (i == 0) {
|
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;
|
attachmentWrapper.needsSlideAnimation = i > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user