當前位置: 首頁>>代碼示例>>Java>>正文


Java CursorLoader類代碼示例

本文整理匯總了Java中android.content.CursorLoader的典型用法代碼示例。如果您正苦於以下問題:Java CursorLoader類的具體用法?Java CursorLoader怎麽用?Java CursorLoader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CursorLoader類屬於android.content包,在下文中一共展示了CursorLoader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreateLoader

import android.content.CursorLoader; //導入依賴的package包/類
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    // Now create and return a CursorLoader that will take care of
    // creating a Cursor for the data being displayed.
    if(id == LOADER_ID_HISTORY) {
        return new CursorLoader(this, ActivityDiaryContract.Diary.CONTENT_URI,
                PROJECTION, SELECTION, null, null);
    }else{

        return new CursorLoader(HistoryActivity.this,
                ActivityDiaryContract.DiaryImage.CONTENT_URI,
                new String[] {ActivityDiaryContract.DiaryImage._ID,
                        ActivityDiaryContract.DiaryImage.URI},
                ActivityDiaryContract.DiaryImage.DIARY_ID + "=? AND "
                        + ActivityDiaryContract.DiaryImage._DELETED + "=0",
                new String[] {Long.toString(args.getLong("DiaryID"))},
                null);
    }
}
 
開發者ID:ramack,項目名稱:ActivityDiary,代碼行數:19,代碼來源:HistoryActivity.java

示例2: onCreateLoader

import android.content.CursorLoader; //導入依賴的package包/類
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:LoginActivity.java

示例3: getRealPathFromURI_API11to18

import android.content.CursorLoader; //導入依賴的package包/類
@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;
}
 
開發者ID:feup-infolab,項目名稱:labtablet,代碼行數:19,代碼來源:FileMgr.java

示例4: onCreateLoader

import android.content.CursorLoader; //導入依賴的package包/類
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

    String[] projection = {
            PetEntry._ID,
            PetEntry.COLUMN_NAME,
            PetEntry.COLUMN_BREED
    };

    return new CursorLoader(
            this,
            PetEntry.CONTENT_URI,
            projection,
            null,
            null,
            null);
}
 
開發者ID:gusbru,項目名稱:pets,代碼行數:18,代碼來源:CatalogActivity.java

示例5: onCreateLoader

import android.content.CursorLoader; //導入依賴的package包/類
/**
 *
 * @param id
 * @param args
 * @return
 */
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

    String[] projection = {
            PetEntry._ID,
            PetEntry.COLUMN_NAME,
            PetEntry.COLUMN_BREED,
            PetEntry.COLUMN_GENDER,
            PetEntry.COLUMN_WEIGHT
    };

    return new CursorLoader(
            this,
            uriCurrentPet,
            projection,
            null,
            null,
            null);
}
 
開發者ID:gusbru,項目名稱:pets,代碼行數:26,代碼來源:EditorActivity.java

示例6: onCreateLoader

import android.content.CursorLoader; //導入依賴的package包/類
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {

    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
開發者ID:nSpider,項目名稱:Paathshala,代碼行數:18,代碼來源:LoginActivity.java

示例7: onCreateLoader

import android.content.CursorLoader; //導入依賴的package包/類
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    //指定獲取_id和display_name兩列數據,display_name即為姓名
    String[] projection = new String[]{
            ContactsContract.Contacts._ID,
            ContactsContract.Contacts.DISPLAY_NAME
    };
    CursorLoader loader = new CursorLoader(
            context,
            ContactsContract.Contacts.CONTENT_URI,
            projection,
            null,
            null,
            null
    );
    return loader;
}
 
開發者ID:jiangkang,項目名稱:KTools,代碼行數:18,代碼來源:ContactsLoaderCallback.java

示例8: createCursorLoader_SessionQuery_Success

import android.content.CursorLoader; //導入依賴的package包/類
@Test
public void createCursorLoader_SessionQuery_Success() {
    // Given a mock cursor loader set up for a session query
    int sessionsLoaderId = SessionFeedbackModel.SessionFeedbackQueryEnum.SESSION.getId();

    CursorLoader mockCursorLoaderSession = mock(CursorLoader.class);

    SessionFeedbackModel spyModel = spy(
            new SessionFeedbackModel(mMockUri, mMockContext, mMockFeedbackHelper));

    doReturn(mockCursorLoaderSession).when(spyModel).getCursorLoaderInstance(
            any(Context.class), any(Uri.class), any(String[].class), any(String.class),
            any(String[].class), any(String.class));

    // When ran with the session query
    CursorLoader createdCursorLoader1 =
            (CursorLoader) spyModel.createCursorLoader(sessionsLoaderId, mMockUri, null);

    // Then the returned cursor loader is the same as the mock one
    assertThat(createdCursorLoader1, sameInstance(mockCursorLoaderSession));
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:22,代碼來源:SessionFeedbackModelTest.java

示例9: createCursorLoader_SpeakersQuery_ReturnsCursor

import android.content.CursorLoader; //導入依賴的package包/類
@Test
public void createCursorLoader_SpeakersQuery_ReturnsCursor() {
    // Given a mock uri and mock cursor loader
    SessionDetailModel spyModel = spy(
            new SessionDetailModel(mMockUri, mMockContext, mMockSessionsHelper));
    doReturn(mMockUri).when(spyModel).getSpeakersDirUri(any(String.class));
    doReturn(mMockCursorLoader).when(spyModel).getCursorLoaderInstance(
            any(Context.class), any(Uri.class), any(String[].class), any(String.class),
            any(String[].class), any(String.class));

    // When ran with mock uri and speakers query loader id
    CursorLoader createdCursorLoader =
            (CursorLoader) spyModel.createCursorLoader(
                    SessionDetailModel.SessionDetailQueryEnum.SPEAKERS.getId(),
                    mMockUri, null);

    // Then the returned cursor loader is the mock cursor loader
    assertThat(createdCursorLoader, sameInstance(mMockCursorLoader));
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:20,代碼來源:SessionDetailModelTest.java

示例10: createCursorLoader_FeedbackQuery_ReturnsCursor

import android.content.CursorLoader; //導入依賴的package包/類
@Test
public void createCursorLoader_FeedbackQuery_ReturnsCursor() {
    // Given a mock uri and mock cursor loader
    SessionDetailModel spyModel = spy(
            new SessionDetailModel(mMockUri, mMockContext, mMockSessionsHelper));
    doReturn(mMockUri).when(spyModel).getFeedbackUri(any(String.class));
    doReturn(mMockCursorLoader).when(spyModel).getCursorLoaderInstance(
            any(Context.class), any(Uri.class), any(String[].class), any(String.class),
            any(String[].class), any(String.class));

    // When ran with mock uri and feedback query loader id
    CursorLoader createdCursorLoader =
            (CursorLoader) spyModel.createCursorLoader(
                    SessionDetailModel.SessionDetailQueryEnum.FEEDBACK.getId(),
                    mMockUri, null);

    // Then the returned cursor loader is the mock cursor loader
    assertThat(createdCursorLoader, sameInstance(mMockCursorLoader));
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:20,代碼來源:SessionDetailModelTest.java

示例11: createCursorLoader_FilteredVideosQuery_Success

import android.content.CursorLoader; //導入依賴的package包/類
@Test
public void createCursorLoader_FilteredVideosQuery_Success() {
    // Given a mock cursor loader set up for a video query
    int videosLoaderId = VideoLibraryModel.VideoLibraryQueryEnum.VIDEOS.getId();

    when(mMockBundle.containsKey(VideoLibraryModel.KEY_TOPIC)).thenReturn(true);
    when(mMockBundle.containsKey(VideoLibraryModel.KEY_YEAR)).thenReturn(true);
    when(mMockBundle.getString(VideoLibraryModel.KEY_TOPIC)).thenReturn("Android");
    when(mMockBundle.getInt(VideoLibraryModel.KEY_YEAR)).thenReturn(2012);

    // When ran with the video query
    CursorLoader createdCursorLoader =
            (CursorLoader) mSpyModel.createCursorLoader(videosLoaderId, Uri.EMPTY, mMockBundle);

    // Then the returned cursor loader is the same as the mock one
    assertThat(createdCursorLoader, sameInstance(mMockCursorLoader));
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:18,代碼來源:VideoLibraryModelTest.java

示例12: getRealPathFromURI_API11to18

import android.content.CursorLoader; //導入依賴的package包/類
@SuppressLint("NewApi")
public static String getRealPathFromURI_API11to18(Context context, Uri contentUri) {
    String[] proj = { MediaStore.Images.Media.DATA };
    String result = null;

    try {
        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);
        }
    } catch (Exception e) {
        result = null;
    }
    return result;
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:20,代碼來源:FileHelper.java

示例13: onCreateLoader

import android.content.CursorLoader; //導入依賴的package包/類
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), RegisterActivity.ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
開發者ID:Luodian,項目名稱:Shared-Route,代碼行數:17,代碼來源:RegisterActivity.java

示例14: onCreateLoader

import android.content.CursorLoader; //導入依賴的package包/類
public Loader<Cursor> onCreateLoader(int loaderID, Bundle bundle) {
    if (loaderID == mLoaderManagerId && (mUri != null || mVideoId != -1)) {
        String selection = (mVideoId != -1 ? BaseColumns._ID : MediaColumns.DATA) + "=?";
        if(LoaderUtils.mustHideUserHiddenObjects())
            selection += " AND "+LoaderUtils.HIDE_USER_HIDDEN_FILTER;
        CursorLoader cursorLoader =  new CursorLoader(
                mContext,
                VideoStore.Video.Media.EXTERNAL_CONTENT_URI,
                VideoDbInfo.COLUMNS,selection
                 ,
                new String [] {(mVideoId != -1 ? String.valueOf(mVideoId) : mUri.toString())},
                null);
        if(mLoaderManager==null)
            cursorLoader.registerListener(loaderID, this);
        return cursorLoader;
    }
    return null;
}
 
開發者ID:archos-sa,項目名稱:aos-MediaLib,代碼行數:19,代碼來源:IndexHelper.java

示例15: onCreateLoader

import android.content.CursorLoader; //導入依賴的package包/類
@Override
public android.support.v4.content.Loader<Cursor> onCreateLoader(int id, Bundle args) {
    return new android.support.v4.content.CursorLoader( mContext,
            MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
            IMAGE_PROJECTION,
            "",
            null,
            IMAGE_PROJECTION[2] + " DESC");
}
 
開發者ID:nickyangjun,項目名稱:EasyEmoji,代碼行數:10,代碼來源:ImageModel.java


注:本文中的android.content.CursorLoader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。