| | |
| | | package com.weikou.beibeivideo.ui.media; |
| | | |
| | | import android.app.Activity; |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | import android.graphics.Canvas; |
| | | import android.graphics.Rect; |
| | | import android.os.Bundle; |
| | | import android.support.v4.view.ViewPager; |
| | | import android.support.v7.widget.GridLayoutManager; |
| | | import android.support.v7.widget.RecyclerView; |
| | | import android.text.Html; |
| | | import android.util.Log; |
| | |
| | | import android.view.animation.Animation; |
| | | import android.view.animation.RotateAnimation; |
| | | import android.view.animation.Transformation; |
| | | import android.widget.AdapterView; |
| | | import android.widget.AdapterView.OnItemClickListener; |
| | | import android.widget.FrameLayout; |
| | | import android.widget.GridView; |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.ScrollView; |
| | |
| | | import com.lcjian.library.RetainViewFragment; |
| | | import com.lcjian.library.util.common.DimenUtils; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.qq.e.ads.cfg.VideoOption; |
| | | import com.qq.e.ads.nativ.ADSize; |
| | | import com.qq.e.ads.nativ.NativeExpressAD; |
| | | import com.qq.e.ads.nativ.NativeExpressADView; |
| | | import com.qq.e.comm.util.AdError; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.weikou.beibeivideo.BasicTextHttpResponseHandler; |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.entity.PushEpisode; |
| | | import com.weikou.beibeivideo.entity.VideoInfo; |
| | | import com.weikou.beibeivideo.entity.ad.ExpressAdContainer; |
| | | import com.weikou.beibeivideo.ui.common.GridVideoAdapter1; |
| | | import com.weikou.beibeivideo.ui.media.VideoDetailActivity.ChangeVideoEvent; |
| | | import com.weikou.beibeivideo.entity.video.ChangeVideoEvent; |
| | | import com.weikou.beibeivideo.ui.video.IVideoClickListener; |
| | | import com.weikou.beibeivideo.ui.video.VideoColumn2Adapter; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.ad.AdUtil; |
| | | import com.weikou.beibeivideo.util.ad.ExpressAdManager; |
| | | import com.weikou.beibeivideo.widget.FullyGridLayoutManager; |
| | | import com.yeshi.buwanshequ.R; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | |
| | | private ImageView video_more_image; |
| | | private LinearLayout video_introduction_more; |
| | | private FrameLayout fl_native_ad_1; |
| | | private LinearLayout ll_relative_video; |
| | | |
| | | public static boolean isShowMore = false;// 是否显示更多 |
| | | public static int page_varietyshow = 0;// 综艺节目的分页 |
| | |
| | | sv_detail = contentView.findViewById(R.id.sv_detail); |
| | | mVideoInfo = (VideoInfo) getArguments().getSerializable("video_info"); |
| | | mPlayingPosition = getArguments().getInt("playing_position"); |
| | | if (getArguments() != null) |
| | | getArguments().clear(); |
| | | // ******简介******* |
| | | video_score = contentView.findViewById(R.id.video_score); |
| | | video_year = contentView.findViewById(R.id.video_year); |
| | |
| | | fl_native_ad_1 = contentView |
| | | .findViewById(R.id.fl_native_ad_1); |
| | | |
| | | ll_relative_video = contentView |
| | | .findViewById(R.id.ll_relative_video); |
| | | |
| | | contentView.findViewById(R.id.ll_container).setFocusable(true); |
| | | contentView.findViewById(R.id.ll_container).setFocusableInTouchMode(true); |
| | | |
| | | |
| | | if (rv_video_related_video.getLayoutManager() == null || !(rv_video_related_video.getLayoutManager() instanceof GridLayoutManager)) { |
| | | RecyclerView.LayoutManager layoutManager = new FullyGridLayoutManager(getContext(), 2); |
| | | rv_video_related_video.setLayoutManager(layoutManager); |
| | | } |
| | | //统一分为2列 |
| | | ((GridLayoutManager) rv_video_related_video.getLayoutManager()).setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { |
| | | @Override |
| | | public int getSpanSize(int position) { |
| | | return 1; |
| | | } |
| | | }); |
| | | |
| | | |
| | | if (rv_video_guess_like.getLayoutManager() == null || !(rv_video_guess_like.getLayoutManager() instanceof GridLayoutManager)) { |
| | | RecyclerView.LayoutManager layoutManager = new FullyGridLayoutManager(getContext(), 2); |
| | | rv_video_guess_like.setLayoutManager(layoutManager); |
| | | } |
| | | //统一分为2列 |
| | | ((GridLayoutManager) rv_video_guess_like.getLayoutManager()).setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { |
| | | @Override |
| | | public int getSpanSize(int position) { |
| | | return 1; |
| | | } |
| | | }); |
| | | |
| | | rv_video_guess_like.addItemDecoration(itemDecoration); |
| | | rv_video_related_video.addItemDecoration(itemDecoration); |
| | | |
| | | rv_video_guess_like.setHasFixedSize(true); |
| | | rv_video_guess_like.setNestedScrollingEnabled(false); |
| | | |
| | | // |
| | | rv_video_related_video.setHasFixedSize(true); |
| | | rv_video_related_video.setNestedScrollingEnabled(false); |
| | | |
| | |
| | | video_introduction.setText(Html.fromHtml(mVideoInfo.getIntroduction())); |
| | | } else { |
| | | video_introduction.setText(""); |
| | | video_introduction.setVisibility(View.GONE); |
| | | video_introduction_more.setVisibility(View.GONE); |
| | | } |
| | | } |
| | |
| | | new TypeToken<List<VideoInfo>>() { |
| | | }.getType()); |
| | | |
| | | rv_video_related_video.postDelayed(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | rv_video_related_video.setAdapter(new VideoColumn2Adapter(getActivity(), getContext(), videoInfos, false, new IVideoClickListener() { |
| | | @Override |
| | | public void onClick(VideoInfo video) { |
| | | ChangeVideoEvent changeVideoEvent_related = new ChangeVideoEvent(); |
| | | changeVideoEvent_related |
| | | .setVideoInfo(video); |
| | | changeVideoEvent_related.setTag("VideoPlayerFragment"); |
| | | EventBus.getDefault().post(changeVideoEvent_related); |
| | | loadAD2(); |
| | | if (videoInfos == null || videoInfos.size() == 0) { |
| | | ll_relative_video.setVisibility(View.GONE); |
| | | } else { |
| | | ll_relative_video.setVisibility(View.VISIBLE); |
| | | final VideoColumn2Adapter adapter = new VideoColumn2Adapter(getActivity(), getContext(), videoInfos, false, 2, new IVideoClickListener() { |
| | | @Override |
| | | public void onClick(VideoInfo video) { |
| | | ChangeVideoEvent changeVideoEvent = new ChangeVideoEvent(); |
| | | changeVideoEvent.setVideoInfo(video); |
| | | changeVideoEvent.setTag("VideoPlayerFragment"); |
| | | EventBus.getDefault().post(changeVideoEvent); |
| | | } |
| | | }); |
| | | adapter.initRecyclerViewDisplayWidthColumn2(rv_video_related_video); |
| | | |
| | | if (getActivity() == null) |
| | | return; |
| | | getActivity().runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if (rv_video_related_video != null) { |
| | | rv_video_related_video.setAdapter(adapter); |
| | | } |
| | | })); |
| | | } |
| | | }, 2000); |
| | | |
| | | |
| | | // sv_detail.scrollTo(0, 0); |
| | | |
| | | if (adRunnable != null) |
| | | rv_video_related_video.post(adRunnable); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private Runnable adRunnable = new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | loadAD2(); |
| | | } |
| | | }; |
| | | |
| | | private void guessLike() { |
| | | SharedPreferences preferences = getContext().getSharedPreferences( |
| | |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoInfo>>() { |
| | | }.getType()); |
| | | // 非聚效广告显示 |
| | | rv_video_guess_like |
| | | .setAdapter(new VideoColumn2Adapter(getActivity(), getContext(), videoInfos, false, new IVideoClickListener() { |
| | | @Override |
| | | public void onClick(VideoInfo video) { |
| | | ChangeVideoEvent changeVideoEvent = new ChangeVideoEvent(); |
| | | changeVideoEvent.setVideoInfo(video); |
| | | changeVideoEvent.setTag("VideoPlayerFragment"); |
| | | EventBus.getDefault().post(changeVideoEvent); |
| | | } |
| | | })); |
| | | final VideoColumn2Adapter adapter = new VideoColumn2Adapter(getActivity(), getContext(), videoInfos, false, 2, new IVideoClickListener() { |
| | | @Override |
| | | public void onClick(VideoInfo video) { |
| | | ChangeVideoEvent changeVideoEvent = new ChangeVideoEvent(); |
| | | changeVideoEvent.setVideoInfo(video); |
| | | changeVideoEvent.setTag("VideoPlayerFragment"); |
| | | EventBus.getDefault().post(changeVideoEvent); |
| | | } |
| | | }); |
| | | adapter.initRecyclerViewDisplayWidthColumn2(rv_video_guess_like); |
| | | if (getActivity() != null) |
| | | getActivity().runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if (rv_video_guess_like != null) |
| | | rv_video_guess_like |
| | | .setAdapter(adapter); |
| | | } |
| | | }); |
| | | |
| | | // sv_detail.scrollTo(0, 0); |
| | | } |
| | | } |
| | |
| | | super.onResume(); |
| | | EventBus.getDefault().register(this); |
| | | MobclickAgent.onPageStart("播放详情—选集"); |
| | | Log.i(TAG,"onResume"); |
| | | } |
| | | |
| | | @Override |
| | |
| | | isShowMore = false; |
| | | page_varietyshow = 0; |
| | | MobclickAgent.onPageEnd("播放详情—选集"); |
| | | Log.i(TAG,"onPause"); |
| | | } |
| | | |
| | | public void onEventMainThread(VideoInfo info) { |
| | | // Log.i("result", "收到来源点击产生的列表EventBus-------------1,电视剧的长度为:" + mVideoInfo.getVideoDetailList().size()); |
| | | int playingPosition = 0; |
| | | if (mPlayingPosition != playingPosition) { |
| | | mPlayingPosition = playingPosition; |
| | |
| | | public void onEventMainThread(PushEpisode info) { |
| | | if (mVideoInfo == null) |
| | | return; |
| | | // Log.i("result", "收到来源点击产生的列表EventBus-------------1,电视剧的长度为:" + mVideoInfo.getVideoDetailList().size()); |
| | | if (mVideoInfo.getShowType() == 1) {// 综艺 如果是综艺的话就分页加载 |
| | | if (info.getEpisodeNum() > 10) { |
| | | page_varietyshow = info.getEpisodeNum() / 10 + 1; |
| | |
| | | */ |
| | | // 加载播放页第二条广告 |
| | | private void loadAD2() { |
| | | new ExpressAdManager(ExpressAdManager.SOURCE_GDT2, getContext()).loadVideoDetailRelativeVideoBottomAd(new ExpressAdManager.IAdLoadListener() { |
| | | new ExpressAdManager(AdUtil.AD_TYPE.gdt2, getContext()).loadVideoDetailRelativeVideoBottomAd(new ExpressAdManager.IAdLoadListener() { |
| | | @Override |
| | | public void onSuccess(List<ExpressAdContainer> adList) { |
| | | if (adList != null && adList.size() > 0) |
| | | ExpressAdManager.render(getActivity(), adList.get(0), fl_native_ad_1, new ExpressAdManager.IAdEventListener() { |
| | | if (adList != null && adList.size() > 0) { |
| | | ExpressAdManager.renderAd(getActivity(), adList.get(0), new ExpressAdManager.IAdRenderListener() { |
| | | @Override |
| | | public void closeAd() { |
| | | public void onRenderSuccess(List<ExpressAdContainer> adList) { |
| | | ExpressAdManager.fillAd(adList.get(0), fl_native_ad_1); |
| | | } |
| | | |
| | | @Override |
| | | public void onRenderFail(List<ExpressAdContainer> adList) { |
| | | |
| | | } |
| | | }, new ExpressAdManager.IAdEventListener() { |
| | | |
| | | @Override |
| | | public void closeAd(ExpressAdContainer ad) { |
| | | fl_native_ad_1.removeAllViews(); |
| | | } |
| | | }); |
| | | } else { |
| | | new ExpressAdManager(AdUtil.AD_TYPE.csj, getContext()).loadVideoDetailRelativeVideoBottomAd(new ExpressAdManager.IAdLoadListener() { |
| | | @Override |
| | | public void onSuccess(List<ExpressAdContainer> adList) { |
| | | if (adList != null && adList.size() > 0) { |
| | | ExpressAdManager.renderAndFillAd(getActivity(), adList.get(0), fl_native_ad_1, new ExpressAdManager.IAdEventListener() { |
| | | @Override |
| | | public void closeAd(ExpressAdContainer ad) { |
| | | fl_native_ad_1.removeAllViews(); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void onDestroy() { |
| | | if (rv_video_related_video != null && adRunnable != null) |
| | | rv_video_related_video.removeCallbacks(adRunnable); |
| | | super.onDestroy(); |
| | | Log.i(TAG,"onDestroy"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDestroyView() { |
| | | super.onDestroyView(); |
| | | Log.i(TAG,"onDestroyView"); |
| | | } |
| | | } |