本文整理了Java中com.bumptech.glide.RequestBuilder.downloadOnly
方法的一些代码示例,展示了RequestBuilder.downloadOnly
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RequestBuilder.downloadOnly
方法的具体详情如下:
包路径:com.bumptech.glide.RequestBuilder
类名称:RequestBuilder
方法名:downloadOnly
[英]Loads the original unmodified data into the cache and returns a java.util.concurrent.Future that can be used to retrieve the cache File containing the data.
[中]将原始未修改的数据加载到缓存中,并返回java。util。同时发生的可用于检索包含数据的缓存文件的。
代码示例来源:origin: chaychan/TouTiao
@Override
protected Void doInBackground(String... params) {
String imgUrl = params[0];
File file = null;
try {
FutureTarget<File> future = Glide
.with(ImageViewPagerActivity.this)
.load(imgUrl)
.downloadOnly(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL);
file = future.get();
String filePath = file.getAbsolutePath();
String destFileName = System.currentTimeMillis() + FileUtils.getImageFileExt(filePath);
File destFile = new File(FileUtils.getDir(""), destFileName);
FileUtils.copy(file, destFile);// 保存图片
// 最后通知图库更新
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
Uri.fromFile(new File(destFile.getPath()))));
} catch (Exception e) {
KLog.e(TAG, e.getMessage());
}
return null;
}
代码示例来源:origin: developerHaoz/GlideUtils
/**
* 根据图片的网络地址,拿到使用 Glide 进行缓存后的图片缓存地址
* 注意!!! 该方法要在子线程中调用,否则会出错
*
* @param imageUrl 图片的网络地址
* @return 图片的缓存地址
*/
public static String getImagePathFromCache(String imageUrl, Context context) {
FutureTarget<File> futureTarget = Glide.with(context)
.load(imageUrl)
.downloadOnly(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL);
File cacheFile;
try {
cacheFile = futureTarget.get();
return cacheFile.getAbsolutePath();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
return null;
}
代码示例来源:origin: wutq/AndroidModuleDemo
@Override
public File downLoad(String url, Activity activity) {
File file = null;
try {
file = Glide.with(activity)
.load(url)
.downloadOnly(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
.get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
Logger.e("下载图片异常" + e.getMessage());
}
return file;
}
};
代码示例来源:origin: leftcoding/GankLy
sliderIv.setLayoutParams(layoutParams);
Glide.with(this).load(mUrl).downloadOnly(new SimpleTarget<File>() {
@Override
public void onResourceReady(File resource, Transition<? super File> transition) {
代码示例来源:origin: ymback/NGA-CLIENT-VER-OPEN-SOURCE
.with(mContext)
.load(url)
.downloadOnly(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
.get();
return new DownloadResult(file, url);
内容来源于网络,如有侵权,请联系作者删除!