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