From 24dd68c99627bbffd7dbe63df248d4ffbdee0453 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Thu, 30 Mar 2023 18:52:24 +0200 Subject: [PATCH] distinguish between different error types in ScheduledStatusActivity (#3487) --- .../scheduled/ScheduledStatusActivity.kt | 15 ++++++++++++--- .../main/res/layout/activity_scheduled_status.xml | 6 +++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusActivity.kt index 3c9a4f23..102e67be 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusActivity.kt @@ -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.setup(R.drawable.elephant_error, R.string.error_generic) { - refreshStatuses() - } 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) { binding.swipeRefreshLayout.isRefreshing = false diff --git a/app/src/main/res/layout/activity_scheduled_status.xml b/app/src/main/res/layout/activity_scheduled_status.xml index 71ba5e65..98b2770a 100644 --- a/app/src/main/res/layout/activity_scheduled_status.xml +++ b/app/src/main/res/layout/activity_scheduled_status.xml @@ -38,9 +38,9 @@ - \ No newline at end of file +