当前位置: 首页>>代码示例>>Java>>正文


Java CursorLoader.loadInBackground方法代码示例

本文整理汇总了Java中android.content.CursorLoader.loadInBackground方法的典型用法代码示例。如果您正苦于以下问题:Java CursorLoader.loadInBackground方法的具体用法?Java CursorLoader.loadInBackground怎么用?Java CursorLoader.loadInBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.CursorLoader的用法示例。


在下文中一共展示了CursorLoader.loadInBackground方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: getPathFromUri

import android.content.CursorLoader; //导入方法依赖的package包/类
/**
 * 根据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, contentUri, proj, null, null, null);
    Cursor cursor = loader.loadInBackground();
    int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.moveToFirst();
    return cursor.getString(column_index);
}
 
开发者ID:wangzhaosheng,项目名称:publicProject,代码行数:17,代码来源:ImageUtils.java

示例4: getRealPathFromURI

import android.content.CursorLoader; //导入方法依赖的package包/类
/**
 * 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(), contentUri, proj, null, null, null);
	Cursor cursor = loader.loadInBackground();
	int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
	cursor.moveToFirst();
	return cursor.getString(column_index);
}
 
开发者ID:takyonxxx,项目名称:AndroidSdrRtlTuner,代码行数:16,代码来源:SettingsFragment.java

示例5: getPath

import android.content.CursorLoader; //导入方法依赖的package包/类
private String getPath(Uri contentUri) {
    String[] proj = { MediaStore.Images.Media.DATA };
    CursorLoader loader = new CursorLoader(getApplicationContext(), contentUri, proj, null, null, null);
    Cursor cursor = loader.loadInBackground();
    int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.moveToFirst();
    String result = cursor.getString(column_index);
    cursor.close();
    return result;
}
 
开发者ID:huluhive,项目名称:android-volley-file-upload,代码行数:11,代码来源:MainActivity.java

示例6: doInBackground

import android.content.CursorLoader; //导入方法依赖的package包/类
@Override
protected BaseTags doInBackground(Video... videos) {
    Video video = videos[0];
    BaseTags tags = video.getFullScraperTags(getActivity());

    // Posters
    if (tags!=null && !isCancelled()) {
        mPosters = tags.getAllPostersInDb(getActivity());
    } else {
        mPosters = null;
    }
    // Backdrops
    if (tags!=null && !isCancelled()) {
        mBackdrops = tags.getAllBackdropsInDb(getActivity());
    } else {
        mBackdrops = null;
    }
    if (tags!=null && !isCancelled())
        mTrailers = tags.getAllTrailersInDb(getActivity());
    else
        mTrailers = null;
    // Check if we have the next episode
    if (tags instanceof EpisodeTags) {
        // Using a CursorLoader but outside of the LoaderManager : need to make sure the Looper is ready
        if (Looper.myLooper()==null) Looper.prepare();
        CursorLoader loader = new NextEpisodeLoader(getActivity(), (EpisodeTags)tags);
        Cursor c = loader.loadInBackground();
        if (c.getCount()>0) {
            c.moveToFirst();
            mNextEpisode = (Episode)new CompatibleCursorMapperConverter(new VideoCursorMapper()).convert(c);
        }
        c.close();
    }

    return tags;
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:37,代码来源:VideoDetailsFragment.java

示例7: getPath

import android.content.CursorLoader; //导入方法依赖的package包/类
public static String getPath(Context context, Uri inputUri) {
    String temp = inputUri.toString();
    if(temp.startsWith("file://")){
        return temp.substring("file://".length());
    }

    String[] proj = { MediaStore.Images.Media.DATA };
    CursorLoader loader = new CursorLoader(context,
            inputUri, proj, null, null, null);
    Cursor cursor = loader.loadInBackground();
    int column_index = cursor
            .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.moveToFirst();
    return cursor.getString(column_index);
}
 
开发者ID:LightSun,项目名称:android-util2,代码行数:16,代码来源:GetImagePath.java

示例8: update

import android.content.CursorLoader; //导入方法依赖的package包/类
public void update(){
	Cursor c = null;

	try {
		CursorLoader cursorloader = new CursorLoader(this,VideoStore.Video.Media.EXTERNAL_CONTENT_URI,
				mProjection, SELECT_LAST_PLAYED+HIDE_WATCHED_FILTER+" AND "+ LoaderUtils.HIDE_USER_HIDDEN_FILTER, null,
				SORT_LAST_PLAYED);
		c = cursorloader.loadInBackground();
		mNameColumn = c.getColumnIndex(Columns.NAME);
		mIDColumns = c.getColumnIndex(Columns.ID);
		mProgressColumns = c.getColumnIndex(VideoColumns.BOOKMARK);
		mDurationColumns = c.getColumnIndex(VideoColumns.DURATION);
		int count = 0;
		int total = c.getCount();
		//mNotificationManager.cancelAll();
		List<Integer> addedCards = new ArrayList<>();
		if(DBG) Log.d(TAG, "Updating");
		while(c.moveToNext()){
			try {
				RecommendationBuilder builder = new RecommendationBuilder()
						.setContext(getApplicationContext())
						.setSmallIcon(R.mipmap.video2);
				final String scraperCover = c.getString(c.getColumnIndexOrThrow(Columns.COVER_PATH));
				Bitmap bitmap = BitmapFactory.decodeFile(scraperCover);
				if (bitmap == null&&c.getLong(mIDColumns) >= 0) {
					BitmapFactory.Options options = new BitmapFactory.Options();
					options.inSampleSize = 2;
					bitmap = VideoStore.Video.Thumbnails.getThumbnail(getContentResolver(), c.getLong(mIDColumns), VideoStore.Video.Thumbnails.MINI_KIND, options);
				}
				if (bitmap == null){
					bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.widget_default_video);
				}
				Notification notification = builder.setTitle(c.getString(mNameColumn))
						.setImage(bitmap)
						.setMax(c.getInt(mDurationColumns))
						.setProgress(c.getInt(mProgressColumns))
						.setPriority(total - count)
						.setIntent(buildPendingIntent(ContentUris.withAppendedId(VideoStore.Video.Media.EXTERNAL_CONTENT_URI,c.getLong(mIDColumns))))
						.build();
				addedCards.add((int)c.getLong(mIDColumns));
				sLastCard.add((int)c.getLong(mIDColumns));
				mNotificationManager.notify((int)c.getLong(mIDColumns), notification);
				count++;
			} catch (IOException e) {
				Log.e(TAG, "Unable to update recommendation", e);
			}
		}
		for(int i : sLastCard){
			if(!addedCards.contains(i))
				mNotificationManager.cancel(i);
		}
		mLastCount = total;
	} catch(SQLiteException ignored){
	} finally {
		if (c != null)
			c.close();
	}
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:59,代码来源:UpdateRecommendationsService.java


注:本文中的android.content.CursorLoader.loadInBackground方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。