AltAlertDialogFragment.java 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 AltAlertDialogFragment extends DialogFragment {
  9. private static final String ARG_MESSAGE = "message";
  10. private static final String ARG_MESSAGE_STR = "message_string";
  11. private static final String ARG_TITLE = "title";
  12. public interface DialogCallback {
  13. void onPositiveCallback();
  14. }
  15. public static AltAlertDialogFragment newInstance(String str, String str2) {
  16. AltAlertDialogFragment altAlertDialogFragment = new AltAlertDialogFragment();
  17. Bundle bundle = new Bundle();
  18. if (str != null) {
  19. bundle.putString(ARG_TITLE, str);
  20. }
  21. bundle.putString(ARG_MESSAGE_STR, str2);
  22. altAlertDialogFragment.setArguments(bundle);
  23. return altAlertDialogFragment;
  24. }
  25. public Dialog onCreateDialog(Bundle bundle) {
  26. Bundle arguments = getArguments();
  27. String string = arguments.getString(ARG_TITLE);
  28. AlertDialog create = new AlertDialog.Builder(getActivity()).setMessage(arguments.getString(ARG_MESSAGE_STR)).setCancelable(false).setPositiveButton(R.string.str_btn_close, new DialogInterface.OnClickListener() {
  29. public void onClick(DialogInterface dialogInterface, int i) {
  30. ((DialogCallback) AltAlertDialogFragment.this.getActivity()).onPositiveCallback();
  31. }
  32. }).create();
  33. if (string != null) {
  34. create.setTitle(string);
  35. }
  36. create.setCanceledOnTouchOutside(false);
  37. return create;
  38. }
  39. }