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 com.mikepenz.iconics.utils.sizeDp
|
||||||
import kotlinx.coroutines.flow.collectLatest
|
import kotlinx.coroutines.flow.collectLatest
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import java.io.IOException
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ScheduledStatusActivity :
|
class ScheduledStatusActivity :
|
||||||
|
@ -98,10 +99,18 @@ class ScheduledStatusActivity :
|
||||||
adapter.addLoadStateListener { loadState ->
|
adapter.addLoadStateListener { loadState ->
|
||||||
if (loadState.refresh is LoadState.Error) {
|
if (loadState.refresh is LoadState.Error) {
|
||||||
binding.progressBar.hide()
|
binding.progressBar.hide()
|
||||||
binding.errorMessageView.setup(R.drawable.elephant_error, R.string.error_generic) {
|
|
||||||
refreshStatuses()
|
|
||||||
}
|
|
||||||
binding.errorMessageView.show()
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (loadState.refresh != LoadState.Loading) {
|
if (loadState.refresh != LoadState.Loading) {
|
||||||
binding.swipeRefreshLayout.isRefreshing = false
|
binding.swipeRefreshLayout.isRefreshing = false
|
||||||
|
|
|
@ -38,9 +38,9 @@
|
||||||
|
|
||||||
<com.keylesspalace.tusky.view.BackgroundMessageView
|
<com.keylesspalace.tusky.view.BackgroundMessageView
|
||||||
android:id="@+id/errorMessageView"
|
android:id="@+id/errorMessageView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:src="@android:color/transparent"
|
android:layout_gravity="center"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
@ -51,4 +51,4 @@
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
Loading…
Reference in a new issue