Well, it appears I didn't get it quite right when I made my last change to fix the totaling logic. Apparently, the quiz start num and possibly the quiz end num aren't being persisted either. I may have gotten over-enthusiastic in my zeal to eliminate unneeded persistence.
Let's double-check the symptoms.
Set the quiz start and end to 500 / 600 respectively.
Press the home key.
Re-enter the app, and check the start & end.
Well, that's ok, no problem. What if we kill it with a task killer?
Ok, that works too. Let's see what happens if we run a few questions, and come in and out.
Well, there doesn't seem to be a problem. What if we re-install?
Right - it changes to 0 to 10. I've never nailed down what exactly it's doing when you reinstall. Does it wipe out all your preferred settings?
One way to test this is to go into airplane mode and re-install. Yes, it seems to have preserved that.
This would be a good time to take those two outof appState and use the new SharedPreferencesUtil. But I still don't get why the existing mechanism doesn't pull it from shared preferences. But, I can test it more quickly if I limit the changes to the settings activity. Actually that does a ton of validation. What if I just pop up an alert at the beginning, reading them using the new util? Or just debug it?
Oh, I think I see the problem - I went temporarily insane and did this:
InitUtils.retrieveAppStateFromSharedPreferences(this);
AppState appState = (AppState) this.getApplicationContext();
When it should be this:
AppState appState = (AppState) this.getApplicationContext();
// initialize app state from shared preferences
InitUtils.retrieveAppStateFromSharedPreferences(this);
What is all the more reason to eliminate the duality. This would be worth it. There's less to do now that I've gotten rid of three or four variable in app state that need to be persisted. appState could be completely separate from shared preferences, a dream come true. It would finally get rid of the legacy from when I was first starting Android and kind of get the two concepts tangled.
Ok, maybe I'll tackle that one tomorrow - I'm getting hungry!
No comments:
Post a Comment