public static void showDialogIf(@Nullable Dialog dialog,boolean show){
  if (dialog != null) {
    if (show) {
      dialog.show();
    }
 else {
      dialog.hide();
    }
  }
}

public static void showDialogIf ( @ Nullable Dialog dialog , boolean show ) { if ( dialog != null ) { if ( show ) { dialog . show ( ) ; } else { dialog . hide ( ) ; } } }
shows or hides a dialog based on a boolean flag .
