Merge "Remove dismiss target only when it's attached to a parent." into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
489880bcfb
@@ -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. */
|
/** Adds the magnetic target view to the WindowManager so it's ready to be animated in. */
|
||||||
public void createOrUpdateDismissTarget() {
|
public void createOrUpdateDismissTarget() {
|
||||||
if (!mTargetViewContainer.isAttachedToWindow()) {
|
if (mTargetViewContainer.getParent() == null) {
|
||||||
mTargetViewContainer.cancelAnimators();
|
mTargetViewContainer.cancelAnimators();
|
||||||
|
|
||||||
mTargetViewContainer.setVisibility(View.INVISIBLE);
|
mTargetViewContainer.setVisibility(View.INVISIBLE);
|
||||||
mTargetViewContainer.getViewTreeObserver().removeOnPreDrawListener(this);
|
mTargetViewContainer.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||||
mHasDismissTargetSurface = false;
|
mHasDismissTargetSurface = false;
|
||||||
|
|
||||||
try {
|
|
||||||
mWindowManager.addView(mTargetViewContainer, getDismissTargetLayoutParams());
|
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());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
mWindowManager.updateViewLayout(mTargetViewContainer, getDismissTargetLayoutParams());
|
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.
|
* Removes the dismiss target and cancels any pending callbacks to show it.
|
||||||
*/
|
*/
|
||||||
public void cleanUpDismissTarget() {
|
public void cleanUpDismissTarget() {
|
||||||
if (mTargetViewContainer.isAttachedToWindow()) {
|
if (mTargetViewContainer.getParent() != null) {
|
||||||
mWindowManager.removeViewImmediate(mTargetViewContainer);
|
mWindowManager.removeViewImmediate(mTargetViewContainer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user