MediaDetailFragment.java: 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.
This commit is contained in:
Jason Whitmore 2024-09-26 16:32:39 -07:00
parent 408f5a3b57
commit 4c8875944f

View file

@ -362,15 +362,13 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment implements
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
if (getParentFragment() != null && getParentFragment().getParentFragment() != null) {
//Added a check because, not necessarily, the parent fragment will have a parent fragment, say //Hide the Nearby card when looking at media details
// in the case when MediaDetailPagerFragment is directly started by the CategoryImagesActivity ContributionsFragment cf = this.getContributionsFragmentParent();
if (getParentFragment() instanceof ContributionsFragment) { if(cf != null && cf.binding != null){
((ContributionsFragment) (getParentFragment() cf.binding.cardViewNearby.setVisibility(View.GONE);
.getParentFragment())).binding.cardViewNearby
.setVisibility(View.GONE);
}
} }
// detail provider is null when fragment is shown in review activity // detail provider is null when fragment is shown in review activity
if (detailProvider != null) { if (detailProvider != null) {
media = detailProvider.getMediaAtPosition(index); media = detailProvider.getMediaAtPosition(index);
@ -448,7 +446,7 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment implements
/** /**
* Retrieves the ContributionsFragment that is potentially the parent, grandparent, etc * Retrieves the ContributionsFragment that is potentially the parent, grandparent, etc
* fragment of this fragment. * fragment of this fragment.
* *
* @return The ContributionsFragment instance. If the ContributionsFragment instance could not * @return The ContributionsFragment instance. If the ContributionsFragment instance could not
* be found, null is returned. * be found, null is returned.
*/ */