Repository navigation
Conversation
Rotating the device recreates the activity, and the search screen can come back restored (submitted query, results branch) while the search state behind it is back at Empty with no results, so the results branch only shows "No Result Found" and nothing re-runs the search. Re-run the submitted search once when the screen is showing results for a submitted query but the UI state is Empty. A finished search leaves the state at Success (even with zero results) and a new submit goes through Loading first, so this cannot loop or double-fire. Refs maxrave-dev#2711
MainActivity did not handle orientation changes, so rotating recreated the activity; on memory-tight devices the whole app state went with it and only the saved query/flags came back — results and suggestions were lost. Two layers: - AndroidManifest: MainActivity now handles orientation config changes, so rotation no longer recreates the activity and nothing is lost. - SearchScreen safety net: if the screen still comes back restored with a submitted query but an Empty UI state, re-run the submitted search; if it comes back on the suggestions branch, unfocused, with a restored query and no suggestions, re-run the suggestion fetch once. Refs maxrave-dev#2711
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Rotating the device on the search screen lost everything: submitted results were replaced by "No Result Found", and suggestions never came back — only the query text was restored.
MainActivitydid not declareorientationinandroid:configChanges, so every rotation recreated the activity, and the in-memory search state (held bySearchViewModel) went with it on memory-tight devices.Changes:
AndroidManifest.xml:MainActivitynow handlesorientationconfig changes, so rotation no longer recreates the activity — results, suggestions and scroll position stay as they are, with no reload.SearchScreen.kt(safety net): if the screen is still restored with a submitted query but anEmptyUI state, it re-runs the submitted search (same dispatch as pull-to-refresh); if it is restored on the suggestions branch, unfocused, with a restored query and no suggestions, it re-runs the suggestion fetch once. A search that completed — even with zero results — leaves aSuccessstate, so neither net can loop.Linked issue
Closes #2711
Checklist
Tested on Android (Galaxy M32, build from this branch): submit a search and rotate — results stay, no loading, scroll position kept; type without submitting and rotate — suggestions stay; rotated Home, Library and the player screen too, with no regressions.