| | |
| | | package com.weikou.beibeivideo.ui.mine; |
| | | |
| | | import android.app.Activity; |
| | | import android.app.AlertDialog; |
| | | import android.app.Dialog; |
| | | import android.app.Notification; |
| | | import android.app.NotificationManager; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.SharedPreferences; |
| | | import android.content.pm.ActivityInfo; |
| | | import android.content.res.Configuration; |
| | | import android.net.http.SslError; |
| | | import android.os.Bundle; |
| | | import android.support.annotation.NonNull; |
| | | import android.support.annotation.Nullable; |
| | | import android.support.v4.app.NotificationCompat; |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | |
| | | import android.webkit.WebView; |
| | | import android.webkit.WebViewClient; |
| | | import android.widget.FrameLayout; |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.ProgressBar; |
| | | import android.widget.TextView; |
| | | |
| | | import com.lcjian.library.RetainViewFragment; |
| | | import com.tencent.smtt.export.external.interfaces.IX5WebChromeClient; |
| | | import com.lcjian.library.util.SingleToast; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.weikou.beibeivideo.BasicTextHttpResponseHandler; |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | | import com.weikou.beibeivideo.BeibeiVideoApplication; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.entity.ad.PlayVideoPreADSetting; |
| | |
| | | import com.weikou.beibeivideo.util.ConfigUtil; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | | import com.weikou.beibeivideo.util.ad.AdUtil; |
| | | import com.weikou.beibeivideo.util.ad.GDTConstant; |
| | | import com.weikou.beibeivideo.util.browser.PPJavaInterface; |
| | | import com.weikou.beibeivideo.util.ui.IPageEventListener; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | public class PPTVPlayFragment extends RetainViewFragment implements OnClickListener { |
| | | private final static int REQUEST_CODE_LOGIN = 1001; |
| | |
| | | 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 boolean showAd = true; |
| | | |
| | |
| | | return R.layout.browser_pptv_activity; |
| | | } |
| | | |
| | | private String videoId; |
| | | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | initView(contentView); |
| | | String url = "http://vip.pptv.com/activity/2021/pg_bwysdqmovie?cid=32159127&vid=32159127&programtype=2"; |
| | | url = "https://acmd.api.pptv.com/2021/bwysdqmovie_thrid_h5.html?cid=32159127&vid=32159127&programtype=3"; |
| | | webview.loadUrl(url); |
| | | Bundle bundle = getArguments(); |
| | | if (bundle != null) { |
| | | String url = bundle.getString("playUrl", ""); |
| | | videoId = bundle.getString("videoId"); |
| | | webview.loadUrl(url); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | tv_top_bar_left = view.findViewById(R.id.tv_top_bar_left); |
| | | tv_top_bar_left.setOnClickListener(this); |
| | | fl_container = view.findViewById(R.id.fl_container); |
| | | |
| | | |
| | | 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_vip_open = view.findViewById(R.id.ll_vip_open); |
| | | tv_vip_open = view.findViewById(R.id.tv_vip_open); |
| | | |
| | | |
| | | iv_favourite.setOnClickListener(this); |
| | | iv_watch_history.setOnClickListener(this); |
| | | ll_vip_open.setOnClickListener(this); |
| | | |
| | | |
| | | vipDialog = new VIPDialog.Builder(getActivity()).setCloseListener(new OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | |
| | | @Override |
| | | public void onClick(View v) { |
| | | vipDialog.dismiss(); |
| | | startActivityForResult(new Intent(BeibeiVideoApplication.application, BrowserActivity.class).putExtra("url", ConfigUtil.getVipLink(BeibeiVideoApplication.application)), REQUEST_CODE_VIP); |
| | | jumpToVIP(); |
| | | } |
| | | }).create(); |
| | | } |
| | | |
| | | //测试 |
| | | // fl_container.postDelayed(new Runnable() { |
| | | // @Override |
| | | // public void run() { |
| | | // getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); |
| | | // if (!vipDialog.isShowing()) |
| | | // vipDialog.show(); |
| | | // } |
| | | // }, 10000); |
| | | private void jumpToVIP() { |
| | | startActivityForResult(new Intent(BeibeiVideoApplication.application, BrowserActivity.class).putExtra("result", true).putExtra("url", ConfigUtil.getVipLink(BeibeiVideoApplication.application)), REQUEST_CODE_VIP); |
| | | } |
| | | |
| | | |
| | | private void initData() { |
| | | if (UserUtil.isVIP(BeibeiVideoApplication.application)) { |
| | | tv_vip_open.setText("VIP续费"); |
| | | } else { |
| | | tv_vip_open.setText("开通VIP"); |
| | | } |
| | | |
| | | isCollect(); |
| | | |
| | | } |
| | | |
| | | Dialog vipDialog; |
| | |
| | | |
| | | PlayVideoPreADFragment mVideoDetailVideoAdFragment; |
| | | |
| | | |
| | | private NotificationManager manager; |
| | | private Notification notif; |
| | | private Notification.Builder oBuilder; |
| | | private NotificationCompat.Builder builder; |
| | | int j = -1; |
| | | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | MobclickAgent.onPageStart("网页"); |
| | | // webview.reload(); |
| | | initData(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | case R.id.tv_top_bar_left: { |
| | | getActivity().finish(); |
| | | } |
| | | break; |
| | | case R.id.iv_add_to_favourite: |
| | | collect(collected); |
| | | break; |
| | | case R.id.iv_watch_history: |
| | | startActivity(new Intent(iv_watch_history.getContext(), WatchHistoryActivity.class)); |
| | | break; |
| | | case R.id.ll_vip_open: |
| | | jumpToVIP(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | // 设置回退 |
| | | // 覆盖Activity类的onKeyDown(int keyCoder,KeyEvent event)方法 |
| | | // @Override |
| | | // public boolean onKeyDown(int keyCode, KeyEvent event) { |
| | | // if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack()) { |
| | | // webview.goBack(); // goBack()表示返回WebView的上一页面 |
| | | // return true; |
| | | // } |
| | | // return super.onKeyDown(keyCode, event); |
| | | // } |
| | | |
| | | |
| | | @Override |
| | | public void onActivityResult(int requestCode, int resultCode, Intent data) { |
| | |
| | | getChildFragmentManager().beginTransaction().remove(mVideoDetailVideoAdFragment).commitAllowingStateLoss(); |
| | | adPlayFinish(); |
| | | } |
| | | }, new PlayVideoPreADSetting(AdUtil.AD_TYPE.gdt, BeibeiConstant.GDT_ID, "5061928359494942", null)); |
| | | }, new PlayVideoPreADSetting(AdUtil.AD_TYPE.gdt, BeibeiConstant.GDT_ID, GDTConstant.PID_2_VIDEO_DETAIL_PLAYER_PRE_PPTV, null)); |
| | | |
| | | } |
| | | }); |
| | |
| | | if (webview != null) |
| | | webview.loadUrl("javascript:adPlayFinish()"); |
| | | } |
| | | |
| | | private boolean collected = false; |
| | | |
| | | private void isCollect() { |
| | | BeibeiVideoAPI.isCollect(iv_favourite.getContext(), UserUtil.getUid(BeibeiVideoApplication.application), videoId, |
| | | 0 + "", new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | collected = true; |
| | | iv_favourite.setImageResource(R.drawable.ic_video_detail_favourite2); |
| | | } else { |
| | | collected = false; |
| | | iv_favourite.setImageResource(R.drawable.ic_video_detail_favourite1); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private void collect(boolean cancel) { |
| | | SharedPreferences preferences = getContext().getSharedPreferences( |
| | | "user", Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | BeibeiVideoAPI.getScoreCollect(getContext(), uid, UserUtil.getLoginUid(BeibeiVideoApplication.application), videoId, |
| | | 0+"", cancel ? "0" : "1", new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | if (!cancel) { |
| | | collected = true; |
| | | SingleToast.showToast(getContext(), "收藏成功"); |
| | | } else { |
| | | collected = false; |
| | | SingleToast.showToast(getContext(), "取消收藏成功"); |
| | | } |
| | | } else { |
| | | if (!cancel) { |
| | | SingleToast.showToast(getContext(), "收藏失败"); |
| | | } else { |
| | | SingleToast.showToast(getContext(), "取消收藏失败"); |
| | | } |
| | | } |
| | | isCollect(); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | } |