I wonder how to manage and build classes in this situation.
AccountManager. - I have account manager class, which manages account, store token, the Method that return new token, the service deals with this class from android settings, etc. -
ApiManager - I have a small class, that extends AsyncTask, takes token and some parameters and does command to server, returns an Responce. Nothing else.
And some class where I need to do ApiManager calls and return Responce (json object) in onPostExecute().
The problem is, where the Responce contains some code (for example code=7) it means that error "token expired" and I should call the Method of AccountManager to get actual token and do last call again.
And in general.. how to do such things - to run a thread and in onResponce() do not interrapt all when an error, but run last call again when some particular error happens?
Aucun commentaire:
Enregistrer un commentaire