I have a few fragments that I use AsyncTask. To do this, I wrote a class which inherits from AsyncTask.

public class MyAsincTask extends AsyncTask<String, Void, Document> {
    private Document document;
    private final ProgressDialog progressDialog;

    public MyAsincTask(Context context) {
        progressDialog = MyProgress.getProgressDialog(context);
    }

    @Override
    protected void onPreExecute() {
        progressDialog.show();
        super.onPreExecute();
    }

    @Override
    protected Document doInBackground(String... params) {
        try {
            document = Jsoup.connect(params[0]).get();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return document;
    }

    @Override
    protected void onPostExecute(Document document) {
        progressDialog.cancel();
        super.onPostExecute(document);
    }
}

And I needed to call it fragments:

new MyAsincTask(getActivity()){
            @Override
            protected void onPreExecute() {
                super.onPreExecute();
            }

            @Override
            protected void onPostExecute(Document document) {
                super.onPostExecute(document);

                //actions

                }
            }
        }.execute(link);

But I have a fragment that implements android-pulltorefresh-and-loadmore And when triggered uploading new data from the library called her progressBar. We have two progressBar. How do I make when you first load was called my progressBar, and when upload the new data library worked progressBar?

Related posts

Recent Viewed