1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- package epson.print.screen;
- import android.app.AlertDialog;
- import android.app.Dialog;
- import android.content.Context;
- import android.content.DialogInterface;
- import android.os.Bundle;
- import android.support.annotation.NonNull;
- import android.support.annotation.Nullable;
- public class StringListSelectDialog extends DialogFragment {
- private static final String ARGS_KEY_STRING_LIST = "key-stringList";
- private OnItemSelectedListener mListener;
- private String[] mStringList;
- public interface OnItemSelectedListener {
- void onItemSelected(@NonNull String str);
- }
- @NonNull
- public static StringListSelectDialog newInstance(@NonNull String[] strArr) {
- StringListSelectDialog stringListSelectDialog = new StringListSelectDialog();
- Bundle bundle = new Bundle();
- bundle.putStringArray(ARGS_KEY_STRING_LIST, strArr);
- stringListSelectDialog.setArguments(bundle);
- return stringListSelectDialog;
- }
- @NonNull
- public Dialog onCreateDialog(@Nullable Bundle bundle) {
- Bundle arguments = getArguments();
- if (arguments != null) {
- this.mStringList = arguments.getStringArray(ARGS_KEY_STRING_LIST);
- if (this.mStringList != null) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- builder.setItems(this.mStringList, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialogInterface, int i) {
- StringListSelectDialog.this.itemSelected(i);
- }
- });
- setCancelable(false);
- return builder.create();
- }
- throw new IllegalArgumentException();
- }
- throw new IllegalArgumentException();
- }
- /* access modifiers changed from: private */
- public void itemSelected(int i) {
- OnItemSelectedListener onItemSelectedListener = this.mListener;
- if (onItemSelectedListener != null) {
- onItemSelectedListener.onItemSelected(this.mStringList[i]);
- }
- }
- public void onAttach(Context context) {
- super.onAttach(context);
- try {
- this.mListener = (OnItemSelectedListener) context;
- } catch (ClassCastException unused) {
- throw new ClassCastException(context.toString() + " must implement StringListSelectDialog.OnItemSelectedListener");
- }
- }
- public void onDetach() {
- super.onDetach();
- this.mListener = null;
- }
- }
|