use of org.aisen.android.component.bitmaploader.core.MyBitmap in project AisenWeiBo by wangdan.
the class CommentPictureView method display.
public void display(String url) {
setTag(url);
ImageConfig config = new ImageConfig();
config.setCompressCacheEnable(false);
config.setDownloaderClass(PictureDownloader.class);
config.setLoadingRes(R.drawable.bg_timeline_loading);
config.setDisplayer(new DefaultDisplayer());
MyBitmap myBitmap = BitmapLoader.getInstance().getMyBitmapFromMemory(url, config);
// 内存缓存存在图片,且未释放
if (myBitmap != null) {
setImageDrawable(new BitmapDrawable(myBitmap.getBitmap()));
} else {
BitmapLoader.getInstance().display(null, url, this, config);
}
}
use of org.aisen.android.component.bitmaploader.core.MyBitmap in project AisenWeiBo by wangdan.
the class BitmapLoader method display.
public void display(BitmapOwner owner, String url, ImageView imageView, ImageConfig imageConfig) {
if (TextUtils.isEmpty(url)) {
setImageFaild(imageView, imageConfig);
return;
}
if (bitmapHasBeenSet(imageView, url))
return;
MyBitmap myBitmap = mImageCache.getBitmapFromMemCache(url, imageConfig);
// 内存缓存存在图片,且未释放
if (myBitmap != null && imageView != null) {
imageView.setImageDrawable(new MyDrawable(mContext.getResources(), myBitmap, imageConfig, null));
} else // 开启线程拉取图片
{
// 线程不存在,获取已经存在的线程不是加载当前的url,如果存在线程,则停止之前存在的线程
if (!checkTaskExistAndRunning(url, imageView, imageConfig)) {
// 2014-08-29 修改为当视图在滚动的时候,不加载图片
boolean canLoad = owner == null || owner.canDisplay() ? true : false;
if (!canLoad) {
Logger.d(TAG, "视图在滚动,显示默认图片");
setImageLoading(imageView, null, imageConfig);
} else {
// 开启新的线程加载图片
MyBitmapLoaderTask newTask = new MyBitmapLoaderTask(url, imageView, this, imageConfig);
WeakReference<MyBitmapLoaderTask> taskReference = new WeakReference<MyBitmapLoaderTask>(newTask);
taskCache.put(KeyGenerator.generateMD5(getKeyByConfig(url, imageConfig)), taskReference);
setImageLoading(imageView, url, imageConfig);
newTask.executrOnImageExecutor();
// 添加到fragment当中,当fragment在Destory的时候,清除task列表
if (owner != null)
getTaskCache(owner).add(new WeakReference<MyBitmapLoaderTask>(newTask));
newTask = null;
}
}
}
}
use of org.aisen.android.component.bitmaploader.core.MyBitmap in project AisenWeiBo by wangdan.
the class VideoCompress method compress.
@Override
public MyBitmap compress(byte[] bitmapBytes, File file, String url, ImageConfig config, int origW, int origH) throws Exception {
String id = KeyGenerator.generateMD5(url);
VideoBean videoBean = SinaDB.getDB().selectById(null, VideoBean.class, id);
if (videoBean != null) {
MyBitmap myBitmap = new BitmapCompress().compress(bitmapBytes, file, url, config, origW, origH);
if (myBitmap != null && myBitmap.getBitmap() != null) {
return new VideoBitmap(myBitmap.getBitmap(), url, videoBean);
}
}
return null;
}
Aggregations