Search in sources :

Example 16 with CursorLoader

use of android.content.CursorLoader in project cardslib by gabrielemariotti.

the class ListCursorCardFragment method onCreateLoader.

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    Loader<Cursor> loader = null;
    loader = new CursorLoader(getActivity(), CardCursorContract.CardCursor.CONTENT_URI, CardCursorContract.CardCursor.ALL_PROJECTION, null, null, CardCursorContract.CardCursor.DEFAULT_SORT);
    return loader;
}
Also used : CursorLoader(android.content.CursorLoader) Cursor(android.database.Cursor)

Example 17 with CursorLoader

use of android.content.CursorLoader in project cardslib by gabrielemariotti.

the class ListGplayCursorCardCABFragment method onCreateLoader.

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    Loader<Cursor> loader = null;
    loader = new CursorLoader(getActivity(), CardCursorContract.CardCursor.CONTENT_URI, CardCursorContract.CardCursor.ALL_PROJECTION, null, null, CardCursorContract.CardCursor.DEFAULT_SORT);
    return loader;
}
Also used : CursorLoader(android.content.CursorLoader) Cursor(android.database.Cursor)

Example 18 with CursorLoader

use of android.content.CursorLoader in project cardslib by gabrielemariotti.

the class NativeGridCursorCardFragment method onCreateLoader.

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    Loader<Cursor> loader = null;
    loader = new CursorLoader(getActivity(), CardCursorContract.CardCursor.CONTENT_URI, CardCursorContract.CardCursor.ALL_PROJECTION, null, null, CardCursorContract.CardCursor.DEFAULT_SORT);
    return loader;
}
Also used : CursorLoader(android.content.CursorLoader) Cursor(android.database.Cursor)

Example 19 with CursorLoader

use of android.content.CursorLoader in project Android by hmkcode.

the class RealPathUtil method getRealPathFromURI_API11to18.

@SuppressLint("NewApi")
public static String getRealPathFromURI_API11to18(Context context, Uri contentUri) {
    String[] proj = { MediaStore.Images.Media.DATA };
    String result = null;
    CursorLoader cursorLoader = new CursorLoader(context, contentUri, proj, null, null, null);
    Cursor cursor = cursorLoader.loadInBackground();
    if (cursor != null) {
        int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
        cursor.moveToFirst();
        result = cursor.getString(column_index);
    }
    return result;
}
Also used : CursorLoader(android.content.CursorLoader) Cursor(android.database.Cursor) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 20 with CursorLoader

use of android.content.CursorLoader in project iosched by google.

the class VideoLibraryModel method createCursorLoader.

@Override
public Loader<Cursor> createCursorLoader(final VideoLibraryQueryEnum query, final Bundle args) {
    CursorLoader loader = null;
    switch(query) {
        case VIDEOS:
            ArrayList<String> selectionArgs = new ArrayList<>();
            ArrayList<String> selectionClauses = new ArrayList<>();
            // Extract possible filter values from the Bundle.
            if (args != null && args.containsKey(KEY_YEAR)) {
                mSelectedYear = args.getInt(KEY_YEAR);
            }
            if (args != null && args.containsKey(KEY_TOPIC)) {
                mSelectedTopic = args.getString(KEY_TOPIC);
            }
            // If filter values have been set we add the filter clause to the Loader.
            if (mSelectedYear > ALL_YEARS) {
                selectionClauses.add(ScheduleContract.Videos.VIDEO_YEAR + "=?");
                selectionArgs.add(Integer.toString(mSelectedYear));
            }
            if (mSelectedTopic != null && !mSelectedTopic.equals(ALL_TOPICS)) {
                selectionClauses.add(ScheduleContract.Videos.VIDEO_TOPIC + "=?");
                selectionArgs.add(mSelectedTopic);
            }
            String selection = selectionClauses.isEmpty() ? null : ParserUtils.joinStrings(" AND ", selectionClauses, null);
            String[] selectionArgsArray = selectionArgs.isEmpty() ? null : selectionArgs.toArray(new String[selectionArgs.size()]);
            LOGD(TAG, "Starting videos query, selection=" + selection + " (year=" + mSelectedYear + ", topic=" + mSelectedTopic);
            // Create and return the Loader.
            loader = getCursorLoaderInstance(mContext, mVideoUri, VideoLibraryQueryEnum.VIDEOS.getProjection(), selection, selectionArgsArray, ScheduleContract.Videos.DEFAULT_SORT);
            break;
        case FILTERS:
            LOGD(TAG, "Starting Video Filters query");
            loader = getCursorLoaderInstance(mContext, mFilterUri, VideoLibraryQueryEnum.FILTERS.getProjection(), null, null, null);
            break;
        case MY_VIEWED_VIDEOS:
            LOGD(TAG, "Starting My Viewed Videos query");
            loader = getCursorLoaderInstance(mContext, mMyVideosUri, VideoLibraryQueryEnum.MY_VIEWED_VIDEOS.getProjection(), null, null, null);
            break;
        case TAGS:
            loader = TagMetadata.createCursorLoader(mContext);
    }
    return loader;
}
Also used : CursorLoader(android.content.CursorLoader) ArrayList(java.util.ArrayList)

Aggregations

CursorLoader (android.content.CursorLoader)30 Cursor (android.database.Cursor)12 Uri (android.net.Uri)11 SmallTest (android.test.suitebuilder.annotation.SmallTest)9 Test (org.junit.Test)9 TagMetadataTest (com.google.samples.apps.iosched.model.TagMetadataTest)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 Context (android.content.Context)4 ArrayList (java.util.ArrayList)4 Matchers.anyString (org.mockito.Matchers.anyString)4 SettingsMockContext (com.google.samples.apps.iosched.testutils.SettingsMockContext)3 SuppressLint (android.annotation.SuppressLint)1 Loader (android.content.Loader)1 Bundle (android.os.Bundle)1 MotionEvent (android.view.MotionEvent)1 View (android.view.View)1 AbsListView (android.widget.AbsListView)1 AdapterView (android.widget.AdapterView)1 GridView (android.widget.GridView)1 ImageView (android.widget.ImageView)1