use of org.aisen.weibo.sina.support.bean.VideoBean 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;
}
use of org.aisen.weibo.sina.support.bean.VideoBean 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;
}
use of org.aisen.weibo.sina.support.bean.VideoBean in project AisenWeiBo by wangdan.
the class TimelinePicActivity method parseShortUrl.
private void parseShortUrl(final String url) {
while (BizFragment.createBizFragment(this).getActivity() == null) {
}
// 检测Cookie
new IAction(this, new WebLoginAction(this, BizFragment.createBizFragment(this))) {
@Override
public void doAction() {
new WorkTask<Void, Integer, String>() {
@Override
protected void onProgressUpdate(Integer... values) {
super.onProgressUpdate(values);
if (values != null && values[0] == 100) {
ViewUtils.createProgressDialog(TimelinePicActivity.this, "正在解析图片", ThemeUtils.getThemeColor()).show();
}
}
@Override
public String workInBackground(Void... params) throws TaskException {
String id = KeyGenerator.generateMD5(url);
VideoBean videoBean = SinaDB.getDB().selectById(null, VideoBean.class, id);
if (videoBean == null) {
videoBean = new VideoBean();
videoBean.setIdStr(id);
videoBean.setShortUrl(url);
}
// 根据短链接解析
if (TextUtils.isEmpty(videoBean.getImage())) {
try {
publishProgress(100);
VideoService.getPicture(videoBean);
} catch (Exception e) {
throw new TaskException("");
}
}
if (TextUtils.isEmpty(videoBean.getImage())) {
throw new TaskException("");
}
SinaDB.getDB().update(null, videoBean);
return videoBean.getImage();
}
@Override
protected void onFailure(TaskException exception) {
super.onFailure(exception);
if (isDestory())
return;
new MaterialDialog.Builder(TimelinePicActivity.this).forceStacking(true).content(R.string.video_short_faild).positiveText(R.string.video2browser).negativeText(R.string.video_again).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(MaterialDialog dialog, DialogAction which) {
toBrowser(url);
}
}).onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(MaterialDialog dialog, DialogAction which) {
loadPicture(url);
}
}).show();
}
@Override
protected void onSuccess(String s) {
super.onSuccess(s);
if (isDestory())
return;
loadPicture(s);
}
@Override
protected void onFinished() {
super.onFinished();
ViewUtils.dismissProgressDialog();
}
}.execute();
}
}.run();
}
Aggregations