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

Fixed #1206 - Weather View Visibility #1207

Conversation

amrhossamdev
Copy link
Member

Fixes #1206.

Control the state of the weather view when switching the fragment from the nav drawer

Video

Screencast.from.04-26-2024.04.07.52.PM.webm
  • Apply the AndroidStyle.xml style template to your code in Android Studio.

  • Run the unit tests with gradlew connectedObaGoogleDebugAndroidTest to make sure you didn't break anything

  • If you have multiple commits please combine them into one commit by squashing them for the initial submission of the pull request. When addressing comments on a pull request, please push a new commit per comment when possible (reviewers will squash and merge using GitHub merge tool)

@@ -39,6 +40,16 @@ public static void setWeatherTemp(TextView weatherTempTxtView, double temp) {
weatherTempTxtView.setText(temperatureText);
}

public static void toggleWeatherViewVisibility(boolean shouldShow, View weatherView) {
Copy link
Member

Choose a reason for hiding this comment

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

I recommend always trying to figure out how to reduce the amount of nesting that occurs from control flow within a method. I would recommend writing this method like this:

  • Check whether weatherView is null or not, and return early if it is.
  • DRY up the call to weatherView.setVisibility() by determining visibility with a ternary expression.
public static void toggleWeatherViewVisibility(boolean shouldShow, View weatherView) {
  (if weatherView == null) {
    return;
  }
  
  weatherView.setVisibility(shouldShow ? View.VISIBLE : View.GONE);
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Much better I will refactor it

Copy link
Member

@aaronbrethorst aaronbrethorst left a comment

Choose a reason for hiding this comment

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

👍 looks good! thanks for thinking about this from the user's perspective and getting it fixed!

@aaronbrethorst aaronbrethorst merged commit 83e7457 into OneBusAway:main Apr 26, 2024
2 checks passed
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.

Issue weather view is being visible on starred routes/stops
2 participants