Android - Modify dialog inside DialogFragment

115 views Asked by At

I have made the following class which is a ProgressDialog inside a DialogFragment. The thing is that I want to update the progress of the dialog from other fragment. How can I do so? Thank you

public class MaterialProgressDialogFragment extends DialogFragment {

private int total;
private MaterialDialog myDialog;

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    return myDialog;
}

public void incrementProgress(int by) {
    myDialog.incrementProgress(by);
}

public void setTotal(int total) {
    this.total = total;
}

public void setUp(Context context) {
    myDialog = new MaterialDialog.Builder(context)
            .title("Progreso")
            .content("Procesando las fotos seleccionadas...")
            .progress(false, total, true)
            .build();
}
}

And then in my fragment:

    MaterialProgressDialogFragment dialogFragment = new MaterialProgressDialogFragment();
    dialogFragment.setTotal(100);
    dialogFragment.setUp(getActivity());
    dialogFragment.show(getActivity().getSupportFragmentManager(), "");
    dialogFragment.incrementProgress(50);

Everything works as expected until I call incrementProgress

0

There are 0 answers