summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/FolderIcon.java
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2011-08-15 15:22:57 -0700
committerAdam Cohen <adamcohen@google.com>2011-08-15 15:36:38 -0700
commit558baaf0a0b1c6a9062a6771088098533a35222b (patch)
treefc15532d861f58493031c32f55e828b219db2ed8 /src/com/android/launcher2/FolderIcon.java
parentc273c5814d7b312628107ad4a7bff9cc64e89eae (diff)
downloadandroid_packages_apps_Trebuchet-558baaf0a0b1c6a9062a6771088098533a35222b.tar.gz
android_packages_apps_Trebuchet-558baaf0a0b1c6a9062a6771088098533a35222b.tar.bz2
android_packages_apps_Trebuchet-558baaf0a0b1c6a9062a6771088098533a35222b.zip
Fix issue 5064004, can't add shortcut to portal from AllApps
Change-Id: I99cd2108af617cf5a80b417f81a86c363fac2377
Diffstat (limited to 'src/com/android/launcher2/FolderIcon.java')
-rw-r--r--src/com/android/launcher2/FolderIcon.java77
1 files changed, 43 insertions, 34 deletions
diff --git a/src/com/android/launcher2/FolderIcon.java b/src/com/android/launcher2/FolderIcon.java
index 10928c05e..f1a150856 100644
--- a/src/com/android/launcher2/FolderIcon.java
+++ b/src/com/android/launcher2/FolderIcon.java
@@ -321,44 +321,53 @@ public class FolderIcon extends LinearLayout implements FolderListener {
float scaleRelativeToDragLayer, int index, Runnable postAnimationRunnable) {
item.cellX = -1;
item.cellY = -1;
- DragLayer dragLayer = mLauncher.getDragLayer();
- Rect from = new Rect();
- dragLayer.getViewRectRelativeToSelf(animateView, from);
- Rect to = finalRect;
- if (to == null) {
- to = new Rect();
- Workspace workspace = mLauncher.getWorkspace();
- // Set cellLayout and this to it's final state to compute final animation locations
- workspace.setFinalTransitionTransform((CellLayout) getParent().getParent());
- float scaleX = getScaleX();
- float scaleY = getScaleY();
- setScaleX(1.0f);
- setScaleY(1.0f);
- scaleRelativeToDragLayer = dragLayer.getDescendantRectRelativeToSelf(this, to);
- // Finished computing final animation locations, restore current state
- setScaleX(scaleX);
- setScaleY(scaleY);
- workspace.resetTransitionTransform((CellLayout) getParent().getParent());
- }
- int[] center = new int[2];
- float scale = getLocalCenterForIndex(index, center);
- center[0] = (int) Math.round(scaleRelativeToDragLayer * center[0]);
- center[1] = (int) Math.round(scaleRelativeToDragLayer * center[1]);
+ // Typically, the animateView corresponds to the DragView; however, if this is being done
+ // after a configuration activity (ie. for a Shortcut being dragged from AllApps) we
+ // will not have a view to animate
+ if (animateView != null) {
+ DragLayer dragLayer = mLauncher.getDragLayer();
+ Rect from = new Rect();
+ dragLayer.getViewRectRelativeToSelf(animateView, from);
+ Rect to = finalRect;
+ if (to == null) {
+ to = new Rect();
+ Workspace workspace = mLauncher.getWorkspace();
+ // Set cellLayout and this to it's final state to compute final animation locations
+ workspace.setFinalTransitionTransform((CellLayout) getParent().getParent());
+ float scaleX = getScaleX();
+ float scaleY = getScaleY();
+ setScaleX(1.0f);
+ setScaleY(1.0f);
+ scaleRelativeToDragLayer = dragLayer.getDescendantRectRelativeToSelf(this, to);
+ // Finished computing final animation locations, restore current state
+ setScaleX(scaleX);
+ setScaleY(scaleY);
+ workspace.resetTransitionTransform((CellLayout) getParent().getParent());
+ }
- to.offset(center[0] - animateView.getMeasuredWidth() / 2,
- center[1] - animateView.getMeasuredHeight() / 2);
+ int[] center = new int[2];
+ float scale = getLocalCenterForIndex(index, center);
+ center[0] = (int) Math.round(scaleRelativeToDragLayer * center[0]);
+ center[1] = (int) Math.round(scaleRelativeToDragLayer * center[1]);
- float finalAlpha = index < NUM_ITEMS_IN_PREVIEW ? 0.5f : 0f;
+ to.offset(center[0] - animateView.getMeasuredWidth() / 2,
+ center[1] - animateView.getMeasuredHeight() / 2);
- dragLayer.animateView(animateView, from, to, finalAlpha, scale * scaleRelativeToDragLayer,
- DROP_IN_ANIMATION_DURATION, new DecelerateInterpolator(2),
- new AccelerateInterpolator(2), postAnimationRunnable, false);
- postDelayed(new Runnable() {
- public void run() {
- addItem(item);
- }
- }, DROP_IN_ANIMATION_DURATION);
+ float finalAlpha = index < NUM_ITEMS_IN_PREVIEW ? 0.5f : 0f;
+
+ dragLayer.animateView(animateView, from, to, finalAlpha,
+ scale * scaleRelativeToDragLayer, DROP_IN_ANIMATION_DURATION,
+ new DecelerateInterpolator(2), new AccelerateInterpolator(2),
+ postAnimationRunnable, false);
+ postDelayed(new Runnable() {
+ public void run() {
+ addItem(item);
+ }
+ }, DROP_IN_ANIMATION_DURATION);
+ } else {
+ addItem(item);
+ }
}
public void onDrop(DragObject d) {