feat:显示多图片
parent
177d5669f8
commit
514493afe7
@ -0,0 +1,92 @@
|
|||||||
|
package com.example.tyre.maintenance.adapter;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.databinding.DataBindingUtil;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.example.tyre.BR;
|
||||||
|
import com.example.tyre.R;
|
||||||
|
import com.example.tyre.databinding.ItemDisposalImgBinding;
|
||||||
|
import com.example.tyre.maintenance.been.CheckInstanceFiles;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wanghao
|
||||||
|
* @date 2024/3/11
|
||||||
|
*/
|
||||||
|
public class DisposalFileAdapter extends RecyclerView.Adapter<DisposalFileAdapter.MyViewHolder> {
|
||||||
|
private List<CheckInstanceFiles> list;
|
||||||
|
private static Context context;
|
||||||
|
private LayoutInflater inflater;
|
||||||
|
private ItemClickCall clickCall;
|
||||||
|
private boolean delectState=false;
|
||||||
|
|
||||||
|
public void setDelectState(boolean delectState) {
|
||||||
|
this.delectState = delectState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DisposalFileAdapter(Context context, ItemClickCall clickCall) {
|
||||||
|
this.context = context;
|
||||||
|
this.clickCall = clickCall;
|
||||||
|
inflater = LayoutInflater.from(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setList(List<CheckInstanceFiles> list) {
|
||||||
|
this.list = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
ItemDisposalImgBinding binding = DataBindingUtil.inflate(inflater, R.layout.item_disposal_img, parent, false);
|
||||||
|
return new MyViewHolder(binding);
|
||||||
|
}
|
||||||
|
|
||||||
|
// @SuppressLint("CheckResult")
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
|
||||||
|
var outstock = list.get(position);
|
||||||
|
var binding = holder.binding;
|
||||||
|
binding.setVariable(BR.vm,outstock);
|
||||||
|
Log.e("TAG", "onBindViewHolder:" + outstock.isState());
|
||||||
|
Glide.with(context)
|
||||||
|
.load(outstock.getFaultFile())
|
||||||
|
.into(binding.disFile);
|
||||||
|
binding.disFile.setOnClickListener(v -> clickCall.onClick(position,true));
|
||||||
|
if (delectState){
|
||||||
|
binding.disposalDelect.setVisibility(View.GONE);
|
||||||
|
}else{
|
||||||
|
binding.disposalDelect.setVisibility(View.VISIBLE);
|
||||||
|
binding.disposalDelect.setOnClickListener(v -> clickCall.onClick(position,false));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return list==null?0:list.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
private ItemDisposalImgBinding binding;
|
||||||
|
|
||||||
|
public MyViewHolder(ItemDisposalImgBinding binding) {
|
||||||
|
super(binding.getRoot());
|
||||||
|
this.binding = binding;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
public interface ItemClickCall {
|
||||||
|
void onClick(int position,boolean type);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
package com.example.tyre.maintenance.been;
|
||||||
|
|
||||||
|
import androidx.databinding.BaseObservable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wanghao
|
||||||
|
* 图片用
|
||||||
|
* @date 2024/3/11 10:00
|
||||||
|
*/
|
||||||
|
public class CheckInstanceFiles extends BaseObservable {
|
||||||
|
private String faultFile;
|
||||||
|
private boolean state=false;
|
||||||
|
|
||||||
|
public boolean isState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(boolean state) {
|
||||||
|
this.state = state;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFaultFile() {
|
||||||
|
return faultFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFaultFile(String faultFile) {
|
||||||
|
this.faultFile = faultFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "CheckInstanceFiles{" +
|
||||||
|
"faultFile='" + faultFile + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<variable
|
||||||
|
name="vm"
|
||||||
|
type="com.example.tyre.maintenance.been.CheckInstanceFiles" />
|
||||||
|
|
||||||
|
<import type="android.view.View" />
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="80dp"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:src="@mipmap/ic_picture_err"
|
||||||
|
android:padding="20dp"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/dis_file"
|
||||||
|
android:paddingTop="5dp"
|
||||||
|
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/disposal_delect"
|
||||||
|
android:layout_width="30dp"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:layout_gravity="right"
|
||||||
|
android:src="@mipmap/ic_cha1" />
|
||||||
|
</FrameLayout>
|
||||||
|
</layout>
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
Loading…
Reference in New Issue