简体   繁体   中英

How to show loading dialog using DialogFragment in koush/ion

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"

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM