| | |
| | | private TreeSet mADSet = new TreeSet(); |
| | | |
| | | public final int TYPE_HEADER = 10001; |
| | | public final int TYPE_FOOTER = 10002; |
| | | |
| | | private Gson gson = new GsonBuilder().setVersion(1.0).setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | |
| | | private View headerView; |
| | | private View footerView; |
| | | |
| | | public void setHeaderView(View view) { |
| | | this.headerView = view; |
| | | } |
| | | |
| | | public void setFooterView(View view) { |
| | | this.footerView = view; |
| | | } |
| | | |
| | | public RecommendNewAdapter(Activity context, List contentList, int recyclerViewWidth) { |
| | |
| | | switch (viewType) { |
| | | case TYPE_HEADER: |
| | | return new HeaderViewHolder(headerView); |
| | | case TYPE_FOOTER: |
| | | return new HeaderViewHolder(footerView); |
| | | case RecommendContent.TYPE_HOMETYPE: |
| | | return new HomeTypeHolder(inflater.inflate(R.layout.item_recommend_home_type, null, false), new RecyclerView.RecycledViewPool()); |
| | | case RecommendContent.TYPE_AD: |
| | |
| | | if (homeType.getVideoInfoList() == null) { |
| | | homeType.setVideoInfoList(new ArrayList<>()); |
| | | } |
| | | |
| | | |
| | | ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); |
| | | holder.view.setLayoutParams(params); |
| | |
| | | homeType.getVideoInfoList().add(homeType.getHomeVideoList().get(j).getVideo()); |
| | | } |
| | | |
| | | holder.view.setVisibility(View.VISIBLE); |
| | | //隐藏 |
| | | if (homeType.getVideoInfoList() != null && homeType.getVideoInfoList().size() > 0) |
| | | holder.view.setVisibility(View.VISIBLE); |
| | | else |
| | | holder.view.setVisibility(View.GONE); |
| | | |
| | | VideoRecommendAdapter adapter = null; |
| | | |
| | |
| | | int count = this.contentList.size(); |
| | | if (headerView != null) |
| | | count++; |
| | | if (footerView != null) |
| | | count++; |
| | | return count; |
| | | } |
| | | |
| | |
| | | |
| | | if (headerView != null) |
| | | position--; |
| | | |
| | | if(position>=contentList.size()) |
| | | return TYPE_FOOTER; |
| | | |
| | | if (contentList.get(position) instanceof HomeType) |
| | | return RecommendContent.TYPE_HOMETYPE; |
| | | else |
| | | return RecommendContent.TYPE_AD; |
| | | |
| | | } |
| | | |
| | | class HomeTypeHolder extends RecyclerView.ViewHolder { |