// Path: app/src/main/java/org/librepilot/lp2go/uavtalk/UAVTalkMissingObjectException.java
// public class UAVTalkMissingObjectException extends Exception {
//     private int mInstance;
//     private boolean mIsSettings;
//     private String mObjectName;
// 
//     public int getInstance() {
//         return mInstance;
//     }
// 
//     public void setInstance(int instance) {
//         this.mInstance = instance;
//     }
// 
//     public String getObjectname() {
//         return mObjectName;
//     }
// 
//     public void setObjectname(String objectname) {
//         this.mObjectName = objectname;
//     }
// 
//     public boolean isSettings() {
//         return mIsSettings;
//     }
// 
//     public void setIsSettings(boolean isSettings) {
//         this.mIsSettings = isSettings;
//     }
// }
// 
// Path: app/src/main/java/org/librepilot/lp2go/ui/SingleToast.java
// public class SingleToast {
// 
//     private static Toast mToast;
// 
//     public static void show(Context context, String text, int duration) {
//         VisualLog.i("Toast", text);
//         if (mToast != null) {
//             mToast.cancel();
//         }
//         try {
//             mToast = Toast.makeText(context, text, duration);
//         } catch (RuntimeException e) {
//             VisualLog.e("SINGLETOAST", e.getMessage(), e);
//         }
//         mToast.show();
//     }
// 
//     public static void show(Context context, int text, int duration) {
//         VisualLog.i("Toast", context.getString(text));
//         if (mToast != null) {
//             mToast.cancel();
//         }
//         mToast = Toast.makeText(context, text, duration);
//         mToast.show();
//     }
// 
//     public static void show(Context context, String text) {
//         show(context, text, Toast.LENGTH_LONG);
//     }
// }


import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.widget.Toast;
import org.librepilot.lp2go.R;
import org.librepilot.lp2go.uavtalk.UAVTalkMissingObjectException;
import org.librepilot.lp2go.ui.SingleToast;

        if (mFcDevice == null) {
            SingleToast.show(getContext(), getContext().getString(R.string.NOT_CONNECTED),
                    Toast.LENGTH_SHORT);
            return;
        }

        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getContext());
        dialogBuilder.setTitle(mTitle);

        String[] types;
        try {
            types = mFcDevice.getObjectTree().getXmlObjects().get(mObject).getFields()
                    .get(mField).getOptions();
        } catch (NullPointerException e) {
            types = null;
        }


        int current = 0;
        try {
            String type =
                    mFcDevice.getObjectTree().getData(mObject, 0, mField, mElement).toString();
            if (type != null && types != null) {
                for (String t : types) {
                    if (t.equals(type)) {
                        break;
                    }
                    current++;
                }
            }

// Path: app/src/main/java/org/librepilot/lp2go/uavtalk/UAVTalkMissingObjectException.java
// public class UAVTalkMissingObjectException extends Exception {
//     private int mInstance;
//     private boolean mIsSettings;
//     private String mObjectName;
// 
//     public int getInstance() {
//         return mInstance;
//     }
// 
//     public void setInstance(int instance) {
//         this.mInstance = instance;
//     }
// 
//     public String getObjectname() {
//         return mObjectName;
//     }
// 
//     public void setObjectname(String objectname) {
//         this.mObjectName = objectname;
//     }
// 
//     public boolean isSettings() {
//         return mIsSettings;
//     }
// 
//     public void setIsSettings(boolean isSettings) {
//         this.mIsSettings = isSettings;
//     }
// }
// 
// Path: app/src/main/java/org/librepilot/lp2go/ui/SingleToast.java
// public class SingleToast {
// 
//     private static Toast mToast;
// 
//     public static void show(Context context, String text, int duration) {
//         VisualLog.i("Toast", text);
//         if (mToast != null) {
//             mToast.cancel();
//         }
//         try {
//             mToast = Toast.makeText(context, text, duration);
//         } catch (RuntimeException e) {
//             VisualLog.e("SINGLETOAST", e.getMessage(), e);
//         }
//         mToast.show();
//     }
// 
//     public static void show(Context context, int text, int duration) {
//         VisualLog.i("Toast", context.getString(text));
//         if (mToast != null) {
//             mToast.cancel();
//         }
//         mToast = Toast.makeText(context, text, duration);
//         mToast.show();
//     }
// 
//     public static void show(Context context, String text) {
//         show(context, text, Toast.LENGTH_LONG);
//     }
// }


// Path: app/src/main/java/org/librepilot/lp2go/ui/alertdialog/EnumInputAlertDialog.java
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.widget.Toast;
import org.librepilot.lp2go.R;
import org.librepilot.lp2go.uavtalk.UAVTalkMissingObjectException;
import org.librepilot.lp2go.ui.SingleToast;

        if (mFcDevice == null) {
            SingleToast.show(getContext(), getContext().getString(R.string.NOT_CONNECTED),
                    Toast.LENGTH_SHORT);
            return;
        }

        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getContext());
        dialogBuilder.setTitle(mTitle);

        String[] types;
        try {
            types = mFcDevice.getObjectTree().getXmlObjects().get(mObject).getFields()
                    .get(mField).getOptions();
        } catch (NullPointerException e) {
            types = null;
        }


        int current = 0;
        try {
            String type =
                    mFcDevice.getObjectTree().getData(mObject, 0, mField, mElement).toString();
            if (type != null && types != null) {
                for (String t : types) {
                    if (t.equals(type)) {
                        break;
                    }
                    current++;
                }
            }

        } catch (UAVTalkMissingObjectException | NumberFormatException | NullPointerException ignored) {
