From 806e56e20bb7452437ce8effde2c4efffff9cd1a Mon Sep 17 00:00:00 2001 From: Amine Date: Mon, 30 Dec 2024 22:12:38 +0100 Subject: [PATCH] fix: Context issues in fragment sheet. --- .../android/fragments/ArticleFragment.kt | 2 +- .../android/fragments/FilterSheetFragment.kt | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ArticleFragment.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ArticleFragment.kt index a624f97..1ebb9dd 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ArticleFragment.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ArticleFragment.kt @@ -225,7 +225,7 @@ class ArticleFragment : Fragment(), DIAware { } this@ArticleFragment.item.unread = false Toast.makeText( - context, + requireContext(), R.string.marked_as_read, Toast.LENGTH_LONG, ).show() diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt index 34eec9a..7af823f 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt @@ -52,19 +52,17 @@ class FilterSheetFragment : BottomSheetDialogFragment(), DIAware { false, ) - val context: Context? = context - - if (context == null) { - dismiss() - Exception("FilterSheetFragment context is null").sendSilentlyWithAcraWithName("FilterSheetFragment > onCreateView") - } else { + try { CoroutineScope(Dispatchers.Main).launch { - handleTagChips(context) - handleSourceChips(context) + handleTagChips(requireContext()) + handleSourceChips(requireContext()) binding.progressBar2.visibility = GONE binding.filterView.visibility = VISIBLE } + } catch (e: IllegalStateException) { + dismiss() + e.sendSilentlyWithAcraWithName("FilterSheetFragment > onCreateView") } binding.floatingActionButton2.setOnClickListener {