riku
2022-02-18 d59d55575d913646b7a90fca651904ab889c6723
app/src/main/java/cn/flightfeather/thirdappmodule/view/recyclerview/RecyclerViewPanel.kt
@@ -18,17 +18,9 @@
 * 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
@@ -38,6 +30,9 @@
    private var tempRecyclerView: RecyclerView? = null
    private var tempRefreshLayout: SwipeRefreshLayout? = null
    /**
     * 在接口[RecyclerViewSetInterface.initList]中会自动初始化
     */
    override var adapter: BaseRecyclerAdapter<T>? = null
    private var mRecyclerView: RecyclerView? = null
@@ -76,8 +71,7 @@
        }
    }
    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()
@@ -86,29 +80,17 @@
    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
@@ -124,8 +106,7 @@
    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)
@@ -135,8 +116,7 @@
    //******************************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