Skip to content

[REFACTOR] Navigation Structure/Logic Improvement#99

Merged
doyoonkim3312 merged 5 commits into
developmentfrom
REFACTOR/1.7.1/navigation-structure-improvement
Mar 30, 2026
Merged

[REFACTOR] Navigation Structure/Logic Improvement#99
doyoonkim3312 merged 5 commits into
developmentfrom
REFACTOR/1.7.1/navigation-structure-improvement

Conversation

@doyoonkim3312

@doyoonkim3312 doyoonkim3312 commented Mar 30, 2026

Copy link
Copy Markdown
Member

πŸ“ Summary (κ°œμš”)

  • Navigation Structure has been refactored to eliminate potential risk of OurOfMemory exception and achieve improved resource management.

πŸ”— Related Issue (κ΄€λ ¨ 이슈)

  • Resolves (if applicable) #
  • Jira Ticket: KAN-112

πŸ›  Type of Change (λ³€κ²½ 사항)

  • FEAT: New feature (μƒˆλ‘œμš΄ κΈ°λŠ₯)
  • FIX: Bug fix (버그 μˆ˜μ •)
  • REFACTOR: Code refactoring (no functional change) (μ½”λ“œ λ¦¬νŒ©ν† λ§)
  • DESIGN: UI/UX changes (λ””μžμΈ λ³€κ²½)
  • !HOTFIX: Critical fix (치λͺ…적인 버그 μˆ˜μ •)
  • CHORE: Build/Config/CI (λΉŒλ“œ/μ„€μ •/CI)

✨ Key Changes (핡심 λ³€κ²½ 사항)

  • Single Monolithic Navigation graph has been separated into independent/encapsulated nav graph based on 1:1 match with usecase and bottom navigation bar tab destination.
  • Nested NavGraph structure has been implemented.
  • Correct navigation configuration has been applied (allow already instantiated instance can be reused.), by enabling saveState/restoreState and launchSingleTop options.
  • Custom-defined BottomBarState object to achieve chronological back-action handling throughout the navigation.
  • Custom-defined OnForegroudFocusEffect to achieve robust management of Lifecycle Event-bind event triggering, respecting both Composition Lifecycle and Application/Activity Lifecycle.

πŸ§ͺ Test Plan (ν…ŒμŠ€νŠΈ κ³„νš)

  • Device: Android Emulator (Google Pixel 9 Pro, SDK 36)
  • Scenario: Launch application -> switch tabs using BottomNavBar -> Navigate Back using Back Action (gesture/button) -> Check the chronological back-navigation is correctly performed.
  • Scenario: Launch Application -> switch tabs using BottomNavBar -> Check lifecycle-bind event is correctly triggered.

πŸ“ˆ Quantitative Analysis (μ •λŸ‰λΆ„μ„)

Method

  • Tools: Android Emulator (Google Pixel 9 Pro, SDK 36), Android Studio Profiler
  • Test Scenario: Launch Legacy/Enhance Build -> Switch Screen between HomeDashboard and NoticeByMajor using BottomNavBar, 10 times
  • Data Collection: 1. Analyze Memory Usage (Instance Creation), 2. Track Memory Consumption (JVM Object Allocations)

Result

Metric Legacy Architecture Enhanced Architecture Net Improvement
HomeViewModel Active Instances 5 1 80% Reduction
NoticeByMajorViewModel Active Instances 4 1 75% Reduction
Total JVM Allocations 1,070,350 817,700 23.6% Reduction (252,650 objects)
Data Fetch per Focus Regain 2 (Race Condition) 1 (Deterministic) 100% Redundancy Elimination

βœ… Checklist (체크리슀트)

  • My code follows the style guidelines of this project (μ½”λ“œ μŠ€νƒ€μΌμ„ μ€€μˆ˜ν–ˆμŠ΅λ‹ˆλ‹€).
  • I have performed a self-review of my own code (슀슀둜 μ½”λ“œλ₯Ό κ²€ν† ν–ˆμŠ΅λ‹ˆλ‹€).
  • I have commented my code, particularly in hard-to-understand areas (μ΄ν•΄ν•˜κΈ° μ–΄λ €μš΄ 뢀뢄에 주석을 μž‘μ„±ν–ˆμŠ΅λ‹ˆλ‹€).

  * Improve navigation structure/logic for the navigation via BottomNavBar.

    - Apply Nested-Navigation graph for increased scalability, encapsulation of related screens, and better BackStackEntry Management.
    - For the robust navigation handling for destinations accessed via BottomNavBar, Each BottomNavBar triggers the navigation to the corresponding NavGraph, with appropriate nav configuration (Save states for related instances, and restore it on later visit; Prevent multiple instantiation of same object per every screen visit)
    - Implement Custom-defined BottomNavigationState composable to perform chronological back-button action handling.
    - Refactor category-specific NavDestination into one, generalized NavDestination that accepts the category as a parameter.
  * Improve navigation structure/logic for the navigation via BottomNavBar.

    - Modify Lifecycle-bind event triggering logic to respect both Composition Lifecycle and Activity Lifecycle.
    - Define Custom OnForegroundFocusEffect to seamlessly respond to both Composition and Activity Lifecycle.
      (Instant event triggering on Screen becomes initially visible (Composition Lifecycle), LifecycleObserver to trigger event based on Application/Activity Lifecycle.
  * Improve navigation structure/logic for the navigation via BottomNavBar.

    - Remove unused import directives
  - Completion of 1.7.1 Epic. Build configuration has been updated.
    * Version Code: 38
    * Version Name: 1.7.1 RC 1
@doyoonkim3312 doyoonkim3312 requested a review from jeongHunE March 30, 2026 04:57
@doyoonkim3312 doyoonkim3312 self-assigned this Mar 30, 2026
@doyoonkim3312 doyoonkim3312 added the Improvement Structural or Functional Improvement label Mar 30, 2026

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

Copy link
Copy Markdown

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 navigation architecture by introducing nested navigation graphs and a custom BottomNavigationState to manage tab history and back-stack synchronization. It also implements an OnForegroundFocusEffect utility to handle lifecycle-aware UI events across several feature screens, including Home, Bookmark, and Major Notices. Review feedback highlights a potential state inconsistency in the preference navigation logic and suggests refactoring duplicated navigation code for better maintainability.

Comment thread app/src/main/java/com/doyoonkim/knutice/navigation/AppNavHost.kt
…ed NavGraph to perform navigation

  - Replace navigation via direct navController access to dedicated navigation function performs navigation via BottomNavState to ensure SSOT
  - Implement separate NavRoute resolver to resolve corresponding NavDestination for NoticeDetail and BookmarkDetail/Edit.
@doyoonkim3312

Copy link
Copy Markdown
Member Author

/gemini summary

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

This pull request refactors the application's navigation architecture to mitigate memory risks and improve resource efficiency. By transitioning to a nested navigation graph structure and implementing custom state management for the bottom navigation bar, the changes ensure more deterministic behavior and reduced object allocations. Additionally, new lifecycle-aware effects were introduced to standardize how data is refreshed when screens regain focus.

Highlights

  • Navigation Refactoring: The monolithic navigation graph has been decomposed into independent, encapsulated graphs mapped 1:1 to use cases and bottom navigation tabs, implementing a nested navigation structure.
  • State Management: Introduced a custom BottomBarState object to manage chronological back-action handling and enabled saveState/restoreState with launchSingleTop for efficient resource management.
  • Lifecycle Management: Implemented a custom OnForegroundFocusEffect to ensure robust lifecycle-bound event triggering that respects both Composition and Activity lifecycles.
Activity
  • Initial PR creation by doyoonkim3312.
  • Gemini Code Assist provided feedback on navigation state synchronization and code duplication.
  • Author resolved review comments by implementing a centralized navigation helper and updating the preference service graph.
  • Author requested a summary via /gemini command.

@doyoonkim3312 doyoonkim3312 merged commit cb51c09 into development Mar 30, 2026
1 check passed
@doyoonkim3312 doyoonkim3312 deleted the REFACTOR/1.7.1/navigation-structure-improvement branch March 30, 2026 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Improvement Structural or Functional Improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants