Search in sources :

Example 6 with CursorLoader

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

the class SessionDetailModel method createCursorLoader.

@Override
public Loader<Cursor> createCursorLoader(SessionDetailQueryEnum query, Bundle args) {
    CursorLoader loader = null;
    if (query == null) {
        return loader;
    }
    switch(query) {
        case SESSIONS:
            mSessionId = getSessionId(mSessionUri);
            loader = getCursorLoaderInstance(mContext, mSessionUri, SessionDetailQueryEnum.SESSIONS.getProjection(), null, null, null);
            break;
        case SPEAKERS:
            Uri speakersUri = getSpeakersDirUri(mSessionId);
            loader = getCursorLoaderInstance(mContext, speakersUri, SessionDetailQueryEnum.SPEAKERS.getProjection(), null, null, ScheduleContract.Speakers.DEFAULT_SORT);
            break;
        case FEEDBACK:
            Uri feedbackUri = getFeedbackUri(mSessionId);
            loader = getCursorLoaderInstance(mContext, feedbackUri, SessionDetailQueryEnum.FEEDBACK.getProjection(), null, null, null);
            break;
        case TAG_METADATA:
            loader = getTagMetadataLoader();
            break;
        case MY_VIEWED_VIDEOS:
            Uri myPlayedVideoUri = ScheduleContract.MyViewedVideos.buildMyViewedVideosUri(AccountUtils.getActiveAccountName(mContext));
            loader = getCursorLoaderInstance(mContext, myPlayedVideoUri, SessionDetailQueryEnum.MY_VIEWED_VIDEOS.getProjection(), null, null, null);
            break;
    }
    return loader;
}
Also used : CursorLoader(android.content.CursorLoader) Uri(android.net.Uri)

Example 7 with CursorLoader

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

the class GridCursorCardFragment 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 8 with CursorLoader

use of android.content.CursorLoader in project WordPress-Android by wordpress-mobile.

the class MediaUtils method getLastRecordedVideoUri.

public static Uri getLastRecordedVideoUri(Activity activity) {
    String[] proj = { MediaStore.Video.Media._ID };
    Uri contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
    String sortOrder = MediaStore.Video.VideoColumns.DATE_TAKEN + " DESC";
    CursorLoader loader = new CursorLoader(activity, contentUri, proj, null, null, sortOrder);
    Cursor cursor = loader.loadInBackground();
    cursor.moveToFirst();
    long value = cursor.getLong(0);
    SqlUtils.closeCursor(cursor);
    return Uri.parse(contentUri.toString() + "/" + value);
}
Also used : CursorLoader(android.content.CursorLoader) Cursor(android.database.Cursor) Uri(android.net.Uri)

Example 9 with CursorLoader

use of android.content.CursorLoader in project android-support-v4-googlemaps by petedoyle.

the class CursorFragment method onCreateLoader.

public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    // This is called when a new Loader needs to be created.  This
    // sample only has one Loader, so we don't care about the ID.
    // First, pick the base URI to use depending on whether we are
    // currently filtering.
    Uri baseUri;
    if (mCurFilter != null) {
        baseUri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI, Uri.encode(mCurFilter));
    } else {
        baseUri = Contacts.CONTENT_URI;
    }
    // Now create and return a CursorLoader that will take care of
    // creating a Cursor for the data being displayed.
    String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND (" + Contacts.HAS_PHONE_NUMBER + "=1) AND (" + Contacts.DISPLAY_NAME + " != '' ))";
    return new CursorLoader(getActivity(), baseUri, CONTACTS_SUMMARY_PROJECTION, select, null, Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC");
}
Also used : CursorLoader(android.content.CursorLoader) Uri(android.net.Uri)

Example 10 with CursorLoader

use of android.content.CursorLoader in project cw-omnibus by commonsguy.

the class ContactSpinners method onCreateLoader.

@Override
public Loader<Cursor> onCreateLoader(int loaderId, Bundle args) {
    String[] projection;
    Uri uri;
    switch(loaderId) {
        case LOADER_NAMES:
            projection = PROJECTION_NAMES;
            uri = ContactsContract.Contacts.CONTENT_URI;
            break;
        case LOADER_NAMES_NUMBERS:
            projection = PROJECTION_NUMBERS;
            uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
            break;
        default:
            projection = PROJECTION_EMAILS;
            uri = ContactsContract.CommonDataKinds.Email.CONTENT_URI;
            break;
    }
    return (new CursorLoader(this, uri, projection, null, null, ContactsContract.Contacts.DISPLAY_NAME));
}
Also used : CursorLoader(android.content.CursorLoader) Uri(android.net.Uri)

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