Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to maintain progress bar state when using volley?

Tags:

android

It is easy to maintain progress bar state when i use AysncTask with fragments Callback but how should i achieve it with volley? I can;t use AsyncTask because it is outdated and volley is better and faster. Any Help or Hint will be grateful.

I am using google's volley to Post and Get Requests

like image 482
Rahul Gupta Avatar asked Dec 19 '13 16:12

Rahul Gupta


People also ask

Is Android volley deprecated?

volley (lib) is not deprecated. Why would it be? More importantly, if it works, why does it matter? Deprecated doesn't necessarily mean something is bad.

How can I call multiple requests at the same time in volley?

1 Answer. Show activity on this post. To achieve it without using any patterns or other libraries, you can mark the request as finished if it responded, and call the method, in each of them, you want to execute if all the requests are finished. On that method, you just need to check if all the requests are done.

How does volley library work?

Although Volley is a part of the Android Open Source Project(AOSP), Google announced in January 2017 that Volley will move to a standalone library. It manages the processing and caching of network requests and it saves developers valuable time from writing the same network call/cache code again and again.


1 Answers

you can add a listener to the queue which is executed when the request end

            mRequestQueue.add(yourRequest);
            mRequestQueue.addRequestFinishedListener(new RequestQueue.RequestFinishedListener<String>() {
                @Override
                public void onRequestFinished(Request<String> request) {
                    if (progressDialog !=  null && progressDialog.isShowing())
                        progressDialog.dismiss();
                }
            });
like image 95
Jch Pal Avatar answered Oct 09 '22 06:10

Jch Pal