12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package com.epson.iprint.storage;
- import android.app.AlertDialog;
- import android.app.Dialog;
- import android.content.DialogInterface;
- import android.os.Bundle;
- import epson.print.R;
- public class OneButtonDialogFragment extends DialogFragment {
- private static final String PARAM_DIALOG_ID = "dialog_id";
- private static final String PARAM_MESSAGE_RESOURCE_ID = "message_id";
- private String mDialogId;
- private int mMessageId;
- public interface DialogCallback {
- void buttonPressed(@Nullable String str);
- }
- public static OneButtonDialogFragment newInstance(int i, String str) {
- OneButtonDialogFragment oneButtonDialogFragment = new OneButtonDialogFragment();
- Bundle bundle = new Bundle();
- bundle.putInt(PARAM_MESSAGE_RESOURCE_ID, i);
- bundle.putSerializable(PARAM_DIALOG_ID, str);
- oneButtonDialogFragment.setArguments(bundle);
- return oneButtonDialogFragment;
- }
- public void onCreate(Bundle bundle) {
- super.onCreate(bundle);
- Bundle arguments = getArguments();
- mMessageId = arguments.getInt(PARAM_MESSAGE_RESOURCE_ID);
- mDialogId = arguments.getString(PARAM_DIALOG_ID);
- setCancelable(false);
- }
- @NonNull
- public Dialog onCreateDialog(Bundle bundle) {
- super.onCreateDialog(bundle);
- return new AlertDialog.Builder(getActivity()).setMessage(mMessageId).setPositiveButton(R.string.str_ok, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialogInterface, int i) {
- FragmentActivity activity = getActivity();
- if (activity != null) {
- ((DialogCallback) activity).buttonPressed (mDialogId);
- }
- }
- }).setCancelable(false).create();
- }
- }
|