| | |
| | | import android.content.Intent; |
| | | import android.content.SharedPreferences; |
| | | import android.content.pm.ActivityInfo; |
| | | import android.graphics.Color; |
| | | import android.net.Uri; |
| | | import android.net.http.SslError; |
| | | import android.os.Build; |
| | |
| | | import android.webkit.ConsoleMessage; |
| | | import android.webkit.SslErrorHandler; |
| | | import android.webkit.WebChromeClient; |
| | | import android.webkit.WebResourceRequest; |
| | | import android.webkit.WebSettings; |
| | | import android.webkit.WebView; |
| | | import android.webkit.WebViewClient; |
| | |
| | | import android.widget.Toast; |
| | | |
| | | import com.androidquery.AQuery; |
| | | import com.google.gson.Gson; |
| | | import com.lcjian.library.RetainViewFragment; |
| | | import com.lcjian.library.dialog.DialogUtil; |
| | | import com.lcjian.library.util.SingleToast; |
| | |
| | | import com.weikou.beibeivideo.entity.ad.AdPositionEnum; |
| | | import com.weikou.beibeivideo.entity.ad.PlayVideoPreADSetting; |
| | | import com.weikou.beibeivideo.entity.ad.RewardVideoAdContainer; |
| | | import com.weikou.beibeivideo.entity.vo.PPTVVideoActivityInfoVO; |
| | | import com.weikou.beibeivideo.entity.vo.PPTVWatchVIPVideoActivityWay; |
| | | 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.dialog.VIPNewDialog; |
| | | import com.weikou.beibeivideo.ui.login.LoginActivity; |
| | | import com.weikou.beibeivideo.ui.main.MainActivity; |
| | | import com.weikou.beibeivideo.ui.video.VideoPlayerBrowserActivity; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.ConfigUtil; |
| | | import com.weikou.beibeivideo.util.DimenUtils; |
| | | import com.weikou.beibeivideo.util.JumpActivityUtil; |
| | | import com.weikou.beibeivideo.util.UmengEventUtil; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | | import com.weikou.beibeivideo.util.ad.AdUtil; |
| | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public class PPTVPlayFragment extends RetainViewFragment implements OnClickListener { |
| | |
| | | private AQuery query; |
| | | |
| | | |
| | | private void getPPVideoInfo(String url) { |
| | | private String[] getPPVideoInfo(String url) { |
| | | if (url.contains("cid=") && url.contains("vid=")) { |
| | | String[] sts = url.split("\\?"); |
| | | if (sts.length > 1) { |
| | |
| | | String[] ps = params.split("&"); |
| | | Map<String, String> map = new HashMap<>(); |
| | | for (String p : ps) { |
| | | map.put(p.split("=")[0], p.split("=")[1]); |
| | | map.put(p.split("=")[0], p.split("=").length > 1 ? 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 { |
| | | |
| | | } |
| | | }); |
| | | return new String[]{cid, vid}; |
| | | |
| | | |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private void initWebView(View view) { |
| | |
| | | } |
| | | |
| | | try { |
| | | getPPVideoInfo(url); |
| | | String[] cvid = getPPVideoInfo(url); |
| | | if (cvid != null && cvid.length > 1) { |
| | | //PPTV播放上传 |
| | | BeibeiVideoAPI.uploadPPTVPlayRecord(getContext(), cvid[0], cvid[1], new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | |
| | | public void onReceivedTitle(WebView view, String title) { |
| | | super.onReceivedTitle(view, title); |
| | | tv_url.setText(view.getUrl()); |
| | | tv_title.setText(title); |
| | | // tv_title.setText(title); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public void run() { |
| | | getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); |
| | | if (vipDialog != null && !vipDialog.isShowing()) |
| | | vipDialog.show(); |
| | | // if (vipDialog != null && !vipDialog.isShowing()) |
| | | // vipDialog.show(); |
| | | getActivityInfo(tv_url.getText() + ""); |
| | | } |
| | | }); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private VIPNewDialog vipNewDialog; |
| | | |
| | | private synchronized void getActivityInfo(String url) { |
| | | String cid = ""; |
| | | String vid = ""; |
| | | try { |
| | | String[] cvids = getPPVideoInfo(url); |
| | | if (cvids != null && cvids.length > 1) { |
| | | cid = cvids[0]; |
| | | vid = cvids[1]; |
| | | } |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | |
| | | DialogUtil.dismiss(vipNewDialog); |
| | | BeibeiVideoAPI.getPPTVVIPVideoActivity(getContext(), url, cid, vid, new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | | JSONObject data = jsonObject.optJSONObject("Data"); |
| | | PPTVVideoActivityInfoVO vo = new Gson().fromJson(data.toString(), PPTVVideoActivityInfoVO.class); |
| | | vipNewDialog = new VIPNewDialog.Builder(getActivity()).setActivityData(vo.getWayList(), vo.getVideoName()).setCloseListener(new OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | DialogUtil.dismiss(vipNewDialog); |
| | | } |
| | | }).setItemClickListener(new VIPNewDialog.ItemClickListener() { |
| | | @Override |
| | | public void onClick(PPTVWatchVIPVideoActivityWay way) { |
| | | DialogUtil.dismiss(vipNewDialog); |
| | | if ("vip".equalsIgnoreCase(way.getType())) { |
| | | jumpToVIP(); |
| | | } else { |
| | | if (way.getJumpDetail() != null) |
| | | JumpActivityUtil.jumpPage(getActivity(), way.getJumpDetail(), way.getParams() != null ? com.alibaba.fastjson.JSONObject.parseObject(way.getParams().replace( |
| | | "\\" + "\"", "\"")) : null); |
| | | } |
| | | } |
| | | }).create(); |
| | | DialogUtil.show(vipNewDialog); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) { |
| | | super.onFailure(statusCode, headers, responseString, throwable); |
| | | Toast.makeText(getContext(), "网络请求出错", Toast.LENGTH_SHORT).show(); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | private void initView(View view) { |
| | | loadingDialog = LoadingDialogUtil.getLoadingDialog(getContext(), ""); |