| | |
| | | * Date: 2019/11/22 |
| | | * reference layout is [R.layout.layout_recycler_view_refresh] |
| | | */ |
| | | abstract class RecyclerViewPanel<T>( |
| | | private val dataLoadModel: DataLoadModel<T>, |
| | | private val rootView: View? = null |
| | | ) : RecyclerViewSetInterface<T>, SwipeRefreshLayoutSetInterface { |
| | | abstract class RecyclerViewPanel<T>(private val dataLoadModel: DataLoadModel<T>, private val rootView: View? = null) : RecyclerViewSetInterface<T>, SwipeRefreshLayoutSetInterface { |
| | | |
| | | constructor( |
| | | dataLoadModel: DataLoadModel<T>, |
| | | recyclerView: RecyclerView, |
| | | context: Context?, |
| | | refreshLayout: SwipeRefreshLayout? = null |
| | | ) : this(dataLoadModel) { |
| | | constructor(dataLoadModel: DataLoadModel<T>, recyclerView: RecyclerView, context: Context?, refreshLayout: SwipeRefreshLayout? = null) : this(dataLoadModel) { |
| | | context?.let { this.context = it } |
| | | tempRecyclerView = recyclerView |
| | | this.tempRefreshLayout = refreshLayout |
| | |
| | | private var tempRecyclerView: RecyclerView? = null |
| | | private var tempRefreshLayout: SwipeRefreshLayout? = null |
| | | |
| | | /** |
| | | * 在接口[RecyclerViewSetInterface.initList]中会自动初始化 |
| | | */ |
| | | override var adapter: BaseRecyclerAdapter<T>? = null |
| | | |
| | | private var mRecyclerView: RecyclerView? = null |
| | |
| | | } |
| | | } |
| | | |
| | | override fun getRecyclerView(): RecyclerView? = |
| | | mRecyclerView ?: rootView?.findViewById(R.id.recycler_view) ?: tempRecyclerView |
| | | override fun getRecyclerView(): RecyclerView? = mRecyclerView ?: rootView?.findViewById(R.id.recycler_view) ?: tempRecyclerView |
| | | |
| | | override fun onRefreshDone() = stopRefresh() |
| | | override fun onRefreshFail() = stopRefresh() |
| | |
| | | override fun onLoadMoreFail() = Unit |
| | | override fun onRefreshNone() = stopRefresh() |
| | | |
| | | override fun getMyLayoutManager(): RecyclerView.LayoutManager = |
| | | LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) |
| | | override fun getMyLayoutManager(): RecyclerView.LayoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) |
| | | |
| | | override fun getItemLayoutIdMap(): Map<Int, Int> = emptyMap() |
| | | |
| | | override fun getSectionLayoutId(): Int = R.layout.recycler_item_section_head |
| | | |
| | | override fun getSectionDataList(): List<MySection<T>> = |
| | | MySection.convert2Section(dataLoadModel.dataList) |
| | | override fun getSectionDataList(): List<MySection<T>> = MySection.convert2Section(dataLoadModel.dataList) |
| | | |
| | | override fun onItemClick( |
| | | adapter: BaseQuickAdapter<Any?, BaseViewHolder>, |
| | | view: View, |
| | | position: Int, |
| | | dataList: List<T> |
| | | ) = Unit |
| | | override fun onItemClick(adapter: BaseQuickAdapter<Any?, BaseViewHolder>, view: View, position: Int, dataList: List<T>) = Unit |
| | | |
| | | override fun onItemChildClick( |
| | | adapter: BaseQuickAdapter<Any?, BaseViewHolder>, |
| | | view: View, |
| | | position: Int, |
| | | dataList: List<T> |
| | | ) = Unit |
| | | override fun onItemChildClick(adapter: BaseQuickAdapter<Any?, BaseViewHolder>, view: View, position: Int, dataList: List<T>) = Unit |
| | | |
| | | override fun enableLoadMore(): Boolean = true |
| | | |
| | |
| | | override fun enableUpFetch(): Boolean = false |
| | | |
| | | @SuppressLint("InflateParams") |
| | | override fun getMyEmptyView(): View? = |
| | | LayoutInflater.from(context).inflate(R.layout.layout_empty_view, null) |
| | | override fun getMyEmptyView(): View? = LayoutInflater.from(context).inflate(R.layout.layout_empty_view, null) |
| | | |
| | | @SuppressLint("InflateParams") |
| | | override fun getMyLoadingView(): View? = LayoutInflater.from(context).inflate(R.layout.layout_loading_view, null) |
| | |
| | | |
| | | //******************************SwipeRefreshLayout************************************************************ |
| | | |
| | | override fun getSwipeRefreshLayout(): SwipeRefreshLayout? = |
| | | refreshLayout ?: rootView?.findViewById(R.id.refresh_layout) ?: tempRefreshLayout |
| | | override fun getSwipeRefreshLayout(): SwipeRefreshLayout? = refreshLayout ?: rootView?.findViewById(R.id.refresh_layout) ?: tempRefreshLayout |
| | | |
| | | override fun enableRefresh(): Boolean = true |
| | | |