package com.bc_chat.bc_base.adapter;

import android.content.Context;

import com.bc_chat.bc_base.entity.ListModel;
import com.zhaohaoting.framework.abs.adapter.AbsRecyclerAdapter;
import com.zhaohaoting.framework.utils.Utils;

/**
 * author：Created by zhaohaoting on 2019/2/27
 * email：526309416@qq.com
 * desc：
 */
public abstract class ModeListAdapter<DATA, BASE_DATA extends ListModel<DATA>> extends AbsRecyclerAdapter<DATA, BASE_DATA> {

    private BASE_DATA mListModel;
//
//    public ModeListAdapter(Context context) {
//        super(context);
//    }

    public ModeListAdapter(Context context, BASE_DATA data) {
        super(context, data.getList());
        mListModel = data;
    }

    @Override
    public void notifyDataChanged(BASE_DATA dataList, boolean isRefresh) {
        if (isRefresh) {
            mDataList.clear();
        }
        if (dataList != null && !Utils.listIsEmpty(dataList.getList())) {
            mDataList.addAll(dataList.getList());
        }
        notifyDataSetChanged();
    }

    @Override
    public BASE_DATA getData() {
        return mListModel;
    }

}
