Example usage for android.support.v4.content CursorLoader setSelectionArgs

List of usage examples for android.support.v4.content CursorLoader setSelectionArgs

Introduction

In this page you can find the example usage for android.support.v4.content CursorLoader setSelectionArgs.

Prototype

public void setSelectionArgs(String[] selectionArgs) 

Source Link

Usage

From source file:com.silentcircle.contacts.list.ScDefaultContactListAdapter.java

private void configureSelection(CursorLoader loader, long directoryId, ContactListFilter filter) {
    if (filter == null) {
        return;/*from   w w w . j a  va  2 s  .c om*/
    }

    if (directoryId != Directory.DEFAULT) {
        return;
    }

    StringBuilder selection = new StringBuilder();
    List<String> selectionArgs = new ArrayList<String>();

    selection.append(RawContacts.CONTACT_TYPE + "=" + RawContacts.CONTACT_TYPE_NORMAL);

    switch (filter.filterType) {
    case ContactListFilter.FILTER_TYPE_SINGLE_CONTACT: {
        // We have already added the lookup key to the URI, which takes care of this
        // filter
        break;
    }
    case ContactListFilter.FILTER_TYPE_STARRED: {
        selection.append(" AND " + RawContacts.STARRED + "!=0");
        break;
    }
    //  TODO           case ContactListFilter.FILTER_TYPE_WITH_PHONE_NUMBERS_ONLY: {
    //                selection.append(Contacts.HAS_PHONE_NUMBER + "=1");
    //                break;
    //            }
    //            case ContactListFilter.FILTER_TYPE_CUSTOM: {
    //                selection.append(RawContacts.IN_VISIBLE_GROUP + "=1");
    //                if (isCustomFilterForPhoneNumbersOnly()) {
    //                    selection.append(" AND " + Contacts.HAS_PHONE_NUMBER + "=1");
    //                }
    //                break;
    //            }
    //            case ContactListFilter.FILTER_TYPE_ACCOUNT: {
    //                // We use query parameters for account filter, so no selection to add here.
    //                break;
    //            }
    }
    loader.setSelection(selection.toString());
    loader.setSelectionArgs(selectionArgs.toArray(new String[0]));
}

From source file:com.amsterdam.marktbureau.makkelijkemarkt.DagvergunningFragment.java

/**
 * Create the loader that will load the dagvergunning from the db when we are editing an existing one
 * @param id the unique loader id/* w ww. j a  v a 2  s.c o  m*/
 * @param args an arguments bundle that contains the dagvergunning id
 * @return a cursor with one record containing the joined dagvergunning details
 */
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

    // load the dagvergunning with given id in the arguments bundle
    if (args != null && args.getInt(MakkelijkeMarktProvider.Dagvergunning.COL_ID, 0) != 0) {
        CursorLoader loader = new CursorLoader(getActivity());
        loader.setUri(MakkelijkeMarktProvider.mUriDagvergunningJoined);
        loader.setSelection(MakkelijkeMarktProvider.mTableDagvergunning + "."
                + MakkelijkeMarktProvider.Dagvergunning.COL_ID + " = ? ");
        loader.setSelectionArgs(
                new String[] { String.valueOf(args.getInt(MakkelijkeMarktProvider.Dagvergunning.COL_ID, 0)) });

        return loader;
    }

    return null;
}