package com.electric.chargingpile.adapter; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.electric.chargingpile.R; import com.electric.chargingpile.util.ScreenUtils; import org.jetbrains.annotations.NotNull; public class LockAdapter extends RecyclerView.Adapter { private int mScreenWidth = 0; private Context mContext; public LockAdapter(Context context) { mContext = context; mScreenWidth = ScreenUtils.getScreenWidth(context); } @NonNull @NotNull @Override public LockHodler onCreateViewHolder(@NonNull @NotNull ViewGroup parent, int viewType) { View inflate = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_lock, parent, false); ViewGroup.LayoutParams layoutParams = inflate.getLayoutParams(); int width = (int) (mScreenWidth / 5F) - 24; layoutParams.width = width; layoutParams.height = width; inflate.setLayoutParams(layoutParams); return new LockHodler(inflate); } @Override public void onBindViewHolder(@NonNull @NotNull LockHodler holder, int position) { } @Override public int getItemCount() { return 7; } public class LockHodler extends RecyclerView.ViewHolder { public LockHodler(@NonNull @NotNull View itemView) { super(itemView); } } }