@@ -35,7 +35,7 @@ import java.util.concurrent.TimeUnit
3535class ErrorPanelHelper (
3636 private val fragment : Fragment ,
3737 rootView : View ,
38- onRetry : Runnable
38+ onRetry : Runnable ? ,
3939) {
4040 private val context: Context = rootView.context!!
4141
@@ -56,12 +56,15 @@ class ErrorPanelHelper(
5656 errorPanelRoot.findViewById(R .id.error_open_in_browser)
5757
5858 private var errorDisposable: Disposable ? = null
59+ private var retryShouldBeShown: Boolean = (onRetry != null )
5960
6061 init {
61- errorDisposable = errorRetryButton.clicks()
62- .debounce(300 , TimeUnit .MILLISECONDS )
63- .observeOn(AndroidSchedulers .mainThread())
64- .subscribe { onRetry.run () }
62+ if (onRetry != null ) {
63+ errorDisposable = errorRetryButton.clicks()
64+ .debounce(300 , TimeUnit .MILLISECONDS )
65+ .observeOn(AndroidSchedulers .mainThread())
66+ .subscribe { onRetry.run () }
67+ }
6568 }
6669
6770 private fun ensureDefaultVisibility () {
@@ -101,7 +104,7 @@ class ErrorPanelHelper(
101104 errorActionButton.setOnClickListener(null )
102105 }
103106
104- errorRetryButton.isVisible = true
107+ errorRetryButton.isVisible = retryShouldBeShown
105108 showAndSetOpenInBrowserButtonAction(errorInfo)
106109 } else if (errorInfo.throwable is AccountTerminatedException ) {
107110 errorTextView.setText(R .string.account_terminated)
@@ -130,7 +133,7 @@ class ErrorPanelHelper(
130133 errorInfo.throwable !is ContentNotSupportedException
131134 ) {
132135 // show retry button only for content which is not unavailable or unsupported
133- errorRetryButton.isVisible = true
136+ errorRetryButton.isVisible = retryShouldBeShown
134137 }
135138 showAndSetOpenInBrowserButtonAction(errorInfo)
136139 }
0 commit comments