How to show loading dialog using DialogFragment in koush/ion

440 views Asked by At

I has written a custom HttpUtil using ion(version 2.1.6) like this: code snippet:

HttpUtil.get(Context ctx, boolean showProgress, String url, Map<String, String> params, Class<T> returnObj).setCallback(new HttpResponseCallback<T>(Context ctx) {
    @Override
    public void onSuccess(T result) {
    }

    @Override
    public void onFail(Exception e, T result) {
    }
});

HttpResponseCallback is my custom response callback. When using it, should implement onSuccess() & onFail method.

When HttpUtil.get() is called, I want to show a loading dialog automatically and when the request is finished, the dialog also should be closed automatically.

(I mean when using HttpUtil.get(), user do not need to open dialog and close dialog manually.)

I went thought koush/ion, it had progressDialog() method, but I didn't found any method which using DialogFragment().

How do I implement this?

PS: I'm using v4 support library.

The package of DialogFragment is "android.support.v4.app.DialogFragment"

1

There are 1 answers

0
Ujjval Shrimali On

can you see this link that is helpful for you

you can also use ProgressDialog into that method onSuccess and onFail...

       progressDialogLoading = ProgressDialog.show(this, "","", true);
                progressDialogLoading.show();
                progressDialogLoading.setCancelable(true);