From 355933e3f984b45fe6d06d47213fd9f49f899d8e Mon Sep 17 00:00:00 2001 From: Gideon Okuro Date: Tue, 9 Jul 2024 16:52:29 +0300 Subject: [PATCH] ensure that the fragment is still attached before performing operations that require context --- .../org/ole/planet/myplanet/ui/resources/ResourcesFragment.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/resources/ResourcesFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/resources/ResourcesFragment.kt index 06afdf6c7c..9295d20b0f 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/resources/ResourcesFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/resources/ResourcesFragment.kt @@ -70,6 +70,7 @@ class ResourcesFragment : BaseRecyclerFragment(), OnLibraryItem override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + if (!isAdded) return searchTags = ArrayList() config = Utilities.getCloudConfig().showClose(R.color.black_overlay) tvAddToLib = view.findViewById(R.id.tv_add) @@ -179,6 +180,7 @@ class ResourcesFragment : BaseRecyclerFragment(), OnLibraryItem } private fun createAlertDialog(): AlertDialog { + if (!isAdded) return AlertDialog.Builder(requireContext()).create() val builder = AlertDialog.Builder(requireContext(), 5) var msg = getString(R.string.success_you_have_added_these_resources_to_your_mylibrary) if ((selectedItems?.size ?: 0) <= 5) { @@ -291,7 +293,6 @@ class ResourcesFragment : BaseRecyclerFragment(), OnLibraryItem return b } - override fun getSelectedFilter(): Map> { val b: MutableMap> = HashMap() b["languages"] = languages @@ -348,7 +349,6 @@ class ResourcesFragment : BaseRecyclerFragment(), OnLibraryItem } } - private fun additionalSetup() { val bottomSheet = requireView().findViewById(R.id.card_filter) requireView().findViewById(R.id.filter).setOnClickListener {