Search in sources :

Example 6 with VideoResult

use of com.dante.data.model.VideoResult in project 91Pop by DanteAndroid.

the class AppApiHelper method loadPorn91VideoUrl.

@Override
public Observable<VideoResult> loadPorn91VideoUrl(String viewKey) {
    String ip = addressHelper.getRandomIPAddress();
    Observable<String> stringObservable = noLimit91PornServiceApi.getVideoPlayPage(viewKey, ip, HeaderUtils.getIndexHeader(addressHelper));
    return cacheProviders.getVideoPlayPage(stringObservable, new DynamicKey(viewKey), new EvictDynamicKey(false)).map(new Function<Reply<String>, String>() {

        @Override
        public String apply(Reply<String> responseBodyReply) throws Exception {
            switch(responseBodyReply.getSource()) {
                case CLOUD:
                    Logger.t(TAG).d("数据来自:网络");
                    break;
                case MEMORY:
                    Logger.t(TAG).d("数据来自:内存");
                    break;
                case PERSISTENCE:
                    Logger.t(TAG).d("数据来自:磁盘缓存");
                    break;
                default:
                    break;
            }
            return responseBodyReply.getData();
        }
    }).map(new Function<String, VideoResult>() {

        @Override
        public VideoResult apply(String s) throws Exception {
            return Parse91PronVideo.parseVideoPlayUrl(s);
        }
    });
}
Also used : Function(io.reactivex.functions.Function) VideoResult(com.dante.data.model.VideoResult) EvictDynamicKey(io.rx_cache2.EvictDynamicKey) Reply(io.rx_cache2.Reply) DynamicKey(io.rx_cache2.DynamicKey) EvictDynamicKey(io.rx_cache2.EvictDynamicKey) FavoriteException(com.dante.exception.FavoriteException) MessageException(com.dante.exception.MessageException)

Example 7 with VideoResult

use of com.dante.data.model.VideoResult in project 91Pop by DanteAndroid.

the class BasePlayVideo method playVideo.

@Override
public void playVideo(UnLimit91PornItem unLimit91PornItem) {
    this.unLimit91PornItem = unLimit91PornItem;
    videoplayerContainer.setVisibility(View.VISIBLE);
    dismissDialog();
    setToolBarLayoutInfo(unLimit91PornItem);
    VideoResult videoResult = unLimit91PornItem.getVideoResult();
    playVideo(unLimit91PornItem.getTitle(), videoResult.getVideoUrl(), "", videoResult.getThumbImgUrl());
    helper.showContent();
    presenter.loadVideoComment(videoResult.getVideoId(), unLimit91PornItem.getViewKey(), true);
    boolean neverAskForWatchDownloadTip = dataManager.isNeverAskForWatchDownloadTip();
    if (!neverAskForWatchDownloadTip) {
        showWatchDownloadVideoTipDialog();
    }
}
Also used : VideoResult(com.dante.data.model.VideoResult)

Example 8 with VideoResult

use of com.dante.data.model.VideoResult in project 91Pop by DanteAndroid.

the class BasePlayVideo method setToolBarLayoutInfo.

private void setToolBarLayoutInfo(final UnLimit91PornItem unLimit91PornItem) {
    if (unLimit91PornItem.getVideoResultId() == 0) {
        return;
    }
    String searchTitleTag = "...";
    VideoResult videoResult = unLimit91PornItem.getVideoResult();
    if (unLimit91PornItem.getTitle().contains(searchTitleTag) || unLimit91PornItem.getTitle().endsWith(searchTitleTag)) {
        tvPlayVideoTitle.setText(videoResult.getVideoName());
    } else {
        tvPlayVideoTitle.setText(unLimit91PornItem.getTitle());
    }
    tvPlayVideoAuthor.setText(String.format("作者:%s", videoResult.getOwnnerName()));
    tvPlayVideoAddDate.setText(videoResult.getAddDate());
    tvPlayVideoInfo.setText(videoResult.getUserOtherInfo());
    tvPlayVideoAuthor.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!UserHelper.isUserInfoComplete(user)) {
                goToLogin();
                showMessage("请先登录", TastyToast.WARNING);
                return;
            }
            if (unLimit91PornItem.getVideoResultId() == 0) {
                showMessage("视频还未解析成功", TastyToast.WARNING);
                return;
            }
            Intent intent = new Intent(BasePlayVideo.this, AuthorActivity.class);
            intent.putExtra(Keys.KEY_INTENT_UID, unLimit91PornItem.getVideoResult().getOwnnerId());
            startActivityForResultWithAnimotion(intent, 1);
        }
    });
}
Also used : VideoResult(com.dante.data.model.VideoResult) Intent(android.content.Intent) AuthorActivity(com.dante.ui.porn91video.author.AuthorActivity) ImageView(android.widget.ImageView) LoadMoreView(com.chad.library.adapter.base.loadmore.LoadMoreView) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView)

Example 9 with VideoResult

use of com.dante.data.model.VideoResult in project 91Pop by DanteAndroid.

the class BasePlayVideo method favoriteVideo.

private void favoriteVideo() {
    if (unLimit91PornItem == null || unLimit91PornItem.getVideoResultId() == 0) {
        showMessage("解析完视频才能收藏哦", TastyToast.WARNING);
        return;
    }
    VideoResult videoResult = unLimit91PornItem.getVideoResult();
    if (!UserHelper.isUserInfoComplete(user)) {
        goToLogin();
        showMessage("请先登录", TastyToast.SUCCESS);
        return;
    }
    if (Integer.parseInt(videoResult.getOwnnerId()) == user.getUserId()) {
        showMessage("不能收藏自己的视频哦", TastyToast.INFO);
        return;
    }
    favoriteDialog.show();
    presenter.favorite(String.valueOf(user.getUserId()), videoResult.getVideoId(), videoResult.getOwnnerId());
}
Also used : VideoResult(com.dante.data.model.VideoResult)

Example 10 with VideoResult

use of com.dante.data.model.VideoResult in project 91Pop by DanteAndroid.

the class PlayVideoPresenter method loadVideoUrl.

@Override
public void loadVideoUrl(final UnLimit91PornItem unLimit91PornItem) {
    String viewKey = unLimit91PornItem.getViewKey();
    dataManager.loadPorn91VideoUrl(viewKey).map(new Function<VideoResult, VideoResult>() {

        @Override
        public VideoResult apply(VideoResult videoResult) throws VideoException {
            if (TextUtils.isEmpty(videoResult.getVideoUrl())) {
                if (VideoResult.OUT_OF_WATCH_TIMES.equals(videoResult.getId())) {
                    // 尝试强行重置,并上报异常
                    cookieManager.resetPorn91VideoWatchTiem(true);
                    Bugsnag.notify(new Throwable(TAG + ":ten videos each day "), Severity.WARNING);
                    throw new VideoException("观看次数达到上限了!");
                } else {
                    throw new VideoException("解析视频链接失败了");
                }
            }
            return videoResult;
        }
    }).retryWhen(new RetryWhenProcess(RetryWhenProcess.PROCESS_TIME)).compose(RxSchedulersHelper.<VideoResult>ioMainThread()).compose(provider.<VideoResult>bindUntilEvent(Lifecycle.Event.ON_DESTROY)).subscribe(new CallBackWrapper<VideoResult>() {

        @Override
        public void onBegin(Disposable d) {
            ifViewAttached(new ViewAction<PlayVideoView>() {

                @Override
                public void run(@NonNull PlayVideoView view) {
                    view.showParsingDialog();
                }
            });
        }

        @Override
        public void onSuccess(final VideoResult videoResult) {
            cookieManager.resetPorn91VideoWatchTiem(false);
            ifViewAttached(new ViewAction<PlayVideoView>() {

                @Override
                public void run(@NonNull PlayVideoView view) {
                    view.playVideo(saveVideoUrl(videoResult, unLimit91PornItem));
                }
            });
        }

        @Override
        public void onError(final String msg, int code) {
            ifViewAttached(new ViewAction<PlayVideoView>() {

                @Override
                public void run(@NonNull PlayVideoView view) {
                    view.errorParseVideoUrl(msg);
                }
            });
        }
    });
}
Also used : Disposable(io.reactivex.disposables.Disposable) RetryWhenProcess(com.dante.rxjava.RetryWhenProcess) VideoException(com.dante.exception.VideoException) VideoResult(com.dante.data.model.VideoResult) NonNull(android.support.annotation.NonNull)

Aggregations

VideoResult (com.dante.data.model.VideoResult)10 UnLimit91PornItem (com.dante.data.model.UnLimit91PornItem)4 NonNull (android.support.annotation.NonNull)2 Date (java.util.Date)2 Document (org.jsoup.nodes.Document)2 Intent (android.content.Intent)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 LoadMoreView (com.chad.library.adapter.base.loadmore.LoadMoreView)1 BaseResult (com.dante.data.model.BaseResult)1 FavoriteException (com.dante.exception.FavoriteException)1 MessageException (com.dante.exception.MessageException)1 VideoException (com.dante.exception.VideoException)1 RetryWhenProcess (com.dante.rxjava.RetryWhenProcess)1 AuthorActivity (com.dante.ui.porn91video.author.AuthorActivity)1 Disposable (io.reactivex.disposables.Disposable)1 Function (io.reactivex.functions.Function)1