doum
6 天以前 2b287056e2f59518888d05a1bbc7e5a55fbd84d5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.doumee.lib_coremodel.view.recyclerview.adapter;
 
import android.content.Context;
 
import androidx.databinding.ViewDataBinding;
 
import com.king.base.adapter.BaseRecyclerAdapter;
 
import java.util.List;
 
public abstract class BindingAdapter<T,DVB extends ViewDataBinding> extends BaseRecyclerAdapter<T, BindingHolder<DVB>> {
 
 
    public BindingAdapter(Context context, int layoutId) {
        super(context, layoutId);
    }
 
    public BindingAdapter(Context context, List<T> listData, int layoutId) {
        super(context, listData, layoutId);
 
    }
 
    public T getItem(int position) {
        if(position<getItemCount()){
            return getListData().get(position);
        }
        return null;
    }
 
    public void refreshData(List<T> list){
        if(list!=null){
            setListData(list);
        }else{
            getListData().clear();
        }
        notifyDataSetChanged();
    }
 
    public T getDataByPosition(int position) {
        if (position >= 0 && position < getListData().size()) {
            return getListData().get(position);
        }
        return null;
    }
 
    public void clearData(){
        getListData().clear();
        notifyDataSetChanged();
    }
}