Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Issue #5832: Navigation Banner Appears in Media Details Screen #5839

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Jason-Whitmore
Copy link
Contributor

Description (required)

Fixes #5832

What changes did you make and why?

There were two changes made.

First, a helper method was created to easily retrieve the ContributionsFragment. Accessing the ContributionsFragment is required to hide the navigation banner.

(One concern I have with this helper method is that it attempts to find the ContributionsFragment by looping through the parent fragments repeatedly in a while loop. The advantage of this strategy is that it can retrieve the ContributionsFragment anywhere in the Fragment parent-child structure if it exists. The primary disadvantage is that if the Fragment parent-child structure is a loop with no ContributionsFragment, then the while loop will never terminate.

I can rewrite this method to retrieve the ContributionsFragment directly (using two calls to getParentFragment()), but this strategy is less flexible. Should I rewrite this helper method to not use a while loop or is the current implementation okay?)

Second, old code which attempted to hide the navigation banner (but was unsuccessful) was replaced with a call to the helper method and then checking for null objects. If the objects are not null, then the navigation banner is successfully hidden.

Tests performed (required)

Tested betaDebug on Android Studio Emulator with API level 34.

Screenshots (for UI changes only)

issue_5832_compressed.webm

In this video, the navigation banner is visible from the contributions menu. When a specific contribution is selected, the navigation banner is hidden. Once the back button is pressed, the contributions menu appears with the navigation banner visible again.

…ragment instance

Before this commit, there was no easy way to check for and retrieve the ContributionFragment instance that
was either the parent or grandparent (parent's parent) fragment. A complicated if check was required to
retrieve it.

After this commit, there is a simple helper method which will retrieve the ContributionFragment instance.
Existing code can now be replaced by calling this method.
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.
@nicolas-raoul
Copy link
Member

I guess the loop will at least terminate when there is no parent, so I don't worry about infinite loop here.

}

//Hide the Nearby card when looking at media details
ContributionsFragment cf = this.getContributionsFragmentParent();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Java we prefer explicit variable names, even if long. So unless there is a reason I missed, would you mind renaming cf to contributionFragment?

* be found, null is returned.
*/
private ContributionsFragment getContributionsFragmentParent(){
Fragment f = this;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, f to fragment.


//Hide the Nearby card when looking at media details
ContributionsFragment cf = this.getContributionsFragmentParent();
if(cf != null && cf.binding != null){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for nitpicking, but would you mind inserting a space character before if and while, here and below?

@nicolas-raoul
Copy link
Member

Before:

screen-20240928-231429.mp4

After:

screen-20240928-225158.mp4

@nicolas-raoul
Copy link
Member

@rohit9625 If you have time, would you mind seeing whether this PR fixes the issue? As seen in my previous post above, for me both before and after are fast enough haha.

@rohit9625
Copy link
Contributor

@rohit9625 If you have time, would you mind seeing whether this PR fixes the issue? As seen in my previous post above, for me both before and after are fast enough haha.

I'm looking into it :》

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Navigation Banner Appears in Media Details Screen
3 participants