megazear7 / adventure-task

2 stars 0 forks source link

Character Singleton and Data sharing #15

Closed megazear7 closed 9 years ago

megazear7 commented 9 years ago

We cant simply do the following inside each activity:

Character character = new Character();

Because we will end up having many different character objects floating around (probably one per page).

Making the character object a singleton might be useful. But I don't know if that would solve the data sharing issue. That is, if a activity changes there character object (and the internals of the character object saves that data to the json on the disk) the other activities character objects wont be updated (unless they reload the json, which is not the right way to do it).

I think that the character objects need to be shared between activities some how. I don't know the correct way to do this in Android, and it might be possible that every time an activity is started it simply needs to reload that data from json, but I think there is a better, more proper way to do it.