-
Notifications
You must be signed in to change notification settings - Fork 0
fix: My -> 내서재 이동 시 백스택 쌓이는 버그 #761
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
Conversation
WalkthroughMyLibraryFragment에서 MainActivity를 시작하던 내서재 이동을 FragmentResult로 바꾸고, MainActivity는 "NAVIGATE_TO_LIBRARY_FRAGMENT" 결과를 수신해 LIBRARY로 전환하도록 리스너를 추가했습니다. MyLibraryFragment의 기존 navigateToLibraryFragment()와 MainActivity import가 제거되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant MLF as MyLibraryFragment
participant FM as FragmentManager
participant MA as MainActivity
participant Tabs as TabController/LIBRARY
MLF->>FM: setFragmentResult("NAVIGATE_TO_LIBRARY_FRAGMENT", Bundle.EMPTY)
Note right of FM: FragmentResult 브로드캐스트
MA->>MA: FragmentResultListener 수신
MA->>Tabs: replaceCurrentFragment(LIBRARY)
Note over MA, Tabs: 탭 전환(백스택 추가 없음)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 1
🧹 Nitpick comments (3)
app/src/main/java/com/into/websoso/ui/main/MainActivity.kt (1)
61-66: 프래그먼트 결과 기반 네비게이션이 올바르게 구현되었습니다.백스택 문제를 해결하기 위해 Activity 시작 대신 Fragment Result API를 사용하는 것은 좋은 접근입니다. 그러나 "NAVIGATE_TO_LIBRARY_FRAGMENT" 문자열을 companion object에 상수로 추출하여 두 파일에서 재사용하는 것을 권장합니다.
다음 diff를 적용하여 매직 스트링을 상수로 추출하세요:
companion object { private const val DESTINATION_KEY = "destination" const val IS_LOGIN_KEY = "isLogin" + const val NAVIGATE_TO_LIBRARY_KEY = "NAVIGATE_TO_LIBRARY_FRAGMENT" fun getIntent(context: Context): Intent =그리고 listener 설정 부분을 업데이트하세요:
supportFragmentManager.setFragmentResultListener( - "NAVIGATE_TO_LIBRARY_FRAGMENT", + NAVIGATE_TO_LIBRARY_KEY, this, ) { _, _ -> handleNavigation(LIBRARY) }app/src/main/java/com/into/websoso/ui/main/myPage/myLibrary/MyLibraryFragment.kt (2)
198-202: 프래그먼트 결과 네비게이션으로의 전환이 올바릅니다.Activity 시작 대신
setFragmentResult를 사용하는 것은 백스택 문제를 해결하는 올바른 접근입니다. 그러나 MainActivity에 정의된 상수를 사용하여 매직 스트링을 제거하는 것을 권장합니다.MainActivity에서 상수를 정의한 후(이전 리뷰 코멘트 참조), 다음과 같이 사용하세요:
binding.clMyLibraryTopBar.setOnClickListener { singleEventHandler.throttleFirst { - requireActivity().supportFragmentManager.setFragmentResult("NAVIGATE_TO_LIBRARY_FRAGMENT", Bundle.EMPTY) + requireActivity().supportFragmentManager.setFragmentResult(MainActivity.NAVIGATE_TO_LIBRARY_KEY, Bundle.EMPTY) } }
204-209: 동일한 네비게이션 로직이 일관되게 적용되었습니다.스토리지 버튼 클릭 핸들러도 프래그먼트 결과 네비게이션을 올바르게 사용합니다. 이전 코멘트와 동일하게 매직 스트링을 상수로 대체하세요.
binding.llMyLibraryStorage.setOnClickListener { singleEventHandler.throttleFirst { - requireActivity().supportFragmentManager.setFragmentResult("NAVIGATE_TO_LIBRARY_FRAGMENT", Bundle.EMPTY) + requireActivity().supportFragmentManager.setFragmentResult(MainActivity.NAVIGATE_TO_LIBRARY_KEY, Bundle.EMPTY) } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
app/src/main/java/com/into/websoso/ui/main/MainActivity.kt(3 hunks)app/src/main/java/com/into/websoso/ui/main/myPage/myLibrary/MyLibraryFragment.kt(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
📌𝘐𝘴𝘴𝘶𝘦𝘴
📎𝘞𝘰𝘳𝘬 𝘋𝘦𝘴𝘤𝘳𝘪𝘱𝘵𝘪𝘰𝘯
💬𝘛𝘰 𝘙𝘦𝘷𝘪𝘦𝘸𝘦𝘳𝘴
Summary by CodeRabbit