Fix memory leaks found by LeakCanary

This commit is contained in:
Kirill Kamakin
2021-12-27 13:25:29 +03:00
parent 25f14226df
commit 50f6066416
2 changed files with 17 additions and 0 deletions

View File

@@ -77,4 +77,11 @@ class RecipesFragment : Fragment(R.layout.fragment_recipes) {
}
}
}
override fun onDestroyView() {
super.onDestroyView()
Timber.v("onDestroyView() called")
// Prevent RV leaking through mObservers list in adapter
binding.recipes.adapter = null
}
}

View File

@@ -51,4 +51,14 @@ class RecipeInfoFragment : BottomSheetDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog =
BottomSheetDialog(requireContext(), R.style.NoShapeBottomSheetDialog)
override fun onDestroyView() {
super.onDestroyView()
Timber.v("onDestroyView() called")
// Prevent RV leaking through mObservers list in adapter
with(binding) {
ingredientsList.adapter = null
instructionsList.adapter = null
}
}
}