I decided to give Volley a try, so presently I have a lot of REST callouts to be done, so I usually create a RequestHandler and a ResponseHandler class which as their names suggest handle requests and responses respectively. I follow this pattern so that I don't write redundant code. I just pass in the dynamic query/url as parameter and using a switch case handle the response to each of the requests. But I am stuck with the below problem :
I have no way of updating my UI thread from where I call the RequestHandler class. What I have tried or already know so far :
- Make the UI elements(Textview, Listview) static and update them after the response comes.
- Pass in a context parameter and update the UI after the response is received.
- Write the request and response as inner classes within the Activity
- Get rid of Volley.
I was wondering, how you guys do it? Is there any pattern better than the Request/Response Handler pattern I follow? Any way of updating the UI thread following the same pattern?
Thanks in advance !