| | |
| | | import android.graphics.drawable.Drawable; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.support.annotation.NonNull; |
| | | import android.support.annotation.Nullable; |
| | | import android.support.v4.app.Fragment; |
| | | import android.support.v4.app.FragmentManager; |
| | | import android.support.v4.app.FragmentTransaction; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.annotation.Nullable; |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.fragment.app.FragmentManager; |
| | | import androidx.fragment.app.FragmentTransaction; |
| | | |
| | | import android.util.Log; |
| | | import android.view.KeyEvent; |
| | | import android.view.View; |
| | |
| | | import com.bumptech.glide.request.RequestOptions; |
| | | import com.bumptech.glide.request.target.SimpleTarget; |
| | | import com.bumptech.glide.request.transition.Transition; |
| | | import com.bytedance.sdk.openadsdk.AdSlot; |
| | | import com.bytedance.sdk.openadsdk.TTAdConstant; |
| | | import com.bytedance.sdk.openadsdk.TTAdNative; |
| | | import com.bytedance.sdk.openadsdk.TTAdSdk; |
| | | import com.bytedance.sdk.openadsdk.TTFullScreenVideoAd; |
| | | import com.bytedance.sdk.openadsdk.TTNativeExpressAd; |
| | | import com.funshion.video.parser.FunshionWebPlayerFragment; |
| | | import com.google.gson.FieldNamingPolicy; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.lcjian.library.entity.eventbus.PlayerControllerShow; |
| | | import com.lcjian.library.entity.eventbus.PlayerLock; |
| | | import com.lcjian.library.util.ManifestDataUtil; |
| | | import com.lcjian.library.util.SingleToast; |
| | | import com.lcjian.library.util.SystemCommon; |
| | | import com.lcjian.library.util.common.DimenUtils; |
| | |
| | | import com.weikou.beibeivideo.entity.VideoDetailInfo; |
| | | import com.weikou.beibeivideo.entity.VideoInfo; |
| | | import com.weikou.beibeivideo.entity.VideoResource; |
| | | import com.weikou.beibeivideo.entity.ad.AdPositionEnum; |
| | | import com.weikou.beibeivideo.entity.video.ChangeVideoEvent; |
| | | import com.weikou.beibeivideo.entity.vo.VideoDetailAdInfoVO; |
| | | import com.weikou.beibeivideo.ui.BaseActivity; |
| | | import com.weikou.beibeivideo.ui.ad.PlayVideoPreADFragment; |
| | | import com.weikou.beibeivideo.ui.common.ShareActivity; |
| | | import com.weikou.beibeivideo.ui.mine.PPTVPlayFragment; |
| | | import com.weikou.beibeivideo.ui.video.VideoPlayerBrowserActivity; |
| | | import com.weikou.beibeivideo.ui.video.FunshionPlayerFragment; |
| | | import com.weikou.beibeivideo.ui.video.VideoPlayerActivity; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | import com.weikou.beibeivideo.util.UmengEventUtil; |
| | | import com.weikou.beibeivideo.util.VideoUtil; |
| | | import com.weikou.beibeivideo.util.ad.AdUtil; |
| | | import com.weikou.beibeivideo.util.ad.CSJConstant; |
| | | import com.weikou.beibeivideo.util.ad.FullVideoAdManager; |
| | | import com.weikou.beibeivideo.util.ad.InterstitialAdUtil; |
| | | import com.weikou.beibeivideo.util.goldcorn.GoldCornUtil; |
| | | import com.weikou.beibeivideo.util.ui.IPageEventListener; |
| | | import com.weikou.beibeivideo.util.ui.TopStatusSettings; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.greenrobot.eventbus.Subscribe; |
| | | import org.json.JSONArray; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import de.greenrobot.event.EventBus; |
| | | import org.greenrobot.eventbus.EventBus; |
| | | |
| | | |
| | | /** |
| | |
| | | OnClickListener { |
| | | |
| | | private final String TAG = VideoDetailActivity2.class.getName(); |
| | | |
| | | //外层容器 |
| | | LinearLayout ll_other; |
| | | FrameLayout fl_pptv; |
| | | |
| | | |
| | | // private boolean mLandscape; |
| | | private VideoInfo videoInfo; |
| | |
| | | |
| | | private boolean playerLock;//播放器是否锁屏 |
| | | |
| | | private String from; |
| | | |
| | | private VideoDetailAdInfoVO adInfo; |
| | | |
| | | //会话ID |
| | | private String sessionId; |
| | | |
| | | @Override |
| | | protected void onSaveInstanceState(Bundle outState) { |
| | | outState.putString("flash exit", "VideoDetailActivity"); |
| | |
| | | } |
| | | |
| | | private void initView() { |
| | | ll_other = findViewById(R.id.ll_other); |
| | | fl_pptv = findViewById(R.id.fl_pptv); |
| | | fl_pptv.setVisibility(View.GONE); |
| | | |
| | | |
| | | iv_select_play = findViewById(R.id.iv_select_play); |
| | | tv_back = findViewById(R.id.iv_back); |
| | | iv_download_failure = findViewById(R.id.iv_download_failure); |
| | |
| | | super.onCreate(savedInstanceState); |
| | | setContentView(R.layout.video_detail_activity); |
| | | VideoUtil.clearVideoEpisodeList(this); |
| | | /* |
| | | * 计算状态栏高度并设置 |
| | | */ |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { |
| | | int result = 0; |
| | | int resourceId = getResources().getIdentifier("status_bar_height", |
| | | "dimen", "android"); |
| | | if (resourceId > 0) { |
| | | result = getResources().getDimensionPixelSize(resourceId); |
| | | } |
| | | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, |
| | | result); |
| | | findViewById(R.id.v_status_bar).setLayoutParams(params); |
| | | } else { |
| | | findViewById(R.id.v_status_bar).setVisibility(View.GONE); |
| | | } |
| | | TopStatusSettings.setStatusViewAndDeepColor(this); |
| | | //屏幕常亮 |
| | | getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); |
| | | |
| | | //广告 |
| | | mVideoDetailVideoAdFragment = new PlayVideoPreADFragment(); |
| | |
| | | "video_info"); |
| | | if (videoInfo != null) |
| | | videoInfo.setVideoDetailList(null); |
| | | |
| | | from = getIntent().getStringExtra("from"); |
| | | UmengEventUtil.videoDetail(getApplicationContext(), from); |
| | | |
| | | if (getIntent().getBooleanExtra("isFromWatchHistory", false)) { |
| | | Cursor cursor = getContentResolver().query( |
| | | WatchHistoryTable.CONTENT_URI, null, |
| | |
| | | |
| | | |
| | | private void loadFullVideoAd() { |
| | | if (adInfo == null || !adInfo.isFullVideo()) |
| | | return; |
| | | |
| | | //如果是全局广告配置不允许展示则不展示 |
| | | if (AdUtil.getAdType(getApplicationContext(), AdPositionEnum.videoDetailFullVideo)==null){ |
| | | return; |
| | | } |
| | | |
| | | |
| | | |
| | | //加载广告 |
| | | if (BeibeiConstant.AD_TYPE.isVideoDetailSplashAd()) { |
| | | if (FullVideoAdManager.getInstance().isCacahed()) { |
| | | FullVideoAdManager.getInstance().showAd(this); |
| | | } else { |
| | | FullVideoAdManager.getInstance().loadAd(BeibeiVideoApplication.application, new FullVideoAdManager.IFullVideoAdListener() { |
| | | @Override |
| | | public void onSuccess(TTFullScreenVideoAd ad) { |
| | | FullVideoAdManager.getInstance().showAd(VideoDetailActivity2.this); |
| | | //如果是华为渠道,固定为广点通插屏 |
| | | String channel = ManifestDataUtil.getAppMetaData(getApplicationContext(), "UMENG_CHANNEL"); |
| | | if("huawei".equalsIgnoreCase(channel)){ |
| | | |
| | | if(!AdUtil.canShowAdHuaWei(getApplicationContext(),AdPositionEnum.videoDetailFullVideo)){ |
| | | return; |
| | | } |
| | | AdUtil.showAdHuaWei(getApplicationContext(),AdPositionEnum.videoDetailFullVideo); |
| | | //采用广点通插屏 |
| | | InterstitialAdUtil.showAd(this, AdUtil.AD_TYPE.gdt,"7002342568464590"); |
| | | return; |
| | | } |
| | | //判断加载广告的类型 |
| | | if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT_WATCH) { |
| | | int fullvideo = adInfo.getFullVideoWeight(); |
| | | int interstitial = adInfo.getInterstitialWeight(); |
| | | int random = (int) ((fullvideo + interstitial) * Math.random()); |
| | | if (random <= fullvideo) { |
| | | if (FullVideoAdManager.getInstance().isCacahed()) { |
| | | FullVideoAdManager.getInstance().showAd(this); |
| | | } else { |
| | | FullVideoAdManager.getInstance().loadAd(VideoDetailActivity2.this, new FullVideoAdManager.IFullVideoAdListener() { |
| | | @Override |
| | | public void onSuccess(TTFullScreenVideoAd ad) { |
| | | FullVideoAdManager.getInstance().showAd(VideoDetailActivity2.this); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | } else { |
| | | showInterstitialAd(); |
| | | } |
| | | } else { |
| | | FullVideoAdManager.getInstance().loadGDT(VideoDetailActivity2.this, null); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 穿山甲插屏广告 |
| | | */ |
| | | private TTFullScreenVideoAd mTTFullScreenVideoAd; |
| | | |
| | | private void showInterstitialAd() { |
| | | |
| | | // InterstitialAdUtil.showAd(this, AdUtil.AD_TYPE.csj,"946608275"); |
| | | // if(1>0){ |
| | | // return; |
| | | // } |
| | | TTAdNative mTTAdNative = TTAdSdk.getAdManager().createAdNative(VideoDetailActivity2.this); |
| | | AdSlot adSlot = new AdSlot.Builder() |
| | | .setCodeId("946608275") |
| | | //模板广告需要设置期望个性化模板广告的大小,单位dp,激励视频场景,只要设置的值大于0即可 |
| | | .setExpressViewAcceptedSize(300, 500) |
| | | .setSupportDeepLink(true) |
| | | .setOrientation(TTAdConstant.VERTICAL)//必填参数,期望视频的播放方向:TTAdConstant.HORIZONTAL 或 TTAdConstant.VERTICAL |
| | | .build(); |
| | | mTTAdNative.loadFullScreenVideoAd(adSlot, new TTAdNative.FullScreenVideoAdListener() { |
| | | |
| | | |
| | | @Override |
| | | public void onError(int i, String s) { |
| | | Log.i(TAG, s); |
| | | } |
| | | |
| | | @Override |
| | | public void onFullScreenVideoAdLoad(TTFullScreenVideoAd ttFullScreenVideoAd) { |
| | | mTTFullScreenVideoAd = ttFullScreenVideoAd; |
| | | } |
| | | |
| | | @Override |
| | | public void onFullScreenVideoCached() { |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void onFullScreenVideoCached(TTFullScreenVideoAd ttFullScreenVideoAd) { |
| | | if (ttFullScreenVideoAd != null) { |
| | | ttFullScreenVideoAd.setFullScreenVideoAdInteractionListener(new TTFullScreenVideoAd.FullScreenVideoAdInteractionListener() { |
| | | @Override |
| | | public void onAdShow() { |
| | | Log.i(TAG, "广告展示----"); |
| | | } |
| | | |
| | | @Override |
| | | public void onAdVideoBarClick() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onAdClose() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onVideoComplete() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onSkippedVideo() { |
| | | |
| | | } |
| | | }); |
| | | //展示广告,并传入广告展示的场景 |
| | | ttFullScreenVideoAd.showFullScreenVideoAd(VideoDetailActivity2.this, TTAdConstant.RitScenes.GAME_GIFT_BONUS, null); |
| | | } |
| | | } |
| | | |
| | | }); |
| | | |
| | | } |
| | | |
| | | |
| | | private static FrameLayout fl_video_play_background; |
| | | |
| | |
| | | private synchronized void startPlay() { |
| | | //移除所有的fragment |
| | | if (mVideoDetailVideoAdFragment.isAdded()) { |
| | | getSupportFragmentManager().beginTransaction().remove(mVideoDetailVideoAdFragment).commit(); |
| | | getSupportFragmentManager().beginTransaction().remove(mVideoDetailVideoAdFragment).commitAllowingStateLoss(); |
| | | } |
| | | |
| | | if (mFunshionPlayerFragment.isAdded()) { |
| | | getSupportFragmentManager().beginTransaction().remove(mFunshionPlayerFragment).commit(); |
| | | getSupportFragmentManager().beginTransaction().remove(mFunshionPlayerFragment).commitAllowingStateLoss(); |
| | | } |
| | | |
| | | iv_select_play.setVisibility(View.GONE); |
| | | if (BeibeiConstant.IS_TEST) |
| | | BeibeiConstant.AD_TYPE = null; |
| | | //需要加载广告 |
| | | if (BeibeiConstant.AD_TYPE != null && BeibeiConstant.AD_TYPE.isPlayerAd() && playUrl.getPlayType() != 2) { |
| | | if (BeibeiConstant.AD_TYPE != null && BeibeiConstant.AD_TYPE.isPlayerAd() && playUrl != null && playUrl.getPlayType() != 2 && adInfo != null && adInfo.isPlayVideo()) { |
| | | mVideoDetailVideoAdFragment = new PlayVideoPreADFragment(); |
| | | mVideoDetailVideoAdFragment.setPageEventListener(new IPageEventListener() { |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public void startPlay() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onOtherClick(String name) { |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | } else if (playUrl.getResource().getName().contains("风行")) { |
| | | |
| | | if (playUrl.getPlayType() == 0) { |
| | | Toast.makeText(VideoDetailActivity2.this, "此节目不可播!", |
| | | Toast.LENGTH_LONG).show(); |
| | |
| | | } else if (playUrl.getPlayType() == 2) {//SDK播放 |
| | | //播放风行视频 |
| | | //添加风行播放页 |
| | | mFunshionPlayerFragment = new FunshionPlayerFragment(); |
| | | Bundle bundle = new Bundle(); |
| | | bundle.putSerializable("videoInfo", videoInfo); |
| | | bundle.putSerializable("playUrl", playUrl); |
| | | bundle.putInt("position", mPosition); |
| | | bundle.putBoolean("collect", false); |
| | | bundle.putSerializable("resource", resource); |
| | | mFunshionPlayerFragment.setArguments(bundle); |
| | | if (!mFunshionPlayerFragment.isAdded()) { |
| | | getSupportFragmentManager().beginTransaction().replace(R.id.fragment_video_play_container, mFunshionPlayerFragment).commit(); |
| | | } |
| | | fl_video_play_background.setVisibility(View.GONE); |
| | | // mFunshionPlayerFragment = new FunshionPlayerFragment(); |
| | | // Bundle bundle = new Bundle(); |
| | | // bundle.putSerializable("videoInfo", videoInfo); |
| | | // bundle.putSerializable("playUrl", playUrl); |
| | | // bundle.putInt("position", mPosition); |
| | | // bundle.putBoolean("collect", false); |
| | | // bundle.putSerializable("resource", resource); |
| | | // mFunshionPlayerFragment.setArguments(bundle); |
| | | // if (!mFunshionPlayerFragment.isAdded()) { |
| | | // getSupportFragmentManager().beginTransaction().replace(R.id.fragment_video_play_container, mFunshionPlayerFragment).commit(); |
| | | // } |
| | | // fl_video_play_background.setVisibility(View.GONE); |
| | | |
| | | |
| | | // 风行网页播放器 |
| | | // iv_select_play.setVisibility(View.GONE); |
| | | // iv_background.setClickable(false); |
| | | // hideImage(); |
| | | // getSupportFragmentManager().beginTransaction().replace(R.id.fragment_video_play_container, new FunshionWebPlayerFragment("测试标题", "http://www.fun.tv/vplay/g-1018345/")).commit(); |
| | | // return; |
| | | } |
| | | |
| | | } else { |
| | |
| | | |
| | | private PlayUrl info; |
| | | |
| | | @Subscribe |
| | | public void onEventMainThread(Playlocation location) { |
| | | fl_ad.setVisibility(View.VISIBLE); |
| | | mPosition = location.getPosition(); |
| | |
| | | } |
| | | |
| | | |
| | | @Subscribe |
| | | public void onEventMainThread(PlayUrl info) { |
| | | this.info = info; |
| | | Toast.makeText(this, "播放", Toast.LENGTH_SHORT).show(); |
| | |
| | | } |
| | | } |
| | | |
| | | @Subscribe |
| | | public void onEventMainThread(AccumulateRule info) {// 播放界面返回替代使用 |
| | | clickBack(); |
| | | } |
| | | |
| | | @Subscribe |
| | | public void onEventMainThread(PlayerLock info) {//播放器锁屏 |
| | | playerLock = info.isLock(); |
| | | } |
| | | |
| | | @Subscribe |
| | | public void onEventMainThread(PlayerControllerShow show) {//播放控制器显示 |
| | | if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { |
| | | tv_back.setVisibility(View.GONE); |
| | |
| | | Log.i(TAG, "clickBack"); |
| | | setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); |
| | | findViewById(R.id.fl_video_detail).setVisibility(View.VISIBLE); |
| | | fl_video_play_background.setVisibility(View.VISIBLE); |
| | | iv_select_play.setVisibility(View.VISIBLE); |
| | | |
| | | // fl_video_play_background.setVisibility(View.VISIBLE); |
| | | // iv_select_play.setVisibility(View.VISIBLE); |
| | | try { |
| | | Glide.with(getApplicationContext()).load(R.drawable.ic_select_play) |
| | | .into(iv_select_play); |
| | |
| | | (int) ((SystemCommon.getScreenWidth(this) * 9) / 16)); |
| | | findViewById(R.id.fragment_video_play_container1).setLayoutParams( |
| | | params); |
| | | |
| | | if (playUrl != null && playUrl.getResource().getName().contains("爱奇艺")) { |
| | | iv_background.setClickable(true); |
| | | if (mIQYVideoPlayerFragment != null) |
| | |
| | | if (newConfig == null) |
| | | return; |
| | | if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {//横屏 |
| | | tv_back.setVisibility(View.GONE); |
| | | findViewById(R.id.fl_video_detail).setVisibility(View.GONE); |
| | | findViewById(R.id.v_status_bar).setVisibility(View.GONE); |
| | | ViewGroup.LayoutParams params1 = findViewById(R.id.v_status_bar).getLayoutParams(); |
| | |
| | | if (mFunshionPlayerFragment != null) |
| | | mFunshionPlayerFragment.requestLayout(); |
| | | } else { |
| | | tv_back.setVisibility(View.VISIBLE); |
| | | findViewById(R.id.v_status_bar).setVisibility(View.VISIBLE); |
| | | findViewById(R.id.fl_video_detail).setVisibility(View.VISIBLE); |
| | | ViewGroup.LayoutParams params1 = findViewById(R.id.v_status_bar).getLayoutParams(); |
| | |
| | | FrameLayout layout = findViewById(R.id.fragment_video_play_container1); |
| | | if (layout == null) |
| | | return; |
| | | android.view.ViewGroup.LayoutParams layoutParams = layout |
| | | ViewGroup.LayoutParams layoutParams = layout |
| | | .getLayoutParams(); |
| | | layoutParams.height = (int) (DimenUtils.getScreenWidth(this) * 0.5625f); |
| | | layout.requestLayout(); |
| | |
| | | EventBus.getDefault().unregister(this); |
| | | } |
| | | |
| | | @Subscribe |
| | | public void onEventMainThread(ChangeVideoEvent changeVideoEvent) { |
| | | VideoInfo videoInfo = changeVideoEvent.getVideoInfo(); |
| | | resourceId = ""; |
| | | if (!progressDialog.isShowing()) { |
| | | progressDialog.show(); |
| | | } |
| | | getVideoDetail(this, videoInfo.getId(), videoInfo.getThirdType(), false); |
| | | uploadSession(); |
| | | getVideoDetail(this, videoInfo.getId(), videoInfo.getThirdType(), false, changeVideoEvent.getFrom()); |
| | | } |
| | | |
| | | @Subscribe |
| | | public void onEventMainThread(Play info) { |
| | | Log.i("mResult", "VideoDetailActivity-----onEventMainThread----开始播放"); |
| | | playUrl = info.getPlayUrl(); |
| | |
| | | } |
| | | } |
| | | |
| | | @Subscribe |
| | | public void onEventMainThread(VideoInfo info) { |
| | | Log.i(TAG, "onEventMainThread-videoInfo"); |
| | | videoInfo = info; |
| | | } |
| | | |
| | | //上报session |
| | | private void uploadSession() { |
| | | if (StringUtils.isEmpty(sessionId)) { |
| | | return; |
| | | } |
| | | BeibeiVideoAPI.uploadSession(BeibeiVideoApplication.application, sessionId, "videoDetail", new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | } |
| | | }); |
| | | } |
| | | |
| | | //赚影视豆 |
| | | private Runnable makeGoldCornRunnable; |
| | | |
| | | private void getVideoDetail(final Context context, String videoId, |
| | | String videoThirdType, final boolean isSetup) { |
| | | String videoThirdType, final boolean isSetup, final String fromName) { |
| | | int position = getIntent().getIntExtra( |
| | | "playing_position", 0); |
| | | SharedPreferences preferences = context.getSharedPreferences("user", |
| | | Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | String loginid = preferences.getString("LoginUid", ""); |
| | | BeibeiVideoAPI.getVideoDetail(context, uid, resourceId, videoId, loginid, |
| | | videoThirdType, new BasicTextHttpResponseHandler() { |
| | | BeibeiVideoAPI.getVideoDetail(context, uid, resourceId, videoId, position, loginid, |
| | | videoThirdType, fromName, new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onStart() { |
| | | super.onStart(); |
| | | // if (BeibeiConstant.DEBUG) |
| | | // Toast.makeText(VideoDetailActivity2.this, "onStart", |
| | | // Toast.LENGTH_SHORT).show(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | String responseString, Throwable throwable) { |
| | | super.onFailure(statusCode, headers, responseString, |
| | | throwable); |
| | | // if (BeibeiConstant.DEBUG) |
| | | // Toast.makeText(VideoDetailActivity2.this, "onFailure", |
| | | // Toast.LENGTH_SHORT).show(); |
| | | if (progressDialog.isShowing()) { |
| | | progressDialog.dismiss(); |
| | | } |
| | |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | |
| | | |
| | | // if (BeibeiConstant.DEBUG) |
| | | // Toast.makeText(VideoDetailActivity2.this, |
| | | // "onSuccessPerfect", |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | |
| | | if (BeibeiConstant.watchVideoGoldCorn != null && BeibeiConstant.watchVideoGoldCorn.expireTime > System.currentTimeMillis() && getIntent() != null) { |
| | | getIntent().putExtra("goldcorn", BeibeiConstant.watchVideoGoldCorn.goldcorn); |
| | | BeibeiConstant.watchVideoGoldCorn = null; |
| | | } |
| | | |
| | | //挣影视豆 |
| | | makeGoldCornRunnable = GoldCornUtil.makeGoldCorn(getIntent(), fl_video_play_background, videoId, resourceId, 20, null); |
| | | |
| | | JSONObject data = jsonObject.optJSONObject("Data"); |
| | | boolean pptv = data.optBoolean("pptv", false); |
| | | if (pptv) { |
| | | UmengEventUtil.pptvPlay(getApplicationContext()); |
| | | String playUrl = data.optString("playUrl"); |
| | | sessionId = data.optString("sessionId"); |
| | | |
| | | fl_pptv.setVisibility(View.VISIBLE); |
| | | ll_other.setVerticalGravity(View.GONE); |
| | | PPTVPlayFragment pptvPlayFragment = new PPTVPlayFragment(); |
| | | Bundle bundle = new Bundle(); |
| | | bundle.putString("playUrl", playUrl); |
| | | bundle.putString("videoId", data.optString("videoId")); |
| | | bundle.putString("name", data.optString("name")); |
| | | bundle.putBoolean("vip", data.optBoolean("vip", false)); |
| | | pptvPlayFragment.setArguments(bundle); |
| | | getSupportFragmentManager().beginTransaction().replace(R.id.fl_pptv, pptvPlayFragment).commit(); |
| | | if (progressDialog.isShowing()) { |
| | | progressDialog.dismiss(); |
| | | } |
| | | return; |
| | | } else { |
| | | fl_pptv.setVisibility(View.GONE); |
| | | ll_other.setVisibility(View.VISIBLE); |
| | | } |
| | | |
| | | |
| | | findViewById(R.id.fragment_video_detail_container) |
| | | .setVisibility(View.VISIBLE); |
| | | findViewById(R.id.fragment_video_episode_container) |
| | |
| | | update(); |
| | | } |
| | | |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | final VideoInfo videoInfo = gson |
| | | .fromJson(jsonObject.getJSONObject("Data") |
| | | |
| | | JSONObject videoJson = data.optJSONObject("Video"); |
| | | final VideoInfo videoInfo = JsonUtil.videoGson |
| | | .fromJson(videoJson |
| | | .toString(), |
| | | new TypeToken<VideoInfo>() { |
| | | }.getType()); |
| | | if (videoInfo != null) { |
| | | VideoUtil.saveVideoEpisodeList(BeibeiVideoApplication.application, videoInfo.getVideoDetailList(), false); |
| | | } |
| | | // 附加字段 |
| | | if (jsonObject.optJSONObject("Extra1") != null) { |
| | | if (jsonObject.optJSONObject("Extra1").optJSONObject("Attention") != null) { |
| | | JSONObject obj = jsonObject.optJSONObject("Extra1").optJSONObject("Attention"); |
| | | Follow attention = new Follow(); |
| | | attention.setMovieName(obj.optString("Name")); |
| | | attention.setMoviePicture(obj.optString("Picture")); |
| | | attention.setUpdateInfo(obj.optString("UpdateInfo")); |
| | | attention.setAttention(Boolean.parseBoolean(obj.optString("IsAttention"))); |
| | | videoInfo.setAttention(attention); |
| | | } |
| | | |
| | | if (data.optJSONObject("AdInfo") != null) { |
| | | adInfo = JsonUtil.videoGson.fromJson(data.optJSONObject("AdInfo").toString(), VideoDetailAdInfoVO.class); |
| | | } |
| | | // 关注 |
| | | if (data.optJSONObject("Attention") != null) { |
| | | JSONObject obj = data.optJSONObject("Attention"); |
| | | Follow attention = new Follow(); |
| | | attention.setMoviePicture(obj.optString("Picture")); |
| | | attention.setMovieName(obj.optString("Name")); |
| | | attention.setUpdateInfo(obj.optString("UpdateInfo")); |
| | | attention.setAttention(obj.optBoolean("Attention")); |
| | | videoInfo.setAttention(attention); |
| | | } |
| | | VideoDetailActivity2.this.videoInfo = videoInfo; |
| | | JSONArray extraData = jsonObject |
| | |
| | | return; |
| | | } |
| | | |
| | | sessionId = data.optString("SessionId"); |
| | | |
| | | |
| | | Glide.with(getApplicationContext()) |
| | | .load(videoInfo.getPlayPicture()).apply(new RequestOptions().centerCrop()).into(target); |
| | |
| | | Log.i("mResult", "是否是从观看记录点击进来的:" + isFromWatchHistory); |
| | | if (isFromWatchHistory || position > 0) { |
| | | mPosition = getIntent().getIntExtra("playing_position", 0); |
| | | //防止数组越界 |
| | | mPosition = mPosition >= VideoUtil.videoEpisodeList.size() ? VideoUtil.videoEpisodeList.size() - 1 : mPosition; |
| | | EventBus.getDefault().post(videoInfo); |
| | | getUrl(VideoUtil.videoEpisodeList.get(mPosition), isSetup); |
| | | EventBus.getDefault().post(VideoUtil.videoEpisodeList.get(mPosition)); |
| | |
| | | |
| | | @Override |
| | | public void run() { |
| | | EventBus.getDefault().post( |
| | | videoInfo); |
| | | EventBus.getDefault() |
| | | .post(VideoUtil.videoEpisodeList |
| | | .get(0)); |
| | | |
| | | try { |
| | | EventBus.getDefault().post( |
| | | videoInfo); |
| | | EventBus.getDefault() |
| | | .post(VideoUtil.videoEpisodeList |
| | | .get(0)); |
| | | } catch (NullPointerException e) { |
| | | //出现过空指针的异常 |
| | | } |
| | | } |
| | | }, 200); |
| | | } |
| | |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | VideoResource resource = gson.fromJson( |
| | | |
| | | VideoResource resource = JsonUtil.videoGson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONObject("Resource") |
| | | .toString(), |
| | |
| | | |
| | | private VideoResource resource; |
| | | |
| | | @Subscribe |
| | | public void onEventMainThread(VideoResource resource) { |
| | | this.resource = resource; |
| | | } |
| | |
| | | if (VideoUtil.videoEpisodeList == null |
| | | || VideoUtil.videoEpisodeList.isEmpty()) { |
| | | getVideoDetail(this, videoInfo.getId(), videoInfo.getThirdType(), |
| | | true); |
| | | true, from); |
| | | } else { |
| | | findViewById(android.R.id.content).postDelayed(new Runnable() { |
| | | |
| | | @Override |
| | | public void run() { |
| | | EventBus.getDefault().post(videoInfo); |
| | | int position = getIntent().getIntExtra("playing_position", 0) >= |
| | | VideoUtil.videoEpisodeList.size() ? VideoUtil.videoEpisodeList.size() - 1 : getIntent().getIntExtra("playing_position", |
| | | 0); |
| | | EventBus.getDefault().post( |
| | | VideoUtil.videoEpisodeList.get( |
| | | getIntent().getIntExtra("playing_position", |
| | | 0))); |
| | | VideoUtil.videoEpisodeList.get(position)); |
| | | } |
| | | }, 200); |
| | | } |
| | |
| | | values.put(WatchHistoryTable.VIDEO_DETAIL_ID, videoDetailId); |
| | | values.put(WatchHistoryTable.VIDEO_THIRD_TYPE, |
| | | videoInfo.getThirdType()); |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE).create(); |
| | | |
| | | values.put(WatchHistoryTable.VIDEO_DETAIL, |
| | | gson.toJson(videoInfo)); |
| | | JsonUtil.videoGson.toJson(videoInfo)); |
| | | values.put(WatchHistoryTable.WATCH_TIME, 0); |
| | | values.put(WatchHistoryTable.VIDEO_RESOURCE, from); |
| | | values.put(WatchHistoryTable.VIDEO_RESOURCE_ID, resoureID); |
| | |
| | | |
| | | @Override |
| | | protected void onDestroy() { |
| | | super.onDestroy(); |
| | | if (BeibeiConstant.AD_TYPE != null && BeibeiConstant.AD_TYPE.isVideoDetailSplashAd()) |
| | | FullVideoAdManager.getInstance().loadAd(BeibeiVideoApplication.application, null); |
| | | FullVideoAdManager.getInstance().loadAd(VideoDetailActivity2.this, null); |
| | | uploadSession(); |
| | | GoldCornUtil.removeCallbacks(fl_video_play_background, makeGoldCornRunnable); |
| | | //屏幕常亮 |
| | | getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); |
| | | if (mTTFullScreenVideoAd != null) |
| | | mTTFullScreenVideoAd = null; |
| | | super.onDestroy(); |
| | | } |
| | | } |