Search in sources :

Example 6 with MyBitmap

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);
    }
}
Also used : ImageConfig(org.aisen.android.component.bitmaploader.core.ImageConfig) MyBitmap(org.aisen.android.component.bitmaploader.core.MyBitmap) DefaultDisplayer(org.aisen.android.component.bitmaploader.display.DefaultDisplayer) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Example 7 with MyBitmap

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;
            }
        }
    }
}
Also used : MyBitmap(org.aisen.android.component.bitmaploader.core.MyBitmap) WeakReference(java.lang.ref.WeakReference) MyDrawable(org.aisen.android.component.bitmaploader.view.MyDrawable)

Example 8 with MyBitmap

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;
}
Also used : BitmapCompress(org.aisen.android.component.bitmaploader.core.BitmapCompress) IBitmapCompress(org.aisen.android.component.bitmaploader.core.IBitmapCompress) MyBitmap(org.aisen.android.component.bitmaploader.core.MyBitmap) VideoBean(org.aisen.weibo.sina.support.bean.VideoBean)

Aggregations

MyBitmap (org.aisen.android.component.bitmaploader.core.MyBitmap)8 MyDrawable (org.aisen.android.component.bitmaploader.view.MyDrawable)4 ImageConfig (org.aisen.android.component.bitmaploader.core.ImageConfig)3 Bitmap (android.graphics.Bitmap)2 BitmapDrawable (android.graphics.drawable.BitmapDrawable)2 TransitionDrawable (android.graphics.drawable.TransitionDrawable)2 LinearLayout (android.widget.LinearLayout)2 BitmapRegionDecoder (android.graphics.BitmapRegionDecoder)1 Paint (android.graphics.Paint)1 Rect (android.graphics.Rect)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1 WeakReference (java.lang.ref.WeakReference)1 BitmapCompress (org.aisen.android.component.bitmaploader.core.BitmapCompress)1 IBitmapCompress (org.aisen.android.component.bitmaploader.core.IBitmapCompress)1 DefaultDisplayer (org.aisen.android.component.bitmaploader.display.DefaultDisplayer)1 VideoBean (org.aisen.weibo.sina.support.bean.VideoBean)1 TimelinePicsView (org.aisen.weibo.sina.ui.widget.TimelinePicsView)1