Example usage for android.content CursorLoader CursorLoader

List of usage examples for android.content CursorLoader CursorLoader

Introduction

In this page you can find the example usage for android.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.petsdb.EditorActivity.java

@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    // Since the editor shows all pet attributes, define a projection that contains
    // all columns from the pet table
    String[] projection = { PetsEntry._ID, PetsEntry.COLUMN_NAME, PetsEntry.COLUMN_BREED,
            PetsEntry.COLUMN_GENDER, PetsEntry.COLUMN_WEIGHT };

    // This loader will execute the ContentProvider's query method on a background thread
    return new CursorLoader(this, // Parent activity context
            mCurrentPetUri, // Query the content URI for the current pet
            projection, // Columns to include in the resulting Cursor
            null, // No selection clause
            null, // No selection arguments
            null); // Default sort order
}

From source file:org.alfresco.mobile.android.application.fragments.upload.UploadFormFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    return new CursorLoader(getActivity(), AccountManager.CONTENT_URI, AccountManager.COLUMN_ALL,
            AccountSchema.COLUMN_ACTIVATION + " IS NULL OR " + AccountSchema.COLUMN_ACTIVATION + "= ''", null,
            null);/*from  w w  w.  j a  v  a  2 s  . c  om*/
}

From source file:org.alfresco.mobile.android.application.fragments.favorites.FavoritesSyncFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    setListShown(false);//  w ww.  j a va  2  s . c  o m
    StringBuilder selection = new StringBuilder();
    if (acc != null) {
        selection.append(SynchroProvider.getAccountFilter(acc));
    }

    if (selection.length() > 0) {
        selection.append(" AND ");
    }

    if (getFolderId() != null) {
        selection.append(SynchroSchema.COLUMN_PARENT_ID + " == '" + getFolderId() + "'");
    } else {
        selection.append(SynchroSchema.COLUMN_IS_FAVORITE + " == '" + SynchroProvider.FLAG_FAVORITE + "'");
        selection.append(" OR ");
        selection.append(SynchroSchema.COLUMN_STATUS + " == '" + SyncOperation.STATUS_REQUEST_USER + "'");
    }

    if (selection.length() > 0) {
        selection.append(" AND ");
    }

    selection.append(SynchroSchema.COLUMN_STATUS + " NOT IN (" + SyncOperation.STATUS_HIDDEN + ")");

    Log.d(TAG, selection.toString());

    return new CursorLoader(getActivity(), SynchroProvider.CONTENT_URI, SynchroSchema.COLUMN_ALL,
            selection.toString(), null, SynchroSchema.COLUMN_TITLE + " COLLATE NOCASE ASC");
}

From source file:com.aengbee.android.leanback.ui.VideoDetailsFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    switch (id) {
    case RELATED_VIDEO_LOADER: {
        String category = args.getString(VideoContract.VideoEntry.COLUMN_CATEGORY);
        String desc = args.getString(VideoContract.VideoEntry.COLUMN_DESC);
        return new CursorLoader(getActivity(), VideoContract.VideoEntry.CONTENT_URI, null,
                //VideoContract.VideoEntry.COLUMN_CATEGORY + " = ? AND " +
                VideoContract.VideoEntry.COLUMN_DESC + " LIKE ? AND "
                        + VideoContract.VideoEntry.COLUMN_RATING_SCORE + " != ? ",
                new String[] { "%" + desc + "%", "0" }, VideoContract.VideoEntry.COLUMN_NAME// Default sort order
        );//  ww  w  . j a  v a2s.c om
    }
    default: {
        // Loading video from global search.
        String videoId = args.getString(VideoContract.VideoEntry._ID);
        return new CursorLoader(getActivity(), VideoContract.VideoEntry.CONTENT_URI, null,
                VideoContract.VideoEntry._ID + " = ?", new String[] { videoId }, null);
    }
    }

}

From source file:com.app.uafeed.activity.HomeActivity.java

@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    CursorLoader cursorLoader = new CursorLoader(this, FeedColumns.GROUPED_FEEDS_CONTENT_URI,
            new String[] { FeedColumns._ID, FeedColumns.URL, FeedColumns.NAME, FeedColumns.IS_GROUP,
                    FeedColumns.GROUP_ID, FeedColumns.ICON, FeedColumns.LAST_UPDATE, FeedColumns.ERROR,
                    FEED_UNREAD_NUMBER },
            PrefUtils.getBoolean(PrefUtils.SHOW_READ, true) ? "" : WHERE_UNREAD_ONLY, null, null);
    cursorLoader.setUpdateThrottle(Constants.UPDATE_THROTTLE_DELAY);
    return cursorLoader;
}

From source file:org.benetech.secureapp.activities.MainActivity.java

@Override
public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {
    String selection = InstanceProviderAPI.InstanceColumns.STATUS + " != ?";
    String[] selectionArgs = { InstanceProviderAPI.STATUS_SUBMITTED };
    String sortOrder = InstanceProviderAPI.InstanceColumns.STATUS + " DESC, "
            + InstanceProviderAPI.InstanceColumns.DISPLAY_NAME + " ASC";
    return new CursorLoader(this, InstanceProviderAPI.InstanceColumns.CONTENT_URI, null, selection,
            selectionArgs, sortOrder);//from  w  w w  .  ja  v  a2 s .  c o  m
}

From source file:nl.privacybarometer.privacyvandaag.activity.HomeActivity.java

@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    CursorLoader cursorLoader = new CursorLoader(this, FeedColumns.GROUPED_FEEDS_CONTENT_URI,
            new String[] { FeedColumns._ID, FeedColumns.URL, FeedColumns.NAME, FeedColumns.IS_GROUP,
                    FeedColumns.ICON, FeedColumns.LAST_UPDATE, FeedColumns.ERROR, FEED_UNREAD_NUMBER,
                    FeedColumns.FETCH_MODE, FeedColumns.ICON_DRAWABLE },
            PrefUtils.getBoolean(PrefUtils.SHOW_READ, true) ? "" : WHERE_UNREAD_ONLY, null, null);
    cursorLoader.setUpdateThrottle(Constants.UPDATE_THROTTLE_DELAY);
    return cursorLoader;
}

From source file:com.google.samples.apps.iosched.ui.SessionLivestreamActivity.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    switch (id) {
    case SessionSummaryQuery._TOKEN:
        return new CursorLoader(this, Sessions.buildSessionUri(mSessionId), SessionSummaryQuery.PROJECTION,
                null, null, null);/*from  ww  w  .jav  a2  s  .  c o  m*/
    case SessionsQuery._TOKEN:
        boolean futureSessions = false;
        if (args != null) {
            futureSessions = args.getBoolean(LOADER_SESSIONS_ARG, false);
        }
        final long currentTime = UIUtils.getCurrentTime(this);
        String selection = Sessions.LIVESTREAM_SELECTION + " and ";
        String[] selectionArgs;
        if (!futureSessions) {
            selection += Sessions.AT_TIME_SELECTION;
            selectionArgs = Sessions.buildAtTimeSelectionArgs(currentTime);
        } else {
            selection += Sessions.UPCOMING_LIVE_SELECTION;
            selectionArgs = Sessions.buildUpcomingSelectionArgs(currentTime);
        }
        return new CursorLoader(this, Sessions.CONTENT_URI, SessionsQuery.PROJECTION, selection, selectionArgs,
                SessionsQuery.SORT_ORDER);
    }
    return null;
}

From source file:com.meiste.tempalarm.ui.CurrentTemp.java

/**
 * Query the content provider for data.//  ww w  . j  a 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(final int id, final Bundle bundle) {
    return new CursorLoader(this, // Context
            RasPiContract.RasPiReport.CONTENT_URI, // URI
            PROJECTION, // Projection
            null, // Selection
            null, // Selection args
            RasPiContract.RasPiReport.SORT_NEWEST_FIRST // Sort
    );
}

From source file:com.aengbee.android.leanback.ui.PlaybackOverlayFragment.java

public CursorLoader CursorLoaderNormalizer(String query) {
    query += "";/*from   w w w .j  a v  a 2 s.  c o  m*/
    return new CursorLoader(getActivity(), VideoContract.VideoEntry.CONTENT_URI, null, // Projection to return - null means return all fields.
            //VideoContract.VideoEntry.COLUMN_CATEGORY + " = ? AND " +
            " ( lower ( trim ( " + VideoContract.VideoEntry.COLUMN_NAME + " , ? ) ) LIKE ? OR "
                    + " lower ( trim ( " + VideoContract.VideoEntry.COLUMN_DESC + " , ? ) ) LIKE ? ) AND "
                    + VideoContract.VideoEntry.COLUMN_RATING_SCORE + " == ? AND "
                    + VideoContract.VideoEntry.COLUMN_CATEGORY + " == ? ",
            // Selection clause is category.
            new String[] { SPECIAL_CHARACTERS, "%" + query + "%", SPECIAL_CHARACTERS, "%" + query + "%", "1",
                    "KY" },
            VideoContract.VideoEntry.COLUMN_NAME// Default sort order
    );

}