I have a photo gallery in my application, not too dissimilar from Facebook photos. I have two basic views:
PhotoGalleryActivity
is an endless list of photos shown chronologically. Tapping into it takes you to a detail view.PhotoDetailView
is basically a view pager of the photos and for each photo, it also shows the user that uploaded it. Clicking on the user, takes you to anotherPhotoGalleryActivity
listing all the photos the user uploaded.
To show the PhotoDetailActivity
, I need to pass the list of photos from the PhotoGalleryActivity
to it. A photo object is basically just a list of URLs and a User Object.
I looked into different possible solutions but none of them fit my bill. Here are the ones I found and why they won't work (please correct me if I am wrong):
Intent: This didn't work because the data can get big (1mb is the limit for passing data through intent). I might need to pass 10,000 photos or 100,000 photos. AND because of this, I can't even save it during orientation changes (am I wrong?).
Singleton + tags: Since the user can keep clicking through to multiple
PhotoGalleryActivity
, I can use tags so that thePhotoDetailActivity
can just grab the list of photos by using the tag thatPhotoGalleryActivity
passes through an Intent. But the problem arises when the application is killed. The singleton loses the data and so I can't reliably do this. (I feel like I might be missing a workaround with this use case).Database: I could save them in a database, but this becomes hard to maintain because let's say the first
PhotoGalleryActivity
shows photos from all users. Then I click on a photo, click on the user that uploaded a photo, and start browsing that users photos. Now when I go back the the the firstPhotoGalleryActivity
, chronologically the last photo in the database is now the last photo of that user, so my data becomes tainted. (I can think of workarounds for this, but it feels like it can get messy very quickly).
I was hoping someone out there has some experience with this and has an idea for a solution.