| | |
| | | } |
| | | |
| | | private String videoId; |
| | | //是否为VIP视频 |
| | | private boolean isVIPVideo; |
| | | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | |
| | | tv_title.setText(title); |
| | | |
| | | videoId = bundle.getString("videoId"); |
| | | isVIPVideo = bundle.getBoolean("vip", false); |
| | | webview.loadUrl(url); |
| | | View view = LayoutInflater.from(getContext()).inflate(R.layout.item_jump_video_loading, null); |
| | | Toast toast = ToastUtil.showMiddleToast(getContext(), view, Toast.LENGTH_SHORT); |
| | |
| | | |
| | | fl_ad.setVisibility(View.VISIBLE); |
| | | PlayVideoPreADSetting setting = new PlayVideoPreADSetting(AdUtil.AD_TYPE.gdt, BeibeiConstant.GDT_ID, GDTConstant.PID_2_VIDEO_DETAIL_PLAYER_PRE_PPTV, null); |
| | | setting.setNeedShowRewardNotify(AdUtil.showPPTVNoAdReward(BeibeiVideoApplication.application)); |
| | | if (isVIPVideo) { |
| | | setting.setOtherAction("0元看本片"); |
| | | } else { |
| | | setting.setOtherAction("获取免广告权益"); |
| | | } |
| | | |
| | | mVideoDetailVideoAdFragment = PlayVideoPreADFragment.newInstance(); |
| | | Bundle bundle = new Bundle(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void noAdRewardClick() { |
| | | int width = DimenUtils.getScreenWidth(getContext()); |
| | | int height = DimenUtils.getScreenHeight(getContext()); |
| | | |
| | | |
| | | DialogUtil.show(loadingDialog); |
| | | //激励视频 |
| | | |
| | | RewardVideoAdManager.IAdShowListener showListener = new RewardVideoAdManager.IAdShowListener() { |
| | | |
| | | private boolean reward = false; |
| | | |
| | | @Override |
| | | public void onShow() { |
| | | reward = false; |
| | | } |
| | | |
| | | @Override |
| | | public void onReward() { |
| | | |
| | | reward = true; |
| | | //免广告3小时 |
| | | AdUtil.setPPTVNoAdRewardSuccess(BeibeiVideoApplication.application); |
| | | } |
| | | |
| | | @Override |
| | | public void onError(String msg) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onClose() { |
| | | if (reward) { |
| | | showRewardSuccessToast(true); |
| | | if (mVideoDetailVideoAdFragment != null) |
| | | mVideoDetailVideoAdFragment.finishPlay(); |
| | | } else { |
| | | showRewardSuccessToast(false); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | Context context = BeibeiVideoApplication.application; |
| | | AdUtil.AD_TYPE pptvNoAdReward = AdUtil.getAdType(context, AdPositionEnum.pptvNoAdReward); |
| | | String pid = AdUtil.getAdPid(context, AdPositionEnum.pptvNoAdReward); |
| | | if (pptvNoAdReward == null) { |
| | | Toast.makeText(context, "暂不可用", Toast.LENGTH_SHORT).show(); |
| | | return; |
| | | public void onOtherClick(String name) { |
| | | if (name != null && name.contains("广告")) { |
| | | loadRewardAd(); |
| | | } else { |
| | | getActivityInfo(tv_url.getText() + ""); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(pid)) { |
| | | if (pptvNoAdReward != null) { |
| | | if (pptvNoAdReward == AdUtil.AD_TYPE.csj) { |
| | | pid = CSJConstant.VIDEO_REWARD_PPTV; |
| | | } else if (pptvNoAdReward == AdUtil.AD_TYPE.gdt2) { |
| | | pid = GDTConstant.PID_2_VIDEO_DETAIL_PLAYER_REWARD_PPTV; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | new RewardVideoAdManager(pptvNoAdReward, BeibeiVideoApplication.application).loadAd(width, height, pid, false, new RewardVideoAdManager.IAdLoadListener() { |
| | | @Override |
| | | public void onSuccess(RewardVideoAdContainer ad) { |
| | | fl_ad.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | UmengEventUtil.pptvNoAdRewardClick(getContext(), pptvNoAdReward.name()); |
| | | DialogUtil.dismiss(loadingDialog); |
| | | RewardVideoAdManager.showAd(getActivity(), ad, showListener); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void onError(String msg) { |
| | | UmengEventUtil.pptvNoAdRewardClick(getContext(), "fail"); |
| | | DialogUtil.dismiss(loadingDialog); |
| | | Toast.makeText(context, "广告拉取失败,请稍后再试", Toast.LENGTH_SHORT).show(); |
| | | } |
| | | }, showListener); |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | getChildFragmentManager().beginTransaction().replace(R.id.fl_ad, mVideoDetailVideoAdFragment).commitAllowingStateLoss(); |
| | | } |
| | | |
| | | private void loadRewardAd() { |
| | | |
| | | int width = DimenUtils.getScreenWidth(getContext()); |
| | | int height = DimenUtils.getScreenHeight(getContext()); |
| | | |
| | | |
| | | DialogUtil.show(loadingDialog); |
| | | //激励视频 |
| | | |
| | | RewardVideoAdManager.IAdShowListener showListener = new RewardVideoAdManager.IAdShowListener() { |
| | | |
| | | private boolean reward = false; |
| | | |
| | | @Override |
| | | public void onShow() { |
| | | reward = false; |
| | | } |
| | | |
| | | @Override |
| | | public void onReward() { |
| | | |
| | | reward = true; |
| | | //免广告3小时 |
| | | AdUtil.setPPTVNoAdRewardSuccess(BeibeiVideoApplication.application); |
| | | } |
| | | |
| | | @Override |
| | | public void onError(String msg) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onClose() { |
| | | if (reward) { |
| | | showRewardSuccessToast(true); |
| | | if (mVideoDetailVideoAdFragment != null) |
| | | mVideoDetailVideoAdFragment.finishPlay(); |
| | | } else { |
| | | showRewardSuccessToast(false); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | Context context = BeibeiVideoApplication.application; |
| | | AdUtil.AD_TYPE pptvNoAdReward = AdUtil.getAdType(context, AdPositionEnum.pptvNoAdReward); |
| | | String pid = AdUtil.getAdPid(context, AdPositionEnum.pptvNoAdReward); |
| | | if (pptvNoAdReward == null) { |
| | | Toast.makeText(context, "暂不可用", Toast.LENGTH_SHORT).show(); |
| | | return; |
| | | } |
| | | |
| | | if (StringUtils.isBlank(pid)) { |
| | | if (pptvNoAdReward != null) { |
| | | if (pptvNoAdReward == AdUtil.AD_TYPE.csj) { |
| | | pid = CSJConstant.VIDEO_REWARD_PPTV; |
| | | } else if (pptvNoAdReward == AdUtil.AD_TYPE.gdt2) { |
| | | pid = GDTConstant.PID_2_VIDEO_DETAIL_PLAYER_REWARD_PPTV; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | new RewardVideoAdManager(pptvNoAdReward, BeibeiVideoApplication.application).loadAd(width, height, pid, false, new RewardVideoAdManager.IAdLoadListener() { |
| | | @Override |
| | | public void onSuccess(RewardVideoAdContainer ad) { |
| | | fl_ad.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | UmengEventUtil.pptvNoAdRewardClick(getContext(), pptvNoAdReward.name()); |
| | | DialogUtil.dismiss(loadingDialog); |
| | | RewardVideoAdManager.showAd(getActivity(), ad, showListener); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void onError(String msg) { |
| | | UmengEventUtil.pptvNoAdRewardClick(getContext(), "fail"); |
| | | DialogUtil.dismiss(loadingDialog); |
| | | Toast.makeText(context, "广告拉取失败,请稍后再试", Toast.LENGTH_SHORT).show(); |
| | | } |
| | | }, showListener); |
| | | |
| | | } |
| | | |
| | | |
| | | private void adPlayFinish() { |
| | | if (webview != null) |