Merge "Reinflate primary action mode view after detach" into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
82f2df6108
@@ -1550,7 +1550,13 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
|
|||||||
private ActionMode createStandaloneActionMode(ActionMode.Callback callback) {
|
private ActionMode createStandaloneActionMode(ActionMode.Callback callback) {
|
||||||
endOnGoingFadeAnimation();
|
endOnGoingFadeAnimation();
|
||||||
cleanupPrimaryActionMode();
|
cleanupPrimaryActionMode();
|
||||||
if (mPrimaryActionModeView == null) {
|
// We want to create new mPrimaryActionModeView in two cases: if there is no existing
|
||||||
|
// instance at all, or if there is one, but it is detached from window. The latter case
|
||||||
|
// might happen when app is resized in multi-window mode and decor view is preserved
|
||||||
|
// along with the main app window. Keeping mPrimaryActionModeView reference doesn't cause
|
||||||
|
// app memory leaks because killMode() is called when the dismiss animation ends and from
|
||||||
|
// cleanupPrimaryActionMode() invocation above.
|
||||||
|
if (mPrimaryActionModeView == null || !mPrimaryActionModeView.isAttachedToWindow()) {
|
||||||
if (mWindow.isFloating()) {
|
if (mWindow.isFloating()) {
|
||||||
// Use the action bar theme.
|
// Use the action bar theme.
|
||||||
final TypedValue outValue = new TypedValue();
|
final TypedValue outValue = new TypedValue();
|
||||||
@@ -1616,6 +1622,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
|
|||||||
ViewStub stub = (ViewStub) findViewById(R.id.action_mode_bar_stub);
|
ViewStub stub = (ViewStub) findViewById(R.id.action_mode_bar_stub);
|
||||||
if (stub != null) {
|
if (stub != null) {
|
||||||
mPrimaryActionModeView = (ActionBarContextView) stub.inflate();
|
mPrimaryActionModeView = (ActionBarContextView) stub.inflate();
|
||||||
|
mPrimaryActionModePopup = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2278,9 +2285,14 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
|
|||||||
}
|
}
|
||||||
if (mPrimaryActionModeView != null) {
|
if (mPrimaryActionModeView != null) {
|
||||||
endOnGoingFadeAnimation();
|
endOnGoingFadeAnimation();
|
||||||
|
// Store action mode view reference, so we can access it safely when animation
|
||||||
|
// ends. mPrimaryActionModePopup is set together with mPrimaryActionModeView,
|
||||||
|
// so no need to store reference to it in separate variable.
|
||||||
|
final ActionBarContextView lastActionModeView = mPrimaryActionModeView;
|
||||||
mFadeAnim = ObjectAnimator.ofFloat(mPrimaryActionModeView, View.ALPHA,
|
mFadeAnim = ObjectAnimator.ofFloat(mPrimaryActionModeView, View.ALPHA,
|
||||||
1f, 0f);
|
1f, 0f);
|
||||||
mFadeAnim.addListener(new Animator.AnimatorListener() {
|
mFadeAnim.addListener(new Animator.AnimatorListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationStart(Animator animation) {
|
public void onAnimationStart(Animator animation) {
|
||||||
|
|
||||||
@@ -2288,13 +2300,18 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationEnd(Animator animation) {
|
public void onAnimationEnd(Animator animation) {
|
||||||
mPrimaryActionModeView.setVisibility(GONE);
|
// If mPrimaryActionModeView has changed - it means that we've
|
||||||
|
// cleared the content while preserving decor view. We don't
|
||||||
|
// want to change the state of new instances accidentally here.
|
||||||
|
if (lastActionModeView == mPrimaryActionModeView) {
|
||||||
|
lastActionModeView.setVisibility(GONE);
|
||||||
if (mPrimaryActionModePopup != null) {
|
if (mPrimaryActionModePopup != null) {
|
||||||
mPrimaryActionModePopup.dismiss();
|
mPrimaryActionModePopup.dismiss();
|
||||||
}
|
}
|
||||||
mPrimaryActionModeView.removeAllViews();
|
lastActionModeView.killMode();
|
||||||
mFadeAnim = null;
|
mFadeAnim = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationCancel(Animator animation) {
|
public void onAnimationCancel(Animator animation) {
|
||||||
|
|||||||
Reference in New Issue
Block a user