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.example.owen.sunshine.DetailFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    Log.v(LOG_TAG, "In onCreateLoader");
    Intent intent = getActivity().getIntent();
    if (intent == null) {
        return null;
    }/*from   w w  w. j ava  2  s.  c o m*/

    // Now create and return a CursorLoader that will take care of
    // creating a Cursor for the data being displayed.
    return new CursorLoader(getActivity(), intent.getData(), DETAIL_COLUMNS, null, null, null);
}

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

public static CursorLoader SearchTags(String query, String username, Context context) {
    final String[] projection = new String[] { Tag._ID, Tag.Name, Tag.Count };
    String selection = null;//  w ww  .j  av  a 2  s.c  o  m

    final String sortorder = Tag.Name + " ASC";
    final ArrayList<String> selectionlist = new ArrayList<String>();

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

    for (String s : query.split(" ")) {
        queryList.add(Tag.Name + " LIKE ?");
        selectionlist.add("%" + s + "%");
    }

    selectionlist.add(username);

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

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

From source file:com.dwdesign.tweetings.fragment.DirectMessagesFragment.java

@Override
public Loader<Cursor> onCreateLoader(final int id, final Bundle args) {
    final Uri uri = DirectMessages.ConversationsEntry.CONTENT_URI;
    final String where = DirectMessages.ACCOUNT_ID + " IN ("
            + ArrayUtils.toString(getActivatedAccountIds(getActivity()), ',', false) + ")";
    return new CursorLoader(getActivity(), uri, null, where, null, null);
}

From source file:com.dgsd.android.ShiftTracker.Fragment.WeekFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle bundle) {
    switch (id) {
    case LOADER_ID_SHIFTS: {
        return mAdapter.getWeeklyLoader(getActivity());
    }//from  w w w .  j  a va  2s  . c  o m
    case LOADER_ID_TOTAL: {
        return mAdapter.getWeeklyLoader(getActivity());
    }
    case LOADER_ID_TEMPLATES:
        return new CursorLoader(getActivity(), Provider.SHIFTS_URI, null, DbField.IS_TEMPLATE + "> 0", null,
                null);
    default:
        return null;
    }
}

From source file:com.developers.pnp.lilly.app.DetailFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    if (null != mUri) {
        if (null != args)
            Log.e(LOG_TAG, "Passed args Bundle: " + args.toString());

        // Now create and return a CursorLoader that will take care of
        // creating a Cursor for the data being displayed.
        return new CursorLoader(getActivity(), mUri, DETAIL_COLUMNS, null, null, null);
    }/*from ww w  .j a  va  2  s .  c  om*/
    return null;
}

From source file:com.bangz.shotrecorder.RecordDetailActivity.java

@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this, mUri, PROJECTION, "", null, null);
}

From source file:com.example.android.network.sync.basicsyncadapter.ModelSelectionFragment.java

/**
 * Query the content provider for data./*from ww w  .  ja  v a 2 s  .c o m*/
 *
 * <p>Loaders do queries in a background thread. They also provide a ContentObserver that is
 * triggered when data in the content provider changes. When the sync adapter updates the
 * content provider, the ContentObserver responds by resetting the loader and then reloading
 * it.
 */
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    // We only have one loader, so we can ignore the value of i.
    // (It'll be '0', as set in onCreate().)

    return new CursorLoader(getActivity(), // Context
            Transformer.CONTENT_URI, null, // URI
            null, // Selection
            null, // Selection args
            null);
}

From source file:com.conferenceengineer.android.iosched.ui.ExploreFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle data) {
    Intent intent = BaseActivity.fragmentArgumentsToIntent(getArguments());
    Uri tracksUri = intent.getData();/*  www.j a v a2s.  co  m*/
    if (tracksUri == null) {
        tracksUri = ScheduleContract.Tracks.CONTENT_URI;
    }

    // Filter our tracks query to only include those with valid results
    String[] projection = TracksAdapter.TracksQuery.PROJECTION;
    String selection = null;

    return new CursorLoader(getActivity(), tracksUri, projection, selection, null,
            ScheduleContract.Tracks.DEFAULT_SORT);
}

From source file:com.heske.alexandria.activities.ListOfBooksFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

    final String selection = AlexandriaContract.BookEntry.TITLE + " LIKE ? OR "
            + AlexandriaContract.BookEntry.SUBTITLE + " LIKE ? ";

    if (mSearchString.length() > 0) {
        mSearchString = "%" + mSearchString + "%";
        return new CursorLoader(getActivity(), AlexandriaContract.BookEntry.CONTENT_URI, null, selection,
                new String[] { mSearchString, mSearchString }, null);
    }//from  w  ww.  j  ava 2  s.c o  m

    return new CursorLoader(getActivity(), AlexandriaContract.BookEntry.CONTENT_URI, null, null, null, null);
}

From source file:com.marvin.rocklock.navigation.CursorGroupedSongPicker.java

/**
 * Updates the music cursor given a new group
 *///w  ww .  j  av a  2s .c om
protected void updateMusicCursor() {
    if (mGroupCursor == null) {
        return;
    }
    CursorLoader loader = new CursorLoader(mParentActivity, getGroupUri(), mProjection, MUSIC_FILTER, null,
            null);
    mMusicCursor = loader.loadInBackground();
    if (mMusicCursor != null) {
        mMusicAvailable = mMusicCursor.moveToFirst();
    }
}