初始化
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
package com.arpa.hndahesudintocctmsdriver.util.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.arpa.hndahesudintocctmsdriver.util.bean.GetObjectName;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AdapterAll extends RecyclerView.Adapter<AdapterAll.ViewHolder> {
|
||||
|
||||
private Context context;
|
||||
private List object;
|
||||
private int layout;
|
||||
|
||||
private onItemViewListenter listenterView;
|
||||
public AdapterAll(Context context, List object, int layout){
|
||||
this.context = context;
|
||||
this.object=object;
|
||||
this.layout=layout;
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(context).inflate(layout, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
View v=holder.itemView;
|
||||
ViewGroup vg=v.findViewById(v.getId());
|
||||
GetObjectName.ZIModel(vg,object.get(position),context);
|
||||
if(listenterView!=null){
|
||||
listenterView.onItemView(position,object.get(position),v);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateItem(int position,Object o) {
|
||||
//更新数据
|
||||
notifyItemChanged(position,o);
|
||||
}
|
||||
public void removeAll(){
|
||||
object=new ArrayList();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
public void delItemV(int position) {
|
||||
object.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyDataSetChanged();
|
||||
//android:editable="false"
|
||||
}
|
||||
|
||||
public void addItemV(Object o) {
|
||||
//增加数据
|
||||
int position = object.size();
|
||||
object.add(o);
|
||||
notifyItemInserted(position);
|
||||
}
|
||||
|
||||
public void removeItemV(int index) {
|
||||
int position = object.size();
|
||||
object.remove(index);
|
||||
notifyItemInserted(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if(object==null){
|
||||
return 0;
|
||||
}
|
||||
return object.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
public ViewHolder(View view) {
|
||||
super(view);
|
||||
}
|
||||
}
|
||||
|
||||
//对内容的补充
|
||||
public void setOnItemViewListener(onItemViewListenter listenterView) { this.listenterView = listenterView; }
|
||||
public interface onItemViewListenter { void onItemView(int position,Object o, View v);}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.arpa.hndahesudintocctmsdriver.util.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.arpa.hndahesudintocctmsdriver.util.bean.GetObjectName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AdapterAlls extends RecyclerView.Adapter<AdapterAlls.ViewHolder> {
|
||||
|
||||
private Context context;
|
||||
private List<ManyBean> object;
|
||||
public AdapterAlls(Context context, List<ManyBean> object){
|
||||
this.context = context;
|
||||
this.object=object;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(context).inflate(object.get(viewType).getLayout(), parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
View v=holder.itemView;
|
||||
ViewGroup vg=v.findViewById(v.getId());
|
||||
GetObjectName.ZIModel(vg,object.get(position).getBean(),context);
|
||||
listenterView.onItemView(position,object.get(position).getBean(),v,object.get(position).getLayout());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if(object==null){
|
||||
return 0;
|
||||
}
|
||||
return object.size();
|
||||
}
|
||||
|
||||
public void add(List<ManyBean> addMessageList) {
|
||||
//增加数据
|
||||
int position = object.size();
|
||||
object.addAll(position, addMessageList);
|
||||
notifyItemInserted(position);
|
||||
}
|
||||
|
||||
public void addItem(ManyBean mb) {
|
||||
//增加数据
|
||||
int position = object.size();
|
||||
object.add(mb);
|
||||
notifyItemInserted(position);
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
public ViewHolder(View view) {
|
||||
super(view);
|
||||
}
|
||||
}
|
||||
//对内容的补充
|
||||
private onItemViewListenter listenterView;
|
||||
public void setOnItemViewListener(onItemViewListenter listenterView) { this.listenterView = listenterView; }
|
||||
public interface onItemViewListenter { void onItemView(int position, Object o, View v, int layout);}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.arpa.hndahesudintocctmsdriver.util.adapter;
|
||||
|
||||
public class ManyBean {
|
||||
private Object bean;
|
||||
private int layout;
|
||||
|
||||
public ManyBean(Object bean, int layout) {
|
||||
this.bean = bean;
|
||||
this.layout = layout;
|
||||
}
|
||||
|
||||
public Object getBean() {
|
||||
return bean;
|
||||
}
|
||||
|
||||
public void setBean(Object bean) {
|
||||
this.bean = bean;
|
||||
}
|
||||
|
||||
public int getLayout() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
public void setLayout(int layout) {
|
||||
this.layout = layout;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.arpa.hndahesudintocctmsdriver.util.adapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TFList {
|
||||
|
||||
public static List<Object> getList(List lists){
|
||||
List<Object> list=new ArrayList<>();
|
||||
for (Object o : lists) {
|
||||
list.add(o);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user