Fix: state loss in SearchActivity and MediaDetailPagerFragment during screen rotation#6605
Fix: state loss in SearchActivity and MediaDetailPagerFragment during screen rotation#6605Kota-Jagadeesh wants to merge 10 commits intocommons-app:mainfrom
Conversation
|
✅ Generated APK variants! |
@RitikaPahwa4444 i've gone througgh the history in #6347 and the implementation in since the and i'm interested in rohit's suggestion to start small with a systematic refactor. i'd love to work on this and would it be a good idea to start by moving the Search state or the Media Detail navigation logic into a |
|
@Kota-Jagadeesh there are several PRs covering memory leaks and seems unrelated to the linked issue. I mentioned about it only because you added that null check. Please avoid that comment as we discussed earlier in your closed PR. Thanks! |
Description (required)
What changes did you make and why?
SearchActivity: added thaonSaveInstanceStateto track the current media position and updatedonCreateto restore the media detail view if a position was previously saved. This replaces the previous temporary fix inonResumewhich forced a back-press on rotation.MediaDetailPagerFragment: Updated the fragment to save and restore its internalViewPagercurrent item index.binding.root.postfor restoration, I ensured the UI is fully laid out before re-opening details, preventing crashes and ensuring the user stays on the same image they were viewing before rotating the device.onBackPressed()call fromonResume()which was an anti-pattern causing the fragment back-stack to increase incorrectly.Tests performed (required)
Tested ProdDebug on Redmi Note 13 Pro with API level 35.
isFeaturedImageandeditableflags are preserved after rotation, keeping menu items consistent.Part of issue #6508