My application needs to periodically request the server for new data. I have researched regarding this and many suggested to use sync adapter for syncing with the server, however my requirement changed and I need to do the following process. Is it still advisable to use sync adapters or can I use any other library to efficiently make the following Http request sequence.
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {
ZipFile imageZipFile;
/*this is a http post request and the size the zipfile is around 1Mb*/
ZipFile resultFile=makeHttpPostRequest(String URL, String payload);
SomeObject result= processZipFile(resultZipFile);
saveData(result);
for(String url:result.getUrls()){
/* this is a HttpGet request which returns a zip file that
contains 8 images , total size of zip would be around 200kb*/
imageZipFile= makeHttpGetRequest(url);
saveImageZipToDisk(imageZipFile)
}
}
As you can see I am making a Http Post request to get some data that contains the image URL's and use those URL's to make a new HttpGet request. I would need both the result from the POST and also the images for my app to run.
Is this a valid way to use sync adapters or is this totally unacceptable? or Can I use Volley/ Robo spice to spawn the image requests to multiple threads? Sorry I am being novice, but this is a scenario I have been trying to solve.
Update:
So after reviewing the pros and cons of Volley and Robospice, I am using volley as I could customize the code and have more control over the caching mechanism.
All alternatives should be working.
With async adapters, you will get :
With Volley, you will get :
With RoboSpice, you will get :