From df33d8a999a49cd837fab42e87fbca3401b4c911 Mon Sep 17 00:00:00 2001 From: Conny Duck Date: Mon, 14 May 2018 18:23:33 +0200 Subject: [PATCH] fix crash in SearchFragment --- .../tusky/fragment/SearchFragment.kt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/SearchFragment.kt b/app/src/main/java/com/keylesspalace/tusky/fragment/SearchFragment.kt index 7afae751..a9339d14 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/SearchFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/SearchFragment.kt @@ -29,7 +29,6 @@ import com.keylesspalace.tusky.R import com.keylesspalace.tusky.ViewTagActivity import com.keylesspalace.tusky.adapter.SearchResultsAdapter import com.keylesspalace.tusky.di.Injectable -import com.keylesspalace.tusky.entity.Attachment import com.keylesspalace.tusky.entity.SearchResults import com.keylesspalace.tusky.entity.Status import com.keylesspalace.tusky.interfaces.StatusActionListener @@ -58,7 +57,7 @@ class SearchFragment : SFragment(), StatusActionListener, Injectable { } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - val preferences = PreferenceManager.getDefaultSharedPreferences(activity) + val preferences = PreferenceManager.getDefaultSharedPreferences(view.context) alwaysShowSensitiveMedia = preferences.getBoolean("alwaysShowSensitiveMedia", false) mediaPreviewEnabled = preferences.getBoolean("mediaPreviewEnabled", true) @@ -106,13 +105,17 @@ class SearchFragment : SFragment(), StatusActionListener, Injectable { } private fun displayNoResults() { - searchProgressBar.visibility = View.GONE - searchNoResultsText.visibility = View.VISIBLE + if(isAdded) { + searchProgressBar.visibility = View.GONE + searchNoResultsText.visibility = View.VISIBLE + } } private fun hideFeedback() { - searchProgressBar.visibility = View.GONE - searchNoResultsText.visibility = View.GONE + if(isAdded) { + searchProgressBar.visibility = View.GONE + searchNoResultsText.visibility = View.GONE + } } override fun timelineCases(): TimelineCases {