153 lines
6.6 KiB
Java
153 lines
6.6 KiB
Java
package com.ubt.jimu.diy.view.adapter;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.drawable.Drawable;
|
|
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 androidx.recyclerview.widget.RecyclerView;
|
|
import butterknife.ButterKnife;
|
|
import butterknife.Unbinder;
|
|
import butterknife.internal.Utils;
|
|
import com.bumptech.glide.Glide;
|
|
import com.bumptech.glide.RequestBuilder;
|
|
import com.bumptech.glide.request.RequestOptions;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.diy.model.DiyModel;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class OfficialDiyAdapter extends RecyclerView.Adapter<OfficialDiyViewHolder> {
|
|
private Context context;
|
|
private LayoutInflater inflater;
|
|
private int itemHeight;
|
|
private RecyclerView.LayoutParams itemLayoutParams;
|
|
private int itemWidth;
|
|
private OnOfficialDiyItemClickListener listener;
|
|
private LinearLayout.LayoutParams logoLayoutParams;
|
|
private FrameLayout.LayoutParams logoParams;
|
|
private List<DiyModel> robots;
|
|
private LinearLayout.LayoutParams starParams;
|
|
|
|
public class OfficialDiyViewHolder extends RecyclerView.ViewHolder {
|
|
public LinearLayout cvContent;
|
|
public FrameLayout flContainer;
|
|
public ImageView imgDiyLogo;
|
|
public ImageView imgStar1;
|
|
public ImageView imgStar2;
|
|
public ImageView imgStar3;
|
|
public TextView tvDiyName;
|
|
|
|
public OfficialDiyViewHolder(View view) {
|
|
super(view);
|
|
ButterKnife.a(this, view);
|
|
view.getLayoutParams().width = OfficialDiyAdapter.this.itemWidth;
|
|
view.getLayoutParams().height = OfficialDiyAdapter.this.itemHeight;
|
|
}
|
|
|
|
private void initStart(DiyModel diyModel) {
|
|
int i;
|
|
if (diyModel == null) {
|
|
return;
|
|
}
|
|
short star = diyModel.getStar();
|
|
int i2 = R.drawable.community_collection;
|
|
int i3 = R.drawable.community_collection_default;
|
|
if (star <= 0) {
|
|
i = R.drawable.community_collection_default;
|
|
i2 = R.drawable.community_collection_default;
|
|
} else if (star == 1) {
|
|
i = R.drawable.community_collection_default;
|
|
} else {
|
|
i = star == 2 ? R.drawable.community_collection_default : R.drawable.community_collection;
|
|
i3 = R.drawable.community_collection;
|
|
}
|
|
this.imgStar1.setImageResource(i2);
|
|
this.imgStar2.setImageResource(i3);
|
|
this.imgStar3.setImageResource(i);
|
|
}
|
|
|
|
public void initHolder(final DiyModel diyModel, final int i) {
|
|
this.tvDiyName.setText(diyModel.getTitle());
|
|
RequestBuilder<Drawable> a = Glide.e(OfficialDiyAdapter.this.context).a(diyModel.getImage());
|
|
a.a(new RequestOptions().b(R.drawable.community_img).a(R.drawable.community_img));
|
|
a.a(this.imgDiyLogo);
|
|
this.cvContent.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.diy.view.adapter.OfficialDiyAdapter.OfficialDiyViewHolder.1
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
if (OfficialDiyAdapter.this.listener != null) {
|
|
OfficialDiyAdapter.this.listener.onOfficialDiyItemClick(diyModel, i);
|
|
}
|
|
}
|
|
});
|
|
initStart(diyModel);
|
|
}
|
|
}
|
|
|
|
public class OfficialDiyViewHolder_ViewBinding implements Unbinder {
|
|
private OfficialDiyViewHolder target;
|
|
|
|
public OfficialDiyViewHolder_ViewBinding(OfficialDiyViewHolder officialDiyViewHolder, View view) {
|
|
this.target = officialDiyViewHolder;
|
|
officialDiyViewHolder.cvContent = (LinearLayout) Utils.b(view, R.id.cvContent, "field 'cvContent'", LinearLayout.class);
|
|
officialDiyViewHolder.flContainer = (FrameLayout) Utils.b(view, R.id.flContainer, "field 'flContainer'", FrameLayout.class);
|
|
officialDiyViewHolder.imgDiyLogo = (ImageView) Utils.b(view, R.id.imgDiyLogo, "field 'imgDiyLogo'", ImageView.class);
|
|
officialDiyViewHolder.tvDiyName = (TextView) Utils.b(view, R.id.tvDiyName, "field 'tvDiyName'", TextView.class);
|
|
officialDiyViewHolder.imgStar1 = (ImageView) Utils.b(view, R.id.imgStar1, "field 'imgStar1'", ImageView.class);
|
|
officialDiyViewHolder.imgStar2 = (ImageView) Utils.b(view, R.id.imgStar2, "field 'imgStar2'", ImageView.class);
|
|
officialDiyViewHolder.imgStar3 = (ImageView) Utils.b(view, R.id.imgStar3, "field 'imgStar3'", ImageView.class);
|
|
}
|
|
|
|
@Override // butterknife.Unbinder
|
|
public void unbind() {
|
|
OfficialDiyViewHolder officialDiyViewHolder = this.target;
|
|
if (officialDiyViewHolder == null) {
|
|
throw new IllegalStateException("Bindings already cleared.");
|
|
}
|
|
this.target = null;
|
|
officialDiyViewHolder.cvContent = null;
|
|
officialDiyViewHolder.flContainer = null;
|
|
officialDiyViewHolder.imgDiyLogo = null;
|
|
officialDiyViewHolder.tvDiyName = null;
|
|
officialDiyViewHolder.imgStar1 = null;
|
|
officialDiyViewHolder.imgStar2 = null;
|
|
officialDiyViewHolder.imgStar3 = null;
|
|
}
|
|
}
|
|
|
|
public interface OnOfficialDiyItemClickListener {
|
|
void onOfficialDiyItemClick(DiyModel diyModel, int i);
|
|
}
|
|
|
|
public OfficialDiyAdapter(Context context, List<DiyModel> list, int i, int i2) {
|
|
this.context = context;
|
|
this.inflater = LayoutInflater.from(context);
|
|
this.robots = list;
|
|
this.itemHeight = i;
|
|
this.itemWidth = i2;
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
|
public int getItemCount() {
|
|
return this.robots.size();
|
|
}
|
|
|
|
public void setListener(OnOfficialDiyItemClickListener onOfficialDiyItemClickListener) {
|
|
this.listener = onOfficialDiyItemClickListener;
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
|
public void onBindViewHolder(OfficialDiyViewHolder officialDiyViewHolder, int i) {
|
|
officialDiyViewHolder.initHolder(this.robots.get(i), i);
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
|
public OfficialDiyViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
|
|
return new OfficialDiyViewHolder(this.inflater.inflate(R.layout.recycler_item_official_diy, viewGroup, false));
|
|
}
|
|
}
|