Search in sources :

Example 1 with WebDownloader

use of org.aisen.android.component.bitmaploader.download.WebDownloader in project AisenWeiBo by wangdan.

the class VideoDownloader method downloadBitmap.

@Override
public byte[] downloadBitmap(Context context, String url, ImageConfig config) throws Exception {
    WebDownloader webDownloader = new WebDownloader();
    String id = KeyGenerator.generateMD5(url);
    VideoBean videoBean = SinaDB.getDB().selectById(null, VideoBean.class, id);
    if (videoBean != null) {
        if (TextUtils.isEmpty(videoBean.getImage()) || TextUtils.isEmpty(videoBean.getVideoUrl())) {
            int repeat = 8;
            while (repeat-- > 0) {
                try {
                    if (videoBean.getType() == VideoService.TYPE_VIDEO_WEIPAI) {
                        videoBean = VideoService.getVideoFromWeipai(videoBean);
                    } else if (videoBean.getType() == VideoService.TYPE_VIDEO_SINA) {
                        videoBean = VideoService.getVideoFromSinaVideo(videoBean);
                    } else if (videoBean.getType() == VideoService.TYPE_VIDEO_MEIPAI) {
                        videoBean = VideoService.getVideoFromMeipai(videoBean);
                    }
                    Logger.d("VidewDownloader", "video = " + videoBean.getVideoUrl() + ", long = " + videoBean.getLongUrl() + ", short = " + videoBean.getShortUrl() + ", image = " + videoBean.getImage());
                    SinaDB.getDB().update(null, videoBean);
                    break;
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            Logger.d(videoBean);
        }
        if (!TextUtils.isEmpty(videoBean.getImage())) {
            return webDownloader.downloadBitmap(context, videoBean.getImage(), config);
        }
    }
    return null;
}
Also used : VideoBean(org.aisen.weibo.sina.support.bean.VideoBean) WebDownloader(org.aisen.android.component.bitmaploader.download.WebDownloader)

Example 2 with WebDownloader

use of org.aisen.android.component.bitmaploader.download.WebDownloader in project AisenWeiBo by wangdan.

the class PictureDownloader method downloadBitmap.

@Override
public byte[] downloadBitmap(Context context, String url, ImageConfig config) throws Exception {
    WebDownloader webDownloader = new WebDownloader();
    String id = KeyGenerator.generateMD5(url);
    VideoBean videoBean = SinaDB.getDB().selectById(null, VideoBean.class, id);
    if (videoBean != null) {
        if (TextUtils.isEmpty(videoBean.getImage())) {
            int repeat = 8;
            while (repeat-- > 0) {
                try {
                    VideoService.getPicture(videoBean);
                    Logger.d("VidewDownloader", "video = " + videoBean.getVideoUrl() + ", long = " + videoBean.getLongUrl() + ", short = " + videoBean.getShortUrl() + ", image = " + videoBean.getImage());
                    SinaDB.getDB().update(null, videoBean);
                    break;
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            Logger.d(videoBean);
        }
        if (!TextUtils.isEmpty(videoBean.getImage())) {
            return webDownloader.downloadBitmap(context, videoBean.getImage().replaceAll("large", "thumbnail"), config);
        }
    }
    return null;
}
Also used : VideoBean(org.aisen.weibo.sina.support.bean.VideoBean) WebDownloader(org.aisen.android.component.bitmaploader.download.WebDownloader)

Aggregations

WebDownloader (org.aisen.android.component.bitmaploader.download.WebDownloader)2 VideoBean (org.aisen.weibo.sina.support.bean.VideoBean)2