Remove dismiss target only when it's attached to a parent.
Bug: 258120818 Change-Id: I63bd5b5cf43db7c794cba84d680b5e168f0e2350 Test: n/a
This commit is contained in:
@@ -235,21 +235,14 @@ public class PipDismissTargetHandler implements ViewTreeObserver.OnPreDrawListen
|
||||
|
||||
/** Adds the magnetic target view to the WindowManager so it's ready to be animated in. */
|
||||
public void createOrUpdateDismissTarget() {
|
||||
if (!mTargetViewContainer.isAttachedToWindow()) {
|
||||
if (mTargetViewContainer.getParent() == null) {
|
||||
mTargetViewContainer.cancelAnimators();
|
||||
|
||||
mTargetViewContainer.setVisibility(View.INVISIBLE);
|
||||
mTargetViewContainer.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
mHasDismissTargetSurface = false;
|
||||
|
||||
try {
|
||||
mWindowManager.addView(mTargetViewContainer, getDismissTargetLayoutParams());
|
||||
} catch (IllegalStateException e) {
|
||||
// This shouldn't happen, but if the target is already added, just update its layout
|
||||
// params.
|
||||
mWindowManager.updateViewLayout(
|
||||
mTargetViewContainer, getDismissTargetLayoutParams());
|
||||
}
|
||||
mWindowManager.addView(mTargetViewContainer, getDismissTargetLayoutParams());
|
||||
} else {
|
||||
mWindowManager.updateViewLayout(mTargetViewContainer, getDismissTargetLayoutParams());
|
||||
}
|
||||
@@ -306,7 +299,7 @@ public class PipDismissTargetHandler implements ViewTreeObserver.OnPreDrawListen
|
||||
* Removes the dismiss target and cancels any pending callbacks to show it.
|
||||
*/
|
||||
public void cleanUpDismissTarget() {
|
||||
if (mTargetViewContainer.isAttachedToWindow()) {
|
||||
if (mTargetViewContainer.getParent() != null) {
|
||||
mWindowManager.removeViewImmediate(mTargetViewContainer);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user