Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1113)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/appmenu/AppMenu.java

Issue 388803006: Add per-item animations to the menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased again Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/appmenu/AppMenu.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/appmenu/AppMenu.java b/chrome/android/java/src/org/chromium/chrome/browser/appmenu/AppMenu.java
index ed11493337fe0f4008eec88bed92d6fe67ca255d..94fe6e3489884beedfcff05708415df7a8e288a3 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/appmenu/AppMenu.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/appmenu/AppMenu.java
@@ -4,6 +4,8 @@
package org.chromium.chrome.browser.appmenu;
+import android.animation.Animator;
+import android.animation.AnimatorSet;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Rect;
@@ -147,6 +149,15 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
mPopup.getListView().setVerticalFadingEdgeEnabled(true);
mPopup.getListView().setFadingEdgeLength(mVerticalFadeDistance);
}
+
+ mPopup.getListView().addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
+ @Override
+ public void onLayoutChange(View v, int left, int top, int right, int bottom,
+ int oldLeft, int oldTop, int oldRight, int oldBottom) {
+ mPopup.getListView().removeOnLayoutChangeListener(this);
+ runMenuItemEnterAnimations();
+ }
+ });
}
private void setPopupOffset(ListPopupWindow popup, int screenRotation, Rect appRect) {
@@ -225,7 +236,9 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
*/
void dismiss() {
mHandler.appMenuDismissed();
- if (isShowing()) mPopup.dismiss();
+ if (isShowing()) {
+ mPopup.dismiss();
+ }
}
/**
@@ -277,4 +290,24 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
mPopup.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
}
}
+
+ private void runMenuItemEnterAnimations() {
+ AnimatorSet animation = new AnimatorSet();
+ AnimatorSet.Builder builder = null;
+
+ ViewGroup list = mPopup.getListView();
+ for (int i = 0; i < list.getChildCount(); i++) {
+ View view = list.getChildAt(i);
+ Object animatorObject = view.getTag(R.id.menu_item_enter_anim_id);
+ if (animatorObject != null) {
+ if (builder == null) {
+ builder = animation.play((Animator) animatorObject);
+ } else {
+ builder.with((Animator) animatorObject);
+ }
+ }
+ }
+
+ animation.start();
+ }
}

Powered by Google App Engine
This is Rietveld 408576698