summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/AppsCustomizeTabHost.java
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2011-10-17 10:20:07 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-10-17 10:20:07 -0700
commit7fe4f8ba0a3c065773f3166940f6b34e42194389 (patch)
tree1f69e23e541313e8b6a15c6f255db6f4269ce994 /src/com/android/launcher2/AppsCustomizeTabHost.java
parent6029d75e75c54ce6f4e69a5dde2cdbc993d772b7 (diff)
parent0cd3b64e607cc1f81ed49b00ef7398c2a2b7a48d (diff)
downloadandroid_packages_apps_Trebuchet-7fe4f8ba0a3c065773f3166940f6b34e42194389.tar.gz
android_packages_apps_Trebuchet-7fe4f8ba0a3c065773f3166940f6b34e42194389.tar.bz2
android_packages_apps_Trebuchet-7fe4f8ba0a3c065773f3166940f6b34e42194389.zip
Merge "Add ability to swipe from apps to widgets in AllAppsCustomize (issue 5453016)" into ics-mr0
Diffstat (limited to 'src/com/android/launcher2/AppsCustomizeTabHost.java')
-rw-r--r--src/com/android/launcher2/AppsCustomizeTabHost.java114
1 files changed, 62 insertions, 52 deletions
diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java
index d37b1c902..404b088dc 100644
--- a/src/com/android/launcher2/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher2/AppsCustomizeTabHost.java
@@ -48,6 +48,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
private ViewGroup mTabs;
private ViewGroup mTabsContainer;
private AppsCustomizePagedView mAppsCustomizePane;
+ private boolean mSuppressContentCallback = false;
private ImageView mAnimationBuffer;
private boolean mInTransition;
@@ -167,6 +168,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
private void onTabChangedStart() {
mAppsCustomizePane.hideScrollingIndicator(false);
}
+
private void onTabChangedEnd(AppsCustomizePagedView.ContentType type) {
mAppsCustomizePane.setContentType(type);
}
@@ -174,59 +176,67 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
@Override
public void onTabChanged(String tabId) {
final AppsCustomizePagedView.ContentType type = getContentTypeForTabTag(tabId);
- if (!mAppsCustomizePane.isContentType(type)) {
- // Animate the changing of the tab content by fading pages in and out
- final Resources res = getResources();
- final int duration = res.getInteger(R.integer.config_tabTransitionDuration);
-
- // We post a runnable here because there is a delay while the first page is loading and
- // the feedback from having changed the tab almost feels better than having it stick
- post(new Runnable() {
- @Override
- public void run() {
- // Setup the animation buffer
- Bitmap b = Bitmap.createBitmap(mAppsCustomizePane.getMeasuredWidth(),
- mAppsCustomizePane.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
- Canvas c = new Canvas(b);
- mAppsCustomizePane.draw(c);
- mAppsCustomizePane.setAlpha(0f);
- mAnimationBuffer.setImageBitmap(b);
- mAnimationBuffer.setAlpha(1f);
- mAnimationBuffer.setVisibility(View.VISIBLE);
- c.setBitmap(null);
- b = null;
-
- // Toggle the new content
- onTabChangedStart();
- onTabChangedEnd(type);
-
- // Animate the transition
- ObjectAnimator outAnim = ObjectAnimator.ofFloat(mAnimationBuffer, "alpha", 0f);
- outAnim.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- mAnimationBuffer.setVisibility(View.GONE);
- mAnimationBuffer.setImageBitmap(null);
- }
- });
- ObjectAnimator inAnim = ObjectAnimator.ofFloat(mAppsCustomizePane, "alpha", 1f);
- inAnim.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- if (!LauncherApplication.isScreenLarge()) {
- mAppsCustomizePane.flashScrollingIndicator();
- }
- mAppsCustomizePane.loadAssociatedPages(
- mAppsCustomizePane.getCurrentPage());
- }
- });
- AnimatorSet animSet = new AnimatorSet();
- animSet.playTogether(outAnim, inAnim);
- animSet.setDuration(duration);
- animSet.start();
- }
- });
+ if (mSuppressContentCallback) {
+ mSuppressContentCallback = false;
+ return;
}
+
+ // Animate the changing of the tab content by fading pages in and out
+ final Resources res = getResources();
+ final int duration = res.getInteger(R.integer.config_tabTransitionDuration);
+
+ // We post a runnable here because there is a delay while the first page is loading and
+ // the feedback from having changed the tab almost feels better than having it stick
+ post(new Runnable() {
+ @Override
+ public void run() {
+ // Setup the animation buffer
+ Bitmap b = Bitmap.createBitmap(mAppsCustomizePane.getMeasuredWidth(),
+ mAppsCustomizePane.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
+ Canvas c = new Canvas(b);
+ mAppsCustomizePane.draw(c);
+ mAppsCustomizePane.setAlpha(0f);
+ mAnimationBuffer.setImageBitmap(b);
+ mAnimationBuffer.setAlpha(1f);
+ mAnimationBuffer.setVisibility(View.VISIBLE);
+ c.setBitmap(null);
+ b = null;
+
+ // Toggle the new content
+ onTabChangedStart();
+ onTabChangedEnd(type);
+
+ // Animate the transition
+ ObjectAnimator outAnim = ObjectAnimator.ofFloat(mAnimationBuffer, "alpha", 0f);
+ outAnim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mAnimationBuffer.setVisibility(View.GONE);
+ mAnimationBuffer.setImageBitmap(null);
+ }
+ });
+ ObjectAnimator inAnim = ObjectAnimator.ofFloat(mAppsCustomizePane, "alpha", 1f);
+ inAnim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ if (!LauncherApplication.isScreenLarge()) {
+ mAppsCustomizePane.flashScrollingIndicator();
+ }
+ mAppsCustomizePane.loadAssociatedPages(
+ mAppsCustomizePane.getCurrentPage());
+ }
+ });
+ AnimatorSet animSet = new AnimatorSet();
+ animSet.playTogether(outAnim, inAnim);
+ animSet.setDuration(duration);
+ animSet.start();
+ }
+ });
+ }
+
+ public void setCurrentTabFromContent(AppsCustomizePagedView.ContentType type) {
+ mSuppressContentCallback = true;
+ setCurrentTabByTag(getTabTagForContentType(type));
}
/**