diff options
author | Winson Chung <winsonc@google.com> | 2013-07-19 13:49:06 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2013-07-25 14:50:49 -0700 |
commit | c763c4e4d28c256d1368be3fc1c4526c8b9bd232 (patch) | |
tree | 6de9501f86f69463c2f6f2528ab6dfd277420acc /src/com/android/launcher3/DragLayer.java | |
parent | 9c0565fe9385f92b7b2608d6506e4e5a7c500c2d (diff) | |
download | android_packages_apps_Trebuchet-c763c4e4d28c256d1368be3fc1c4526c8b9bd232.tar.gz android_packages_apps_Trebuchet-c763c4e4d28c256d1368be3fc1c4526c8b9bd232.tar.bz2 android_packages_apps_Trebuchet-c763c4e4d28c256d1368be3fc1c4526c8b9bd232.zip |
Verifying that new applications are added and fixing issue with new items getting wrong ids.
- Fixing issue where the LauncherModel would be out of sync on first migration, and subsequent crashes
Change-Id: I6f58b09b615b28958c7f941e58ff9ae0ee3ba939
Diffstat (limited to 'src/com/android/launcher3/DragLayer.java')
-rw-r--r-- | src/com/android/launcher3/DragLayer.java | 73 |
1 files changed, 2 insertions, 71 deletions
diff --git a/src/com/android/launcher3/DragLayer.java b/src/com/android/launcher3/DragLayer.java index 3c064badb..514dca29f 100644 --- a/src/com/android/launcher3/DragLayer.java +++ b/src/com/android/launcher3/DragLayer.java @@ -327,84 +327,15 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang */ public float getDescendantCoordRelativeToSelf(View descendant, int[] coord, boolean includeRootScroll) { - return DragLayer.getDescendantCoordRelativeToParent(descendant, this, + return Utilities.getDescendantCoordRelativeToParent(descendant, this, coord, includeRootScroll); } - public static float getDescendantCoordRelativeToParent(View descendant, View root, - int[] coord, boolean includeRootScroll) { - ArrayList<View> ancestorChain = new ArrayList<View>(); - - float[] pt = {coord[0], coord[1]}; - - View v = descendant; - while(v != root && v != null) { - ancestorChain.add(v); - v = (View) v.getParent(); - } - ancestorChain.add(root); - - float scale = 1.0f; - int count = ancestorChain.size(); - for (int i = 0; i < count; i++) { - View v0 = ancestorChain.get(i); - View v1 = i < count -1 ? ancestorChain.get(i + 1) : null; - - // For TextViews, scroll has a meaning which relates to the text position - // which is very strange... ignore the scroll. - if (v0 != descendant || includeRootScroll) { - pt[0] -= v0.getScrollX(); - pt[1] -= v0.getScrollY(); - } - - v0.getMatrix().mapPoints(pt); - pt[0] += v0.getLeft(); - pt[1] += v0.getTop(); - scale *= v0.getScaleX(); - } - - coord[0] = (int) Math.round(pt[0]); - coord[1] = (int) Math.round(pt[1]); - return scale; - } - /** * Inverse of {@link #getDescendantCoordRelativeToSelf(View, int[])}. */ public float mapCoordInSelfToDescendent(View descendant, int[] coord) { - ArrayList<View> ancestorChain = new ArrayList<View>(); - - float[] pt = {coord[0], coord[1]}; - - View v = descendant; - while(v != this) { - ancestorChain.add(v); - v = (View) v.getParent(); - } - ancestorChain.add(this); - - float scale = 1.0f; - Matrix inverse = new Matrix(); - int count = ancestorChain.size(); - for (int i = count - 1; i >= 0; i--) { - View ancestor = ancestorChain.get(i); - View next = i > 0 ? ancestorChain.get(i-1) : null; - - pt[0] += ancestor.getScrollX(); - pt[1] += ancestor.getScrollY(); - - if (next != null) { - pt[0] -= next.getLeft(); - pt[1] -= next.getTop(); - next.getMatrix().invert(inverse); - inverse.mapPoints(pt); - scale *= next.getScaleX(); - } - } - - coord[0] = (int) Math.round(pt[0]); - coord[1] = (int) Math.round(pt[1]); - return scale; + return Utilities.mapCoordInSelfToDescendent(descendant, this, coord); } public void getViewRectRelativeToSelf(View v, Rect r) { |