mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-05-02 13:13:10 -04:00
Use ViewModel to prevent hammering storage
When you turn a LoyaltyCard into a bundle, it writes the files to storage as it can't otherwise fit in the limited storage size. This means that, on rotation, you write all images to storage and load them again. Using a ViewModel prevents that storage hit due to holding it in memory (as a ViewModel has a longer lifecycle).
This commit is contained in:
@@ -585,13 +585,13 @@ public class LoyaltyCardViewActivityTest {
|
||||
// A change was made
|
||||
shadowOf(activity).clickMenuItem(android.R.id.home);
|
||||
assertEquals(true, activity.confirmExitDialog.isShowing());
|
||||
assertEquals(true, activity.hasChanged);
|
||||
assertEquals(true, activity.viewModel.getHasChanged());
|
||||
assertEquals(false, activity.isFinishing());
|
||||
|
||||
// Exit after setting hasChanged to false
|
||||
activity.hasChanged = false;
|
||||
activity.viewModel.setHasChanged(false);
|
||||
shadowOf(activity).clickMenuItem(android.R.id.home);
|
||||
assertEquals(false, activity.hasChanged);
|
||||
assertEquals(false, activity.viewModel.getHasChanged());
|
||||
assertEquals(true, activity.isFinishing());
|
||||
}
|
||||
|
||||
@@ -708,13 +708,13 @@ public class LoyaltyCardViewActivityTest {
|
||||
// A change was made
|
||||
shadowOf(activity).clickMenuItem(android.R.id.home);
|
||||
assertEquals(true, activity.confirmExitDialog.isShowing());
|
||||
assertEquals(true, activity.hasChanged);
|
||||
assertEquals(true, activity.viewModel.getHasChanged());
|
||||
assertEquals(false, activity.isFinishing());
|
||||
|
||||
// Exit after setting hasChanged to false
|
||||
activity.hasChanged = false;
|
||||
activity.viewModel.setHasChanged(false);
|
||||
shadowOf(activity).clickMenuItem(android.R.id.home);
|
||||
assertEquals(false, activity.hasChanged);
|
||||
assertEquals(false, activity.viewModel.getHasChanged());
|
||||
assertEquals(true, activity.isFinishing());
|
||||
|
||||
database.close();
|
||||
|
||||
Reference in New Issue
Block a user