aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/utils/PhoneHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu/siacs/conversations/utils/PhoneHelper.java')
-rw-r--r--src/eu/siacs/conversations/utils/PhoneHelper.java22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/eu/siacs/conversations/utils/PhoneHelper.java b/src/eu/siacs/conversations/utils/PhoneHelper.java
index 63c17761..25cff099 100644
--- a/src/eu/siacs/conversations/utils/PhoneHelper.java
+++ b/src/eu/siacs/conversations/utils/PhoneHelper.java
@@ -2,6 +2,7 @@ package eu.siacs.conversations.utils;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.RejectedExecutionException;
import android.content.Context;
import android.content.CursorLoader;
@@ -18,7 +19,7 @@ public class PhoneHelper {
public static void loadPhoneContacts(Context context,
final OnPhoneContactsLoadedListener listener) {
final List<Bundle> phoneContacts = new ArrayList<Bundle>();
-
+
final String[] PROJECTION = new String[] { ContactsContract.Data._ID,
ContactsContract.Data.DISPLAY_NAME,
ContactsContract.Data.PHOTO_THUMBNAIL_URI,
@@ -38,7 +39,7 @@ public class PhoneHelper {
@Override
public void onLoadComplete(Loader<Cursor> arg0, Cursor cursor) {
- if (cursor==null) {
+ if (cursor == null) {
return;
}
while (cursor.moveToNext()) {
@@ -55,8 +56,10 @@ public class PhoneHelper {
.getColumnIndex(ContactsContract.Data.PHOTO_THUMBNAIL_URI)));
contact.putString("lookup", cursor.getString(cursor
.getColumnIndex(ContactsContract.Data.LOOKUP_KEY)));
-
- contact.putString("jid",cursor.getString(cursor
+
+ contact.putString(
+ "jid",
+ cursor.getString(cursor
.getColumnIndex(ContactsContract.CommonDataKinds.Im.DATA)));
phoneContacts.add(contact);
}
@@ -65,12 +68,17 @@ public class PhoneHelper {
}
}
});
- mCursorLoader.startLoading();
+ try {
+ mCursorLoader.startLoading();
+ } catch (RejectedExecutionException e) {
+ if (listener != null) {
+ listener.onPhoneContactsLoaded(phoneContacts);
+ }
+ }
}
public static Uri getSefliUri(Context context) {
- String[] mProjection = new String[] { Profile._ID,
- Profile.PHOTO_URI };
+ String[] mProjection = new String[] { Profile._ID, Profile.PHOTO_URI };
Cursor mProfileCursor = context.getContentResolver().query(
Profile.CONTENT_URI, mProjection, null, null, null);