123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- package epson.print;
- import android.app.AlertDialog;
- import android.app.Dialog;
- import android.content.DialogInterface;
- import android.os.Bundle;
- import android.view.KeyEvent;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.Button;
- import android.widget.TextView;
- public class CustomLayoutDialogFragment extends DialogFragment {
- private static final String TAG_CLOSE_BUTTON_STRING_ID = "close_button_string_id";
- private static final String TAG_DIALOG_ID = "dialog_id";
- private static final String TAG_MESSAGE = "message";
- private static final String TAG_POSITIVE_BUTTON_STRING_ID = "positive_button_string_id";
- private static final String TAG_TITLE_ID = "title_id";
- private static final String TAG_TITLE_STRING = "title_string";
- public static CustomLayoutDialogFragment newInstance(int i, String str, int i2, int i3, int i4) {
- CustomLayoutDialogFragment customLayoutDialogFragment = new CustomLayoutDialogFragment();
- Bundle bundle = new Bundle();
- bundle.putInt(TAG_DIALOG_ID, i);
- bundle.putString("message", str);
- bundle.putInt(TAG_TITLE_ID, i2);
- bundle.putInt(TAG_POSITIVE_BUTTON_STRING_ID, i3);
- bundle.putInt(TAG_CLOSE_BUTTON_STRING_ID, i4);
- customLayoutDialogFragment.setArguments(bundle);
- return customLayoutDialogFragment;
- }
- public static CustomLayoutDialogFragment newInstance(int i, String str, String str2, int i2, int i3) {
- CustomLayoutDialogFragment customLayoutDialogFragment = new CustomLayoutDialogFragment();
- Bundle bundle = new Bundle();
- bundle.putInt(TAG_DIALOG_ID, i);
- bundle.putString("message", str);
- bundle.putString(TAG_TITLE_STRING, str2);
- bundle.putInt(TAG_POSITIVE_BUTTON_STRING_ID, i2);
- bundle.putInt(TAG_CLOSE_BUTTON_STRING_ID, i3);
- customLayoutDialogFragment.setArguments(bundle);
- return customLayoutDialogFragment;
- }
- public Dialog onCreateDialog(Bundle bundle) {
- Bundle arguments = getArguments();
- final int i = arguments.getInt(TAG_DIALOG_ID);
- String string = arguments.getString("message");
- int i2 = arguments.getInt(TAG_TITLE_ID);
- String string2 = arguments.getString(TAG_TITLE_STRING);
- int i3 = arguments.getInt(TAG_POSITIVE_BUTTON_STRING_ID);
- int i4 = arguments.getInt(TAG_CLOSE_BUTTON_STRING_ID);
- final CustomTitleDialogFragment.Callback callback = (CustomTitleDialogFragment.Callback) getActivity();
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- View inflate = getActivity().getLayoutInflater().inflate(R.layout.dialog_custom_layout01, (ViewGroup) null);
- TextView textView = (TextView) inflate.findViewById(R.id.title_text);
- if (string2 != null) {
- textView.setText(string2);
- } else {
- textView.setText(i2);
- }
- ((TextView) inflate.findViewById(R.id.message_text)).setText(string);
- Button button = (Button) inflate.findViewById(R.id.close_button);
- button.setOnClickListener(new View.OnClickListener() {
- public void onClick(View view) {
- CustomLayoutDialogFragment.this.dismiss();
- callback.onLocalNegativeCallback(i);
- }
- });
- button.setText(i4);
- Button button2 = (Button) inflate.findViewById(R.id.browse_button);
- button2.setOnClickListener(new View.OnClickListener() {
- public void onClick(View view) {
- CustomLayoutDialogFragment.this.dismiss();
- callback.onLocalPositiveCallback(i);
- }
- });
- if (i3 != 0) {
- button2.setText(i3);
- } else {
- button2.setVisibility(View.GONE);
- }
- builder.setView(inflate);
- AlertDialog create = builder.create();
- create.setCanceledOnTouchOutside(false);
- create.setOnKeyListener(new DialogInterface.OnKeyListener() {
- public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
- return keyEvent.getKeyCode() == 84;
- }
- });
- return create;
- }
- }
|