| | |
| | | import android.view.ViewGroup |
| | | import com.chad.library.adapter.base.BaseQuickAdapter |
| | | import com.chad.library.adapter.base.BaseViewHolder |
| | | import com.chad.library.adapter.base.loadmore.LoadMoreView |
| | | import com.chad.library.adapter.base.loadmore.SimpleLoadMoreView |
| | | |
| | | /** |
| | | * @author riku |
| | |
| | | //设置空布局 |
| | | getMyLoadingView()?.let { emptyView = it } |
| | | |
| | | // setLoadMoreView(SimpleLoadMoreView()) |
| | | getLoadMoreView()?.let { setLoadMoreView(it)} |
| | | } |
| | | //加载更多 |
| | | setLoadMore() |
| | |
| | | /** |
| | | * 将列表数据替换成新的数据 |
| | | */ |
| | | fun setNewData(dataList: ArrayList<T>) { |
| | | fun setNewData(dataList: List<T>) { |
| | | val resultList = convertToSection(dataList) |
| | | addSection(resultList) |
| | | adapter?.setNewData(resultList) |
| | |
| | | /** |
| | | * 在原数据基础上添加新数据 |
| | | */ |
| | | fun addData(dataList: ArrayList<T>) { |
| | | fun addData(dataList: List<T>) { |
| | | val resultList = convertToSection(dataList) |
| | | addSection(resultList) |
| | | adapter?.addData(resultList) |
| | | onDataUpdated(adapter) |
| | | } |
| | | |
| | | fun addData(pos: Int, dataList: ArrayList<T>){ |
| | | fun addData(pos: Int, dataList: List<T>){ |
| | | val resultList = convertToSection(dataList) |
| | | addSection(resultList) |
| | | adapter?.addData(pos, resultList) |
| | |
| | | fun getSectionLayoutId(): Int |
| | | |
| | | //自定义是否需要添加列表分组 |
| | | fun addSection(dataList: ArrayList<MySection<T>>) = Unit |
| | | fun addSection(dataList: MutableList<MySection<T>>) = Unit |
| | | |
| | | //将数据转换为列表能接受的固定结构 |
| | | fun convertToSection(list: ArrayList<T>): ArrayList<MySection<T>> = MySection.convert2Section(list) |
| | | fun convertToSection(list: List<T>): MutableList<MySection<T>> = MySection.convert2Section(list) |
| | | |
| | | //数据更新结束 |
| | | fun onDataUpdated(adapter: BaseRecyclerAdapter<T>?, pos: Int? = null) = Unit |
| | |
| | | //获取空布局 |
| | | fun getMyLoadFailView(): View? = null |
| | | |
| | | //获取加载布局 |
| | | fun getLoadMoreView(): LoadMoreView? = null |
| | | |
| | | //分割线 |
| | | fun getDivider(): RecyclerView.ItemDecoration? = null |
| | | |