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.android.inventoryapp.CatalogActivity.java

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

    // Perform a query using CursorLoader
    return new CursorLoader(this, // Parent activity context
            InventoryContract.ItemEntry.CONTENT_URI, // Provider content URI to query
            projection, // The columns to include in the resulting Cursor
            selection, // The values for the WHERE clause
            null, // No selection arguments
            sortOrder); // Default sort order
}

From source file:com.money.manager.ex.fragment.AllDataFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    if (getSearResultFragmentLoaderCallbacks() != null)
        getSearResultFragmentLoaderCallbacks().onCallbackCreateLoader(id, args);
    //animation/*www  .  j  av  a 2s . c  om*/
    setListShown(false);

    switch (id) {
    case ID_LOADER_ALL_DATA_DETAIL:
        QueryAllData allData = new QueryAllData(getActivity());
        // compose selection and sort
        String selection = "", sort = "";
        if (args != null && args.containsKey(KEY_ARGUMENTS_WHERE)) {
            ArrayList<String> whereClause = args.getStringArrayList(KEY_ARGUMENTS_WHERE);
            if (whereClause != null) {
                for (int i = 0; i < whereClause.size(); i++) {
                    selection += (!TextUtils.isEmpty(selection) ? " AND " : "") + whereClause.get(i);
                }
            }
        }
        // set sort
        if (args != null && args.containsKey(KEY_ARGUMENTS_SORT)) {
            sort = args.getString(KEY_ARGUMENTS_SORT);
        }
        // create loader
        return new CursorLoader(getActivity(), allData.getUri(), allData.getAllColumns(), selection, null,
                sort);
    }
    return null;
}

From source file:com.orangelabs.rcs.ri.sharing.video.VideoSharingList.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    /* Create a new CursorLoader with the following query parameters. */
    return new CursorLoader(this, VideoSharingLog.CONTENT_URI, PROJECTION, null, null, SORT_ORDER);
}

From source file:com.android.calendar.month.MonthByWeekFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    if (mIsMiniMonth) {
        return null;
    }//from w w  w  .  ja v  a2  s  .co m
    CursorLoader loader;
    synchronized (mUpdateLoader) {
        mFirstLoadedJulianDay = Time.getJulianDay(mSelectedDay.toMillis(true), mSelectedDay.gmtoff)
                - (mNumWeeks * 7 / 2);
        mEventUri = updateUri();
        String where = updateWhere();

        loader = new CursorLoader(getActivity(), mEventUri, Event.EVENT_PROJECTION, where,
                null /* WHERE_CALENDARS_SELECTED_ARGS */, INSTANCES_SORT_ORDER);
        loader.setUpdateThrottle(LOADER_THROTTLE_DELAY);
    }
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "Returning new loader with uri: " + mEventUri);
    }
    return loader;
}

From source file:com.example.mahendran.moviecritic.DetailFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    return new CursorLoader(getActivity(), MovieContract.MovieEntry.CONTENT_URI, null, null, null, null);
}

From source file:com.hangulo.powercontact.ErrorContactsListFragment.java

@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {

    String[] projection = { PowerContactContract.PowerContactEntry.COLUMN_ID, // cursor adapter? .
            PowerContactContract.PowerContactEntry.COLUMN_CONTACT_ID,
            PowerContactContract.PowerContactEntry.COLUMN_DATA_ID,
            PowerContactContract.PowerContactEntry.COLUMN_LOOKUP_KEY,
            PowerContactContract.PowerContactEntry.COLUMN_NAME,
            PowerContactContract.PowerContactEntry.COLUMN_ADDR,
            PowerContactContract.PowerContactEntry.COLUMN_TYPE,
            PowerContactContract.PowerContactEntry.COLUMN_LABEL,
            PowerContactContract.PowerContactEntry.COLUMN_PHOTO,
            PowerContactContract.PowerContactEntry.COLUMN_LAT,
            PowerContactContract.PowerContactEntry.COLUMN_LNG,
            PowerContactContract.PowerContactEntry.COLUMN_CONTACT_DATA_TYPE, };

    Log.v(LOG_TAG, "LOADER:MainActivity/onCreateLoader : ");

    return new CursorLoader(getActivity(),
            PowerContactContract.PowerContactEntry
                    .buildLocationByMode(PowerContactContract.PowerContactEntry.POWERCONTACT_MODE_ERROR), // only error status
            projection, // projection // only works
            null, // cols for "where" clause // ignored  ?
            null, // values for "where" clause // ignored  ?
            PowerContactContract.PowerContactEntry.COLUMN_NAME + " ASC"); // sort order --> by name);
}

From source file:com.orangelabs.rcs.ri.sharing.image.ImageSharingList.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    /* Create a new CursorLoader with the following query parameters. */
    return new CursorLoader(this, ImageSharingLog.CONTENT_URI, PROJECTION, null, null, SORT_ORDER);
}

From source file:com.beesham.popularmovies.DetailsFragment.java

private CursorLoader loadFromMovieEntry() {
    String[] projection = new String[] { MoviesEntry._ID, MoviesEntry.COLUMN_MOVIE_ID,
            MoviesEntry.COLUMN_MOVIE_TITLE, MoviesEntry.COLUMN_MOVIE_SYNOPSIS, MoviesEntry.COLUMN_MOVIE_POSTER,
            MoviesEntry.COLUMN_MOVIE_RELEASE_DATE, MoviesEntry.COLUMN_MOVIE_USER_RATING,
            MoviesEntry.COLUMN_MOVIE_TRAILERS, MoviesEntry.COLUMN_MOVIE_REVIEWS };

    if (mUri != null) {
        String selection = MoviesEntry.COLUMN_MOVIE_TITLE + "=?";
        String[] selectionArgs = { mUri.getPathSegments().get(1) };

        return new CursorLoader(getActivity(), MoviesEntry.CONTENT_URI, projection, selection, selectionArgs,
                null);//from  w  w  w  .  ja  v a2 s  .co m
    }
    return null;
}

From source file:com.coderming.weatherwatch.ForecastFragment.java

@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    // This is called when a new Loader needs to be created.  This
    // fragment only uses one loader, so we don't care about checking the id.

    // To only show current and future dates, filter the query to return weather only for
    // dates after or including today.

    // Sort order:  Ascending, by date.
    String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";

    String locationSetting = com.coderming.weatherwatch.Utility.getPreferredLocation(getActivity());
    Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate(locationSetting,
            System.currentTimeMillis());

    return new CursorLoader(getActivity(), weatherForLocationUri, FORECAST_COLUMNS, null, null, sortOrder);
}

From source file:com.example.amit.tellymoviebuzzz.ImdbFragment.java

@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    // String locationSetting = Utility.getPreferredLocation(getActivity());
    String movie = "thisyear";
    String country = bundle.getString("choice");
    //  Utility.getPreferredMovie(getActivity());
    // Sort order:  Ascending, by date.
    // String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
    // Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate(
    //       locationSetting, System.currentTimeMillis());

    // Uri movieForMovieIdUri = MovieContract.MovieNumberEntry.buildMovieType(movie);
    String sortOrder = MovieContract.MovieImdbEntry.TABLE_NAME + "."
            + MovieContract.MovieImdbEntry.COLUMN_IMDB_RATING + " DESC";

    String sMovieTypeWithMovieID = MovieContract.MovieImdbEntry.TABLE_NAME + "."
            + MovieContract.MovieImdbEntry.COLUMN_TEMP + " = ? AND " +
            // MovieContract.MovieImdbEntry.COLUMN_IMDB_ID + " != ? AND ";
            //   MovieContract.MovieImdbEntry.COLUMN_IMDB_RATING + " != ? AND "+
            MovieContract.MovieImdbEntry.COLUMN_PRO_COUNTRY + " LIKE ? ";

    return new CursorLoader(getActivity(), MovieContract.MovieImdbEntry.CONTENT_URI, FORECAST_MOVIE_COLUMNS,
            sMovieTypeWithMovieID, new String[] { "thisyear", '%' + country + '%' }, null);

    //   '%' + country + '%'
    //  "helloworld","0.5"
}