I'm working to an application that makes some webcalls and I want to add a DialogFragment (with a ProgressBar at the center) that shows when I'm waiting for the call to complete.
Webcalls are extended from AsyncTask with a private library that gives an interface (DialogInterface) to set what to do when the dialog it's shown and hidden.
For the DialogFragment I've found some nice code from here:
https://code.luasoftware.com/tutorials/android/android-show-loading-and-prevent-touch/
It works without problems from an Activity class, but the DialogInterface has to be set to the WebService builder which is initialized into the Application class
This is the init sequence in the Application class
WebService.init(
WebServiceBuilder(this)
.setBaseUrlTest("http://google.it/")
.setUrlType(UrlType.TEST)
.setDialogInterface(object : DialogInterface {
override fun showDialog(context: Context?) {
if (context != null)
val busyDialog = BusyDialogFragment.show(supportFragmentManager)
}
override fun hideDialog() {
//code that hide the DialogFragment
}
})
Obviously in the Application class I cannot get the FragmentManager so this code doesn't works.