Skip to content

RT schedule UI improvements...#154

Merged
mmathieum merged 9 commits into
masterfrom
mm/gtfs_rt_trip_updates_2
Mar 17, 2026
Merged

RT schedule UI improvements...#154
mmathieum merged 9 commits into
masterfrom
mm/gtfs_rt_trip_updates_2

Conversation

@mmathieum

@mmathieum mmathieum commented Mar 16, 2026

Copy link
Copy Markdown
Member

@mmathieum mmathieum self-assigned this Mar 16, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily focuses on refining the user experience for real-time schedule displays by enhancing how real-time data is processed and presented. It includes updates to UI text formatting for schedule statuses, a significant refactoring of time change listeners for better maintainability, and improvements to the underlying data merging logic for real-time updates. Additionally, it incorporates minor fixes for clipboard functionality and logging clarity.

Highlights

  • Real-time Schedule UI Enhancements: Improved the display of real-time schedule information, including how 'early' or 'late' statuses are presented and how headings are integrated into time displays.
  • Real-time Data Processing Logic: Refined the logic within the ScheduleViewModel for merging and sorting real-time timestamps with scheduled timestamps, ensuring more accurate and up-to-date schedule displays.
  • Time Change Receiver Refactoring: Refactored the UITimeUtils.TimeChangedReceiver implementation across several UI components (News List, News Details, Schedule) to use a dedicated TimeChangedListener object, improving callback management.
  • Localization Updates for Schedule Status: Updated short localized strings for 'late' and 'early' schedule statuses in both English and French to include explicit '+' and '-' signs for clarity.
  • Minor Fixes and Logging Improvements: Addressed a minor issue with copying Firebase Installation Tokens to the clipboard and enhanced logging for ad initialization processes.
Changelog
  • app-android/src/main/java/org/mtransit/android/ad/GlobalAdManager.kt
    • Added context to ad initialization log message.
  • app-android/src/main/java/org/mtransit/android/data/POIManager.java
    • Reordered conditions in the getStatus method for improved clarity.
  • app-android/src/main/java/org/mtransit/android/data/UISchedule.java
    • Modified the display of early/late departure text to include parentheses.
  • app-android/src/main/java/org/mtransit/android/ui/news/NewsListAdapter.kt
    • Refactored UITimeUtils.TimeChangedReceiver to utilize a TimeChangedListener object.
  • app-android/src/main/java/org/mtransit/android/ui/news/details/NewsDetailsFragment.kt
    • Refactored UITimeUtils.TimeChangedReceiver to utilize a TimeChangedListener object.
  • app-android/src/main/java/org/mtransit/android/ui/pref/main/MainPreferencesFragment.kt
    • Corrected the variable used when copying the Firebase Installation Token to the clipboard.
  • app-android/src/main/java/org/mtransit/android/ui/schedule/ScheduleAdapter.kt
    • Updated the timestamps setter for clarity and consistency.
    • Changed loop from for to forEach for iterating over timestamps.
    • Reordered private constants P1 and P2.
    • Modified how heading is appended to time, removing parentheses and using a space.
  • app-android/src/main/java/org/mtransit/android/ui/schedule/ScheduleFragment.kt
    • Refactored UITimeUtils.TimeChangedReceiver to utilize a TimeChangedListener object and updated its invocation.
  • app-android/src/main/java/org/mtransit/android/ui/schedule/ScheduleViewModel.kt
    • Removed unused imports related to arrival, departure, and updateForRealTime.
    • Updated real-time timestamp processing to remove and re-add real-time timestamps, then sort the list.
  • app-android/src/main/res/values-fr/strings_schedule.xml
    • Updated short strings for 'late' and 'early' to include '+' and '-' signs.
  • app-android/src/main/res/values/strings_schedule.xml
    • Updated short strings for 'late' and 'early' to include '+' and '-' signs.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions

github-actions Bot commented Mar 16, 2026

Copy link
Copy Markdown

Qodana for JVM

It seems all right 👌

No new problems were found according to the checks applied

☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

The pull request refactors how UITimeUtils.TimeChangedReceiver listeners are handled in NewsListAdapter, NewsDetailsFragment, and ScheduleFragment. Instead of using direct lambdas, explicit UITimeUtils.TimeChangedReceiver.TimeChangedListener objects are now created and passed to the receiver. This change ensures that the WeakReference mechanism within the TimeChangedReceiver correctly maintains references to the listeners, preventing premature garbage collection and ensuring time change events are reliably processed. Additionally, the ScheduleViewModel was updated to correctly apply real-time schedule updates by removing the original timestamp and adding the real-time one, then re-sorting the list. Minor changes include adding onInitializationComplete() > to an ad log message, reordering conditions in POIManager.getStatus for readability, adjusting UISchedule to wrap early/late text in parentheses and simplify heading appending, updating the timestamps setter in ScheduleAdapter for clarity, changing for loop to forEach in ScheduleAdapter, and updating string resources for short late/early indicators to include + and - signs.

@mmathieum mmathieum marked this pull request as ready for review March 17, 2026 14:54
@mmathieum

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

The pull request introduces several UI improvements related to schedule display and refactors the handling of time change listeners across various fragments and adapters. A notable change is the revised logic in ScheduleViewModel.kt for applying real-time timestamp updates, which now ensures better accuracy and consistency by replacing old timestamps with new real-time data and re-sorting the list. One comment related to displaying early/late status text when a headsign is unavailable has been updated to reference an existing rule. Overall, these changes enhance the user experience and improve code maintainability.

I am having trouble creating individual review comments. Click here to see my feedback.

app-android/src/main/java/org/mtransit/android/ui/schedule/ScheduleViewModel.kt (231-232)

high

The change in real-time timestamp update logic, where old timestamps are removed and new real-time timestamps are added, followed by sorting, is a significant functional improvement. This ensures that the schedule always reflects the most accurate and up-to-date information, which is critical for a real-time transit application. This change enhances the reliability and correctness of the displayed schedule.

app-android/src/main/java/org/mtransit/android/ui/schedule/ScheduleViewModel.kt (249)

high

Explicitly sorting the scheduleTimestamps after applying real-time updates ensures that the displayed schedule is always in the correct chronological order, which is essential for user experience and data consistency.

app-android/src/main/java/org/mtransit/android/ui/schedule/ScheduleViewModel.kt (239-248)

high

The new approach of converting scheduleTimestamps to a mutable list, then iterating through rtTimestamps to remove existing entries and add new real-time ones, followed by sorting, is a more robust way to handle real-time updates. This ensures data integrity and proper ordering, which is crucial for accurate schedule display.

app-android/src/main/java/org/mtransit/android/ui/schedule/ScheduleAdapter.kt (247)

medium

Replacing the for loop with timestamps.forEach { timestamp -> is a more idiomatic and concise way to iterate over collections in Kotlin, improving code style and readability.

app-android/src/main/java/org/mtransit/android/ui/schedule/ScheduleAdapter.kt (635)

medium

Using EMPTY instead of Constants.EMPTY is consistent with the specific imports added earlier in the file, improving code consistency and reducing verbosity.

app-android/src/main/java/org/mtransit/android/ui/news/NewsListAdapter.kt (101-103)

medium

Removing the onTimeChanged() private function is a clean-up that aligns with the refactoring of the timeChangedReceiver to use a named listener object. This reduces redundant code and improves clarity.

app-android/src/main/java/org/mtransit/android/ui/news/details/NewsDetailsFragment.kt (115-119)

medium

Extracting the lambda into a named timeChangedListener object improves code readability and explicitly manages the WeakReference lifecycle, which is crucial for preventing memory leaks in Android development. This is a good practice for maintainability.

app-android/src/main/java/org/mtransit/android/ui/news/details/NewsDetailsFragment.kt (478-480)

medium

Removing the onTimeChanged() private function is a clean-up that aligns with the refactoring of the timeChangedReceiver to use a named listener object. This reduces redundant code and improves clarity.

app-android/src/main/java/org/mtransit/android/ui/pref/main/MainPreferencesFragment.kt (223-227)

medium

Removing the redundant token variable and directly using the it parameter in the let block makes the code more concise and readable without altering its functionality.

app-android/src/main/java/org/mtransit/android/ui/schedule/ScheduleAdapter.kt (34-35)

medium

Using specific imports for EMPTY and SPACE from org.mtransit.commons.Constants improves code clarity by indicating exactly which constants are being used and reduces the overall scope of the import.

app-android/src/main/java/org/mtransit/android/ui/schedule/ScheduleAdapter.kt (48-49)

medium

Adjusting the class declaration formatting improves code readability and aligns with common Kotlin style guidelines for multi-line declarations.

app-android/src/main/java/org/mtransit/android/ui/schedule/ScheduleAdapter.kt (125-129)

medium

Refactoring the setter for timestamps to use newValue and curly braces for the if statement improves code readability and consistency with modern Kotlin style.

app-android/src/main/java/org/mtransit/android/ad/GlobalAdManager.kt (125)

medium

Adding onInitializationComplete() > to the log message provides more context about where the log is originating from, which can be helpful for debugging and understanding the application flow.

app-android/src/main/java/org/mtransit/android/ui/schedule/ScheduleAdapter.kt (603-604)

medium

Reordering the P1 and P2 constants, while minor, can improve logical grouping if there's an implicit order or relationship between them. This contributes to better code organization.

app-android/src/main/java/org/mtransit/android/ui/news/NewsListAdapter.kt (75-79)

medium

Extracting the lambda into a named timeChangedListener object improves code readability and explicitly manages the WeakReference lifecycle, which is crucial for preventing memory leaks in Android development. This is a good practice for maintainability.

app-android/src/main/java/org/mtransit/android/ui/schedule/ScheduleAdapter.kt (643)

medium

Changing the heading formatting from (P1) + it + (P2) to SPACE + it simplifies the output by removing parentheses and using a single space. This can improve the visual presentation of the heading.

app-android/src/main/java/org/mtransit/android/ui/schedule/ScheduleFragment.kt (117-124)

medium

Extracting the lambda into a named timeChangedListener object improves code readability and explicitly manages the WeakReference lifecycle, which is crucial for preventing memory leaks in Android development. This is a good practice for maintainability.

app-android/src/main/java/org/mtransit/android/ui/schedule/ScheduleFragment.kt (124)

medium

The creation of timeChangedReceiver now correctly uses the timeChangedListener object, ensuring proper WeakReference management and consistent behavior with the refactored listener.

app-android/src/main/java/org/mtransit/android/ui/schedule/ScheduleFragment.kt (283)

medium

Calling timeChangedListener.onTimeChanged() directly instead of the removed onTimeChanged() function ensures consistency with the refactored listener implementation and maintains the intended behavior of forcing an update.

app-android/src/main/java/org/mtransit/android/ui/schedule/ScheduleViewModel.kt (20-23)

medium

Removing unused imports for arrival, departure, and updateForRealTime cleans up the code and indicates that these functions are no longer directly utilized in this file, improving code maintainability.

app-android/src/main/java/org/mtransit/android/data/UISchedule.java (520)

medium

Wrapping the earlyOrLateText with parentheses () when headSignSSB is null provides better visual grouping and clarity for the user, making it easier to distinguish this information. This aligns with the practice of using late/early status text as the primary headsign when a timestamp heading is not available.

References
  1. If a timestamp heading is not available, the late/early status text can be used as the primary headsign.

app-android/src/main/java/org/mtransit/android/data/UISchedule.java (517)

medium

Changing the short parameter to true in getAbsoluteDepartureDiffString ensures a consistent short format for departure differences. This improves the uniformity of the displayed information.

app-android/src/main/java/org/mtransit/android/data/POIManager.java (237-238)

medium

Reordering the conditions to check !this.status.isUseful() before this.lastFindStatusTimestampMs < 0L can slightly improve efficiency if isUseful() is a quick check and lastFindStatusTimestampMs is frequently positive. This prioritizes a potentially faster check, leading to minor performance gains in some scenarios.

app-android/src/main/res/values-fr/strings_schedule.xml (98)

medium

Adding a + sign to the short version of "late" (R:+%dm) improves clarity and consistency in the French translation, making it easier for users to understand the direction of the time difference.

app-android/src/main/res/values-fr/strings_schedule.xml (100)

medium

Adding a - sign to the short version of "early" (A:-%dm) improves clarity and consistency in the French translation, making it easier for users to understand the direction of the time difference.

app-android/src/main/res/values/strings_schedule.xml (92)

medium

Adding a + sign to the short version of "late" (R:+%dm) improves clarity and consistency in the English translation, making it easier for users to understand the direction of the time difference.

app-android/src/main/res/values/strings_schedule.xml (94)

medium

Adding a - sign to the short version of "early" (A:-%dm) improves clarity and consistency in the English translation, making it easier for users to understand the direction of the time difference.

@mmathieum mmathieum merged commit 48c7b60 into master Mar 17, 2026
7 of 8 checks passed
@mmathieum mmathieum deleted the mm/gtfs_rt_trip_updates_2 branch March 17, 2026 18:36
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.

1 participant