List of usage examples for android.support.v4.content CursorLoader CursorLoader
public CursorLoader(Context context, Uri uri, String[] projection, String selection, String[] selectionArgs,
String sortOrder)
From source file:com.gsma.rcs.ri.messaging.GroupTalkView.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle arg) { /* Create a new CursorLoader with the following query parameters. */ return new CursorLoader(this, mUriHistoryProvider, PROJ_CHAT_MSG, WHERE_CLAUSE, new String[] { mChatId }, ORDER_CHAT_MSG);/*from w w w .j av a 2s. c o m*/ }
From source file:co.taqat.call.ChatFragment.java
public String getRealPathFromURI(Uri contentUri) { String[] proj = { MediaStore.Images.Media.DATA }; CursorLoader loader = new CursorLoader(getActivity(), contentUri, proj, null, null, null); Cursor cursor = loader.loadInBackground(); if (cursor != null && cursor.moveToFirst()) { int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); String result = cursor.getString(column_index); cursor.close();//from w w w . j a v a 2 s.c o m return result; } return null; }
From source file:com.kncwallet.wallet.ui.SendCoinsFragment.java
@Override public void onResume() { super.onResume(); contentResolver.registerContentObserver(AddressBookProvider.contentUri(activity.getPackageName()), true, contentObserver);/* ww w . ja va2s . c om*/ amountCalculatorLink.setListener(amountsListener); loaderManager.initLoader(ID_RATE_LOADER, null, rateLoaderCallbacks); updateView(); new Handler().post(new Runnable() { @Override public void run() { clearActionMode(); } }); createWalletAddressSelection(); loaderManager.restartLoader(ID_LIST_LOADER, null, new LoaderCallbacks<Cursor>() { @Override public Loader<Cursor> onCreateLoader(final int id, final Bundle args) { final Uri uri = AddressBookProvider.contentUri(activity.getPackageName()); return new CursorLoader(activity, uri, null, AddressBookProvider.SELECTION_ACTIVE_STATE, new String[] { walletAddressesSelection != null ? walletAddressesSelection : "" }, AddressBookProvider.KEY_LABEL + " COLLATE LOCALIZED ASC"); } @Override public void onLoadFinished(final Loader<Cursor> loader, final Cursor data) { contactListAdapter.swapCursor(data); } @Override public void onLoaderReset(final Loader<Cursor> loader) { contactListAdapter.swapCursor(null); } }); }
From source file:com.gsma.rcs.ri.sharing.SharingListView.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { if (LogUtils.isActive) { Log.d(LOGTAG, "onCreateLoader " + id); }//from w w w.j a va 2 s . c o m List<Integer> selectedProviderIds = getSelectedProviderIds(); String contact = getSelectedContact(); if (!selectedProviderIds.isEmpty()) { Uri uri = createSharingLogUri(selectedProviderIds); // Create a new CursorLoader with the following query parameters. if (getString(R.string.label_sharing_log_contact_spinner_default_value).equals(contact)) { // No contact is selected return new CursorLoader(this, uri, PROJECTION, null, null, SORT_BY); } return new CursorLoader(this, uri, PROJECTION, WHERE_CLAUSE_WITH_CONTACT, new String[] { contact }, SORT_BY); } return null; }
From source file:com.google.android.apps.muzei.gallery.GallerySettingsActivity.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { return new CursorLoader(this, GalleryContract.ChosenPhotos.CONTENT_URI, new String[] { BaseColumns._ID, GalleryContract.ChosenPhotos.COLUMN_NAME_URI }, null, null, null); }
From source file:com.fbartnitzek.tasteemall.addentry.AddLocationFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { Log.v(LOG_TAG,//from ww w .ja v a2 s . co m "onCreateLoader, hashCode=" + this.hashCode() + ", " + "id = [" + id + "], args = [" + args + "]"); if (mContentUri != null) { return new CursorLoader(getActivity(), mContentUri, QueryColumns.LocationFragment.ShowQuery.COLUMNS, null, null, null); } else { return null; } }
From source file:com.lewa.crazychapter11.MainActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); switch (requestCode) { case PICK_CONTACT: if (resultCode == Activity.RESULT_OK) { Uri contactData = intent.getData(); CursorLoader cursorLoader = new CursorLoader(this, contactData, null, null, null, null); Cursor cursor = cursorLoader.loadInBackground(); if (cursor != null && cursor.moveToFirst()) { Log.i("algerheContact", " comhere 111"); String contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID)); String name = cursor .getString(cursor.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); String phoneNumber = "????"; Cursor phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + "=" + contactId, null, null); if (phones == null) { return; }//from ww w. j a v a2s . co m // Log.i("algerheContact"," comhere 222 phones.moveToFirst()="+phones.moveToFirst()); if (phones.moveToFirst()) { phoneNumber = phones .getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); } phones.close(); EditText show = (EditText) findViewById(R.id.show); show.setText(name); EditText phone = (EditText) findViewById(R.id.phone); phone.setText(phoneNumber); show.setVisibility(View.GONE); phone.setVisibility(View.GONE); } cursor.close(); } break; } if (requestCode == 0 && resultCode == 0 && intent != null) { Bundle data = intent.getExtras(); if (data == null) { return; } String resultArms = data.getString("armType"); String showArms = "?" + resultArms; show_txt = (EditText) findViewById(R.id.show_txt); if (resultArms != null && show_txt != null) { show_txt.setText(showArms); } } }
From source file:com.example.android.contactslist.ui.eventEntry.EventEntryFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { switch (id) { // main queries to load the required information case ContactDetailQuery.QUERY_ID: // This query loads main contact details, see // ContactDetailQuery for more information. return new CursorLoader(getActivity(), mContactUri, ContactDetailQuery.PROJECTION, null, //ContactDetailQuery.SELECTION, null, //ContactDetailQuery.ARGS, null);//from w w w. jav a2 s . c o m case ContactAddressQuery.QUERY_ID: // This query loads contact address details, see // ContactAddressQuery for more information. final Uri uri = Uri.withAppendedPath(mContactUri, Contacts.Data.CONTENT_DIRECTORY); return new CursorLoader(getActivity(), uri, ContactAddressQuery.PROJECTION, ContactAddressQuery.SELECTION, null, null); case ContactStatsQuery.QUERY_ID: // This query loads data from ContactStatsContentProvider. //prepare the shere and args clause for the contact lookup key final String where = ContactStatsContract.TableEntry.KEY_CONTACT_KEY + " = ? "; String[] whereArgs = { mContactLookupKey }; return new CursorLoader(getActivity(), ContactStatsContentProvider.CONTACT_STATS_URI, null, where, whereArgs, null); case ContactVoiceNumberQuery.QUERY_ID: // get all the phone numbers for this contact, sorted by whether it is super primary // https://android.googlesource.com/platform/development/+/gingerbread/samples/ApiDemos/src/com/example/android/apis/view/List7.java return new CursorLoader(getActivity(), ContactsContract.CommonDataKinds.Phone.CONTENT_URI, new String[] { ContactsContract.CommonDataKinds.Phone.NUMBER }, //null ContactsContract.CommonDataKinds.Phone.LOOKUP_KEY + " = ?", new String[] { mContactLookupKey }, ContactsContract.CommonDataKinds.Phone.IS_SUPER_PRIMARY + " DESC"); case ContactSMSNumberQuery.QUERY_ID: // get all the phone numbers for this contact, sorted by whether it is super primary return new CursorLoader(getActivity(), ContactsContract.CommonDataKinds.Phone.CONTENT_URI, new String[] { ContactsContract.CommonDataKinds.Phone.NUMBER }, //null ContactsContract.CommonDataKinds.Phone.LOOKUP_KEY + " = ? AND " + ContactsContract.CommonDataKinds.Phone.TYPE + " = ?", new String[] { mContactLookupKey, Integer.toString(ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE) }, ContactsContract.CommonDataKinds.Phone.IS_SUPER_PRIMARY + " DESC"); case ContactEmailAddressQuery.QUERY_ID: // get all the phone numbers for this contact, sorted by whether it is super primary return new CursorLoader(getActivity(), ContactsContract.CommonDataKinds.Email.CONTENT_URI, new String[] { ContactsContract.CommonDataKinds.Email.ADDRESS }, //null ContactsContract.CommonDataKinds.Phone.LOOKUP_KEY + " = ? ", new String[] { mContactLookupKey }, ContactsContract.CommonDataKinds.Phone.IS_SUPER_PRIMARY + " DESC"); } return null; }
From source file:com.gsma.rcs.ri.messaging.OneToOneTalkView.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { /* Create a new CursorLoader with the following query parameters. */ return new CursorLoader(this, mUriHistoryProvider, PROJECTION, WHERE_CLAUSE, new String[] { mContact.toString() }, ORDER_ASC); }
From source file:com.dsdar.thosearoundme.util.ContactsListFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { // If this is the loader for finding contacts in the Contacts Provider // (the only one supported) if (id == ContactsQuery.QUERY_ID) { Uri contentUri;/*from w ww . j a v a 2 s. co m*/ // There are two types of searches, one which displays all contacts // and // one which filters contacts by a search query. If mSearchTerm is // set // then a search query has been entered and the latter should be // used. if (mSearchTerm == null) { // Since there's no search string, use the content URI that // searches the entire // Contacts table contentUri = ContactsQuery.CONTENT_URI; } else { // Since there's a search string, use the special content Uri // that searches the // Contacts table. The URI consists of a base Uri and the search // string. contentUri = Uri.withAppendedPath(ContactsQuery.FILTER_URI, Uri.encode(mSearchTerm)); } // Returns a new CursorLoader for querying the Contacts table. No // arguments are used // for the selection clause. The search string is either encoded // onto the content URI, // or no contacts search string is used. The other search criteria // are constants. See // the ContactsQuery interface. return new CursorLoader(getActivity(), contentUri, ContactsQuery.PROJECTION, ContactsQuery.SELECTION, null, ContactsQuery.SORT_ORDER); } Log.e(TAG, "onCreateLoader - incorrect ID provided (" + id + ")"); return null; }