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.md
source 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

  1. 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 with
    Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP
    to ensure the back stack is cleared correctly and the target activity is brought to the front.
  2. Instance Check: Before starting an activity, check
    if (!(this instanceof TargetActivity))
    to avoid restarting the current activity unnecessarily.
  3. Firebase Sync Preservation: For specific activities (e.g.,
    LeaderboardActivity
    ), strictly preserve the existing data synchronization logic. If
    FirebaseDatabaseUtil.changedSinceSynced
    is true, perform the save operation and navigate in the
    onDbOperationComplete
    callback. Otherwise, navigate directly.
  4. 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