From 26529b19d5c3a690523a5e426426803bd6b55a43 Mon Sep 17 00:00:00 2001 From: Conny Duck Date: Sun, 8 Jul 2018 11:41:08 +0200 Subject: [PATCH] fix crash in AccountMediaFragment --- .../tusky/fragment/AccountMediaFragment.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/AccountMediaFragment.kt b/app/src/main/java/com/keylesspalace/tusky/fragment/AccountMediaFragment.kt index b713ee84..66b3035e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/AccountMediaFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/AccountMediaFragment.kt @@ -79,16 +79,20 @@ class AccountMediaFragment : BaseFragment(), Injectable { private val callback = object : Callback> { override fun onFailure(call: Call>?, t: Throwable?) { fetchingStatus = FetchingStatus.NOT_FETCHING - swipe_refresh_layout.isRefreshing = false - progress_bar.visibility = View.GONE + if(isAdded) { + swipe_refresh_layout.isRefreshing = false + progress_bar.visibility = View.GONE + } Log.d(TAG, "Failed to fetch account media", t) } override fun onResponse(call: Call>, response: Response>) { fetchingStatus = FetchingStatus.NOT_FETCHING - swipe_refresh_layout.isRefreshing = false - progress_bar.visibility = View.GONE + if(isAdded) { + swipe_refresh_layout.isRefreshing = false + progress_bar.visibility = View.GONE + } val body = response.body() body?.let { fetched -> statuses.addAll(0, fetched) @@ -221,6 +225,7 @@ class AccountMediaFragment : BaseFragment(), Injectable { }/* Intentionally do nothing. This case is here is to handle when new attachment * types are added to the API before code is added here to handle them. So, the * best fallback is to just show the preview and ignore requests to view them. */ + } }