nutritionfactsorg / daily-dozen-android

Keep track of the foods that Dr. Greger recommends in his NYT's best-selling book, How Not to Die with this Android app
https://play.google.com/store/apps/details?id=org.nutritionfacts.dailydozen&hl=en
Other
274 stars 95 forks source link

Calendar Navigation #36

Closed notmypassword closed 7 years ago

notmypassword commented 7 years ago
slavick commented 7 years ago

I have found an issue that needs to be resolved before I will merge this pull request.

When the user selects a date in the calendar, an Intent is created to open MainActivity. This Intent causes a duplicate copy of MainActivity to be created. You can verify this by pressing the back button from the newly created MainActivity and see that you will traverse the back stack until you get to the original MainActivity. This process can be repeated until there are many duplicate copies of MainActivity.

This is an issue because it will increase the memory usage and make OutOfMemory errors much more likely.

I see in your last commit you attempted to use the Bus to change the date. I think this is the correct way to go but won't be as simple as posting a Bus event while FoodHistoryActivity is running. I think FoodHistoryActivity should be created with startActivityForResult and when the user selects a date, the result is set to the selected date and FoodHistoryActivity is finished. From there, the MainActivity will need to check the result and post the Bus event for displaying the date.

Let me know if you have any questions.