summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/Workspace.java
diff options
context:
space:
mode:
authorDave Hawkey <dhawkey@google.com>2013-09-19 17:16:32 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-09-19 17:16:32 +0000
commit8c082818a8ee813318e32a667883f73d7b94126a (patch)
tree866ad2c2122203217514d38d26a659492290b58a /src/com/android/launcher3/Workspace.java
parentdbdff6bc7b225255207a46fad8f536b55a18efac (diff)
parenta888158880fea53479447d883391f552604e46b6 (diff)
downloadandroid_packages_apps_Trebuchet-8c082818a8ee813318e32a667883f73d7b94126a.tar.gz
android_packages_apps_Trebuchet-8c082818a8ee813318e32a667883f73d7b94126a.tar.bz2
android_packages_apps_Trebuchet-8c082818a8ee813318e32a667883f73d7b94126a.zip
Merge "Support for dynamically adding/removing -1 screen" into jb-ub-now-indigo-rose
Diffstat (limited to 'src/com/android/launcher3/Workspace.java')
-rw-r--r--src/com/android/launcher3/Workspace.java51
1 files changed, 35 insertions, 16 deletions
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 76d60a80b..596ac1113 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -52,7 +52,6 @@ import android.view.Display;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
-import android.view.ViewParent;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.widget.TextView;
@@ -540,6 +539,24 @@ public class Workspace extends SmoothPagedView
setCurrentPage(getCurrentPage() + 1);
}
+ public void removeCustomContentPage() {
+ Launcher.addDumpLog(TAG, "10249126 - removeCustomContentPage()", true);
+
+ CellLayout customScreen = getScreenWithId(CUSTOM_CONTENT_SCREEN_ID);
+ if (customScreen == null) {
+ throw new RuntimeException("Expected custom content screen to exist");
+ }
+
+ mWorkspaceScreens.remove(CUSTOM_CONTENT_SCREEN_ID);
+ mScreenOrder.remove(CUSTOM_CONTENT_SCREEN_ID);
+ removeView(customScreen);
+ mCustomContentCallbacks = null;
+
+ // Ensure that the current page and default page are maintained.
+ mDefaultPage = mOriginalDefaultPage - 1;
+ setCurrentPage(getCurrentPage() - 1);
+ }
+
public void addToCustomContentPage(View customContent, CustomContentCallbacks callbacks) {
if (getPageIndexForScreenId(CUSTOM_CONTENT_SCREEN_ID) < 0) {
throw new RuntimeException("Expected custom content screen to exist");
@@ -1326,30 +1343,32 @@ public class Workspace extends SmoothPagedView
}
private void updateStateForCustomContent(int screenCenter) {
+ float translationX = 0;
+ float progress = 0;
if (hasCustomContent()) {
int index = mScreenOrder.indexOf(CUSTOM_CONTENT_SCREEN_ID);
int scrollDelta = getScrollForPage(index + 1) - getScrollX();
- float translationX = Math.max(scrollDelta, 0);
- float progress = (1.0f * scrollDelta) /
+ translationX = Math.max(scrollDelta, 0);
+ progress = (1.0f * scrollDelta) /
(getScrollForPage(index + 1) - getScrollForPage(index));
progress = Math.max(0, progress);
+ }
- if (Float.compare(progress, mLastCustomContentScrollProgress) == 0) return;
- mLastCustomContentScrollProgress = progress;
+ if (Float.compare(progress, mLastCustomContentScrollProgress) == 0) return;
+ mLastCustomContentScrollProgress = progress;
- setBackgroundAlpha(progress * 0.8f);
+ setBackgroundAlpha(progress * 0.8f);
- if (mLauncher.getHotseat() != null) {
- mLauncher.getHotseat().setTranslationX(translationX);
- }
+ if (mLauncher.getHotseat() != null) {
+ mLauncher.getHotseat().setTranslationX(translationX);
+ }
- if (getPageIndicator() != null) {
- getPageIndicator().setTranslationX(translationX);
- }
+ if (getPageIndicator() != null) {
+ getPageIndicator().setTranslationX(translationX);
+ }
- if (mCustomContentCallbacks != null) {
- mCustomContentCallbacks.onScrollProgressChanged(progress);
- }
+ if (mCustomContentCallbacks != null) {
+ mCustomContentCallbacks.onScrollProgressChanged(progress);
}
}
@@ -3809,7 +3828,7 @@ public class Workspace extends SmoothPagedView
@Override
protected void dispatchRestoreInstanceState(SparseArray<Parcelable> container) {
// We don't dispatch restoreInstanceState to our children using this code path.
- // Some pages will be restored immediately as their items are bound immediately, and
+ // Some pages will be restored immediately as their items are bound immediately, and
// others we will need to wait until after their items are bound.
mSavedStates = container;
}