I have IntentService which I use for uploading photo files to server sequentially. I have Gallery fragment showing files from upload queue and files already uploaded to server. I get list of already uploaded files using api-call to server. Local files which going to be uploaded just stored in DB.
Once next file is uploaded - IntentService sends event to Gallery fragment. After that I can hide progress-wheel for uploaded file and remove record about that file from DB. This part work well.
For synchronization reasons I want to block all events coming from upload Service (make them wait) while api-request for fetching remote files are in progress.
What I'm worry about - some file can be uploaded at the same time with requesting remote files and I will loose that event. How can I delay delivering events from Service until api-request is finish?