diff options
author | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-02-19 01:35:23 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-02-19 01:35:23 +0100 |
commit | 746f9591553a5373e8ce1211ed066cbbf6a31cb5 (patch) | |
tree | f4832ba070106fc7e892c8a6ee1272233d4463ab /src/de/gultsch/chat/utils/PhoneHelper.java | |
parent | 0392e6b2dc4c9bc4063fce5c1b4817c3c6460426 (diff) |
roster versioning. roster updates on air. performance fixes in conversation listview
Diffstat (limited to 'src/de/gultsch/chat/utils/PhoneHelper.java')
-rw-r--r-- | src/de/gultsch/chat/utils/PhoneHelper.java | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/de/gultsch/chat/utils/PhoneHelper.java b/src/de/gultsch/chat/utils/PhoneHelper.java index 3a53c08f..14773caa 100644 --- a/src/de/gultsch/chat/utils/PhoneHelper.java +++ b/src/de/gultsch/chat/utils/PhoneHelper.java @@ -1,6 +1,5 @@ package de.gultsch.chat.utils; -import java.util.ArrayList; import java.util.Hashtable; import android.app.Activity; @@ -11,14 +10,19 @@ import android.content.Loader.OnLoadCompleteListener; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; +import android.os.Looper; import android.provider.ContactsContract; import android.provider.ContactsContract.Profile; public class PhoneHelper { public static void loadPhoneContacts(Context context, final OnPhoneContactsLoadedListener listener) { + if (Looper.myLooper()==null) { + Looper.prepare(); + } + final Looper mLooper = Looper.myLooper(); final Hashtable<String, Bundle> phoneContacts = new Hashtable<String, Bundle>(); - + final String[] PROJECTION = new String[] { ContactsContract.Data._ID, ContactsContract.Data.DISPLAY_NAME, @@ -31,7 +35,7 @@ public class PhoneHelper { + "\") AND (" + ContactsContract.CommonDataKinds.Im.PROTOCOL + "=\"" + ContactsContract.CommonDataKinds.Im.PROTOCOL_JABBER + "\")"; - + CursorLoader mCursorLoader = new CursorLoader(context, ContactsContract.Data.CONTENT_URI, PROJECTION, SELECTION, null, null); @@ -61,6 +65,7 @@ public class PhoneHelper { if (listener!=null) { listener.onPhoneContactsLoaded(phoneContacts); } + mLooper.quit(); } }); mCursorLoader.startLoading(); |