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
public void onResume() {
super.onResume();
if (getParentFragment() != null && getParentFragment().getParentFragment() != 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 (getParentFragment() instanceof ContributionsFragment) {
((ContributionsFragment) (getParentFragment()
.getParentFragment())).binding.cardViewNearby
.setVisibility(View.GONE);
}
//Hide the Nearby card when looking at media details
ContributionsFragment cf = this.getContributionsFragmentParent();
if(cf != null && cf.binding != null){
cf.binding.cardViewNearby.setVisibility(View.GONE);
}
// detail provider is null when fragment is shown in review activity
if (detailProvider != null) {
media = detailProvider.getMediaAtPosition(index);