LocalAlertDialogFragment.java 2.7 KB

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