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;
}
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;
}
Aggregations