本文整理汇总了Java中com.lidroid.xutils.bitmap.callback.BitmapLoadFrom类的典型用法代码示例。如果您正苦于以下问题:Java BitmapLoadFrom类的具体用法?Java BitmapLoadFrom怎么用?Java BitmapLoadFrom使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BitmapLoadFrom类属于com.lidroid.xutils.bitmap.callback包,在下文中一共展示了BitmapLoadFrom类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: doInBackground
import com.lidroid.xutils.bitmap.callback.BitmapLoadFrom; //导入依赖的package包/类
@Override
protected Bitmap doInBackground(Object... params) {
synchronized (pauseTaskLock) {
while (pauseTask && !this.isCancelled()) {
try {
pauseTaskLock.wait(); //将锁释放, 让其他Bitmap任务也进来。 当暂停且没有销毁的的时候就是一个死循环
if (cancelAllTask) {
return null;
}
} catch (Throwable e) {
}
}
}
Bitmap bitmap = null;
// get cache from disk cache
if (!this.isCancelled() && this.getTargetContainer() != null) {
this.publishProgress(PROGRESS_LOAD_STARTED);
//这里是优先从闪存内存中读取
bitmap = globalConfig.getBitmapCache().getBitmapFromDiskCache(uri, displayConfig);
//from 默认是BitmapLoadFrom.DISK_CACHE, 所以这里不需要设置
}
// download image
if (bitmap == null && !this.isCancelled() && this.getTargetContainer() != null) {
//开启下载任务
bitmap = globalConfig.getBitmapCache().downloadBitmap(uri, displayConfig, this);
from = BitmapLoadFrom.URI;
}
return bitmap;
}
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:35,代码来源:BitmapUtils.java
示例2: onLoadCompleted
import com.lidroid.xutils.bitmap.callback.BitmapLoadFrom; //导入依赖的package包/类
@Override
public void onLoadCompleted(ImageView arg0, String arg1, Bitmap arg2,
BitmapDisplayConfig arg3, BitmapLoadFrom arg4) {
LoadPercentImageView imageView = (LoadPercentImageView)arg0;
imageView.setProgress(100);
imageView.setComplete(true);
imageView.setImageBitmap(arg2);
}
开发者ID:liuling07,项目名称:QiQuYing,代码行数:9,代码来源:PercentImageViewLoadCallBack.java
示例3: doInBackground
import com.lidroid.xutils.bitmap.callback.BitmapLoadFrom; //导入依赖的package包/类
@Override
protected Bitmap doInBackground(Object... params) {
synchronized (pauseTaskLock) {
while (pauseTask && !this.isCancelled()) {
try {
pauseTaskLock.wait();
if (cancelAllTask) {
return null;
}
} catch (Throwable e) {
}
}
}
Bitmap bitmap = null;
// get cache from disk cache
if (!this.isCancelled() && this.getTargetContainer() != null) {
this.publishProgress(PROGRESS_LOAD_STARTED);
bitmap = globalConfig.getBitmapCache().getBitmapFromDiskCache(uri, displayConfig);
}
// download image
if (bitmap == null && !this.isCancelled() && this.getTargetContainer() != null) {
bitmap = globalConfig.getBitmapCache().downloadBitmap(uri, displayConfig, this);
from = BitmapLoadFrom.URI;
}
return bitmap;
}
开发者ID:android-quick-dev,项目名称:AndroidDevFramework,代码行数:32,代码来源:BitmapUtils.java
示例4: display
import com.lidroid.xutils.bitmap.callback.BitmapLoadFrom; //导入依赖的package包/类
public <T extends View> void display(T container, String uri, BitmapDisplayConfig displayConfig, BitmapLoadCallBack<T> callBack) {
if (container == null) {
return;
}
if (callBack == null) {
callBack = new DefaultBitmapLoadCallBack<T>(); //默认的回调
}
if (displayConfig == null || displayConfig == defaultDisplayConfig) {
displayConfig = defaultDisplayConfig.cloneNew();// 默认展示图片的设置
}
// Optimize Max Size
BitmapSize size = displayConfig.getBitmapMaxSize();
//配置显示控件的大小
displayConfig.setBitmapMaxSize(BitmapCommonUtils.optimizeMaxSizeByView(container, size.getWidth(), size.getHeight()));
container.clearAnimation();
if (TextUtils.isEmpty(uri)) {
callBack.onLoadFailed(container, uri, displayConfig.getLoadFailedDrawable());
return;
}
// start loading
callBack.onPreLoad(container, uri, displayConfig);
// find bitmap from mem cache. 优先从运行内存的缓存中读取
Bitmap bitmap = globalConfig.getBitmapCache().getBitmapFromMemCache(uri, displayConfig);
if (bitmap != null) {
callBack.onLoadStarted(container, uri, displayConfig);
callBack.onLoadCompleted(
container,
uri,
bitmap,
displayConfig,
BitmapLoadFrom.MEMORY_CACHE);
} else if (!bitmapLoadTaskExist(container, uri, callBack)) { //这里判断任务是否正在加载中
final BitmapLoadTask<T> loadTask = new BitmapLoadTask<T>(container, uri, displayConfig, callBack);
// get executor
PriorityExecutor executor = globalConfig.getBitmapLoadExecutor();
File diskCacheFile = this.getBitmapFileFromDiskCache(uri);
boolean diskCacheExist = diskCacheFile != null && diskCacheFile.exists();
if (diskCacheExist && executor.isBusy()) {
//如果闪存中有缓存,而且BitmapLoadExecutor线程池不够用就使用DiskCacheExecutor的线程池
executor = globalConfig.getDiskCacheExecutor();
}
// set loading image
Drawable loadingDrawable = displayConfig.getLoadingDrawable();
callBack.setDrawable(container, new AsyncDrawable<T>(loadingDrawable, loadTask));
loadTask.setPriority(displayConfig.getPriority());
loadTask.executeOnExecutor(executor);
}
}
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:60,代码来源:BitmapUtils.java
示例5: display
import com.lidroid.xutils.bitmap.callback.BitmapLoadFrom; //导入依赖的package包/类
public <T extends View> void display(T container, String uri, BitmapDisplayConfig displayConfig, BitmapLoadCallBack<T> callBack) {
if (container == null) {
return;
}
if (callBack == null) {
callBack = new DefaultBitmapLoadCallBack<T>();
}
if (displayConfig == null || displayConfig == defaultDisplayConfig) {
displayConfig = defaultDisplayConfig.cloneNew();
}
// Optimize Max Size
BitmapSize size = displayConfig.getBitmapMaxSize();
displayConfig.setBitmapMaxSize(BitmapCommonUtils.optimizeMaxSizeByView(container, size.getWidth(), size.getHeight()));
container.clearAnimation();
if (TextUtils.isEmpty(uri)) {
callBack.onLoadFailed(container, uri, displayConfig.getLoadFailedDrawable());
return;
}
// start loading
callBack.onPreLoad(container, uri, displayConfig);
// find bitmap from mem cache.
Bitmap bitmap = globalConfig.getBitmapCache().getBitmapFromMemCache(uri, displayConfig);
if (bitmap != null) {
callBack.onLoadStarted(container, uri, displayConfig);
callBack.onLoadCompleted(
container,
uri,
bitmap,
displayConfig,
BitmapLoadFrom.MEMORY_CACHE);
} else if (!bitmapLoadTaskExist(container, uri, callBack)) {
final BitmapLoadTask<T> loadTask = new BitmapLoadTask<T>(container, uri, displayConfig, callBack);
// get executor
PriorityExecutor executor = globalConfig.getBitmapLoadExecutor();
File diskCacheFile = this.getBitmapFileFromDiskCache(uri);
boolean diskCacheExist = diskCacheFile != null && diskCacheFile.exists();
if (diskCacheExist && executor.isBusy()) {
executor = globalConfig.getDiskCacheExecutor();
}
// set loading image
Drawable loadingDrawable = displayConfig.getLoadingDrawable();
callBack.setDrawable(container, new AsyncDrawable<T>(loadingDrawable, loadTask));
loadTask.setPriority(displayConfig.getPriority());
loadTask.executeOnExecutor(executor);
}
}
开发者ID:android-quick-dev,项目名称:AndroidDevFramework,代码行数:58,代码来源:BitmapUtils.java
注:本文中的com.lidroid.xutils.bitmap.callback.BitmapLoadFrom类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论