-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Hey,
I found minor problem when marking a Image as favorite. I don't know if you are aware of that and just ignore that issue (I ignore such "issues" most of the time 😄 ). However, the problem is as follows:
- search for an Image in
SearchFragmentpart ofMainActivity - open an image -->
DetailsActivitiycontaining aDetailsFragment(I'm talking about phone layout) starts and displays the image MainActivityget's destroyed in background (i.e. because of low memory) then SearchFragment'sSerachViewStateget's stored into the Bundle, containing the search result.- Mark the image displayed in
DetailsFragmentas favorite - Press the back button -->
MainActivityandSearchFragmentgets recreated. Since SearchFragment's Bundle contains aSearchViewStatethe ViewState will be restored which contains the data from before favoring the Image. That means that the Image gets displayed NOT as favorite while it should be displayed as favorite since it has been marked as favorite by the user.
You can reproduce that issue by enabling "Don't keep Activities" in the developer settings of your device.
I see 4 solutions for that problem:
- Simply ignore that "issue" since it happens rarely and if there is no sensitive data most of the time the user of your app doesn't notice that "issue" anyway.
- Don't use a ViewState at all. I do that if the displayed data is sensitive.
- Use a
RetainingViewState. By doing so the view state will never be stored into the Bundle and data will always be reloaded when activity / fragment gets recreated. But in that brings another problem: when the user is inDetailsActivityand presses the back button then itMainActivitygets recreated and displays the initial state, but the user would expect that the previous search result gets displayed. A workaround would be to save the latest search string into fragments bundle and then rerun the search query. - Rethink the internal "update" mechanism, i.e. use
onActivityResult()to notify theSearchFragmentthat the Image has been marked as favorite.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels