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:cn.pjt.rxjava.contacts.ContactsFragment.java

/**
 * Initialises a new {@link CursorLoader} that queries the {@link ContactsContract}.
 *///w  w  w. j a  v a 2  s.  c  o  m
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(getActivity(), ContactsContract.Contacts.CONTENT_URI, PROJECTION, null, null,
            ORDER);
}

From source file:com.dhayanand.apps.stockhawkk.StockDetailFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    if (id == CURSOR_LOADER_ID) {
        return new CursorLoader(getContext(), QuoteProvider.Quotes.CONTENT_URI,
                new String[] { QuoteColumns._ID, QuoteColumns.SYMBOL, QuoteColumns.BIDPRICE,
                        QuoteColumns.PERCENT_CHANGE, QuoteColumns.CHANGE, QuoteColumns.ISUP,
                        QuoteColumns.NAME },
                QuoteColumns.SYMBOL + " = \"" + mSymbol + "\"", null, null);
    } else if (id == CURSOR_LOADER_ID_FOR_LINE_CHART) {

        String sortOrder = QuoteColumns._ID + " ASC LIMIT 5";
        if (mSelectedTab.equals(getString(R.string.stock_detail_tab2))) {
            sortOrder = QuoteColumns._ID + " ASC LIMIT 14";
        } else if (mSelectedTab.equals(getString(R.string.stock_detail_tab3))) {
            sortOrder = QuoteColumns._ID + " ASC";
        }//from   w ww.j a v  a  2 s. c o  m

        return new CursorLoader(getContext(), QuoteProvider.QuotesHistoricData.CONTENT_URI,
                new String[] { QuoteHistoricalDataColumns._ID, QuoteHistoricalDataColumns.SYMBOL,
                        QuoteHistoricalDataColumns.BIDPRICE, QuoteHistoricalDataColumns.DATE },
                QuoteHistoricalDataColumns.SYMBOL + " = \"" + mSymbol + "\"", null, sortOrder);
    } else {
        throw new IllegalStateException();
    }
}

From source file:com.murrayc.galaxyzoo.app.ListFragment.java

@Override
public Loader<Cursor> onCreateLoader(final int loaderId, final Bundle bundle) {
    if (loaderId != URL_LOADER) {
        return null;
    }//ww w .j  av a2  s.c o  m

    final Activity activity = getActivity();

    final Uri uriItems = Item.ITEMS_URI;

    return new CursorLoader(activity, uriItems, mColumns, null, // No where clause, return all records.
            null, // No where clause, therefore no where column values.
            null // Use the default sort order.
    );
}

From source file:com.kaku.weac.fragment.LocalMusicFragment.java

@Override
public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {
    // //  ww w  .j a  v a  2  s. c o m
    return new CursorLoader(getActivity(), MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
            new String[] { MediaStore.Audio.Media.DISPLAY_NAME, MediaStore.Audio.Media.DATA }, null, null,
            MediaStore.Audio.Media.DISPLAY_NAME);
}

From source file:com.google.android.demos.jamendo.app.ArtistGalleryActivity.java

/** {@inheritDoc} */
public Loader<Cursor> onCreateLoader(int loaderId, Bundle args) {
    Intent intent = getIntent();//w w w . j a  v  a 2s  .  com
    Uri uri = Artists.CONTENT_URI;
    String selectionExtra = intent.getStringExtra(JamendoContract.EXTRA_SELECTION);
    QueryBuilder builder = new QueryBuilder(selectionExtra);
    builder.append(JamendoContract.PARAM_IMAGE_SIZE, String.valueOf(mImageSize));

    String[] projection = ArtistGalleryAdapter.PROJECTION;
    String selection = builder.build();
    String[] selectionArgs = intent.getStringArrayExtra(JamendoContract.EXTRA_SELECTION_ARGS);
    String sortOrder = intent.getStringExtra(JamendoContract.EXTRA_SORT_ORDER);
    return new CursorLoader(this, uri, projection, selection, selectionArgs, sortOrder);
}

From source file:com.arcusapp.soundbox.data.MediaProvider.java

/**
 * Returns the name ({@linkplain MediaStore.Audio.Albums.ALBUM}) of all the Albums of the specified Artist in the MediaStore.
 * // w ww.ja  va2s .  co m
 * @param artist the name of the Artist ({@linkplain MediaStore.Audio.Artists.ARTIST})
 * @return list with the names
 */
public List<String> getAlbumsFromArtist(String artist) {
    List<String> albums = new ArrayList<String>();

    String[] projection = { "DISTINCT " + MediaStore.Audio.Artists.Albums.ALBUM };
    String selection = MediaStore.Audio.Media.IS_MUSIC + " != 0 AND " + MediaStore.Audio.Artists.ARTIST
            + " = ?";
    String sortOrder = MediaStore.Audio.Artists.Albums.ALBUM;
    String[] selectionArgs = new String[] { artist };

    CursorLoader cl = new CursorLoader(SoundBoxApplication.getContext(), defaultDirectoryUri, projection,
            selection, selectionArgs, sortOrder);
    myCursor = cl.loadInBackground();

    while (myCursor.moveToNext()) {
        albums.add(myCursor.getString(0));
    }

    myCursor.close();
    return albums;
}

From source file:com.amgems.uwschedule.ui.ScheduleFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    // Because each request for a set of the meetings data must know what position it's group (corresponding course)
    // is at, extra data must be stored within the Loader. Because extras can't be attached to a specific loader, a
    // a group id that can specify a unique group must be used as the loader id. This can then ae translated to a
    // group position using CourseCursorTreeAdapter#getGroupPosition(int loaderId).
    switch (id) {
    case COURSE_CURSOR_LOADER: {
        return new CursorLoader(getActivity(), ScheduleContract.Courses.CONTENT_URI, null, null, null, null);
    }/*from   w  w  w .j a  v a2  s.  c om*/
    default: { // A request for meeting data was made.
        String groupSln = args.getString(CoursesCursorTreeAdapter.BUNDLE_SLN_KEY);
        return new CursorLoader(getActivity(), ScheduleContract.Meetings.CONTENT_URI, null,
                ScheduleContract.Meetings.SLN + " = ?", new String[] { groupSln }, null);
    }
    }
}

From source file:com.android.transmart.UI.fragments.PlaceListFragment.java

/**
 * {@inheritDoc}//w ww. j  a v a2 s  . c o m
 * This loader will return the ID, Reference, Name, and Distance of all the venues
 * currently stored in the {@link PlacesContentProvider}.
 */
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    String[] projection = new String[] { PlacesContentProvider.KEY_ID, PlacesContentProvider.KEY_NAME,
            PlacesContentProvider.KEY_DISTANCE, PlacesContentProvider.KEY_REFERENCE };

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

From source file:com.google.android.demos.jamendo.app.AlbumGalleryActivity.java

/** {@inheritDoc} */
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    Intent intent = getIntent();/*from   w  w  w . j a  v  a2s  .c om*/
    Uri uri = Albums.CONTENT_URI;
    String selectionExtra = intent.getStringExtra(JamendoContract.EXTRA_SELECTION);
    QueryBuilder builder = new QueryBuilder(selectionExtra);
    builder.append(JamendoContract.PARAM_IMAGE_SIZE, String.valueOf(mImageSize));

    String[] projection = AlbumGalleryAdapter.PROJECTION;
    String selection = builder.build();
    String[] selectionArgs = intent.getStringArrayExtra(JamendoContract.EXTRA_SELECTION_ARGS);
    String sortOrder = intent.getStringExtra(JamendoContract.EXTRA_SORT_ORDER);
    return new CursorLoader(this, uri, projection, selection, selectionArgs, sortOrder);
}

From source file:com.dabay6.android.apps.carlog.ui.base.fragments.BaseDetailFragment.java

/**
 * {@inheritDoc}/*from   w  w w.j av a2 s.co m*/
 */
@Override
public Loader<Cursor> onCreateLoader(final int i, final Bundle bundle) {
    final Uri uri = getUri().buildUpon().appendPath(entityId.toString()).build();

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