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(); 
 | 
    } 
 | 
} 
 |