微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android.content.CursorLoader的实例源码

项目:ActivityDiary    文件HistoryActivity.java   
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);
    }
}
项目:GitHub    文件LoginActivity.java   
@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");
}
项目:GSB-2017-Android    文件DummyLoginActivity.java   
@Override
public Loader<Cursor> onCreateLoader(int i,// 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");
}
项目:NewsApp    文件LoginActivity.java   
@Override
public Loader<Cursor> onCreateLoader(int i,// 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");
}
项目:19porn    文件LoginActivity.java   
@Override
public Loader<Cursor> onCreateLoader(int i,// 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");
}
项目:FlashCards    文件LoginActivity.java   
@Override
public Loader<Cursor> onCreateLoader(int i,// 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");
}
项目:Chore-Manager-App    文件AppLoginActivity.java   
@Override
public Loader<Cursor> onCreateLoader(int i,// 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");
}
项目:labtablet    文件FileMgr.java   
@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);
    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;
}
项目:atlas    文件LoginActivity.java   
@Override
public Loader<Cursor> onCreateLoader(int i,// 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");
}
项目:FastAndroid    文件LoginActivity.java   
@Override
public Loader<Cursor> onCreateLoader(int i,// 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");
}
项目:pets    文件CatalogActivity.java   
@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);
}
项目:pets    文件EditorActivity.java   
/**
 *
 * @param id
 * @param args
 * @return
 */
@Override
public Loader<Cursor> onCreateLoader(int id,PetEntry.COLUMN_BREED,PetEntry.COLUMN_GENDER,PetEntry.COLUMN_WEIGHT
    };

    return new CursorLoader(
            this,uriCurrentPet,null);
}
项目:changApp    文件LoginActivity.java   
@Override
public Loader<Cursor> onCreateLoader(int i,// 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");
}
项目:maklib    文件LoginActivity.java   
@Override
public Loader<Cursor> onCreateLoader(int i,// 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");
}
项目:Book-Tea_Project    文件Registeractivity.java   
@Override
public Loader<Cursor> onCreateLoader(int i,// 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");
}
项目:Paathshala    文件LoginActivity.java   
@Override
public Loader<Cursor> onCreateLoader(int i,Bundle bundle) {

    return new CursorLoader(this,// 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");
}
项目:Paathshala    文件SignUp.java   
@Override
public Loader<Cursor> onCreateLoader(int i,// 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");
}
项目:ShotsNewsApp    文件LoginActivity.java   
@Override
public Loader<Cursor> onCreateLoader(int i,// 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");
}
项目:KTools    文件ContactsLoaderCallback.java   
@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,null
    );
    return loader;
}
项目:study-buddy    文件LoginActivity.java   
@Override
public Loader<Cursor> onCreateLoader(int i,// 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");
}
项目:iosched-reader    文件SessionFeedbackModelTest.java   
@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));

    // 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));
}
项目:iosched-reader    文件SessionDetailModelTest.java   
@Test
public void createCursorLoader_SpeakersQuery_ReturnsCursor() {
    // Given a mock uri and mock cursor loader
    SessionDetailModel spyModel = spy(
            new SessionDetailModel(mMockUri,mMockSessionsHelper));
    doReturn(mMockUri).when(spyModel).getSpeakersDirUri(any(String.class));
    doReturn(mMockCursorLoader).when(spyModel).getCursorLoaderInstance(
            any(Context.class),any(String.class));

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

    // Then the returned cursor loader is the mock cursor loader
    assertthat(createdCursorLoader,sameInstance(mMockCursorLoader));
}
项目:iosched-reader    文件SessionDetailModelTest.java   
@Test
public void createCursorLoader_FeedbackQuery_ReturnsCursor() {
    // Given a mock uri and mock cursor loader
    SessionDetailModel spyModel = spy(
            new SessionDetailModel(mMockUri,mMockSessionsHelper));
    doReturn(mMockUri).when(spyModel).getFeedbackUri(any(String.class));
    doReturn(mMockCursorLoader).when(spyModel).getCursorLoaderInstance(
            any(Context.class),any(String.class));

    // When ran with mock uri and Feedback query loader id
    CursorLoader createdCursorLoader =
            (CursorLoader) spyModel.createCursorLoader(
                    SessionDetailModel.SessionDetailQueryEnum.FeedBACK.getId(),sameInstance(mMockCursorLoader));
}
项目:iosched-reader    文件VideoLibraryModelTest.java   
@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));
}
项目:localcloud_fe    文件FileHelper.java   
@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,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;
}
项目:AndroidApp-Deploy    文件LoginActivity.java   
@Override
public Loader<Cursor> onCreateLoader(int i,// 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");
}
项目:programming    文件Login.java   
@Override
public Loader<Cursor> onCreateLoader(int i,// 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");
}
项目:dapay    文件Login_BT_Activity.java   
@Override
public Loader<Cursor> onCreateLoader(int i,// 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");
}
项目:Shared-Route    文件LoginActivity.java   
@Override
public Loader<Cursor> onCreateLoader(int i,// 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");
}
项目:Shared-Route    文件PayBillActivity.java   
@Override
public Loader<Cursor> onCreateLoader(int i,// 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");
}
项目:Shared-Route    文件Registeractivity.java   
@Override
public Loader<Cursor> onCreateLoader(int i,Registeractivity.ProfileQuery.PROJECTION,// 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");
}
项目:BestBlog    文件LoginActivity.java   
@Override
public Loader<Cursor> onCreateLoader(int i,// 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");
}
项目:aos-MediaLib    文件IndexHelper.java   
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;
}
项目:EasyEmoji    文件ImageModel.java   
@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,"",IMAGE_PROJECTION[2] + " DESC");
}
项目:publicProject    文件ImageUtils.java   
/**
 * 根据uri获取图片路径
 *
 * @param mContext
 * @param contentUri
 * @return
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static String getPathFromUri(Context mContext,Uri contentUri) {
    String[] proj = {MediaStore.Images.Media.DATA};
    CursorLoader loader = new CursorLoader(mContext,null);
    Cursor cursor = loader.loadInBackground();
    int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.movetoFirst();
    return cursor.getString(column_index);
}
项目:android-ContentProviderPaging    文件ImageClientFragment.java   
@Override
public Loader<Cursor> onCreateLoader(int id,Bundle args) {
    final Activity activity = ImageClientFragment.this.getActivity();
    return new CursorLoader(activity) {
        @Override
        public Cursor loadInBackground() {
            Bundle bundle = new Bundle();
            bundle.putInt(ContentResolver.QUERY_ARG_OFFSET,mOffset.intValue());
            bundle.putInt(ContentResolver.QUERY_ARG_LIMIT,LIMIT);
            return activity.getContentResolver()
                    .query(ImageContract.CONTENT_URI,bundle,null);
        }
    };
}
项目:AndroidSdrRtlTuner    文件SettingsFragment.java   
/**
 * Extract the path from an uri
 * This code was published on StackOverflow by dextor
 *
 * @param contentUri        uri that contains the file path
 * @return absolute file path as string
 */
private String getRealPathFromURI(Uri contentUri) {
    String[] proj = { MediaStore.Images.Media.DATA };
    CursorLoader loader = new CursorLoader(this.getActivity(),null);
    Cursor cursor = loader.loadInBackground();
    int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.movetoFirst();
    return cursor.getString(column_index);
}
项目:CodeWatch    文件ProfileActivity.java   
@Override
public Loader<Cursor> onCreateLoader(int id,Bundle args) {
    return new CursorLoader(this,leaderContract.leaderEntry.buildProfileUri(userId),null);
}
项目:CodeWatch    文件NavigationDrawerActivity.java   
@Override
public Loader<Cursor> onCreateLoader(int id,leaderContract.leaderEntry.buildProfileUri(getWakatimeUid()),null);
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。