summaryrefslogtreecommitdiff
path: root/src/com/android/dialer/list/PhoneFavoriteTileView.java
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2013-10-01 09:38:53 -0700
committerYorke Lee <yorkelee@google.com>2013-10-01 09:58:34 -0700
commit05aaae3bc5541a3319b834929ca8eb41e300aa79 (patch)
tree810e54666c423053d0bbf4632790af78fb156a2d /src/com/android/dialer/list/PhoneFavoriteTileView.java
parent19518d2db02f4e6a4f7f32dfd969864ff0f55114 (diff)
Fix crash when dragging a contact to searchbox
Also fix drag handling so that dropping outside the listview will also complete the drag animation. Bug: 11017468 Change-Id: I968cc8463e9d567b0a8c62f851c067d589571c6d
Diffstat (limited to 'src/com/android/dialer/list/PhoneFavoriteTileView.java')
-rw-r--r--src/com/android/dialer/list/PhoneFavoriteTileView.java11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/com/android/dialer/list/PhoneFavoriteTileView.java b/src/com/android/dialer/list/PhoneFavoriteTileView.java
index ac89fd693..371c8057c 100644
--- a/src/com/android/dialer/list/PhoneFavoriteTileView.java
+++ b/src/com/android/dialer/list/PhoneFavoriteTileView.java
@@ -20,6 +20,7 @@ import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
+import android.content.ClipData;
import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
@@ -68,6 +69,10 @@ public abstract class PhoneFavoriteTileView extends ContactTileView {
/** Custom gesture detector.*/
protected GestureDetector mGestureDetector;
+ // Dummy clip data object that is attached to drag shadows so that text views
+ // don't crash with an NPE if the drag shadow is released in their bounds
+ private static final ClipData EMPTY_CLIP_DATA = ClipData.newPlainText("", "");
+
public PhoneFavoriteTileView(Context context, AttributeSet attrs) {
super(context, attrs);
mAnimationDuration = context.getResources().getInteger(R.integer.fade_duration);
@@ -99,15 +104,15 @@ public abstract class PhoneFavoriteTileView extends ContactTileView {
final PhoneFavoriteTileView view = (PhoneFavoriteTileView) v;
// NOTE The drag shadow is handled in the ListView.
if (view instanceof PhoneFavoriteRegularRowView) {
- final ContactTileRow parent = (ContactTileRow) view.getParentRow();
+ final ContactTileRow parent = view.getParentRow();
// If the view is regular row, start drag the row view.
// Drag is not available for the item exceeds the PIN_LIMIT.
if (parent.getRegularRowItemIndex() < PhoneFavoritesTileAdapter.PIN_LIMIT) {
- parent.startDrag(null, new View.DragShadowBuilder(), null, 0);
+ parent.startDrag(EMPTY_CLIP_DATA, new View.DragShadowBuilder(), null, 0);
}
} else {
// If the view is a tile view, start drag the tile.
- view.startDrag(null, new View.DragShadowBuilder(), null, 0);
+ view.startDrag(EMPTY_CLIP_DATA, new View.DragShadowBuilder(), null, 0);
}
return true;
}