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

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

Introduction

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

Prototype

public CursorLoader(Context context, Uri uri, String[] projection, String selection, String[] selectionArgs,
        String sortOrder) 

Source Link

Document

Creates a fully-specified CursorLoader.

Usage

From source file:com.chatwing.whitelabel.fragments.CategoriesFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    Uri uri = ChatWingContentProvider.getAggregatedCategoriesUri();
    String projection[] = new String[] { CategoryTable.TABLE_CATEGORY + "." + CategoryTable._ID,
            CategoryTable.TABLE_CATEGORY + "." + CategoryTable.TITLE + "  as " + GROUP_NAME,
            "SUM (" + ChatBoxTable.UNREAD_COUNT + ") as " + UNREAD_GROUP_COUNT_COLLUMN_NAME };

    return new CursorLoader(getActivity(), uri, projection, null, null, null);
}

From source file:com.jwork.dhammapada.ContentFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    int verseIndex = args.getInt(KEY_VERSE_INDEX);
    log.v(this, "onCreateLoader(id:" + id + "|" + verseIndex + ")");
    Uri baseUri;//from w  w  w .  j  a va  2s.  c  om
    baseUri = DhammapadaContentProvider.getVerseIndexUri(verseIndex);
    return new CursorLoader(getActivity(), baseUri, LOADER_CHAPTER_PROJECTION, null, null, null);
}

From source file:com.commonsware.android.contacts.spinners.ContactSpinners.java

@Override
public Loader<Cursor> onCreateLoader(int loaderId, Bundle args) {
    String[] projection;//from  w ww  . ja v  a 2  s  .c  o m
    Uri uri;

    switch (loaderId) {
    case LOADER_NAMES:
        projection = PROJECTION_NAMES;
        uri = ContactsContract.Contacts.CONTENT_URI;
        break;

    case LOADER_NAMES_NUMBERS:
        projection = PROJECTION_NUMBERS;
        uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
        break;

    default:
        projection = PROJECTION_EMAILS;
        uri = ContactsContract.CommonDataKinds.Email.CONTENT_URI;
        break;
    }

    return new CursorLoader(this, uri, projection, null, null, ContactsContract.Contacts.DISPLAY_NAME);
}

From source file:com.mfcoding.locationBP.UI.fragments.LocationListFragment.java

/**
 * {@inheritDoc}//  w  w w .j  av a  2  s  .c  o  m
 * This loader will return the ID, Reference, Name, and Distance of all the venues
 * currently stored in the {@link LocationsContentProvider}.
 */
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    Log.d(TAG, "onCreateLoader");
    String[] projection = new String[] { LocationsContentProvider.KEY_ID,
            LocationsContentProvider.KEY_LOCATION_LAT, LocationsContentProvider.KEY_LOCATION_LNG,
            LocationsContentProvider.KEY_LAST_UPDATE_TIME };

    return new CursorLoader(activity, LocationsContentProvider.CONTENT_URI, projection, null, null, null);
}

From source file:android.example.com.squawker.MainActivity.java

/**
 * Loader callbacks/*from w w  w . j av a  2s . c o  m*/
 */

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    // This method generates a selection off of only the current followers
    String selection = SquawkContract
            .createSelectionForCurrentFollowers(PreferenceManager.getDefaultSharedPreferences(this));
    Log.d(LOG_TAG, "Selection is " + selection);
    return new CursorLoader(this, SquawkProvider.SquawkMessages.CONTENT_URI, MESSAGES_PROJECTION, selection,
            null, SquawkContract.COLUMN_DATE + " DESC");
}

From source file:com.example.igorklimov.popularmoviesdemo.fragments.MoviesGridFragment.java

@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    Uri contentUri = Utility.getContentUri(mContext);
    return new CursorLoader(getActivity(), contentUri, null, null, null, null);
}

From source file:com.dgsd.android.ShiftTracker.Adapter.DayAdapter.java

public CursorLoader getDayLoader(Context context) {
    final String sel = DbField.JULIAN_DAY + " = ?";
    final String[] args = { String.valueOf(mJulianDay) };

    final String sort = DbField.START_TIME + " ASC, " + DbField.NAME + " ASC";

    return new CursorLoader(context, Provider.SHIFTS_URI, DbTable.SHIFTS.getFieldNames(), sel, args, sort);
}

From source file:com.enadein.carlogbook.ui.FuelRateFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    Long carId = DBUtils.getActiveCarId(getActivity().getContentResolver());
    CursorLoader cursorLoader = new CursorLoader(getActivity(), ProviderDescriptor.FuelRateView.CONTENT_URI,
            null, DBUtils.CAR_SELECTION_RATE, new String[] { String.valueOf(carId) }, null);

    return cursorLoader;
}

From source file:com.actinarium.nagbox.ui.MainActivity.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    return new CursorLoader(this, TasksTable.CONTENT_URI, NagboxContract.TASK_FULL_PROJECTION.getColumns(),
            null, null, BuildingBlocks.ORDER_BY_DISPLAY_ORDER_ASC);
}

From source file:com.deliciousdroid.platform.BundleManager.java

public static CursorLoader SearchBundles(String query, String username, Context context) {
    String[] projection = new String[] { Bundle._ID, Bundle.Name, Bundle.Tags };
    String selection = null;//from w ww  . j  a v  a 2  s. c om
    String sortorder = null;

    String[] queryBundles = query.split(" ");

    ArrayList<String> queryList = new ArrayList<String>();
    final ArrayList<String> selectionlist = new ArrayList<String>();

    for (String s : queryBundles) {
        queryList.add(Bundle.Name + " LIKE ?");
        selectionlist.add("%" + s + "%");
    }
    selectionlist.add(username);

    if (query != null && query != "") {
        selection = "(" + TextUtils.join(" OR ", queryList) + ")" + " AND " + Bundle.Account + "=?";
    } else {
        selection = Bundle.Account + "=?";
    }

    sortorder = Bundle.Name + " ASC";

    Uri bundles = Bundle.CONTENT_URI;

    return new CursorLoader(context, bundles, projection, selection, selectionlist.toArray(new String[] {}),
            sortorder);
}