| | |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.widget.FrameLayout; |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.TextView; |
| | |
| | | import com.bumptech.glide.Glide; |
| | | import com.tejia.lijin.app.R; |
| | | import com.tejia.lijin.app.entity.SpecialOffer2; |
| | | import com.tejia.lijin.app.util.GlideRoundTransform; |
| | | import com.tejia.lijin.app.util.JumpActivityUtil; |
| | | import com.tejia.lijin.app.util.ui.HomeUIUtil; |
| | | import com.tejia.lijin.app.util.umengCustomEvent.MainCustomEvent; |
| | | import com.wpc.library.util.SystemCommon; |
| | | import com.wpc.library.util.common.DimenUtils; |
| | | import com.wpc.library.util.common.StringUtils; |
| | | |
| | | import java.util.List; |
| | |
| | | * 推荐圆形专题 |
| | | */ |
| | | public class RecommendCircleSpecialAdapter extends RecyclerView.Adapter { |
| | | |
| | | public final static int SPCAE_DP = 14; |
| | | |
| | | private Activity mContext; |
| | | private List<SpecialOffer2> mList; |
| | |
| | | |
| | | @Override |
| | | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { |
| | | return new Holder(inflater.inflate(R.layout.item_special_offer, parent, false)); |
| | | return new Holder(inflater.inflate(R.layout.item_home_special_circle, parent, false)); |
| | | } |
| | | |
| | | @Override |
| | | public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, final int position) { |
| | | final SpecialOffer2 info = mList.get(position); |
| | | if (StringUtils.isNullOrEmpty(info.getBgColor())) |
| | | info.setBgColor("#FFFFFF"); |
| | | Holder holder = (Holder) viewHolder; |
| | | holder.tv_name.setText(mList.get(position).getName() + ""); |
| | | Glide.with(mContext).load(mList.get(position).getPicture()).into(holder.iv_special_offer); |
| | | if (!StringUtils.isEmpty(mList.get(position).getIcon())) { |
| | | holder.iv_hot.setVisibility(View.VISIBLE); |
| | | Glide.with(mContext).load(mList.get(position).getIcon()).into(holder.iv_hot); |
| | | holder.tv_name.setText(info.getName() + ""); |
| | | Glide.with(mContext).load(info.getPicture()).transform(new GlideRoundTransform(mContext, 18)).into(holder.iv_icon); |
| | | if (!StringUtils.isEmpty(info.getIcon())) { |
| | | holder.iv_tag.setVisibility(View.VISIBLE); |
| | | Glide.with(mContext).load(info.getIcon()).into(holder.iv_tag); |
| | | } else { |
| | | holder.iv_hot.setVisibility(View.GONE); |
| | | holder.iv_tag.setVisibility(View.GONE); |
| | | } |
| | | |
| | | int itemWidth = (int) (SystemCommon.getScreenWidth(mContext) / 5); |
| | | int itemWidth = (int) ((SystemCommon.getScreenWidth(mContext) - DimenUtils.dip2px(mContext, 10) * 2 - DimenUtils.dip2px(mContext, SPCAE_DP) * 3) / 4); |
| | | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(itemWidth, |
| | | ViewGroup.LayoutParams.WRAP_CONTENT); |
| | | holder.ll_item.setLayoutParams(params); |
| | | holder.view.setLayoutParams(params); |
| | | |
| | | // ImageLoader.getInstance().displayImage(mList.get(position).getPicture(), iv_special_offer); |
| | | holder.ll_item.setOnClickListener(new View.OnClickListener() { |
| | | |
| | | if (!StringUtils.isNullOrEmpty(info.getBgColor())) { |
| | | holder.fl_content.setBackground(HomeUIUtil.getCircleSpecialBg(mContext, info.getBgColor())); |
| | | } |
| | | |
| | | holder.view.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | MainCustomEvent.rmdSpecial(mContext, mList.get(position).getName()); |
| | | if (mList.get(position).getJumpDetail() == null) |
| | | MainCustomEvent.rmdSpecial(mContext, info.getName()); |
| | | if (info.getJumpDetail() == null) |
| | | return; |
| | | JumpActivityUtil.jumpPage(mContext, mList.get(position).getJumpDetail(), mList.get(position).getParams()); |
| | | JumpActivityUtil.jumpPage(mContext, info.getJumpDetail(), info.getParams()); |
| | | clickTime = System.currentTimeMillis(); |
| | | clickId = mList.get(position).getId(); |
| | | clickId = info.getId(); |
| | | } |
| | | }); |
| | | } |
| | |
| | | |
| | | class Holder extends RecyclerView.ViewHolder { |
| | | |
| | | FrameLayout fl_content; |
| | | TextView tv_name; |
| | | ImageView iv_special_offer; |
| | | ImageView iv_hot; |
| | | LinearLayout ll_item; |
| | | ImageView iv_icon; |
| | | ImageView iv_tag; |
| | | View view; |
| | | |
| | | public Holder(View itemView) { |
| | | super(itemView); |
| | | view = itemView; |
| | | fl_content = itemView.findViewById(R.id.fl_content); |
| | | tv_name = itemView.findViewById(R.id.tv_name); |
| | | iv_special_offer = itemView.findViewById(R.id.iv_special_offer); |
| | | iv_hot = itemView.findViewById(R.id.iv_hot); |
| | | ll_item = itemView.findViewById(R.id.ll_item); |
| | | iv_icon = itemView.findViewById(R.id.iv_icon); |
| | | iv_tag = itemView.findViewById(R.id.iv_tag); |
| | | } |
| | | } |
| | | } |