|
|
@ -2,10 +2,10 @@ package com.android.base.app.fragment |
|
|
|
|
|
|
|
|
|
|
|
import android.graphics.drawable.Drawable |
|
|
|
import android.graphics.drawable.Drawable |
|
|
|
import android.view.View |
|
|
|
import android.view.View |
|
|
|
import com.android.base.app.ui.CommonId |
|
|
|
|
|
|
|
import com.android.base.app.ui.* |
|
|
|
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 { |
|
|
|
companion object { |
|
|
|
fun init(view: View): RefreshLoadMoreStateLayoutImpl { |
|
|
|
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 _multiStateView: StateLayout? = layout.findViewById<View>(CommonId.STATE_ID) as? StateLayout |
|
|
|
private var mRefreshView: RefreshLoadMoreView |
|
|
|
private var _refreshView: RefreshLoadMoreView |
|
|
|
|
|
|
|
|
|
|
|
val refreshView: RefreshLoadMoreView |
|
|
|
val refreshView: RefreshLoadMoreView |
|
|
|
get() = mRefreshView |
|
|
|
get() = _refreshView |
|
|
|
|
|
|
|
|
|
|
|
init { |
|
|
|
init { |
|
|
|
val refreshLayout = mLayout.findViewById<View>(CommonId.REFRESH_ID) |
|
|
|
val refreshLayout = layout.findViewById<View>(CommonId.REFRESH_ID) |
|
|
|
mRefreshView = RefreshLoadViewFactory.createRefreshView(refreshLayout) |
|
|
|
?: 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 showLoadingLayout() = checkMultiStateView().showLoadingLayout() |
|
|
|
override fun showContentLayout() = mMultiStateView.showContentLayout() |
|
|
|
override fun showContentLayout() = checkMultiStateView().showContentLayout() |
|
|
|
override fun showEmptyLayout() = mMultiStateView.showEmptyLayout() |
|
|
|
override fun showEmptyLayout() = checkMultiStateView().showEmptyLayout() |
|
|
|
override fun showErrorLayout() = mMultiStateView.showErrorLayout() |
|
|
|
override fun showErrorLayout() = checkMultiStateView().showErrorLayout() |
|
|
|
override fun showRequesting() = mMultiStateView.showRequesting() |
|
|
|
override fun showRequesting() = checkMultiStateView().showRequesting() |
|
|
|
override fun showBlank() = mMultiStateView.showBlank() |
|
|
|
override fun showBlank() = checkMultiStateView().showBlank() |
|
|
|
override fun showNetErrorLayout() = mMultiStateView.showNetErrorLayout() |
|
|
|
override fun showNetErrorLayout() = checkMultiStateView().showNetErrorLayout() |
|
|
|
override fun showServerErrorLayout() = mMultiStateView.showServerErrorLayout() |
|
|
|
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 { |
|
|
|
override fun setStateMessage(state: Int, message: CharSequence?): StateLayoutConfig { |
|
|
|
mMultiStateView.stateLayoutConfig.setStateMessage(state, message) |
|
|
|
checkMultiStateView().stateLayoutConfig.setStateMessage(state, message) |
|
|
|
return mMultiStateView.stateLayoutConfig |
|
|
|
return checkMultiStateView().stateLayoutConfig |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun setStateIcon(state: Int, drawable: Drawable?): StateLayoutConfig { |
|
|
|
override fun setStateIcon(state: Int, drawable: Drawable?): StateLayoutConfig { |
|
|
|
mMultiStateView.stateLayoutConfig.setStateIcon(state, drawable) |
|
|
|
checkMultiStateView().stateLayoutConfig.setStateIcon(state, drawable) |
|
|
|
return mMultiStateView.stateLayoutConfig |
|
|
|
return checkMultiStateView().stateLayoutConfig |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun setStateIcon(state: Int, drawableId: Int): StateLayoutConfig { |
|
|
|
override fun setStateIcon(state: Int, drawableId: Int): StateLayoutConfig { |
|
|
|
mMultiStateView.stateLayoutConfig.setStateIcon(state, drawableId) |
|
|
|
checkMultiStateView().stateLayoutConfig.setStateIcon(state, drawableId) |
|
|
|
return mMultiStateView.stateLayoutConfig |
|
|
|
return checkMultiStateView().stateLayoutConfig |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun setStateAction(state: Int, actionText: CharSequence?): StateLayoutConfig { |
|
|
|
override fun setStateAction(state: Int, actionText: CharSequence?): StateLayoutConfig { |
|
|
|
mMultiStateView.stateLayoutConfig.setStateAction(state, actionText) |
|
|
|
checkMultiStateView().stateLayoutConfig.setStateAction(state, actionText) |
|
|
|
return mMultiStateView.stateLayoutConfig |
|
|
|
return checkMultiStateView().stateLayoutConfig |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun setStateRetryListener(retryActionListener: OnRetryActionListener?): StateLayoutConfig { |
|
|
|
override fun setStateRetryListener(retryActionListener: OnRetryActionListener?): StateLayoutConfig { |
|
|
|
mMultiStateView.stateLayoutConfig.setStateRetryListener(retryActionListener) |
|
|
|
checkMultiStateView().stateLayoutConfig.setStateRetryListener(retryActionListener) |
|
|
|
return mMultiStateView.stateLayoutConfig |
|
|
|
return checkMultiStateView().stateLayoutConfig |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun disableOperationWhenRequesting(disable: Boolean): StateLayoutConfig { |
|
|
|
override fun disableOperationWhenRequesting(disable: Boolean): StateLayoutConfig { |
|
|
|
mMultiStateView.stateLayoutConfig.disableOperationWhenRequesting(disable) |
|
|
|
checkMultiStateView().stateLayoutConfig.disableOperationWhenRequesting(disable) |
|
|
|
return mMultiStateView.stateLayoutConfig |
|
|
|
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") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |