| | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | public class PPTVPlayFragment extends RetainViewFragment implements OnClickListener { |
| | | private final static int REQUEST_CODE_LOGIN = 1001; |
| | | |
| | |
| | | |
| | | private boolean showAd = true; |
| | | |
| | | private void getPPVideoInfo(String url) { |
| | | if (url.contains("cid=") && url.contains("vid=")) { |
| | | String[] sts = url.split("\\?"); |
| | | if (sts.length > 1) { |
| | | String params = sts[1]; |
| | | String[] ps = params.split("&"); |
| | | Map<String, String> map = new HashMap<>(); |
| | | for (String p : ps) { |
| | | map.put(p.split("=")[0], p.split("=")[1]); |
| | | } |
| | | String cid = map.get("cid"); |
| | | String vid = map.get("vid"); |
| | | //PPTV播放上传 |
| | | BeibeiVideoAPI.uploadPPTVPlayRecord(getContext(), cid, vid, new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | |
| | | } |
| | | }); |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void initWebView(View view) { |
| | | fl_ad = view.findViewById(R.id.fl_ad); |
| | | webview = view.findViewById(R.id.webview); |
| | | webview.setWebViewClient(new WebViewClient() { |
| | | @Override |
| | | public boolean shouldOverrideUrlLoading(WebView view, String url) { |
| | | Log.i(TAG, "shouldOverrideUrlLoading:" + url); |
| | | if (url != null && (!url.startsWith("http"))) { |
| | | return true; |
| | | } |
| | | |
| | | try { |
| | | getPPVideoInfo(url); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | return super.shouldOverrideUrlLoading(view, url); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void onPageFinished(WebView webView, String s) { |
| | |
| | | public void onClick(View v) { |
| | | switch (v.getId()) { |
| | | case R.id.tv_top_bar_left: { |
| | | |
| | | if (getActivity().getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) { |
| | | if (webview != null) |
| | | webview.loadUrl("javascript:exitFullScreenPlay();"); |
| | | getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); |
| | | WindowManager.LayoutParams attrs = getActivity().getWindow().getAttributes(); |
| | | attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN; |
| | |
| | | } else { |
| | | getActivity().finish(); |
| | | } |
| | | |
| | | } |
| | | break; |
| | | case R.id.iv_add_to_favourite: |