diff options
author | yueg <yueg@google.com> | 2017-07-10 14:39:31 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-07-11 08:00:44 -0700 |
commit | 7a4b7090da0366e02e742325a6c531c4bdaff0d0 (patch) | |
tree | 8e43d6bad9a683747e724f496c26700f51484d68 /java/com/android | |
parent | b63f4ccc97375947833110dbb910074f122207d3 (diff) |
Fix NPE in PhoneFavoriteTileView.onClick.
Although we don't know the reason why v.getParent() can be null, we can avoid calling it.
Test: manual
PiperOrigin-RevId: 161442696
Change-Id: I07af0da9b64fb3fa77b01c0b619837a79d593b67
Diffstat (limited to 'java/com/android')
-rw-r--r-- | java/com/android/dialer/app/list/PhoneFavoriteTileView.java | 8 | ||||
-rw-r--r-- | java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java | 1 |
2 files changed, 7 insertions, 2 deletions
diff --git a/java/com/android/dialer/app/list/PhoneFavoriteTileView.java b/java/com/android/dialer/app/list/PhoneFavoriteTileView.java index eb4f8e967..30870eb39 100644 --- a/java/com/android/dialer/app/list/PhoneFavoriteTileView.java +++ b/java/com/android/dialer/app/list/PhoneFavoriteTileView.java @@ -62,6 +62,7 @@ public abstract class PhoneFavoriteTileView extends ContactTileView { private String mPhoneNumberString; private boolean isPinned; private boolean isStarred; + private int position = -1; public PhoneFavoriteTileView(Context context, AttributeSet attrs) { super(context, attrs); @@ -126,8 +127,7 @@ public abstract class PhoneFavoriteTileView extends ContactTileView { CallSpecificAppData.Builder callSpecificAppData = CallSpecificAppData.newBuilder() .setCallInitiationType(CallInitiationType.Type.SPEED_DIAL) - .setSpeedDialContactPosition( - ((PhoneFavoriteListView) v.getParent()).getPositionForView(v)); + .setSpeedDialContactPosition(position); if (isStarred) { callSpecificAppData.addSpeedDialContactType(SpeedDialContactType.Type.STARRED_CONTACT); } else { @@ -182,4 +182,8 @@ public abstract class PhoneFavoriteTileView extends ContactTileView { // Unlike Contacts' tiles, the Dialer's favorites tiles are square. return false; } + + public void setPosition(int position) { + this.position = position; + } } diff --git a/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java b/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java index 876fbf146..dbd601a7d 100644 --- a/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java +++ b/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java @@ -440,6 +440,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop tileView.setPhotoManager(mPhotoManager); tileView.setListener(mListener); tileView.loadFromContact(getItem(position)); + tileView.setPosition(position); return tileView; } |