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.csipsimple.ui.messages.MessageFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    Builder toLoadUriBuilder = SipMessage.THREAD_ID_URI_BASE.buildUpon()
            .appendEncodedPath(remoteFrom.replaceAll("/", "%2F"));
    return new CursorLoader(getActivity(), toLoadUriBuilder.build(), null, null, null,
            SipMessage.FIELD_DATE + " ASC");
}

From source file:com.itime.team.itime.fragments.ProfileFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    Uri userByIdUri = ITimeDataStore.User.CONTENT_URI.buildUpon().appendPath(mUserId).build();
    return new CursorLoader(getActivity(), userByIdUri, null, null, null, null);
}

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

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle data) {
    final Intent intent = BaseActivity.fragmentArgumentsToIntent(data);
    Uri sessionsUri = intent.getData();//  w  w  w.j av a 2s . c o  m
    if (sessionsUri == null) {
        sessionsUri = ScheduleContract.Sessions.CONTENT_URI;
    }
    Loader<Cursor> loader = null;
    if (id == SessionsQuery._TOKEN) {
        loader = new CursorLoader(getActivity(), sessionsUri, SessionsQuery.PROJECTION, null, null,
                ScheduleContract.Sessions.DEFAULT_SORT);
    } else if (id == SearchQuery._TOKEN) {
        loader = new CursorLoader(getActivity(), sessionsUri, SearchQuery.PROJECTION, null, null,
                ScheduleContract.Sessions.DEFAULT_SORT);
    }
    return loader;
}

From source file:com.conferenceengineer.android.iosched.ui.tablet.TracksDropdownFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle data) {
    // Filter our tracks query to only include those with valid results
    String[] projection = TracksAdapter.TracksQuery.PROJECTION;
    String selection = null;//from ww w .java 2s .c om

    switch (mViewType) {
    case VIEW_TYPE_SESSIONS:
        // Only show tracks with at least one session
        projection = TracksAdapter.TracksQuery.PROJECTION_WITH_SESSIONS_COUNT;
        selection = ScheduleContract.Tracks.SESSIONS_COUNT + ">0";
        break;

    case VIEW_TYPE_OFFICE_HOURS:
        // Only show tracks with at least one office hours
        projection = TracksAdapter.TracksQuery.PROJECTION_WITH_OFFICE_HOURS_COUNT;
        selection = ScheduleContract.Tracks.OFFICE_HOURS_COUNT + ">0";
        break;

    case VIEW_TYPE_SANDBOX:
        // Only show tracks with at least one company
        projection = TracksAdapter.TracksQuery.PROJECTION_WITH_SANDBOX_COUNT;
        selection = ScheduleContract.Tracks.SANDBOX_COUNT + ">0";
        break;
    }
    return new CursorLoader(getActivity(), ScheduleContract.Tracks.CONTENT_URI, projection, selection, null,
            ScheduleContract.Tracks.DEFAULT_SORT);
}

From source file:com.gdgdevfest.android.apps.devfestbcn.ui.ScheduleFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle data) {
    String liveStreamedOnlyBlocksSelection = "(" + (UIUtils.shouldShowLiveSessionsOnly(getActivity())
            ? ScheduleContract.Blocks.BLOCK_TYPE + " NOT IN ('" + ScheduleContract.Blocks.BLOCK_TYPE_SESSION
                    + "','" + ScheduleContract.Blocks.BLOCK_TYPE_CODELAB + "','"
                    + ScheduleContract.Blocks.BLOCK_TYPE_OFFICE_HOURS + "','"
                    + ScheduleContract.Blocks.BLOCK_TYPE_FOOD + "')" + " OR "
                    + ScheduleContract.Blocks.NUM_LIVESTREAMED_SESSIONS + ">1 "
            : "1==1") + ")";
    String onlyStarredOfficeHoursSelection = "(" + ScheduleContract.Blocks.BLOCK_TYPE + " != '"
            + ScheduleContract.Blocks.BLOCK_TYPE_OFFICE_HOURS + "' OR "
            + ScheduleContract.Blocks.NUM_STARRED_SESSIONS + ">0)";
    String excludeSandbox = "(" + ScheduleContract.Blocks.BLOCK_TYPE + " != '"
            + ScheduleContract.Blocks.BLOCK_TYPE_SANDBOX + "')";

    return new CursorLoader(getActivity(), ScheduleContract.Blocks.CONTENT_URI, BlocksQuery.PROJECTION,
            liveStreamedOnlyBlocksSelection + " AND " + onlyStarredOfficeHoursSelection + " AND "
                    + excludeSandbox,/* w  w  w  .  j a  v a 2  s  .c o m*/
            null, ScheduleContract.Blocks.DEFAULT_SORT);
}

From source file:com.dilyar.weather.app.ForecastFragment.java

/**
 * Only create loader when mInputLocationName is not null
 *///  www .  j a v a2  s . com
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle bundle) {
    mRefreshLayout.setRefreshing(true);

    Log.d(LOG_TAG, "onCreateLoader() called. Loader id: " + id);
    Log.d(LOG_TAG, "loader city: " + this.mInputLocationName);

    switch (id) {
    case FORECAST_LOADER:
        // Sort order:  Ascending, by date.
        String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
        Uri weatherUriWithLocationAndStartDate = WeatherContract.WeatherEntry
                .buildWeatherLocationWithDateInQueryParameter(mInputLocationName, System.currentTimeMillis());

        Log.d(LOG_TAG, "Create Weather loader uri: " + weatherUriWithLocationAndStartDate);
        return new CursorLoader(getActivity(), weatherUriWithLocationAndStartDate, FORECAST_COLUMNS, null, null,
                sortOrder);

    case PHOTO_LOADER:
        Uri photoUriWithLocation = WeatherContract.PhotoEntry.buildPhotoUriWithLocation(mInputLocationName);
        Log.d(LOG_TAG, "Create Photo loader uri: " + photoUriWithLocation);

        return new CursorLoader(getActivity(), photoUriWithLocation, PHOTO_COLUMNS, null, null, null);

    default:
        Log.e(LOG_TAG, "Cannot find loader of id: " + id);
        return null;
    }

}

From source file:com.csipsimple.ui.filters.AccountFiltersListFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    return new CursorLoader(getActivity(), SipManager.FILTER_URI,
            new String[] { BaseColumns._ID, Filter.FIELD_ACCOUNT, Filter.FIELD_ACTION, Filter.FIELD_MATCHES,
                    Filter.FIELD_PRIORITY, Filter.FIELD_REPLACE },
            Filter.FIELD_ACCOUNT + "=?", new String[] { Long.toString(accountId) }, Filter.DEFAULT_ORDER);

}

From source file:com.alley.android.ppi.app.OverviewFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle bundle) {
    String sortOrder = PropertyContract.PropertyEntry.COLUMN_DATE + " DESC";
    String locationSetting = Utility.getPreferredLocation(getActivity());
    Uri propertyForLocationUri = null;/*from www  . ja  va 2  s  .c  om*/

    propertyForLocationUri = PropertyContract.PropertyEntry
            .buildPropertiesLocationWithStartDate(locationSetting, System.currentTimeMillis()
                    - TimeUnit.DAYS.toMillis(Utility.getPreferredNumberOfDaysToKeep(this.getActivity())));

    return new CursorLoader(getActivity(), propertyForLocationUri, PROPERTY_LIST_COLUMNS, null, null,
            sortOrder);
}

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

/**
 * Returns a list of SongEntries for the specified Songs.
 * //from   w  w  w. ja v  a2s . com
 * @param songsID list of ids ({@linkplain MediaStore.Audio.Media._ID})
 * @param projection one key from {@linkplain MediaStore.Audio.Media} to associate on the SongEntry's value
 * @return a list of SongEntries
 */
public List<SongEntry> getValueFromSongs(List<String> songsID, String projection) {
    List<SongEntry> songs = new ArrayList<SongEntry>();

    String[] ids = new String[songsID.size()];
    ids = songsID.toArray(ids);

    String[] cursorProjection = new String[] { MediaStore.Audio.Media._ID, projection,
            MediaStore.Audio.Media.DATA };

    String selection = MediaStore.Audio.Media.IS_MUSIC + " != 0 AND " + MediaStore.Audio.Media._ID + " IN (";
    for (int i = 0; i < songsID.size() - 1; i++) {
        selection += "?, ";
    }
    selection += "?)";

    CursorLoader cl = new CursorLoader(SoundBoxApplication.getContext(), defaultDirectoryUri, cursorProjection,
            selection, ids, null);
    myCursor = cl.loadInBackground();

    while (myCursor.moveToNext()) {
        songs.add(new SongEntry(myCursor.getString(0), myCursor.getString(1)));
    }

    Collections.sort(songs);

    myCursor.close();
    return songs;
}

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

@Override
public Loader<Cursor> onCreateLoader(final int id, final Bundle args) {
    final boolean activated_only = false;
    final Uri uri = Accounts.CONTENT_URI;
    final String[] cols = Accounts.COLUMNS;
    final String where = activated_only ? Accounts.IS_ACTIVATED + " = " + 1 : null;
    return new CursorLoader(getActivity(), uri, cols, where, null, null);
}