Skip to content

Commit

Permalink
fixing interface onRetry
Browse files Browse the repository at this point in the history
  • Loading branch information
yzzzd committed Sep 22, 2021
1 parent d838347 commit c75158b
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions core/src/main/java/com/crocodic/core/helper/StateViewHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import com.crocodic.core.widget.stateview.StateView
* Created by @yzzzd on 4/19/18.
*/

class StateViewHelper(val stateView: StateView?, @LayoutRes emptyRes: Int = R.layout.state_empty, @LayoutRes val errorRes: Int = R.layout.state_error, @LayoutRes loadingRes: Int = R.layout.state_loading, val overContent: Boolean = true) {
class StateViewHelper(val stateView: StateView?, @LayoutRes emptyRes: Int = R.layout.state_empty, @LayoutRes val errorRes: Int = R.layout.state_error, @LayoutRes loadingRes: Int = R.layout.state_loading) {

var withRetry = false
var overContent = true

init {
setState(STATE_ERROR, errorRes)
Expand Down Expand Up @@ -41,14 +44,10 @@ class StateViewHelper(val stateView: StateView?, @LayoutRes emptyRes: Int = R.la
if (message != null && stateView != null) {
val binding = stateView.generateViewBinding<ViewDataBinding>(errorRes)
binding.setVariable(BR.data, message)

onRetry?.let {
binding.setVariable(BR.showButton, true)
binding.root.findViewById<View>(R.id.btn_retry)?.setOnClickListener {
onRetry()
}
binding.setVariable(BR.showButton, withRetry)
binding.root.findViewById<View>(R.id.btn_retry)?.setOnClickListener {
onRetry?.invoke()
}

stateView.setStateView(STATE_ERROR, binding.root)
}

Expand Down

0 comments on commit c75158b

Please sign in to comment.