| | |
| | | |
| | | 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.RecyclerView; |
| | | import android.text.Html; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | |
| | | 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.google.gson.GsonBuilder; |
| | | import com.google.gson.reflect.TypeToken; |
| | | 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.ui.common.GridVideoAdapter1; |
| | | import com.weikou.beibeivideo.ui.media.VideoDetailActivity.ChangeVideoEvent; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.yeshi.buwanshequ.R; |
| | | import com.weikou.beibeivideo.entity.ad.ExpressAdContainer; |
| | | 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.ad.AdUtil; |
| | | import com.weikou.beibeivideo.util.ad.ExpressAdManager; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | |
| | | |
| | | private ViewPager vp_episode; |
| | | |
| | | private GridView gv_video_related_video, gv_video_guess_like, |
| | | gv_video_everybody_look; |
| | | private RecyclerView rv_video_related_video, rv_video_guess_like; |
| | | |
| | | private ScrollView sv_detail; |
| | | |
| | |
| | | video_actor, video_introduction, video_more_text; |
| | | private ImageView video_more_image; |
| | | private LinearLayout video_introduction_more; |
| | | private FrameLayout fl_native_ad2, fl_native_ad3; |
| | | // 查看更多 |
| | | private LinearLayout ll_more; |
| | | private ImageView iv_episode; |
| | | private TextView tv_more; |
| | | private FrameLayout fl_native_ad_1; |
| | | private LinearLayout ll_relative_video; |
| | | |
| | | public static boolean isShowMore = false;// 是否显示更多 |
| | | public static int page_varietyshow = 0;// 综艺节目的分页 |
| | | int maxDescripLine = 2; |
| | | |
| | | |
| | | final String TAG = "VideoEpisodeFragment"; |
| | | |
| | | public static VideoEpisodeFragment newInstance(VideoInfo videoInfo, |
| | | int playingPostion) { |
| | |
| | | args.putSerializable("video_info", videoInfo); |
| | | args.putInt("playing_position", playingPostion); |
| | | videoEpisodeFragment.setArguments(args); |
| | | // Log.i("result","进入了VideoEpisodeFragment"); |
| | | return videoEpisodeFragment; |
| | | } |
| | | |
| | | |
| | | RecyclerView.ItemDecoration itemDecoration = new RecyclerView.ItemDecoration() { |
| | | @Override |
| | | public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { |
| | | super.onDraw(c, parent, state); |
| | | } |
| | | |
| | | @Override |
| | | public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { |
| | | super.onDrawOver(c, parent, state); |
| | | } |
| | | |
| | | @Override |
| | | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { |
| | | super.getItemOffsets(outRect, view, parent, state); |
| | | int index = parent.getChildAdapterPosition(view); |
| | | int total = parent.getAdapter().getItemCount(); |
| | | if (index % 2 == 0) { |
| | | outRect.left = 0; //第一列左边贴边 |
| | | outRect.right = DimenUtils.dipToPixels(5, view.getContext()); |
| | | } else { |
| | | outRect.right = 0; //第一列左边贴边 |
| | | outRect.left = DimenUtils.dipToPixels(5, view.getContext()); |
| | | } |
| | | |
| | | if (index - 1 > 0) { |
| | | outRect.top = DimenUtils.dipToPixels(5, view.getContext()); |
| | | } else |
| | | outRect.top = 0; |
| | | |
| | | if (total % 2 == 0) { |
| | | if (total > 2 && (index < total - 2)) |
| | | outRect.bottom = DimenUtils.dipToPixels(5, view.getContext()); |
| | | else |
| | | outRect.bottom = 0; |
| | | } else { |
| | | if (total > 2 && (index < total - 1)) |
| | | outRect.bottom = DimenUtils.dipToPixels(5, view.getContext()); |
| | | else |
| | | outRect.bottom = 0; |
| | | } |
| | | } |
| | | }; |
| | | |
| | | @Override |
| | | public int getContentResource() { |
| | |
| | | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | |
| | | // Toast.makeText(getActivity(), "我到VideoEpisodeFragment了", |
| | | // Toast.LENGTH_LONG).show(); |
| | | sv_detail = (ScrollView) contentView.findViewById(R.id.sv_detail); |
| | | // Log.i("result", "VideoEpisodeFragment被创建了"); |
| | | Log.d(TAG, "onCreateView"); |
| | | sv_detail = contentView.findViewById(R.id.sv_detail); |
| | | mVideoInfo = (VideoInfo) getArguments().getSerializable("video_info"); |
| | | mPlayingPosition = getArguments().getInt("playing_position"); |
| | | tv_more = (TextView) contentView |
| | | .findViewById(R.id.tv_video_episode_more); |
| | | iv_episode = (ImageView) contentView.findViewById(R.id.iv_video_episode_more); |
| | | ll_more = (LinearLayout) contentView.findViewById(R.id.video_episode_tv_lookmore); |
| | | ll_more.setOnClickListener(this); |
| | | if (getArguments() != null) |
| | | getArguments().clear(); |
| | | // ******简介******* |
| | | video_score = (TextView) contentView.findViewById(R.id.video_score); |
| | | video_year = (TextView) contentView.findViewById(R.id.video_year); |
| | | video_type = (TextView) contentView.findViewById(R.id.video_type); |
| | | video_actor = (TextView) contentView.findViewById(R.id.video_actor); |
| | | video_introduction = (TextView) contentView |
| | | video_score = contentView.findViewById(R.id.video_score); |
| | | video_year = contentView.findViewById(R.id.video_year); |
| | | video_type = contentView.findViewById(R.id.video_type); |
| | | video_actor = contentView.findViewById(R.id.video_actor); |
| | | video_introduction = contentView |
| | | .findViewById(R.id.video_introduction); |
| | | video_introduction_more = (LinearLayout) contentView |
| | | video_introduction_more = contentView |
| | | .findViewById(R.id.video_introduction_more); |
| | | video_more_image = (ImageView) contentView |
| | | video_more_image = contentView |
| | | .findViewById(R.id.video_more_image); |
| | | video_more_text = (TextView) contentView |
| | | video_more_text = contentView |
| | | .findViewById(R.id.video_more_text); |
| | | |
| | | video_introduction_more.setOnClickListener(this); |
| | | vp_episode = (ViewPager) contentView.findViewById(R.id.vp_episode); |
| | | vp_episode = contentView.findViewById(R.id.vp_episode); |
| | | |
| | | gv_video_related_video = (GridView) contentView |
| | | .findViewById(R.id.gv_video_related_video); |
| | | rv_video_related_video = contentView |
| | | .findViewById(R.id.rv_video_related_video); |
| | | |
| | | gv_video_guess_like = (GridView) contentView |
| | | .findViewById(R.id.gv_video_guess_like); |
| | | rv_video_guess_like = contentView |
| | | .findViewById(R.id.rv_video_guess_like); |
| | | |
| | | fl_native_ad2 = (FrameLayout) contentView |
| | | .findViewById(R.id.fl_native_ad_2); |
| | | fl_native_ad_1 = contentView |
| | | .findViewById(R.id.fl_native_ad_1); |
| | | |
| | | gv_video_everybody_look = (GridView) contentView |
| | | .findViewById(R.id.gv_video_everybody_look); |
| | | |
| | | fl_native_ad3 = (FrameLayout) contentView |
| | | .findViewById(R.id.fl_native_ad_3); |
| | | 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); |
| | | |
| | | gv_video_related_video |
| | | .setOnItemClickListener(new OnItemClickListener() { |
| | | rv_video_guess_like.setHasFixedSize(true); |
| | | rv_video_guess_like.setNestedScrollingEnabled(false); |
| | | // |
| | | rv_video_related_video.setHasFixedSize(true); |
| | | rv_video_related_video.setNestedScrollingEnabled(false); |
| | | |
| | | @Override |
| | | public void onItemClick(AdapterView<?> parent, View view, |
| | | int position, long id) { |
| | | ChangeVideoEvent changeVideoEvent_related = new ChangeVideoEvent(); |
| | | changeVideoEvent_related |
| | | .setVideoInfo((VideoInfo) parent |
| | | .getItemAtPosition(position)); |
| | | changeVideoEvent_related.setTag("VideoPlayerFragment"); |
| | | EventBus.getDefault().post(changeVideoEvent_related); |
| | | } |
| | | }); |
| | | |
| | | gv_video_guess_like.setOnItemClickListener(new OnItemClickListener() { |
| | | |
| | | @Override |
| | | public void onItemClick(AdapterView<?> parent, View view, |
| | | int position, long id) { |
| | | // if (position == mVideoInfos.size() - 1) { |
| | | // mList.get(0).onAdClicked(); |
| | | // } else { |
| | | ChangeVideoEvent changeVideoEvent = new ChangeVideoEvent(); |
| | | changeVideoEvent.setVideoInfo((VideoInfo) parent |
| | | .getItemAtPosition(position)); |
| | | changeVideoEvent.setTag("VideoPlayerFragment"); |
| | | EventBus.getDefault().post(changeVideoEvent); |
| | | // } |
| | | } |
| | | }); |
| | | |
| | | gv_video_everybody_look |
| | | .setOnItemClickListener(new OnItemClickListener() { |
| | | |
| | | @Override |
| | | public void onItemClick(AdapterView<?> parent, View view, |
| | | int position, long id) { |
| | | ChangeVideoEvent changeVideoEvent_look = new ChangeVideoEvent(); |
| | | changeVideoEvent_look.setVideoInfo((VideoInfo) parent |
| | | .getItemAtPosition(position)); |
| | | changeVideoEvent_look.setTag("VideoPlayerFragment"); |
| | | EventBus.getDefault().post(changeVideoEvent_look); |
| | | } |
| | | }); |
| | | |
| | | if (mVideoInfo == null) |
| | | return; |
| | | |
| | | if (mVideoInfo.getShowType() == 1) {// 综艺 |
| | | if (mVideoInfo.getVideoDetailList().size() <= 2) { |
| | | ll_more.setVisibility(View.GONE); |
| | | } else { |
| | | ll_more.setVisibility(View.VISIBLE); |
| | | } |
| | | } else if (mVideoInfo.getShowType() == 2) {// 电视剧什么的 |
| | | if (mVideoInfo.getVideoDetailList().size() <= 10) { |
| | | ll_more.setVisibility(View.GONE); |
| | | } else { |
| | | ll_more.setVisibility(View.VISIBLE); |
| | | } |
| | | } |
| | | mEpisodePagerAdapter = new EpisodePagerAdapter( |
| | | getChildFragmentManager(), mVideoInfo, mPlayingPosition); |
| | | // |
| | |
| | | } |
| | | } |
| | | }); |
| | | gv_video_related_video.postDelayed(new Runnable() { |
| | | |
| | | @Override |
| | | public void run() { |
| | | getRelativeVideos(); |
| | | guessLike(); |
| | | getPeopleSeeVideos(); |
| | | } |
| | | }, 1000 * 2); |
| | | getRelativeVideos(); |
| | | guessLike(); |
| | | |
| | | |
| | | video_introduction.setHeight(video_introduction.getLineHeight() |
| | | * maxDescripLine); |
| | |
| | | |
| | | } |
| | | }); |
| | | loadAD2(); |
| | | loadAD3(); |
| | | getIntroductionInfo(); |
| | | } |
| | | |
| | |
| | | video_type.setText("类型:" + (StringUtils.isEmpty(mVideoInfo.getVideoType().getName()) ? "未知" : mVideoInfo.getVideoType().getName())); |
| | | video_actor.setText("主演:" + mVideoInfo.getMainActor()); |
| | | if (!StringUtils.isBlank(mVideoInfo.getIntroduction())) { |
| | | video_introduction.setText(Html.fromHtml("主要内容:" + mVideoInfo.getIntroduction())); |
| | | video_introduction_more.setVisibility(View.VISIBLE); |
| | | video_introduction.setText(Html.fromHtml(mVideoInfo.getIntroduction())); |
| | | } else { |
| | | video_introduction.setText("主要内容:"); |
| | | video_introduction.setText(""); |
| | | video_introduction.setVisibility(View.GONE); |
| | | video_introduction_more.setVisibility(View.GONE); |
| | | } |
| | | } |
| | | |
| | | private void getRelativeVideos() { |
| | | SharedPreferences preferences = tv_more.getContext().getSharedPreferences( |
| | | SharedPreferences preferences = getContext().getSharedPreferences( |
| | | "user", Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | BeibeiVideoAPI.getRelativeVideos(tv_more.getContext(), uid, |
| | | BeibeiVideoAPI.getRelativeVideos(getContext(), uid, |
| | | mVideoInfo.getId(), new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<VideoInfo> videoInfos = gson.fromJson( |
| | | final List<VideoInfo> videoInfos = gson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoInfo>>() { |
| | | }.getType()); |
| | | gv_video_related_video |
| | | .setAdapter(new GridVideoAdapter1( |
| | | videoInfos, getActivity().getApplicationContext(), false)); |
| | | sv_detail.scrollTo(0, 0); |
| | | |
| | | 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); |
| | | } |
| | | if (adRunnable != null) |
| | | rv_video_related_video.post(adRunnable); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private Runnable adRunnable = new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | loadAD2(); |
| | | } |
| | | }; |
| | | |
| | | private void guessLike() { |
| | | SharedPreferences preferences = tv_more.getContext().getSharedPreferences( |
| | | SharedPreferences preferences = getContext().getSharedPreferences( |
| | | "user", Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | BeibeiVideoAPI.guessLike(tv_more.getContext(), uid, mVideoInfo.getId(), |
| | | BeibeiVideoAPI.guessLike(getContext(), uid, mVideoInfo.getId(), |
| | | new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoInfo>>() { |
| | | }.getType()); |
| | | // 非聚效广告显示 |
| | | gv_video_guess_like |
| | | .setAdapter(new GridVideoAdapter1( |
| | | videoInfos, getActivity().getApplicationContext(), false)); |
| | | sv_detail.scrollTo(0, 0); |
| | | // 聚效广告 |
| | | // if (videoInfos.size() > 2) { |
| | | // videoInfos.remove(videoInfos.size() - 1); |
| | | // } |
| | | // mVideoInfos.addAll(videoInfos); |
| | | // mAdView.loadAds(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | 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); |
| | | } |
| | | }); |
| | | |
| | | private void getPeopleSeeVideos() { |
| | | SharedPreferences preferences = tv_more.getContext().getSharedPreferences( |
| | | "user", Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | BeibeiVideoAPI.getPeopleSeeVideos(tv_more.getContext(), uid, |
| | | mVideoInfo.getId(), new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<VideoInfo> videoInfos = gson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoInfo>>() { |
| | | }.getType()); |
| | | gv_video_everybody_look |
| | | .setAdapter(new GridVideoAdapter1( |
| | | videoInfos, getActivity().getApplicationContext(), false)); |
| | | sv_detail.scrollTo(0, 0); |
| | | // 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) { |
| | | // Log.i("result", "收到来源点击产生的列表EventBus-------------1,电视剧的长度为:" + mVideoInfo.getVideoDetailList().size()); |
| | | if (mVideoInfo == null) |
| | | return; |
| | | if (mVideoInfo.getShowType() == 1) {// 综艺 如果是综艺的话就分页加载 |
| | | if (info.getEpisodeNum() > 10) { |
| | | page_varietyshow = info.getEpisodeNum() / 10 + 1; |
| | |
| | | } else { |
| | | if (info.getEpisodeNum() > 12) { |
| | | isShowMore = true; |
| | | tv_more.setText("点击收起"); |
| | | // Drawable drawable = getResources().getDrawable( |
| | | // R.drawable.more_introduction2); |
| | | // drawable.setBounds(0, 0, drawable.getMinimumWidth(), |
| | | // drawable.getMinimumHeight());// 必须设置图片大小,否则不显示 |
| | | iv_episode.setImageResource(R.drawable.more_introduction2); |
| | | } |
| | | } |
| | | mEpisodePagerAdapter.setPlayingPosition(info.getEpisodeNum()); |
| | | // if (mVideoInfo != null && mVideoInfo.getVideoDetailList() != null && mVideoInfo.getVideoDetailList().size() > 12) |
| | | // EpisodeFragment.refresh(); |
| | | } |
| | | |
| | | boolean isExpand; |
| | |
| | | animation.setDuration(durationMillis); |
| | | video_introduction.startAnimation(animation); |
| | | break; |
| | | |
| | | case R.id.video_episode_tv_lookmore:// 查看更多 |
| | | if (mVideoInfo.getShowType() == 1) {// 综艺 如果是综艺的话就分页加载 |
| | | page_varietyshow++; |
| | | isShowMore = true; |
| | | } else { |
| | | if (!isShowMore) {// 如果还没有点击查看更多,点击后查看更多 |
| | | isShowMore = true; |
| | | tv_more.setText("点击收起"); |
| | | // Drawable drawable = getResources().getDrawable( |
| | | // R.drawable.more_introduction2); |
| | | // drawable.setBounds(0, 0, drawable.getMinimumWidth(), |
| | | // drawable.getMinimumHeight());// 必须设置图片大小,否则不显示 |
| | | iv_episode.setImageResource(R.drawable.more_introduction2); |
| | | } else {// 如果以查看更多。点击后不查看更多 |
| | | sv_detail.scrollTo(0, 0);// 回到顶部 |
| | | isShowMore = false; |
| | | tv_more.setText("查看更多"); |
| | | // Drawable drawable = getResources().getDrawable( |
| | | // R.drawable.more_introduction); |
| | | // drawable.setBounds(0, 0, drawable.getMinimumWidth(), |
| | | // drawable.getMinimumHeight());// 必须设置图片大小,否则不显示 |
| | | // tv_more.setCompoundDrawables(null, null, drawable, null); |
| | | iv_episode.setImageResource(R.drawable.more_introduction); |
| | | } |
| | | } |
| | | // EpisodeFragment.refresh(); |
| | | break; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | // 加载播放页第二条广告 |
| | | private void loadAD2() { |
| | | NativeExpressAD nativeExpressAD = new NativeExpressAD(iv_episode.getContext(), new ADSize(ADSize.FULL_WIDTH, ADSize.AUTO_HEIGHT), |
| | | BeibeiConstant.GDT_ID, BeibeiConstant.GDT_PLAYER_NATIVE1, new NativeExpressAD.NativeExpressADListener() { |
| | | new ExpressAdManager(AdUtil.AD_TYPE.gdt2, getContext()).loadVideoDetailRelativeVideoBottomAd(new ExpressAdManager.IAdLoadListener() { |
| | | @Override |
| | | public void onADLoaded(final List<NativeExpressADView> list) { |
| | | tv_more.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if (null != list && list.size() > 0) { |
| | | NativeExpressADView adView = list.get(0); |
| | | adView.render(); |
| | | FrameLayout parent = (FrameLayout) adView.getParent(); |
| | | if (parent != null) { |
| | | parent.removeAllViews(); |
| | | } |
| | | fl_native_ad2.addView(adView); |
| | | public void onSuccess(List<ExpressAdContainer> adList) { |
| | | if (adList != null && adList.size() > 0) { |
| | | ExpressAdManager.renderAd(getActivity(), adList.get(0), new ExpressAdManager.IAdRenderListener() { |
| | | @Override |
| | | 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 onRenderFail(NativeExpressADView nativeExpressADView) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onRenderSuccess(NativeExpressADView nativeExpressADView) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADExposure(NativeExpressADView nativeExpressADView) { |
| | | } |
| | | |
| | | @Override |
| | | public void onADClicked(NativeExpressADView nativeExpressADView) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADClosed(NativeExpressADView nativeExpressADView) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADLeftApplication(NativeExpressADView nativeExpressADView) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADOpenOverlay(NativeExpressADView nativeExpressADView) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADCloseOverlay(NativeExpressADView nativeExpressADView) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onNoAD(AdError adError) { |
| | | } |
| | | }); // 传入Activity |
| | | // 注意:如果您在联盟平台上新建原生模板广告位时,选择了支持视频,那么可以进行个性化设置(可选) |
| | | nativeExpressAD.setVideoOption(new VideoOption.Builder() |
| | | .setAutoPlayPolicy(VideoOption.AutoPlayPolicy.WIFI) // WIFI 环境下可以自动播放视频 |
| | | .setAutoPlayMuted(true) // 自动播放时为静音 |
| | | .build()); // |
| | | nativeExpressAD.loadAD(2); |
| | | }); |
| | | } |
| | | |
| | | // 加载播放页第三条广告 |
| | | private void loadAD3() { |
| | | NativeExpressAD nativeExpressAD = new NativeExpressAD(iv_episode.getContext(), new ADSize(ADSize.FULL_WIDTH, ADSize.AUTO_HEIGHT), |
| | | BeibeiConstant.GDT_ID, BeibeiConstant.GDT_PLAYER_NATIVE1, new NativeExpressAD.NativeExpressADListener() { |
| | | @Override |
| | | public void onADLoaded(final List<NativeExpressADView> list) { |
| | | tv_more.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if (null != list && list.size() > 0) { |
| | | NativeExpressADView adView = list.get(0); |
| | | adView.render(); |
| | | FrameLayout parent = (FrameLayout) adView.getParent(); |
| | | if (parent != null) { |
| | | parent.removeAllViews(); |
| | | } |
| | | fl_native_ad3.addView(adView); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onRenderFail(NativeExpressADView nativeExpressADView) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onRenderSuccess(NativeExpressADView nativeExpressADView) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADExposure(NativeExpressADView nativeExpressADView) { |
| | | } |
| | | |
| | | @Override |
| | | public void onADClicked(NativeExpressADView nativeExpressADView) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADClosed(NativeExpressADView nativeExpressADView) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADLeftApplication(NativeExpressADView nativeExpressADView) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADOpenOverlay(NativeExpressADView nativeExpressADView) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADCloseOverlay(NativeExpressADView nativeExpressADView) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onNoAD(AdError adError) { |
| | | } |
| | | }); // 传入Activity |
| | | // 注意:如果您在联盟平台上新建原生模板广告位时,选择了支持视频,那么可以进行个性化设置(可选) |
| | | nativeExpressAD.setVideoOption(new VideoOption.Builder() |
| | | .setAutoPlayPolicy(VideoOption.AutoPlayPolicy.WIFI) // WIFI 环境下可以自动播放视频 |
| | | .setAutoPlayMuted(true) // 自动播放时为静音 |
| | | .build()); // |
| | | nativeExpressAD.loadAD(2); |
| | | @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"); |
| | | } |
| | | } |