diff --git a/src/com/android/launcher3/popup/ArrowPopup.java b/src/com/android/launcher3/popup/ArrowPopup.java index d5b32fccd1..90285c470b 100644 --- a/src/com/android/launcher3/popup/ArrowPopup.java +++ b/src/com/android/launcher3/popup/ArrowPopup.java @@ -151,32 +151,52 @@ public abstract class ArrowPopup extends Abstrac * @param viewsToFlip number of views from the top to to flip in case of reverse order */ protected void reorderAndShow(int viewsToFlip) { + setupForDisplay(); + boolean reverseOrder = mIsAboveIcon; + if (reverseOrder) { + reverseOrder(viewsToFlip); + } + onInflationComplete(reverseOrder); + addArrow(); + animateOpen(); + } + + /** + * Shows the popup at the desired location. + */ + protected void show() { + setupForDisplay(); + onInflationComplete(false); + addArrow(); + animateOpen(); + } + + private void setupForDisplay() { setVisibility(View.INVISIBLE); mIsOpen = true; getPopupContainer().addView(this); orientAboutObject(); + } - boolean reverseOrder = mIsAboveIcon; - if (reverseOrder) { - int count = getChildCount(); - ArrayList allViews = new ArrayList<>(count); - for (int i = 0; i < count; i++) { - if (i == viewsToFlip) { - Collections.reverse(allViews); - } - allViews.add(getChildAt(i)); + private void reverseOrder(int viewsToFlip) { + int count = getChildCount(); + ArrayList allViews = new ArrayList<>(count); + for (int i = 0; i < count; i++) { + if (i == viewsToFlip) { + Collections.reverse(allViews); } - Collections.reverse(allViews); - removeAllViews(); - for (int i = 0; i < count; i++) { - addView(allViews.get(i)); - } - - orientAboutObject(); + allViews.add(getChildAt(i)); + } + Collections.reverse(allViews); + removeAllViews(); + for (int i = 0; i < count; i++) { + addView(allViews.get(i)); } - onInflationComplete(reverseOrder); - // Add the arrow. + orientAboutObject(); + } + + private void addArrow() { final Resources res = getResources(); final int arrowCenterOffset = res.getDimensionPixelSize(isAlignedWithStart() ? R.dimen.popup_arrow_horizontal_center_start @@ -214,8 +234,6 @@ public abstract class ArrowPopup extends Abstrac mArrow.setPivotX(arrowLp.width / 2); mArrow.setPivotY(mIsAboveIcon ? arrowLp.height : 0); - - animateOpen(); } protected boolean isAlignedWithStart() { diff --git a/src/com/android/launcher3/views/OptionsPopupView.java b/src/com/android/launcher3/views/OptionsPopupView.java index a8caa9ea00..80f0981af5 100644 --- a/src/com/android/launcher3/views/OptionsPopupView.java +++ b/src/com/android/launcher3/views/OptionsPopupView.java @@ -133,7 +133,7 @@ public class OptionsPopupView extends ArrowPopup view.setOnLongClickListener(popup); popup.mItemMap.put(view, item); } - popup.reorderAndShow(popup.getChildCount()); + popup.show(); } @VisibleForTesting