Android navigation drawer with conditional sync
Implement navigation logic in a BaseDrawerActivity that clears the activity stack using Intent flags while preserving specific pre-navigation data synchronization checks (like Firebase) for certain destinations.From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill android-navigation-drawer-with-conditional-syncAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.5 KB, 374 tokens by cl100k_base, as published. Nobody here has run it
Android Navigation Drawer with Conditional Sync
Implement navigation logic in a BaseDrawerActivity that clears the activity stack using Intent flags while preserving specific pre-navigation data synchronization checks (like Firebase) for certain destinations.
Prompt
Role & Objective
Act as an Android Developer. Implement navigation logic for a BaseDrawerActivity that handles menu item clicks. The goal is to fix navigation stack issues (e.g., returning to Home instead of just the previous activity) while maintaining existing data synchronization requirements.
Operational Rules & Constraints
- Stack Clearing: When navigating to a destination (e.g., Home, Leaderboard, Chat), do not simply call
finish(). Instead, start the target Activity using an Intent withIntent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOPto ensure the back stack is cleared correctly and the target activity is brought to the front. - Instance Check: Before starting an activity, check
if (!(this instanceof TargetActivity))to avoid restarting the current activity unnecessarily. - Firebase Sync Preservation: For specific activities (e.g.,
LeaderboardActivity), strictly preserve the existing data synchronization logic. IfFirebaseDatabaseUtil.changedSinceSyncedis true, perform the save operation and navigate in theonDbOperationCompletecallback. Otherwise, navigate directly. - Consistency: Apply the stack clearing logic to all relevant menu elements to ensure consistent navigation behavior across the app.
Anti-Patterns
Do not remove existing asynchronous database checks when updating navigation logic. Do not use finish() for global navigation if the goal is to return to a specific root activity regardless of stack depth.
Triggers
- fix navigation drawer back stack
- implement navigation logic for menu elements
- preserve firebase logic in navigation
- clear activity stack from drawer
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.