AutoSkill 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.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/android-navigation-drawer-with-conditional-sync" ~/.claude/skills/ecnu-icalk-autoskill-android-navigation-drawer-with-conditional-sync && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8_GLM4.7/android-navigation-drawer-with-conditional-sync/SKILL.mdsource content
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
. Instead, start the target Activity using an Intent withfinish()
to ensure the back stack is cleared correctly and the target activity is brought to the front.Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP - Instance Check: Before starting an activity, check
to avoid restarting the current activity unnecessarily.if (!(this instanceof TargetActivity)) - Firebase Sync Preservation: For specific activities (e.g.,
), strictly preserve the existing data synchronization logic. IfLeaderboardActivity
is true, perform the save operation and navigate in theFirebaseDatabaseUtil.changedSinceSynced
callback. Otherwise, navigate directly.onDbOperationComplete - 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