|
|
|
@ -2,10 +2,10 @@ package com.android.base.app.fragment |
|
|
|
|
|
|
|
|
|
import android.graphics.drawable.Drawable |
|
|
|
|
import android.view.View |
|
|
|
|
import com.android.base.app.ui.CommonId |
|
|
|
|
import com.android.base.app.ui.* |
|
|
|
|
import com.android.base.widget.StateProcessor |
|
|
|
|
|
|
|
|
|
internal class RefreshLoadMoreStateLayoutImpl private constructor(private val mLayout: View) : StateLayout, StateLayoutConfig { |
|
|
|
|
internal class RefreshLoadMoreStateLayoutImpl private constructor(layout: View) : StateLayout, StateLayoutConfig { |
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
|
fun init(view: View): RefreshLoadMoreStateLayoutImpl { |
|
|
|
@ -13,56 +13,72 @@ internal class RefreshLoadMoreStateLayoutImpl private constructor(private val mL |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private var mMultiStateView: StateLayout = mLayout.findViewById<View>(CommonId.STATE_ID) as StateLayout |
|
|
|
|
private var mRefreshView: RefreshLoadMoreView |
|
|
|
|
private var _multiStateView: StateLayout? = layout.findViewById<View>(CommonId.STATE_ID) as? StateLayout |
|
|
|
|
private var _refreshView: RefreshLoadMoreView |
|
|
|
|
|
|
|
|
|
val refreshView: RefreshLoadMoreView |
|
|
|
|
get() = mRefreshView |
|
|
|
|
get() = _refreshView |
|
|
|
|
|
|
|
|
|
init { |
|
|
|
|
val refreshLayout = mLayout.findViewById<View>(CommonId.REFRESH_ID) |
|
|
|
|
mRefreshView = RefreshLoadViewFactory.createRefreshView(refreshLayout) |
|
|
|
|
val refreshLayout = layout.findViewById<View>(CommonId.REFRESH_ID) |
|
|
|
|
?: throw NullPointerException("You need to provide a refreshable layout with id R.id.base_refresh_layout in your xml.") |
|
|
|
|
|
|
|
|
|
_refreshView = RefreshLoadViewFactory.createRefreshView(refreshLayout) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun showLoadingLayout() = mMultiStateView.showLoadingLayout() |
|
|
|
|
override fun showContentLayout() = mMultiStateView.showContentLayout() |
|
|
|
|
override fun showEmptyLayout() = mMultiStateView.showEmptyLayout() |
|
|
|
|
override fun showErrorLayout() = mMultiStateView.showErrorLayout() |
|
|
|
|
override fun showRequesting() = mMultiStateView.showRequesting() |
|
|
|
|
override fun showBlank() = mMultiStateView.showBlank() |
|
|
|
|
override fun showNetErrorLayout() = mMultiStateView.showNetErrorLayout() |
|
|
|
|
override fun showServerErrorLayout() = mMultiStateView.showServerErrorLayout() |
|
|
|
|
override fun showLoadingLayout() = checkMultiStateView().showLoadingLayout() |
|
|
|
|
override fun showContentLayout() = checkMultiStateView().showContentLayout() |
|
|
|
|
override fun showEmptyLayout() = checkMultiStateView().showEmptyLayout() |
|
|
|
|
override fun showErrorLayout() = checkMultiStateView().showErrorLayout() |
|
|
|
|
override fun showRequesting() = checkMultiStateView().showRequesting() |
|
|
|
|
override fun showBlank() = checkMultiStateView().showBlank() |
|
|
|
|
override fun showNetErrorLayout() = checkMultiStateView().showNetErrorLayout() |
|
|
|
|
override fun showServerErrorLayout() = checkMultiStateView().showServerErrorLayout() |
|
|
|
|
|
|
|
|
|
override fun getStateLayoutConfig(): StateLayoutConfig = mMultiStateView.stateLayoutConfig |
|
|
|
|
override fun getStateLayoutConfig(): StateLayoutConfig = checkMultiStateView().stateLayoutConfig |
|
|
|
|
|
|
|
|
|
override fun setStateMessage(state: Int, message: CharSequence?): StateLayoutConfig { |
|
|
|
|
mMultiStateView.stateLayoutConfig.setStateMessage(state, message) |
|
|
|
|
return mMultiStateView.stateLayoutConfig |
|
|
|
|
checkMultiStateView().stateLayoutConfig.setStateMessage(state, message) |
|
|
|
|
return checkMultiStateView().stateLayoutConfig |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun setStateIcon(state: Int, drawable: Drawable?): StateLayoutConfig { |
|
|
|
|
mMultiStateView.stateLayoutConfig.setStateIcon(state, drawable) |
|
|
|
|
return mMultiStateView.stateLayoutConfig |
|
|
|
|
checkMultiStateView().stateLayoutConfig.setStateIcon(state, drawable) |
|
|
|
|
return checkMultiStateView().stateLayoutConfig |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun setStateIcon(state: Int, drawableId: Int): StateLayoutConfig { |
|
|
|
|
mMultiStateView.stateLayoutConfig.setStateIcon(state, drawableId) |
|
|
|
|
return mMultiStateView.stateLayoutConfig |
|
|
|
|
checkMultiStateView().stateLayoutConfig.setStateIcon(state, drawableId) |
|
|
|
|
return checkMultiStateView().stateLayoutConfig |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun setStateAction(state: Int, actionText: CharSequence?): StateLayoutConfig { |
|
|
|
|
mMultiStateView.stateLayoutConfig.setStateAction(state, actionText) |
|
|
|
|
return mMultiStateView.stateLayoutConfig |
|
|
|
|
checkMultiStateView().stateLayoutConfig.setStateAction(state, actionText) |
|
|
|
|
return checkMultiStateView().stateLayoutConfig |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun setStateRetryListener(retryActionListener: OnRetryActionListener?): StateLayoutConfig { |
|
|
|
|
mMultiStateView.stateLayoutConfig.setStateRetryListener(retryActionListener) |
|
|
|
|
return mMultiStateView.stateLayoutConfig |
|
|
|
|
checkMultiStateView().stateLayoutConfig.setStateRetryListener(retryActionListener) |
|
|
|
|
return checkMultiStateView().stateLayoutConfig |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun disableOperationWhenRequesting(disable: Boolean): StateLayoutConfig { |
|
|
|
|
mMultiStateView.stateLayoutConfig.disableOperationWhenRequesting(disable) |
|
|
|
|
return mMultiStateView.stateLayoutConfig |
|
|
|
|
checkMultiStateView().stateLayoutConfig.disableOperationWhenRequesting(disable) |
|
|
|
|
return checkMultiStateView().stateLayoutConfig |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun getProcessor(): StateProcessor { |
|
|
|
|
return checkMultiStateView().stateLayoutConfig.processor |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun setMessageGravity(state: Int, gravity: Int): StateLayoutConfig { |
|
|
|
|
checkMultiStateView().stateLayoutConfig.setMessageGravity(state, gravity) |
|
|
|
|
return this |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun checkMultiStateView(): StateLayout { |
|
|
|
|
return _multiStateView |
|
|
|
|
?: throw IllegalStateException("Calling this function requires defining a view that implements StateLayout in the Layout") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |