Skip to content
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

Fix in-app gallery resetting to the first image on orientation change #440

Merged
merged 1 commit into from
Jul 18, 2024

Conversation

MHShetty
Copy link
Member

Changing the orientation in the in-app gallery currently causes the entire gallery activity to reset

This pull request would help resolve the issue described at #370

@muhomorr
Copy link
Member

Activity is recreated after almost all configuration changes, not just after rotation. Proper solution for this is to use a ViewModel or to save activity state in onSaveInstanceState().

The proposed solution doesn't work in my testing even for orientation changes, not clear why.

@muhomorr
Copy link
Member

muhomorr commented Jul 2, 2024

Special handling of lastCapturedItem should be skipped when lastViewedMediaPosition is not 0, otherwise decoding of item at lastViewedMediaPosition will be delayed until decoding of lastCapturedItem is complete.

@MHShetty
Copy link
Member Author

MHShetty commented Jul 2, 2024

Special handling of lastCapturedItem should be skipped when lastViewedMediaPosition is not 0, otherwise decoding of item at lastViewedMediaPosition will be delayed until decoding of lastCapturedItem is complete.

Yes, loading the first item would be un-necessary in this case. Thanks a lot for reviewing this PR!

@muhomorr
Copy link
Member

muhomorr commented Jul 3, 2024

Item position is not guaranteed to be stable after the item list is re-fetched, missed that initially. A stable item identifier should be saved in onSaveInstanceState, not its position.

@MHShetty
Copy link
Member Author

MHShetty commented Jul 9, 2024

Hi @muhomorr,

I have updated the code to use CapturedItem based comparison to identify the position of the slider over just saving the position to address this issue. Thank you for mentioning this out!

Regards,
Mohit

(on rotation/any config changes)
@thestinger thestinger merged commit 0429a83 into GrapheneOS:main Jul 18, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants