| | |
| | | import com.lcjian.library.RetainViewFragment; |
| | | import com.lcjian.library.dialog.DialogUtil; |
| | | import com.lcjian.library.util.SingleToast; |
| | | import com.lcjian.library.util.common.ClipboardUtil; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.weikou.beibeivideo.BasicTextHttpResponseHandler; |
| | |
| | | import com.weikou.beibeivideo.entity.ad.PlayVideoPreADSetting; |
| | | import com.weikou.beibeivideo.entity.ad.RewardVideoAdContainer; |
| | | import com.weikou.beibeivideo.ui.ad.PlayVideoPreADFragment; |
| | | import com.weikou.beibeivideo.ui.dialog.JumpVideoLoadingDialog; |
| | | import com.weikou.beibeivideo.ui.dialog.LoadingDialogUtil; |
| | | import com.weikou.beibeivideo.ui.dialog.VIPDialog; |
| | | import com.weikou.beibeivideo.ui.login.LoginActivity; |
| | |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.ConfigUtil; |
| | | import com.weikou.beibeivideo.util.DimenUtils; |
| | | import com.weikou.beibeivideo.util.UmengEventUtil; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | | import com.weikou.beibeivideo.util.ad.AdUtil; |
| | | import com.weikou.beibeivideo.util.ad.CSJConstant; |
| | |
| | | private final static String TAG = PPTVPlayFragment.class.getSimpleName(); |
| | | |
| | | private TextView tv_top_bar_left; |
| | | private TextView tv_no_ad_reward_notify; |
| | | private android.webkit.WebView webview; |
| | | FrameLayout fl_ad; |
| | | FrameLayout fl_container; |
| | | private ImageView iv_favourite, iv_watch_history; |
| | | private LinearLayout ll_bottom, ll_vip_open; |
| | | private TextView tv_vip_open; |
| | | private LinearLayout ll_bottom, ll_vip_open, ll_top; |
| | | private TextView tv_vip_open, tv_title, tv_url; |
| | | |
| | | private boolean showAd = true; |
| | | |
| | | private Dialog loadingDialog; |
| | | private ImageView iv_refresh; |
| | | |
| | | |
| | | private void getPPVideoInfo(String url) { |
| | | if (url.contains("cid=") && url.contains("vid=")) { |
| | |
| | | showAd = true; |
| | | adPlayFinish(); |
| | | } |
| | | setLeftTime(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | WindowManager.LayoutParams attrs = getActivity().getWindow().getAttributes(); |
| | | attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN; |
| | | getActivity().getWindow().setAttributes(attrs); |
| | | ll_bottom.setVisibility(View.GONE); |
| | | ll_top.setVisibility(View.GONE); |
| | | } |
| | | |
| | | @Override |
| | |
| | | viewGroup.removeView(myVideoView); |
| | | viewGroup.addView(myNormalView); |
| | | } |
| | | // ll_bottom.setVisibility(View.VISIBLE); |
| | | ll_top.setVisibility(View.VISIBLE); |
| | | getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); |
| | | WindowManager.LayoutParams attrs = getActivity().getWindow().getAttributes(); |
| | | attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN; |
| | | getActivity().getWindow().setAttributes(attrs); |
| | | setLeftTime(); |
| | | } |
| | | }); |
| | | WebSettings webSetting = webview.getSettings(); |
| | |
| | | Bundle bundle = getArguments(); |
| | | if (bundle != null) { |
| | | String url = bundle.getString("playUrl", ""); |
| | | String title = bundle.getString("name", ""); |
| | | tv_url.setText(url); |
| | | tv_title.setText(title); |
| | | |
| | | videoId = bundle.getString("videoId"); |
| | | 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); |
| | | webview.postDelayed(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | toast.cancel(); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | } |
| | | }, 1000); |
| | | } |
| | | } |
| | | |
| | |
| | | tv_top_bar_left.setOnClickListener(this); |
| | | fl_container = view.findViewById(R.id.fl_container); |
| | | |
| | | tv_no_ad_reward_notify = view.findViewById(R.id.tv_no_ad_reward_notify); |
| | | |
| | | |
| | | iv_favourite = view.findViewById(R.id.iv_add_to_favourite); |
| | | iv_watch_history = view.findViewById(R.id.iv_watch_history); |
| | | ll_bottom = view.findViewById(R.id.ll_bottom); |
| | | ll_bottom.setVisibility(View.GONE); |
| | | ll_vip_open = view.findViewById(R.id.ll_vip_open); |
| | | tv_vip_open = view.findViewById(R.id.tv_vip_open); |
| | | ll_top = view.findViewById(R.id.ll_top); |
| | | tv_title = view.findViewById(R.id.tv_title); |
| | | tv_url = view.findViewById(R.id.tv_url); |
| | | iv_refresh = view.findViewById(R.id.iv_refresh); |
| | | |
| | | |
| | | iv_favourite.setOnClickListener(this); |
| | | iv_watch_history.setOnClickListener(this); |
| | | ll_vip_open.setOnClickListener(this); |
| | | iv_refresh.setOnClickListener(this); |
| | | tv_url.setOnClickListener(new View.OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (tv_url.getText() != null) { |
| | | ClipboardUtil.copy(getContext(), tv_url.getText().toString()); |
| | | Toast.makeText(getContext(), "链接复制成功", Toast.LENGTH_SHORT).show(); |
| | | } |
| | | } |
| | | }); |
| | | tv_url.setOnLongClickListener(new View.OnLongClickListener() { |
| | | @Override |
| | | public boolean onLongClick(View v) { |
| | | if (tv_url.getText() != null) { |
| | | ClipboardUtil.copy(getContext(), tv_url.getText().toString()); |
| | | Toast.makeText(getContext(), "链接复制成功", Toast.LENGTH_SHORT).show(); |
| | | } |
| | | return true; |
| | | } |
| | | }); |
| | | |
| | | |
| | | vipDialog = new VIPDialog.Builder(getActivity()).setCloseListener(new OnClickListener() { |
| | |
| | | jumpToVIP(); |
| | | } |
| | | }).create(); |
| | | |
| | | } |
| | | |
| | | private void jumpToVIP() { |
| | |
| | | } |
| | | |
| | | isCollect(); |
| | | setLeftTime(); |
| | | } |
| | | |
| | | private void setLeftTime() { |
| | | if (tv_no_ad_reward_notify == null) |
| | | return; |
| | | int leftTime = AdUtil.getPPTVNoAdRewardLeftTimeWithMinute(getContext()); |
| | | //设置免广告权益倒计时 |
| | | if (leftTime > 0) { |
| | | tv_no_ad_reward_notify.setVisibility(View.VISIBLE); |
| | | tv_no_ad_reward_notify.setText(String.format("恭喜你!免广告权益%s分钟后可重新获得", leftTime)); |
| | | } else { |
| | | tv_no_ad_reward_notify.setVisibility(View.GONE); |
| | | } |
| | | } |
| | | |
| | | Dialog vipDialog; |
| | |
| | | case R.id.ll_vip_open: |
| | | jumpToVIP(); |
| | | break; |
| | | case R.id.iv_refresh: |
| | | if (webview != null) { |
| | | webview.reload(); |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | |
| | | super.onActivityResult(requestCode, resultCode, data); |
| | | } |
| | | |
| | | private void showRewardSuccessToast() { |
| | | private void showRewardSuccessToast(boolean success) { |
| | | |
| | | fl_ad.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | TextView textView = new TextView(getContext()); |
| | | textView.setText(String.format("高清视频免广告权益发放成功(%s小时内有效)", AdUtil.getPPTVNoAdRewardHour(BeibeiVideoApplication.application))); |
| | | textView.setTextColor(Color.WHITE); |
| | | textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); |
| | | textView.setBackgroundResource(R.drawable.shape_video_no_ad_reward_success_notify_bg); |
| | | ToastUtil.showMiddleToast(getContext(), textView, Toast.LENGTH_LONG); |
| | | // TextView textView = new TextView(getContext()); |
| | | // textView.setText(String.format("高清视频免广告权益发放成功(%s小时内有效)", AdUtil.getPPTVNoAdRewardHour(BeibeiVideoApplication.application))); |
| | | // textView.setTextColor(Color.WHITE); |
| | | // textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); |
| | | // textView.setBackgroundResource(R.drawable.shape_video_no_ad_reward_success_notify_bg); |
| | | View view = null; |
| | | if (success) |
| | | view = LayoutInflater.from(getContext()).inflate(R.layout.item_no_ad_reward_notify_success, null); |
| | | else { |
| | | view = LayoutInflater.from(getContext()).inflate(R.layout.item_no_ad_reward_notify_fail, null); |
| | | view.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); |
| | | } |
| | | ToastUtil.showMiddleToast(getContext(), view, Toast.LENGTH_LONG); |
| | | } |
| | | }); |
| | | |
| | |
| | | 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)); |
| | | |
| | | mVideoDetailVideoAdFragment = new PlayVideoPreADFragment(); |
| | | mVideoDetailVideoAdFragment = PlayVideoPreADFragment.newInstance(); |
| | | Bundle bundle = new Bundle(); |
| | | bundle.putInt("skipDuration", 15); |
| | | mVideoDetailVideoAdFragment.setArguments(bundle); |
| | | |
| | | mVideoDetailVideoAdFragment.setPageEventListener(new IPageEventListener() { |
| | | @Override |
| | | public void onCreateView() { |
| | |
| | | |
| | | @Override |
| | | public void onReward() { |
| | | showRewardSuccessToast(); |
| | | |
| | | reward = true; |
| | | //免广告3小时 |
| | | AdUtil.setPPTVNoAdRewardSuccess(BeibeiVideoApplication.application); |
| | |
| | | @Override |
| | | public void onClose() { |
| | | if (reward) { |
| | | showRewardSuccessToast(true); |
| | | if (mVideoDetailVideoAdFragment != null) |
| | | mVideoDetailVideoAdFragment.finishPlay(); |
| | | } else { |
| | | showRewardSuccessToast(false); |
| | | } |
| | | } |
| | | }; |
| | |
| | | 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(); |
| | | } |
| | |
| | | |
| | | } |
| | | }); |
| | | getChildFragmentManager().beginTransaction().replace(R.id.fl_ad, mVideoDetailVideoAdFragment).commit(); |
| | | getChildFragmentManager().beginTransaction().replace(R.id.fl_ad, mVideoDetailVideoAdFragment).commitAllowingStateLoss(); |
| | | } |
| | | |
| | | |