-
Notifications
You must be signed in to change notification settings - Fork 0
Fix interstitial ads #115
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
Fix interstitial ads #115
Conversation
- Add import for InterstitialAdManager - Create GlobalKey<NavigatorState> for BuildContext access - Pass navigatorKey to App for use by AppBloc and InterstitialAdManager
- Add InterstitialAdManager class to handle interstitial ad lifecycle - Implement logic to preload and show interstitial ads based on user role and app state - Integrate with AdService and AppBloc for ad configuration and user state management - Support for AdMob, local, and demo ad types - Logging for ad manager actions and events
- Removed the entire AdNavigatorObserver class and its related imports - This change simplifies the codebase by eliminating unused广告-related functionality
- Remove AdNavigatorObserver and related ad navigation logic - Integrate InterstitialAdManager for handling interstitial ads - Update App component to use InterstitialAdManager instead of AdNavigatorObserver - Adjust dependencies and routing to support new ad implementation
- Add GlobalKey<NavigatorState> to AppBloc constructor - Implement navigatorKey getter for accessing NavigatorState - Update class fields and constructor parameters to include _navigatorKey
- Remove AdNavigatorObserver import and usage - Add GlobalKey<NavigatorState> navigatorKey parameter - Implement custom GoRouterObserver using navigatorKey - Update router creation to use GoRouterObserver - Remove unnecessary comments and clean up code
- Add InterstitialAdManager import to headlines_feed_page.dart - Implement interstitial ad trigger on headline tap for different image styles - Ensure ad trigger logic is applied consistently across all headline tile types
- Changed appEnvironment from AppEnvironment.demo to AppEnvironment.development in main.dart
- Relocate InterstitialAdManager provider to ensure creation after AppBloc - Remove redundant comments - Adjust dispose method to remove explicit InterstitialAdManager disposal
…ming - Updated InterstitialAdManager to use AppState for theme information - Replaced BuildContext-based theming with ThemeData creation from AppState - Added logic to handle system/theme-mode brightness detection - Removed navigatorKey dependency for ad theming
- Change appEnvironment from AppEnvironment.development to AppEnvironment.demo in main.dart
- Import InterstitialAdManager in saved_headlines_page.dart - Add onPotentialAdTrigger call before navigating to article details - Implement ad trigger for all headline image style cases
- Import InterstitialAdManager in followed_countries_list_page.dart - Add onPotentialAdTrigger call in the onTap event of country list items
- Import InterstitialAdManager in followed_sources_list_page.dart - Add InterstitialAdManager instance call on source item tap
- Import InterstitialAdManager in followed_topics_list_page.dart - Add onPotentialAdTrigger call in the onTap callback of the topic item
- Add InterstitialAdManager import to entity_details_page.dart - Implement interstitial ad trigger on headline tap for different image styles - Ensure ad trigger is called before navigating to article details page
- Add InterstitialAdManager import to headline_details_page.dart - Integrate onPotentialAdTrigger call before navigating to entity details - Implement interstitial ad trigger for similar headline taps
- Add InterstitialAdManager import to headlines_search_page.dart - Implement interstitial ad trigger on headline tap for different image styles - Maintain existing navigation to article details after ad trigger
- Import InterstitialAdManager in country_item_widget.dart - Add FlutterBloc dependency for context access - Implement interstitial ad trigger logic on country item tap
- Import InterstitialAdManager in source_item_widget.dart - Add context read for InterstitialAdManager on tap event - Call onPotentialAdTrigger method when source item is tapped
- Import InterstitialAdManager and Bloc dependencies - Add interstitial ad trigger logic in TopicItemWidget's onTap event
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @fulleni, 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 overhauls the application's interstitial ad display system. It introduces a dedicated manager for ad lifecycle, moving away from a navigation-observer-based approach. This change centralizes ad logic, enables proactive ad pre-loading, and provides more granular control over ad triggers from various UI components, leading to a more efficient and integrated ad experience.
Highlights
- Refactored Interstitial Ad Management: The previous
AdNavigatorObserver
has been replaced by a newInterstitialAdManager
. This centralizes the logic for handling and displaying interstitial ads, making the system more robust and maintainable. - Explicit Ad Triggering: Instead of relying on a navigation observer, UI components now explicitly call
onPotentialAdTrigger
on theInterstitialAdManager
before navigating to detail pages or similar actions. This provides precise control over when ads are considered for display. - Ad Pre-loading and Theme Integration: The new
InterstitialAdManager
proactively pre-loads interstitial ads in the background, aiming to reduce latency and improve user experience. It also enhances theme integration by deriving ad theme styles from theAppState
without needing a directBuildContext
. - Navigator Key Integration: A
GlobalKey<NavigatorState>
is now passed through the application's dependency injection (frombootstrap
toAppBloc
and_AppView
) to allow services like theInterstitialAdManager
to obtain aBuildContext
when needed for showing dialogs or ads.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
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 issue 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
-
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. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refactors the interstitial ad logic by replacing the AdNavigatorObserver
with a more explicit InterstitialAdManager
. This is a positive change towards better control over ad triggers. My review focuses on improving the robustness of the new implementation, particularly around BuildContext
handling, and on reducing code duplication that has been introduced across several UI files.
Status
READY
Description
This pull request overhauls the application's interstitial ad display system. It introduces a dedicated manager for ad lifecycle, moving away from a navigation-observer-based approach. This change centralizes ad logic, enables proactive ad pre-loading, and provides more granular control over ad triggers from various UI components, leading to a more efficient and integrated ad experience.
Type of Change