我实施的ProgressDialog将是旋转证明,可以在课外解散,并且应该将内容文本作为参数,但是在分析了样本和文档后,我仍然有旋转问题。什么是最好的模式?我已经尝试将其作为单例实现,以传递内容文本。
public class ProgressDialog extends DialogFragment {
public static void show(FragmentActivity context) {
ProgressDialog dialog = new ProgressDialog();
dialog.show(context.getSupportFragmentManager(), "progress");
}
public static void dismiss(FragmentActivity context) {
DialogFragment progressDialog = (DialogFragment) context.getSupportFragmentManager().findFragmentByTag("progress");
if(context != null && progressDialog!=null) {
progressDialog.dismiss();
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
}
@Override
public void onDestroyView() {
super.onDestroyView();
if(this.getDialog() != null && getRetainInstance()) {
getDialog().setDismissMessage(null);
}
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new MaterialDialog.Builder(getActivity())
.title("title")
.content("content")
.progress(true, 0)
.progressIndeterminateStyle(false)
.cancelable(false)
.show();
}
}