LocalAlertDialogFragment.java 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package epson.print.imgsel;
  2. import android.app.AlertDialog;
  3. import android.app.Dialog;
  4. import android.content.DialogInterface;
  5. import android.os.Bundle;
  6. import epson.print.R;
  7. public class LocalAlertDialogFragment extends DialogFragment {
  8. private static final String KEY_DIALOG_CODE = "dialog_code";
  9. private static final String KEY_MESSAGE = "message";
  10. private static final String KEY_NO_TITLE = "no_title";
  11. private static final String KEY_TITLE = "title";
  12. private int mDialogCode;
  13. public interface DialogCallback {
  14. void onDialogCallback(int i);
  15. }
  16. public static LocalAlertDialogFragment newInstance(String str, int i, int i2) {
  17. LocalAlertDialogFragment localAlertDialogFragment = new LocalAlertDialogFragment();
  18. Bundle bundle = new Bundle();
  19. bundle.putString("message", str);
  20. bundle.putInt(KEY_TITLE, i);
  21. bundle.putInt(KEY_DIALOG_CODE, i2);
  22. localAlertDialogFragment.setArguments(bundle);
  23. return localAlertDialogFragment;
  24. }
  25. public static LocalAlertDialogFragment newInstance(String str, int i) {
  26. LocalAlertDialogFragment localAlertDialogFragment = new LocalAlertDialogFragment();
  27. Bundle bundle = new Bundle();
  28. bundle.putString("message", str);
  29. bundle.putInt(KEY_DIALOG_CODE, i);
  30. bundle.putBoolean(KEY_NO_TITLE, true);
  31. localAlertDialogFragment.setArguments(bundle);
  32. return localAlertDialogFragment;
  33. }
  34. public Dialog onCreateDialog(Bundle bundle) {
  35. Bundle arguments = getArguments();
  36. String string = arguments.getString("message");
  37. if (string == null) {
  38. string = "";
  39. }
  40. int i = arguments.getInt(KEY_TITLE, 0);
  41. boolean z = arguments.getBoolean(KEY_NO_TITLE, false);
  42. this.mDialogCode = arguments.getInt(KEY_DIALOG_CODE);
  43. AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
  44. builder.setMessage(string).setPositiveButton(getActivity().getString(R.string.str_ok), new DialogInterface.OnClickListener() {
  45. public void onClick(DialogInterface dialogInterface, int i) {
  46. LocalAlertDialogFragment.this.execCallback();
  47. }
  48. });
  49. if (!z) {
  50. builder.setTitle(i);
  51. }
  52. AlertDialog create = builder.create();
  53. create.setCanceledOnTouchOutside(false);
  54. return create;
  55. }
  56. /* access modifiers changed from: private */
  57. public void execCallback() {
  58. try {
  59. DialogCallback dialogCallback = (DialogCallback) getActivity();
  60. if (dialogCallback != null) {
  61. dialogCallback.onDialogCallback(this.mDialogCode);
  62. }
  63. } catch (ClassCastException unused) {
  64. }
  65. }
  66. }