5

I have seen the following post: Working POST Multipart Request with Volley and without HttpEntity

My problem is how to include a progress bar.

There are solutions around for the progress bar but they all use HttpClient which I want to avoid since it is deprecated.

I just can't work out how to combine the two.

Edit:

I am looking for a progress bar that shows percentage and not just a continuous circle. An example with a bar that I want appears here but is using HTTPClient: How to send a “multipart/form-data” POST in Android with Volley

Community
  • 1
  • 1
theblitz
  • 6,683
  • 16
  • 60
  • 114

1 Answers1

0

It seems simple to me, if I am not misunderstanding the problem. Why don't you just start showing your progress bar (preferably indeterminate one) and when your requests succeeds or fails, your just stop the progress bar.

Something like this :-

myRequest(){ 

     //Start Showing your progress bar here
     showProgressBar();  

     JsonObjectRequest myRequest = 
            new JsonObjectRequest(Request.Method.GET, URL, 
                new Response.Listener<JSONObject>() {
                               @Override 
                                public void onResponse(JSONObject response) {
                                   //Hide progress bar here
                                   hideProgressDialog();   
                                   //TODO: I forgot what to do 
                                 } 
                              }, 
                new Response.ErrorListener() {
                               @Override 
                               public void onErrorResponse(VolleyError error) {
                                  //Hide progress bar here
                                  hideProgressDialog(); 
                                 } 
                              }); 
queue.add(myRequest);
}

I hope this helps :)

Dave Ranjan
  • 2,966
  • 24
  • 55
  • I am looking for a progress bar that shows percentage. My mistake for not making as clear in the question. Updated it. – theblitz Feb 29 '16 at 20:14
  • Looks like volley provides no support for multipart data, instead you can use VolleyPlus :- https://github.com/DWorkS/VolleyPlus It has support for multi-part and also provides a progress listener. https://github.com/DWorkS/VolleyPlus/blob/master/library/src/com/android/volley/request/MultiPartRequest.java – Dave Ranjan Feb 29 '16 at 20:20
  • 1
    Unfortunately, using that is not an option. There is no way my boss would accept me using a branch of something that is in continuous update by Google. Especially since the "branch" is not being updated whilst the Google one is. TBH, I would agree with him in this case. – theblitz Feb 29 '16 at 21:03