| | |
| | | import com.weikou.beibeivideo.util.ad.ExpressAdManager; |
| | | import com.weikou.beibeivideo.util.ad.GDTConstant; |
| | | import com.weikou.beibeivideo.util.ad.GDTNativeADUnifiedManager; |
| | | import com.weikou.beibeivideo.util.video.VideoUIUtil; |
| | | |
| | | import java.text.DecimalFormat; |
| | | import java.util.ArrayList; |
| | |
| | | this.footerView = footerView; |
| | | } |
| | | |
| | | RecyclerView.ItemDecoration itemDecorationRow = 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(); |
| | | int minWidth = DimenUtils.dipToPixels(3, view.getContext()); |
| | | if (index == 0) { |
| | | outRect.left = minWidth * 2; //第一列左边贴边 |
| | | outRect.right = minWidth; |
| | | } else if (index == total - 1) { |
| | | outRect.right = minWidth; |
| | | outRect.left = minWidth; |
| | | } else { |
| | | outRect.right = minWidth * 2; //第一列左边贴边 |
| | | outRect.left = minWidth; |
| | | } |
| | | } |
| | | }; |
| | | RecyclerView.ItemDecoration itemDecoration2 = new RecyclerView.ItemDecoration() { |
| | | @Override |
| | | public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { |
| | |
| | | super.getItemOffsets(outRect, view, parent, state); |
| | | int index = parent.getChildAdapterPosition(view); |
| | | int total = parent.getAdapter().getItemCount(); |
| | | int minWidth = DimenUtils.dipToPixels(2, view.getContext()); |
| | | int minWidth = DimenUtils.dipToPixels(3, view.getContext()); |
| | | |
| | | GridLayoutManager.SpanSizeLookup lookup = ((GridLayoutManager) parent.getLayoutManager()).getSpanSizeLookup(); |
| | | int size = lookup.getSpanSize(index); |
| | |
| | | } |
| | | }; |
| | | |
| | | RecyclerView.ItemDecoration itemDecorationRow = 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(); |
| | | int minWidth = DimenUtils.dipToPixels(2, view.getContext()); |
| | | if (index == 0) { |
| | | outRect.left = minWidth * 2; //第一列左边贴边 |
| | | outRect.right = minWidth; |
| | | } else if (index == total - 1) { |
| | | outRect.right = minWidth; |
| | | outRect.left = minWidth; |
| | | } else { |
| | | outRect.right = minWidth * 2; //第一列左边贴边 |
| | | outRect.left = minWidth; |
| | | } |
| | | } |
| | | }; |
| | | |
| | | RecyclerView.ItemDecoration itemDecoration3 = new RecyclerView.ItemDecoration() { |
| | | @Override |
| | |
| | | super.getItemOffsets(outRect, view, parent, state); |
| | | int index = parent.getChildAdapterPosition(view); |
| | | int total = parent.getAdapter().getItemCount(); |
| | | int minWidth = DimenUtils.dipToPixels(1, view.getContext()); |
| | | int minWidth = DimenUtils.dipToPixels(2, view.getContext()); |
| | | if (index % 3 == 0) { |
| | | outRect.left = 0; //第一列左边贴边 |
| | | outRect.right = minWidth * 2; |
| | |
| | | if (viewHolder instanceof VideoHolder) { |
| | | VideoHolder holder = (VideoHolder) viewHolder; |
| | | final VideoInfo info = content.getVideo(); |
| | | //设置内容 |
| | | holder.ll_video_show.setVisibility(View.VISIBLE); |
| | | String defaultPicture = ""; |
| | | if (columns == 2) { |
| | | defaultPicture = info.getHpicture(); |
| | | } else if (columns == 3) { |
| | | defaultPicture = info.getVpicture(); |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(defaultPicture)) { |
| | | defaultPicture = info.getPicture(); |
| | | } |
| | | |
| | | try { |
| | | Glide.with(mContext).load(defaultPicture).transition(withCrossFade()) |
| | | .apply(new RequestOptions().placeholder(R.drawable.shape_default_cover).error(R.drawable.shape_default_cover)) |
| | | .into(new DrawableImageViewTarget(holder.iv_movie_cover, true)); |
| | | } catch (IllegalArgumentException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | //vip标识 |
| | | if (info.getFree() == 1) { |
| | | holder.iv_vip.setVisibility(View.VISIBLE); |
| | | } else { |
| | | holder.iv_vip.setVisibility(View.GONE); |
| | | } |
| | | |
| | | |
| | | holder.tv_movie_title.setText(info.getName()); |
| | | |
| | | String tag = StringUtils.isBlank(info.getTag()) ? "" : info |
| | | .getTag(); |
| | | holder.tv_movie_rating.setText(tag); |
| | | if (StringUtils.isBlank(tag)) { |
| | | holder.tv_movie_rating.setVisibility(View.GONE); |
| | | } else { |
| | | holder.tv_movie_rating.setVisibility(View.VISIBLE); |
| | | } |
| | | |
| | | DecimalFormat df = new DecimalFormat("###.0"); |
| | | holder.tv_movie_play_num.setText(VideoUtil.getWatchCountShortName(info.getWatchCount())); |
| | | holder.tv_movie_comment_num.setText(StringUtils.isBlank(info.getCommentCount()) ? "0" : info.getCommentCount()); |
| | | holder.ll_video_show |
| | | .setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(final View v) { |
| | | //跳转到商品视频播放页 |
| | | if (itemClickListener == null) |
| | | myClick(info, v); |
| | | else |
| | | itemClickListener.onClick(info); |
| | | } |
| | | }); |
| | | holder.tv_movie_play_num.setVisibility(View.GONE); |
| | | |
| | | if (columns == 2) { |
| | | holder.rl_ratio.setRatio(0.625f); |
| | | } else if (columns == 3) { |
| | | holder.rl_ratio.setRatio(1.4f); |
| | | } else { |
| | | holder.rl_ratio.setRatio(0.625f); |
| | | } |
| | | |
| | | VideoUIUtil.setVideoListItem(mContext, holder, new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(final View v) { |
| | | //跳转到商品视频播放页 |
| | | if (itemClickListener == null) |
| | | myClick(info, v); |
| | | else |
| | | itemClickListener.onClick(info); |
| | | } |
| | | }, info, columns); |
| | | } else if (viewHolder instanceof RecommendVideoAdHolder) {//广告 |
| | | final RecommendVideoAdHolder holder = (RecommendVideoAdHolder) viewHolder; |
| | | if (columns == 2) { |