distinguish between different error types in ScheduledStatusActivity (#3487)
This commit is contained in:
parent
9e66ccf4a6
commit
24dd68c996
2 changed files with 15 additions and 6 deletions
|
@ -47,6 +47,7 @@ import com.mikepenz.iconics.utils.colorInt
|
|||
import com.mikepenz.iconics.utils.sizeDp
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.IOException
|
||||
import javax.inject.Inject
|
||||
|
||||
class ScheduledStatusActivity :
|
||||
|
@ -98,10 +99,18 @@ class ScheduledStatusActivity :
|
|||
adapter.addLoadStateListener { loadState ->
|
||||
if (loadState.refresh is LoadState.Error) {
|
||||
binding.progressBar.hide()
|
||||
binding.errorMessageView.show()
|
||||
|
||||
val errorState = loadState.refresh as LoadState.Error
|
||||
if (errorState.error is IOException) {
|
||||
binding.errorMessageView.setup(R.drawable.elephant_offline, R.string.error_network) {
|
||||
refreshStatuses()
|
||||
}
|
||||
} else {
|
||||
binding.errorMessageView.setup(R.drawable.elephant_error, R.string.error_generic) {
|
||||
refreshStatuses()
|
||||
}
|
||||
binding.errorMessageView.show()
|
||||
}
|
||||
}
|
||||
if (loadState.refresh != LoadState.Loading) {
|
||||
binding.swipeRefreshLayout.isRefreshing = false
|
||||
|
|
|
@ -38,9 +38,9 @@
|
|||
|
||||
<com.keylesspalace.tusky.view.BackgroundMessageView
|
||||
android:id="@+id/errorMessageView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@android:color/transparent"
|
||||
android:layout_gravity="center"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
|
|
Loading…
Reference in a new issue