From e50bade808c7bd5d4f719d15f720c3df54082cac Mon Sep 17 00:00:00 2001 From: Jason Whitmore Date: Fri, 10 Jan 2025 18:51:03 -0800 Subject: [PATCH] MediaDetailFragment.kt: replace code that is meant to hide nearby card Before this commit, code would attempt to find and hide the nearby card that would appear when the user was looking at media details. However, this code did not work. After this commit, the old code has been replaced with code that correctly hides the nearby card. Also, this new code uses a helper method call and is overall easier to read. --- .../free/nrw/commons/media/MediaDetailFragment.kt | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt b/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt index 3b2c0652e..8c29f9939 100644 --- a/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt +++ b/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt @@ -490,16 +490,12 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C override fun onResume() { super.onResume() - if (parentFragment != null && requireParentFragment().parentFragment != null) { - // Added a check because, not necessarily, the parent fragment - // will have a parent fragment, say in the case when MediaDetailPagerFragment - // is directly started by the CategoryImagesActivity - if (parentFragment is ContributionsFragment) { - (((parentFragment as ContributionsFragment) - .parentFragment) as ContributionsFragment).binding.cardViewNearby.visibility = - View.GONE - } + + val contributionsFragment: ContributionsFragment? = this.getContributionsFragmentParent() + if (contributionsFragment?.binding != null) { + contributionsFragment.binding.cardViewNearby.visibility = View.GONE } + // detail provider is null when fragment is shown in review activity media = if (detailProvider != null) { detailProvider!!.getMediaAtPosition(index)