| | |
| | | import android.widget.RelativeLayout; |
| | | import android.widget.TextView; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.bumptech.glide.Glide; |
| | | import com.bumptech.glide.request.RequestOptions; |
| | | import com.bumptech.glide.request.target.DrawableImageViewTarget; |
| | | import com.bytedance.sdk.openadsdk.TTAdDislike; |
| | | import com.google.gson.FieldNamingPolicy; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.lcjian.library.widget.RatioLayout; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.entity.HomeType; |
| | | import com.weikou.beibeivideo.entity.HomeVideo; |
| | |
| | | import com.weikou.beibeivideo.ui.common.VideosLiveActivity; |
| | | import com.weikou.beibeivideo.ui.discover.StarsActivity; |
| | | import com.weikou.beibeivideo.ui.media.VideoDetailActivity2; |
| | | import com.weikou.beibeivideo.ui.video.VideoColumn2Adapter; |
| | | import com.weikou.beibeivideo.ui.video.VideoRecommendAdapter; |
| | | import com.weikou.beibeivideo.util.JumpActivityUtil; |
| | | import com.weikou.beibeivideo.util.VideoUtil; |
| | | import com.weikou.beibeivideo.util.ad.AdUtil; |
| | | import com.weikou.beibeivideo.util.ad.ExpressAdManager; |
| | |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.TreeSet; |
| | | |
| | | import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade; |
| | | |
| | | public class RecommendNewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
| | | |
| | |
| | | return; |
| | | } |
| | | if (homeType.getVideoInfoList() == null) { |
| | | homeType.setVideoInfoList(new ArrayList<VideoInfo>()); |
| | | homeType.setVideoInfoList(new ArrayList<>()); |
| | | } |
| | | |
| | | //是否为广告 |
| | | if (homeType.getAd() != null) { |
| | | holder.fl_ad.setVisibility(View.VISIBLE); |
| | | holder.fl_content.setVisibility(View.GONE); |
| | | holder.rl_ad.setRatio(homeType.getAd().getPictureRate().floatValue()); |
| | | try { |
| | | Glide.with(mContext).load(homeType.getAd().getPicture()).transition(withCrossFade()) |
| | | .apply(new RequestOptions().placeholder(R.drawable.shape_default_cover).error(R.drawable.shape_default_cover)) |
| | | .into(new DrawableImageViewTarget(holder.iv_ad, true)); |
| | | } catch (IllegalArgumentException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | holder.view.setOnClickListener(new OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | |
| | | JumpActivityUtil.jumpPage(mContext,homeType.getAd().getJumpDetail(),homeType.getAd().getParams()!=null? JSONObject.parseObject(homeType.getAd().getParams().replace( |
| | | "\\" + "\"", "\"")):null); |
| | | } |
| | | }); |
| | | |
| | | return; |
| | | } |
| | | |
| | | holder.fl_ad.setVisibility(View.GONE); |
| | | holder.fl_content.setVisibility(View.VISIBLE); |
| | | |
| | | |
| | | homeType.getVideoInfoList().clear(); |
| | | int bigPictureIndex = -1; |
| | | if (homeType.getHomeVideoList() != null) |
| | | for (HomeVideo hv : homeType.getHomeVideoList()) { |
| | | homeType.getVideoInfoList().add(hv.getVideo()); |
| | | for (int j = 0; j < homeType.getHomeVideoList().size(); j++) { |
| | | if (homeType.getHomeVideoList().get(j).isBigPicture()) |
| | | bigPictureIndex = j; |
| | | homeType.getVideoInfoList().add(homeType.getHomeVideoList().get(j).getVideo()); |
| | | } |
| | | |
| | | holder.view.setVisibility(View.VISIBLE); |
| | | |
| | | VideoColumn2Adapter adapter = null; |
| | | // if (isFirst) { |
| | | // homeType.setColumns(Integer.MAX_VALUE); |
| | | // homeType.setNeedAd(true); |
| | | // } |
| | | VideoRecommendAdapter adapter = null; |
| | | |
| | | holder.rv_content.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); |
| | | |
| | | if (homeType.getColumns() > 3) {//第一排为小视频 |
| | | adapter = new VideoColumn2Adapter(mContext, mContext, homeType.getVideoInfoList(), homeType.isNeedAd(), Integer.MAX_VALUE, "recommend", null, new ExpressAdManager.IAdShowListener() { |
| | | adapter = new VideoRecommendAdapter(mContext, mContext, homeType.getVideoInfoList(), homeType.isNeedAd(), Integer.MAX_VALUE, "recommend", homeType.getName(), null, new ExpressAdManager.IAdShowListener() { |
| | | @Override |
| | | public void show() { |
| | | holder.rv_content.scrollToPosition(0); |
| | |
| | | }); |
| | | adapter.initRecyclerViewDisplayWidthRow1(holder.rv_content); |
| | | } else { |
| | | adapter = new VideoColumn2Adapter(mContext, mContext, homeType.getVideoInfoList(), homeType.isNeedAd(), homeType.getColumns(), "recommend", null); |
| | | adapter = new VideoRecommendAdapter(mContext, mContext, homeType.getVideoInfoList(), homeType.isNeedAd(), homeType.getColumns(), "recommend", homeType.getName(), null); |
| | | if (homeType.getColumns() == 2) |
| | | adapter.initRecyclerViewDisplayWidthColumn2(holder.rv_content); |
| | | adapter.initRecyclerViewDisplayWidthColumn2(holder.rv_content, bigPictureIndex); |
| | | else if (homeType.getColumns() == 3) |
| | | adapter.initRecyclerViewDisplayWidthColumn3(holder.rv_content); |
| | | else |
| | | adapter.initRecyclerViewDisplayWidthRow1(holder.rv_content); |
| | | } |
| | | if (homeType.getVideoInfoList() != null && homeType.getVideoInfoList().size() > 0) |
| | | if (homeType.getVideoInfoList() != null && homeType.getVideoInfoList().size() > 0) { |
| | | holder.rv_content.setAdapter(adapter); |
| | | } |
| | | |
| | | |
| | | Glide.with(mContext).load(homeType.getIcon()) |
| | |
| | | } |
| | | |
| | | class HomeTypeHolder extends RecyclerView.ViewHolder { |
| | | LinearLayout fl_content; |
| | | FrameLayout fl_ad; |
| | | RatioLayout rl_ad; |
| | | TextView tv_category_name; |
| | | ImageView tv_category_icon; |
| | | ImageView iv_ad; |
| | | TextView tv_more; |
| | | RecyclerView rv_content; |
| | | RelativeLayout rl_title_item; |
| | |
| | | this.view = convertView; |
| | | rl_title_item = convertView |
| | | .findViewById(R.id.rl_title_item); |
| | | |
| | | fl_content = convertView |
| | | .findViewById(R.id.fl_content); |
| | | |
| | | fl_ad = convertView |
| | | .findViewById(R.id.fl_ad); |
| | | |
| | | iv_ad = convertView |
| | | .findViewById(R.id.iv_ad); |
| | | |
| | | rl_ad = convertView |
| | | .findViewById(R.id.rl_ad); |
| | | |
| | | |
| | | tv_category_name = convertView |
| | | .findViewById(R.id.tv_category_name); |
| | | tv_category_icon = convertView |
| | |
| | | .findViewById(R.id.tv_more); |
| | | rv_content = convertView |
| | | .findViewById(R.id.rv_content); |
| | | |
| | | |
| | | if (recycledViewPool != null) |
| | | rv_content.setRecycledViewPool(recycledViewPool); |
| | | } |