Search in sources :

Example 6 with VideoBean

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

Example 7 with VideoBean

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

Example 8 with VideoBean

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();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) IAction(org.aisen.android.support.action.IAction) TaskException(org.aisen.android.network.task.TaskException) TaskException(org.aisen.android.network.task.TaskException) VideoBean(org.aisen.weibo.sina.support.bean.VideoBean) DialogAction(com.afollestad.materialdialogs.DialogAction) WorkTask(org.aisen.android.network.task.WorkTask) WebLoginAction(org.aisen.weibo.sina.support.action.WebLoginAction)

Aggregations

VideoBean (org.aisen.weibo.sina.support.bean.VideoBean)8 UrlBean (org.aisen.weibo.sina.sinasdk.bean.UrlBean)3 UrlsBean (org.aisen.weibo.sina.sinasdk.bean.UrlsBean)3 SpannableString (android.text.SpannableString)2 URLSpan (android.text.style.URLSpan)2 DialogAction (com.afollestad.materialdialogs.DialogAction)2 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 WebDownloader (org.aisen.android.component.bitmaploader.download.WebDownloader)2 TaskException (org.aisen.android.network.task.TaskException)2 Uri (android.net.Uri)1 BitmapCompress (org.aisen.android.component.bitmaploader.core.BitmapCompress)1 IBitmapCompress (org.aisen.android.component.bitmaploader.core.IBitmapCompress)1 MyBitmap (org.aisen.android.component.bitmaploader.core.MyBitmap)1 WorkTask (org.aisen.android.network.task.WorkTask)1 IAction (org.aisen.android.support.action.IAction)1 StatusComment (org.aisen.weibo.sina.sinasdk.bean.StatusComment)1 StatusContent (org.aisen.weibo.sina.sinasdk.bean.StatusContent)1