Merge "Fix issue with loading profile photo."
diff --git a/src/com/android/contacts/list/PhoneNumberListAdapter.java b/src/com/android/contacts/list/PhoneNumberListAdapter.java
index fee1064..53a9e5f 100644
--- a/src/com/android/contacts/list/PhoneNumberListAdapter.java
+++ b/src/com/android/contacts/list/PhoneNumberListAdapter.java
@@ -27,6 +27,7 @@
import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.Directory;
import android.text.TextUtils;
+import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
@@ -34,6 +35,7 @@
* A cursor adapter for the {@link Phone#CONTENT_TYPE} content type.
*/
public class PhoneNumberListAdapter extends ContactEntryListAdapter {
+ private static final String TAG = PhoneNumberListAdapter.class.getSimpleName();
protected static final String[] PHONES_PROJECTION = new String[] {
Phone._ID, // 0
@@ -137,11 +139,18 @@
/**
* Builds a {@link Data#CONTENT_URI} for the given cursor position.
+ *
+ * @return Uri for the data. may be null if the cursor is not ready.
*/
public Uri getDataUri(int position) {
Cursor cursor = ((Cursor)getItem(position));
- long id = cursor.getLong(PHONE_ID_COLUMN_INDEX);
- return ContentUris.withAppendedId(Data.CONTENT_URI, id);
+ if (cursor != null) {
+ long id = cursor.getLong(PHONE_ID_COLUMN_INDEX);
+ return ContentUris.withAppendedId(Data.CONTENT_URI, id);
+ } else {
+ Log.w(TAG, "Cursor was null in getDataUri() call. Returning null instead.");
+ return null;
+ }
}
@Override
diff --git a/src/com/android/contacts/list/PhoneNumberPickerFragment.java b/src/com/android/contacts/list/PhoneNumberPickerFragment.java
index b40f80a..3be55ce 100644
--- a/src/com/android/contacts/list/PhoneNumberPickerFragment.java
+++ b/src/com/android/contacts/list/PhoneNumberPickerFragment.java
@@ -21,6 +21,7 @@
import android.content.Intent;
import android.net.Uri;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -30,6 +31,8 @@
*/
public class PhoneNumberPickerFragment extends ContactEntryListFragment<ContactEntryListAdapter>
implements OnShortcutIntentCreatedListener {
+ private static final String TAG = PhoneNumberPickerFragment.class.getSimpleName();
+
private OnPhoneNumberPickerActionListener mListener;
private String mShortcutAction;
@@ -58,12 +61,20 @@
@Override
protected void onItemClick(int position, long id) {
+ final Uri phoneUri;
if (!isLegacyCompatibilityMode()) {
PhoneNumberListAdapter adapter = (PhoneNumberListAdapter)getAdapter();
- pickPhoneNumber(adapter.getDataUri(position));
+ phoneUri = adapter.getDataUri(position);
+
} else {
LegacyPhoneNumberListAdapter adapter = (LegacyPhoneNumberListAdapter)getAdapter();
- pickPhoneNumber(adapter.getPhoneUri(position));
+ phoneUri = adapter.getPhoneUri(position);
+ }
+
+ if (phoneUri != null) {
+ pickPhoneNumber(phoneUri);
+ } else {
+ Log.w(TAG, "Item at " + position + " was clicked before adapter is ready. Ignoring");
}
}