-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Media details lost on device rotation #894
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
Comments
Looking into things a little more: each of the media pager adapter fragments reach back to the @Override
public Media getMediaAtPosition(int i) {
if (contributionsList.getAdapter() == null) {
// not yet ready to return data
return null;
} else {
return Contribution.fromCursor((Cursor) contributionsList.getAdapter().getItem(i));
}
} The problem isn't so much that the adapter is null, it's that we are relying on the adapter to be our source of truth. Android configuration change will drop and recreate the GUI and steps need to be taken to hold data in a location that will persist across configuration changes. Since we have data that is shared between the Google haven't yet released their "architecture components" but they are close - the release notes on 9/21 say
so it might still be early days to adopt them directly, but they do have an excellent write up of the problem of configuration change, and what the role of a view model should be - https://developer.android.com/topic/libraries/architecture/viewmodel.html Also, it doesn't inspire me with confidence when a comment in the if (savedInstanceState != null) {
final int pageNumber = savedInstanceState.getInt("current-page");
// Adapter doesn't seem to be loading immediately.
// Dear God, please forgive us for our sins
view.postDelayed(() -> {
...
}, 100);
} else {
...
} |
I am working to fix this issue. |
@JohnKal great, thanks! :) |
This bug seems solved. |
I happened to be testing the app on a tablet (real hardware) and rotated the screen. I then verified and it also occurs on a phone (emulator) -
This is a bug that is present on current master but not present in the released version in the Google Play Store.
The text was updated successfully, but these errors were encountered: