Mew v1.1.3版本的 MD5 值为:2c97fc89b634adccdf2e096067417e16

以下内容为反编译后的 VentanaFlotante.java 源代码,内容仅作参考


package cl.datacomputer.alejandrob.newgpsjoysticl;

import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.hardware.GeomagneticField;
import android.location.ILocationManager;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.UrlQuerySanitizer;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.SystemClock;
import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.support.v4.app.NotificationCompat;
import android.support.v4.view.ViewCompat;
import android.support.v7.app.AlertDialog;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.ActionMode;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.webkit.WebView;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.SimpleAdapter;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.Toast;
import cl.datacomputer.alejandrob.newgpsjoysticl.modules.Distance;
import cl.datacomputer.alejandrob.newgpsjoysticl.modules.Duration;
import cl.datacomputer.alejandrob.newgpsjoysticl.modules.Route;
import cl.datacomputer.alejandrob.newgpsjoysticl.sqlite.data.PokestopsContract;
import com.google.android.gms.maps.model.LatLng;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.firebase.auth.FirebaseUser;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import cz.msebera.android.httpclient.Header;
import cz.msebera.android.httpclient.HttpHeaders;
import cz.msebera.android.httpclient.protocol.HTTP;
import java.io.DataOutputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class VentanaFlotante extends Service {
    public static final String Configuracion = "config";
    private static final String[] MOCK_PROVIDER = {LocationManager.GPS_PROVIDER, LocationManager.NETWORK_PROVIDER, LocationManager.PASSIVE_PROVIDER};
    static final int myID = 66543;
    Button Drag;
    private LatLng endPos;
    GeomagneticField geoField;
    Handler handler;
    ImageView image_border;
    ImageView image_joystick;
    private Intent intentService;
    private boolean isLongPress;
    Button itinerary;
    JoyStickClass js;
    private Bundle k;
    private Method l;
    long lastDown;
    long lastDuration;
    private float latDelta;
    RelativeLayout layout_joystick;
    LinearLayout ll;
    LinearLayout ll2;
    private float lngDelta;
    LocationManager locationManager;
    private ILocationManager m;
    SharedPreferences mapStatePrefs;
    private double mxSec;
    SharedPreferences pref;
    SharedPreferences sharedpreferences;
    Button sniper;
    Button speed;
    private LatLng startPos;
    Button stop;
    private boolean stopButton;
    private Location test;
    TextView texto1;
    private long then;
    private FirebaseUser user;
    private View view;
    WindowManager wm;
    WindowManager wm2;
    private int j = new Random().nextInt(10) + 1;
    private boolean newMethodSwitch = false;
    Method method = null;
    double metroLat = 2.4882415E-6d;
    double metroLng = 2.9907028E-6d;
    private String[] array = null;
    private double speedKM = 10.0d;
    private int MOCK_UPDATE_TIMER = 500;
    private boolean agps = false;
    Context context = this;
    private ArrayList<Ubicacion> resultsLocations = new ArrayList<>();
    private ArrayList<Ubicacion> results = new ArrayList<>();
    private ArrayList<Itinerario> resultsItinerarios = new ArrayList<>();
    private boolean fromWalkTo = false;
    private boolean yes = true;
    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            VentanaFlotante.this.nuevoMetodo();
            super.handleMessage(msg);
        }
    };
    public Handler _handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            VentanaFlotante.this.setLocation();
            if (VentanaFlotante.this.joy) {
                VentanaFlotante.this.texto1.setText("Lat: " + ((float) VentanaFlotante.this.latitude) + ", Lng: " + ((float) VentanaFlotante.this.longitude));
            }
            if (VentanaFlotante.this.agps) {
                Bundle extras = new Bundle();
                extras.putBoolean("all", true);
                try {
                    VentanaFlotante.this.locationManager.sendExtraCommand(LocationManager.GPS_PROVIDER, "delete_aiding_data", extras);
                    VentanaFlotante.this.locationManager.sendExtraCommand(LocationManager.PASSIVE_PROVIDER, "delete_aiding_data", extras);
                    VentanaFlotante.this.locationManager.sendExtraCommand(LocationManager.NETWORK_PROVIDER, "delete_aiding_data", extras);
                } catch (Exception e) {
                }
            }
            super.handleMessage(msg);
        }
    };
    public WindowManager.LayoutParams parameters = new WindowManager.LayoutParams(-2, -2, 2003, 8, -3);
    public WindowManager.LayoutParams parameters2 = new WindowManager.LayoutParams(-2, -2, 2003, 8, -3);
    private double escala = 1.0d;
    private boolean joy = false;
    private double velocidad = 10.0d;
    private int longMinTime = 100;
    private int minDistance = 5;
    private int sleepUpdates = 500;
    private float curBearing = 0.0f;
    private float MperSec = 10.0f;
    private float DEFAULT_ACCURACY = 1.0f;
    private double cantidadPasos = 0.0d;
    private double distancia = 0.0d;
    private double curLat = 0.0d;
    private double curLng = 0.0d;
    private boolean isAutoWalk = true;
    private boolean oneTime = true;
    private boolean pause = false;
    StringBuilder builder = new StringBuilder();
    String accion = "";
    boolean botonPresionado = false;
    private double latitude = 0.0d;
    private double longitude = 0.0d;
    private int limite = 0;
    private boolean locationUpdates = false;
    private boolean stoppedByButton = false;
    private boolean unaVez = true;
    private boolean speedChanged = false;
    Runnable action = new Runnable() {
        @Override
        public void run() {
            if (VentanaFlotante.this.isLongPress) {
                Vibrator vibrator = (Vibrator) VentanaFlotante.this.getSystemService("vibrator");
                vibrator.vibrate(100L);
                SharedPreferences.Editor edit = VentanaFlotante.this.sharedpreferences.edit();
                edit.putString("latHome", String.valueOf(VentanaFlotante.this.test.getLatitude()));
                edit.putString("longHome", String.valueOf(VentanaFlotante.this.test.getLongitude()));
                edit.commit();
                VentanaFlotante.this.crearToast();
            }
        }
    };
    private int longClickDuration = 3000;
    Thread autoWalk = new Thread() {
        @Override
        public void run() {
            int seconds;
            int autoWalkSize = Integer.parseInt(VentanaFlotante.this.pref.getString("autoWalkSize", "6"));
            while (true) {
                if (VentanaFlotante.this.isAutoWalk) {
                    if (autoWalkSize == 0) {
                        seconds = 6000;
                    } else {
                        seconds = autoWalkSize * 1000;
                    }
                    try {
                        if (!VentanaFlotante.this.isAutoWalk) {
                            seconds = 0;
                        }
                        VentanaFlotante.this.lastDown = System.currentTimeMillis();
                        if (VentanaFlotante.this.isAutoWalk) {
                            VentanaFlotante.this.accion = "right";
                            Thread.sleep(seconds);
                        }
                        if (VentanaFlotante.this.isAutoWalk) {
                            VentanaFlotante.this.accion = "downright";
                            Thread.sleep(seconds);
                        }
                        if (VentanaFlotante.this.isAutoWalk) {
                            VentanaFlotante.this.accion = "down";
                            Thread.sleep(seconds);
                        }
                        if (VentanaFlotante.this.isAutoWalk) {
                            VentanaFlotante.this.accion = "downleft";
                            Thread.sleep(seconds);
                        }
                        if (VentanaFlotante.this.isAutoWalk) {
                            VentanaFlotante.this.accion = "left";
                            Thread.sleep(seconds);
                        }
                        if (VentanaFlotante.this.isAutoWalk) {
                            VentanaFlotante.this.accion = "upleft";
                            Thread.sleep(seconds);
                        }
                        if (VentanaFlotante.this.isAutoWalk) {
                            VentanaFlotante.this.accion = "up";
                            Thread.sleep(seconds);
                        }
                        if (VentanaFlotante.this.isAutoWalk) {
                            VentanaFlotante.this.accion = "upright";
                            Thread.sleep(seconds);
                        }
                    } catch (Exception e) {
                    }
                }
            }
        }
    };
    Thread unSegundo = new Thread() {
        @Override
        public void run() {
            while (true) {
                super.run();
                String str = VentanaFlotante.this.accion;
                char c = 65535;
                switch (str.hashCode()) {
                    case -838604510:
                        if (str.equals("upleft")) {
                            c = 4;
                        }
                        switch (c) {
                            case 0:
                                VentanaFlotante.this.latitude -= VentanaFlotante.this.metroLat * VentanaFlotante.this.velocidad;
                                try {
                                    VentanaFlotante.this.runOnUiThread(new Runnable() {
                                        @Override
                                        public void run() {
                                            if (VentanaFlotante.this.joy) {
                                                VentanaFlotante.this.texto1.setText("Lat: " + ((float) VentanaFlotante.this.latitude) + ", Lng: " + ((float) VentanaFlotante.this.longitude));
                                            }
                                        }
                                    });
                                    sleep(1000L);
                                } catch (InterruptedException e) {
                                    e.printStackTrace();
                                }
                            case 1:
                                VentanaFlotante.this.latitude += VentanaFlotante.this.metroLat * VentanaFlotante.this.velocidad;
                                VentanaFlotante.this.runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        if (VentanaFlotante.this.joy) {
                                            VentanaFlotante.this.texto1.setText("Lat: " + ((float) VentanaFlotante.this.latitude) + ", Lng: " + ((float) VentanaFlotante.this.longitude));
                                        }
                                    }
                                });
                                sleep(1000L);
                            case 2:
                                VentanaFlotante.this.longitude -= VentanaFlotante.this.metroLng * VentanaFlotante.this.velocidad;
                                VentanaFlotante.this.runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        if (VentanaFlotante.this.joy) {
                                            VentanaFlotante.this.texto1.setText("Lat: " + ((float) VentanaFlotante.this.latitude) + ", Lng: " + ((float) VentanaFlotante.this.longitude));
                                        }
                                    }
                                });
                                sleep(1000L);
                            case 3:
                                VentanaFlotante.this.longitude += VentanaFlotante.this.metroLng * VentanaFlotante.this.velocidad;
                                VentanaFlotante.this.runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        if (VentanaFlotante.this.joy) {
                                            VentanaFlotante.this.texto1.setText("Lat: " + ((float) VentanaFlotante.this.latitude) + ", Lng: " + ((float) VentanaFlotante.this.longitude));
                                        }
                                    }
                                });
                                sleep(1000L);
                            case 4:
                                VentanaFlotante.this.latitude += VentanaFlotante.this.metroLat * VentanaFlotante.this.velocidad;
                                VentanaFlotante.this.longitude -= VentanaFlotante.this.metroLng * VentanaFlotante.this.velocidad;
                                VentanaFlotante.this.runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        if (VentanaFlotante.this.joy) {
                                            VentanaFlotante.this.texto1.setText("Lat: " + ((float) VentanaFlotante.this.latitude) + ", Lng: " + ((float) VentanaFlotante.this.longitude));
                                        }
                                    }
                                });
                                sleep(1000L);
                            case 5:
                                VentanaFlotante.this.latitude += VentanaFlotante.this.metroLat * VentanaFlotante.this.velocidad;
                                VentanaFlotante.this.longitude += VentanaFlotante.this.metroLng * VentanaFlotante.this.velocidad;
                                VentanaFlotante.this.runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        if (VentanaFlotante.this.joy) {
                                            VentanaFlotante.this.texto1.setText("Lat: " + ((float) VentanaFlotante.this.latitude) + ", Lng: " + ((float) VentanaFlotante.this.longitude));
                                        }
                                    }
                                });
                                sleep(1000L);
                            case 6:
                                VentanaFlotante.this.latitude -= VentanaFlotante.this.metroLat * VentanaFlotante.this.velocidad;
                                VentanaFlotante.this.longitude -= VentanaFlotante.this.metroLng * VentanaFlotante.this.velocidad;
                                VentanaFlotante.this.runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        if (VentanaFlotante.this.joy) {
                                            VentanaFlotante.this.texto1.setText("Lat: " + ((float) VentanaFlotante.this.latitude) + ", Lng: " + ((float) VentanaFlotante.this.longitude));
                                        }
                                    }
                                });
                                sleep(1000L);
                            case 7:
                                VentanaFlotante.this.latitude -= VentanaFlotante.this.metroLat * VentanaFlotante.this.velocidad;
                                VentanaFlotante.this.longitude += VentanaFlotante.this.metroLng * VentanaFlotante.this.velocidad;
                                VentanaFlotante.this.runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        if (VentanaFlotante.this.joy) {
                                            VentanaFlotante.this.texto1.setText("Lat: " + ((float) VentanaFlotante.this.latitude) + ", Lng: " + ((float) VentanaFlotante.this.longitude));
                                        }
                                    }
                                });
                                sleep(1000L);
                            default:
                                VentanaFlotante.this.runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        if (VentanaFlotante.this.joy) {
                                            VentanaFlotante.this.texto1.setText("Lat: " + ((float) VentanaFlotante.this.latitude) + ", Lng: " + ((float) VentanaFlotante.this.longitude));
                                        }
                                    }
                                });
                                sleep(1000L);
                        }
                    case -221275039:
                        if (str.equals("upright")) {
                            c = 5;
                        }
                        switch (c) {
                        }
                    case 3739:
                        if (str.equals("up")) {
                            c = 1;
                        }
                        switch (c) {
                        }
                    case 3089570:
                        if (str.equals("down")) {
                            c = 0;
                        }
                        switch (c) {
                        }
                    case 3317767:
                        if (str.equals("left")) {
                            c = 2;
                        }
                        switch (c) {
                        }
                    case 108511772:
                        if (str.equals("right")) {
                            c = 3;
                        }
                        switch (c) {
                        }
                    case 1318073018:
                        if (str.equals("downright")) {
                            c = 7;
                        }
                        switch (c) {
                        }
                    case 1427809193:
                        if (str.equals("downleft")) {
                            c = 6;
                        }
                        switch (c) {
                        }
                    default:
                        switch (c) {
                        }
                }
            }
        }
    };
    Runnable mAction = new Runnable() {
        @Override
        public void run() {
            String str = VentanaFlotante.this.accion;
            char c = 65535;
            switch (str.hashCode()) {
                case -838604510:
                    if (str.equals("upleft")) {
                        c = 4;
                        break;
                    }
                    break;
                case -221275039:
                    if (str.equals("upright")) {
                        c = 5;
                        break;
                    }
                    break;
                case 3739:
                    if (str.equals("up")) {
                        c = 1;
                        break;
                    }
                    break;
                case 3089570:
                    if (str.equals("down")) {
                        c = 0;
                        break;
                    }
                    break;
                case 3317767:
                    if (str.equals("left")) {
                        c = 2;
                        break;
                    }
                    break;
                case 108511772:
                    if (str.equals("right")) {
                        c = 3;
                        break;
                    }
                    break;
                case 1318073018:
                    if (str.equals("downright")) {
                        c = 7;
                        break;
                    }
                    break;
                case 1427809193:
                    if (str.equals("downleft")) {
                        c = 6;
                        break;
                    }
                    break;
            }
            switch (c) {
                case 0:
                    VentanaFlotante.this.latitude -= VentanaFlotante.this.metroLat * VentanaFlotante.this.velocidad;
                    return;
                case 1:
                    VentanaFlotante.this.latitude += VentanaFlotante.this.metroLat * VentanaFlotante.this.velocidad;
                    return;
                case 2:
                    VentanaFlotante.this.longitude -= VentanaFlotante.this.metroLng * VentanaFlotante.this.velocidad;
                    return;
                case 3:
                    VentanaFlotante.this.longitude += VentanaFlotante.this.metroLng * VentanaFlotante.this.velocidad;
                    return;
                case 4:
                    VentanaFlotante.this.latitude += VentanaFlotante.this.metroLat * VentanaFlotante.this.velocidad;
                    VentanaFlotante.this.longitude -= VentanaFlotante.this.metroLng * VentanaFlotante.this.velocidad;
                    return;
                case 5:
                    VentanaFlotante.this.latitude += VentanaFlotante.this.metroLat * VentanaFlotante.this.velocidad;
                    VentanaFlotante.this.longitude += VentanaFlotante.this.metroLng * VentanaFlotante.this.velocidad;
                    return;
                case 6:
                    VentanaFlotante.this.latitude -= VentanaFlotante.this.metroLat * VentanaFlotante.this.velocidad;
                    VentanaFlotante.this.longitude -= VentanaFlotante.this.metroLng * VentanaFlotante.this.velocidad;
                    return;
                case 7:
                    VentanaFlotante.this.latitude -= VentanaFlotante.this.metroLat * VentanaFlotante.this.velocidad;
                    VentanaFlotante.this.longitude += VentanaFlotante.this.metroLng * VentanaFlotante.this.velocidad;
                    return;
                default:
                    return;
            }
        }
    };
    private boolean onPause = false;
    boolean ejecutado = false;
    Thread thread = new Thread() {
        @Override
        public final void run() {
            try {
                VentanaFlotante.this.method = Location.class.getMethod("makeComplete", new Class[0]);
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            }
            if (Build.VERSION.SDK_INT <= 22) {
                VentanaFlotante.a(1, VentanaFlotante.this.getApplicationContext());
                VentanaFlotante.this.test = new Location(LocationManager.GPS_PROVIDER);
                while (true) {
                    if (!VentanaFlotante.this.onPause) {
                        try {
                            VentanaFlotante.this.locationManager = (LocationManager) VentanaFlotante.this.getSystemService("location");
                            if (VentanaFlotante.this.array == null) {
                                VentanaFlotante.this.test.setLatitude(VentanaFlotante.this.latitude);
                                VentanaFlotante.this.test.setLongitude(VentanaFlotante.this.longitude);
                            } else {
                                if (!VentanaFlotante.this.ejecutado) {
                                    VentanaFlotante.this.itinerary.setBackgroundResource(R.drawable.ic_pause);
                                    VentanaFlotante.this.itinerary.getBackground().setAlpha((int) (80.0d * VentanaFlotante.this.escala));
                                    VentanaFlotante.this.ejecutarItinerario();
                                    VentanaFlotante.this.ejecutado = true;
                                }
                                sleep(500L);
                            }
                            VentanaFlotante.this.test.setAltitude(0.0d);
                            VentanaFlotante.this.test.setBearing(VentanaFlotante.this.curBearing);
                            VentanaFlotante.this.test.setAccuracy(VentanaFlotante.this.DEFAULT_ACCURACY);
                            if (Build.VERSION.SDK_INT > 19) {
                                VentanaFlotante.this.test.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
                            }
                            VentanaFlotante.this.test.setSpeed(VentanaFlotante.this.MperSec);
                            VentanaFlotante.this.test.setTime(System.currentTimeMillis());
                            VentanaFlotante.this.method = Location.class.getMethod("makeComplete", new Class[0]);
                            if (VentanaFlotante.this.method != null) {
                                try {
                                    try {
                                        try {
                                            VentanaFlotante.this.method.invoke(VentanaFlotante.this.test, new Object[0]);
                                        } catch (IllegalArgumentException e2) {
                                            e2.printStackTrace();
                                        }
                                    } catch (InvocationTargetException e3) {
                                        e3.printStackTrace();
                                    }
                                } catch (IllegalAccessException e22) {
                                    e22.printStackTrace();
                                }
                            }
                            VentanaFlotante.this.locationManager.addTestProvider(LocationManager.GPS_PROVIDER, false, false, false, false, false, true, true, 0, 5);
                            VentanaFlotante.this.locationManager.setTestProviderStatus(LocationManager.GPS_PROVIDER, 2, null, System.currentTimeMillis());
                            VentanaFlotante.this.locationManager.setTestProviderLocation(LocationManager.GPS_PROVIDER, VentanaFlotante.this.test);
                            VentanaFlotante.this.locationManager.setTestProviderEnabled(LocationManager.GPS_PROVIDER, true);
                            VentanaFlotante.this.locationManager.addTestProvider(LocationManager.NETWORK_PROVIDER, false, false, true, false, false, true, true, 0, 5);
                            VentanaFlotante.this.locationManager.setTestProviderStatus(LocationManager.NETWORK_PROVIDER, 2, null, System.currentTimeMillis());
                            VentanaFlotante.this.locationManager.setTestProviderLocation(LocationManager.NETWORK_PROVIDER, VentanaFlotante.this.test);
                            VentanaFlotante.this.locationManager.setTestProviderEnabled(LocationManager.NETWORK_PROVIDER, true);
                            LocationListener lis = new LocationListener() {
                                @Override
                                public void onLocationChanged(Location location) {
                                }

                                @Override
                                public void onStatusChanged(String s, int i, Bundle bundle) {
                                }

                                @Override
                                public void onProviderEnabled(String s) {
                                }

                                @Override
                                public void onProviderDisabled(String s) {
                                }
                            };
                            VentanaFlotante.this.locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, VentanaFlotante.this.longMinTime, VentanaFlotante.this.minDistance, lis);
                        } catch (Exception e4) {
                        }
                        if (VentanaFlotante.this.array == null) {
                            VentanaFlotante.this.test.setLongitude(VentanaFlotante.this.longitude);
                            VentanaFlotante.this.test.setLatitude(VentanaFlotante.this.latitude);
                        }
                        VentanaFlotante.this.test.setAltitude(0.0d);
                        VentanaFlotante.this.test.setBearing(VentanaFlotante.this.curBearing);
                        if (Build.VERSION.SDK_INT > 18) {
                            VentanaFlotante.this.test.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
                        }
                        VentanaFlotante.this.test.setAccuracy(VentanaFlotante.this.DEFAULT_ACCURACY);
                        VentanaFlotante.this.test.setSpeed(VentanaFlotante.this.MperSec);
                        VentanaFlotante.this.test.setTime(System.currentTimeMillis());
                        try {
                            VentanaFlotante.this.method = Location.class.getMethod("makeComplete", new Class[0]);
                            if (VentanaFlotante.this.method != null) {
                                VentanaFlotante.this.method.invoke(VentanaFlotante.this.test, new Object[0]);
                            }
                        } catch (IllegalAccessException | IllegalArgumentException | NoSuchMethodException | InvocationTargetException e6) {
                            e6.printStackTrace();
                            Log.e("TAG", "locationJellyBeanFixMethod" + e6.toString());
                        }
                        try {
                            VentanaFlotante.this.locationManager.addTestProvider(LocationManager.GPS_PROVIDER, false, false, false, false, false, true, true, 0, 5);
                            VentanaFlotante.this.locationManager.setTestProviderStatus(LocationManager.GPS_PROVIDER, 2, null, System.currentTimeMillis());
                            VentanaFlotante.this.locationManager.setTestProviderLocation(LocationManager.GPS_PROVIDER, VentanaFlotante.this.test);
                            VentanaFlotante.this.locationManager.setTestProviderEnabled(LocationManager.GPS_PROVIDER, true);
                            VentanaFlotante.this.locationManager.addTestProvider(LocationManager.NETWORK_PROVIDER, true, false, true, false, false, true, true, 0, 5);
                            VentanaFlotante.this.locationManager.setTestProviderStatus(LocationManager.NETWORK_PROVIDER, 2, null, System.currentTimeMillis());
                            VentanaFlotante.this.locationManager.setTestProviderLocation(LocationManager.NETWORK_PROVIDER, VentanaFlotante.this.test);
                            VentanaFlotante.this.locationManager.setTestProviderEnabled(LocationManager.NETWORK_PROVIDER, true);
                        } catch (Exception e5) {
                            try {
                                VentanaFlotante.this.m.reportLocation(VentanaFlotante.this.test, true);
                                VentanaFlotante.a(0, VentanaFlotante.this.getApplicationContext());
                            } catch (Exception e8) {
                                e8.printStackTrace();
                            }
                        }
                        try {
                            VentanaFlotante.this.au();
                            VentanaFlotante.a(0, VentanaFlotante.this.getApplicationContext());
                        } catch (Exception e7) {
                        }
                        try {
                            sleep(VentanaFlotante.this.sleepUpdates);
                        } catch (InterruptedException e9) {
                            e9.printStackTrace();
                        }
                    }
                }
            } else if (Build.VERSION.SDK_INT >= 23) {
                try {
                    VentanaFlotante.this.onMockStart();
                } catch (Exception e10) {
                    e10.printStackTrace();
                }
            }
        }
    };
    Thread itinerario = new Thread() {
        @Override
        public void run() {
            String[] separated2;
            while (true) {
                if (VentanaFlotante.this.yes) {
                    String latLngInicio = null;
                    String latLngFin = null;
                    try {
                        if (VentanaFlotante.this.array != null) {
                            String[] arrNew = VentanaFlotante.this.array;
                            for (int i = 0; i < arrNew.length; i++) {
                                try {
                                    if (i < arrNew.length) {
                                        latLngInicio = arrNew[i];
                                        latLngFin = arrNew[i + 1];
                                    }
                                } catch (IndexOutOfBoundsException e) {
                                }
                                String[] separated1 = new String[i];
                                if (i >= 1) {
                                    if (i + 1 == arrNew.length) {
                                        separated2 = new String[0];
                                    } else {
                                        separated2 = new String[i + 1];
                                    }
                                } else {
                                    separated2 = new String[i];
                                }
                                Pattern compiledPattern2 = Pattern.compile("([+-]?\\d+\\.?\\d+)\\s*,\\s*([+-]?\\d+\\.?\\d+)", 2);
                                Matcher matcher1 = compiledPattern2.matcher(latLngInicio);
                                Matcher matcher2 = compiledPattern2.matcher(latLngFin);
                                if (matcher1.find() && matcher2.find()) {
                                    try {
                                        separated1 = matcher1.group().split(", ");
                                        separated2 = matcher2.group().split(", ");
                                    } catch (Exception e2) {
                                    }
                                }
                                VentanaFlotante.this.startPos = new LatLng(Double.valueOf(separated1[0]).doubleValue(), Double.valueOf(separated1[1]).doubleValue());
                                VentanaFlotante.this.endPos = new LatLng(Double.valueOf(separated2[0]).doubleValue(), Double.valueOf(separated2[1]).doubleValue());
                                VentanaFlotante.this.distancia = VentanaFlotante.this.getDistanceFromLatLonInKm(VentanaFlotante.this.startPos.latitude, VentanaFlotante.this.startPos.longitude, VentanaFlotante.this.endPos.latitude, VentanaFlotante.this.endPos.longitude);
                                VentanaFlotante.this.mxSec = ((VentanaFlotante.this.speedKM * 1000.0d) / 60.0d) / 60.0d;
                                VentanaFlotante.this.MperSec = (float) VentanaFlotante.this.mxSec;
                                VentanaFlotante.this.cantidadPasos = (VentanaFlotante.this.distancia * 1000.0d) / VentanaFlotante.this.mxSec;
                                VentanaFlotante.this.latDelta = (float) ((VentanaFlotante.this.endPos.latitude - VentanaFlotante.this.startPos.latitude) / VentanaFlotante.this.cantidadPasos);
                                VentanaFlotante.this.lngDelta = (float) ((VentanaFlotante.this.endPos.longitude - VentanaFlotante.this.startPos.longitude) / VentanaFlotante.this.cantidadPasos);
                                int x = 0;
                                while (VentanaFlotante.this.cantidadPasos > x) {
                                    if (VentanaFlotante.this.pause) {
                                        x--;
                                    } else {
                                        VentanaFlotante.this.curLat = VentanaFlotante.this.startPos.latitude + (x * VentanaFlotante.this.latDelta);
                                        VentanaFlotante.this.curLng = VentanaFlotante.this.startPos.longitude + (x * VentanaFlotante.this.lngDelta);
                                        VentanaFlotante.this.test.setLatitude(VentanaFlotante.this.curLat);
                                        VentanaFlotante.this.test.setLongitude(VentanaFlotante.this.curLng);
                                        VentanaFlotante.this.latitude = VentanaFlotante.this.curLat;
                                        VentanaFlotante.this.longitude = VentanaFlotante.this.curLng;
                                        if (VentanaFlotante.this.speedChanged) {
                                            VentanaFlotante.this.startPos = new LatLng(VentanaFlotante.this.curLat, VentanaFlotante.this.curLng);
                                            x = 0;
                                            VentanaFlotante.this.distancia = VentanaFlotante.this.getDistanceFromLatLonInKm(VentanaFlotante.this.curLat, VentanaFlotante.this.curLng, VentanaFlotante.this.endPos.latitude, VentanaFlotante.this.endPos.longitude);
                                            VentanaFlotante.this.mxSec = ((VentanaFlotante.this.speedKM * 1000.0d) / 60.0d) / 60.0d;
                                            VentanaFlotante.this.MperSec = (float) VentanaFlotante.this.mxSec;
                                            VentanaFlotante.this.cantidadPasos = (VentanaFlotante.this.distancia * 1000.0d) / VentanaFlotante.this.mxSec;
                                            VentanaFlotante.this.latDelta = (float) ((VentanaFlotante.this.endPos.latitude - VentanaFlotante.this.curLat) / VentanaFlotante.this.cantidadPasos);
                                            VentanaFlotante.this.lngDelta = (float) ((VentanaFlotante.this.endPos.longitude - VentanaFlotante.this.curLng) / VentanaFlotante.this.cantidadPasos);
                                            VentanaFlotante.this.speedChanged = false;
                                        }
                                    }
                                    try {
                                        sleep(1000L);
                                    } catch (InterruptedException e3) {
                                        e3.printStackTrace();
                                    }
                                    x++;
                                }
                            }
                        }
                    } catch (Exception e4) {
                    }
                    if (VentanaFlotante.this.fromWalkTo) {
                        VentanaFlotante.this.yes = false;
                        Bundle b = new Bundle();
                        b.putStringArray("Array", null);
                        VentanaFlotante.this.intentService.putExtras(b);
                        VentanaFlotante.this.array = null;
                        VentanaFlotante.this.runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                VentanaFlotante.this.speed.setText("X1");
                                VentanaFlotante.this.itinerary.setBackgroundResource(R.drawable.ic_itinerary);
                                VentanaFlotante.this.itinerary.getBackground().setAlpha((int) (80.0d * VentanaFlotante.this.escala));
                            }
                        });
                    }
                }
            }
        }
    };

    static int access$1508(VentanaFlotante x0) {
        int i = x0.limite;
        x0.limite = i + 1;
        return i;
    }

    public void runOnUiThread(Runnable runnable) {
        this.handler.post(runnable);
    }

    private void prueba() {
        try {
            this.locationManager.addTestProvider(LocationManager.GPS_PROVIDER, false, false, false, false, false, false, false, 1, 1);
            if (!this.locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
                this.locationManager.setTestProviderEnabled(LocationManager.GPS_PROVIDER, true);
                this.locationManager.setTestProviderStatus(LocationManager.GPS_PROVIDER, 2, null, System.currentTimeMillis());
            }
            this.locationManager.setTestProviderLocation(LocationManager.GPS_PROVIDER, this.test);
        } catch (Exception e) {
        } finally {
            this.locationManager.setTestProviderEnabled(LocationManager.GPS_PROVIDER, false);
            this.locationManager.removeTestProvider(LocationManager.GPS_PROVIDER);
        }
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onCreate() {
        this.handler = new Handler();
        super.onCreate();
        this.locationManager = (LocationManager) getSystemService("location");
        LayoutInflater inflater = (LayoutInflater) getSystemService("layout_inflater");
        this.view = inflater.inflate(R.layout.analogo, (ViewGroup) null);
        this.layout_joystick = (RelativeLayout) this.view.findViewById(R.id.layout_joystick);
        this.pref = PreferenceManager.getDefaultSharedPreferences(this);
        this.sharedpreferences = getSharedPreferences(Configuracion, 0);
        this.mapStatePrefs = getSharedPreferences("mapCameraState", 0);
        this.MOCK_UPDATE_TIMER = Integer.parseInt(this.pref.getString("MOCK_UPDATE_TIMER", "500"));
        this.newMethodSwitch = this.pref.getBoolean("new_method_switch", false);
        try {
            this.agps = this.pref.getBoolean("agps_switch", false);
            this.joy = this.pref.getBoolean("example_switch", true);
            this.stopButton = this.pref.getBoolean("example_switch_exit", false);
            this.escala = Double.parseDouble(this.pref.getString("example_text", "1.0"));
            this.velocidad = Double.parseDouble(this.pref.getString("velocidadX1", "10"));
            this.longMinTime = this.pref.getInt("longMinTime", 100);
            this.minDistance = this.pref.getInt("minDistance", 5);
            this.sleepUpdates = this.pref.getInt("sleepUpdates", 500);
            this.curBearing = Float.parseFloat(this.pref.getString("curBearing", "0"));
            this.MperSec = Float.parseFloat(this.pref.getString("MperSec", "10"));
            this.DEFAULT_ACCURACY = Float.parseFloat(this.pref.getString("DEFAULT_ACCURACY", "1"));
        } catch (Exception e) {
        }
        SharedPreferences.Editor editor = this.sharedpreferences.edit();
        if (this.sharedpreferences.getString(PokestopsContract.PokeStopEntry.latitude, "").isEmpty() || this.sharedpreferences.getString(PokestopsContract.PokeStopEntry.longitude, "").isEmpty()) {
            editor.putString(PokestopsContract.PokeStopEntry.latitude, "35.704802");
            editor.putString(PokestopsContract.PokeStopEntry.longitude, "139.731068");
            if (this.sharedpreferences.getString("velocidadX1", "").isEmpty()) {
                editor.putString("velocidadX1", String.valueOf(this.velocidad));
            }
            if (this.sharedpreferences.getString("escala", "").isEmpty()) {
                editor.putString("escala", String.valueOf(this.escala));
            }
            editor.commit();
        } else {
            try {
                this.latitude = Double.parseDouble(this.sharedpreferences.getString(PokestopsContract.PokeStopEntry.latitude, ""));
                this.longitude = Double.parseDouble(this.sharedpreferences.getString(PokestopsContract.PokeStopEntry.longitude, ""));
            } catch (Exception e2) {
            }
        }
        if (this.joy) {
            inicializarAnalogo();
            this.wm = (WindowManager) getSystemService("window");
            this.wm2 = (WindowManager) getSystemService("window");
            this.ll = new LinearLayout(this);
            this.ll2 = new LinearLayout(this);
            this.ll.setOrientation(1);
            this.ll.setBackgroundColor(ViewCompat.MEASURED_STATE_MASK);
            LinearLayout.LayoutParams layoutParameteres = new LinearLayout.LayoutParams(-1, -2);
            this.ll.setBackgroundColor(Color.argb(0, 255, 0, 0));
            this.ll.setLayoutParams(layoutParameteres);
            this.ll2.setOrientation(1);
            this.ll2.setBackgroundColor(ViewCompat.MEASURED_STATE_MASK);
            LinearLayout.LayoutParams layoutParameteres2 = new LinearLayout.LayoutParams(-1, -2);
            this.ll2.setBackgroundColor(Color.argb(0, 255, 0, 0));
            this.ll2.setLayoutParams(layoutParameteres2);
            this.parameters2.gravity = 85;
            if (this.sharedpreferences.getString("x", "").isEmpty() || this.sharedpreferences.getString("y", "").isEmpty()) {
                this.parameters.x = 0;
                this.parameters.y = 0;
            } else {
                this.parameters.x = (int) Double.parseDouble(this.sharedpreferences.getString("x", ""));
                this.parameters.y = (int) Double.parseDouble(this.sharedpreferences.getString("y", ""));
            }
            this.stop = new Button(this);
            this.stop.setBackgroundColor(Color.argb(60, 122, 122, 255));
            this.texto1 = new TextView(this);
            this.texto1.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Toast.makeText(VentanaFlotante.this.context, VentanaFlotante.this.getResources().getString(R.string.copiedtoclip), 0).show();
                    ClipboardManager clipboard = (ClipboardManager) VentanaFlotante.this.getSystemService("clipboard");
                    ClipData clip = ClipData.newPlainText("Coordinates", VentanaFlotante.this.latitude + ", " + VentanaFlotante.this.longitude);
                    clipboard.setPrimaryClip(clip);
                    Vibrator v = (Vibrator) VentanaFlotante.this.getSystemService("vibrator");
                    v.vibrate(200L);
                }
            });
            this.texto1.setPadding(0, 0, 0, 30);
            this.stop.setText("Press Here to 'Exit'");
            this.stop.setTextSize(8.0f);
            this.texto1.setText("Lat: " + ((float) this.latitude) + ", Lng: " + ((float) this.longitude));
            this.texto1.setTextColor(Color.argb(255, 255, 51, 51));
            this.texto1.setTypeface(null, 1);
            this.texto1.setTextSize(12.0f);
            this.texto1.setGravity(1);
            ViewGroup.LayoutParams btnParameters = new ViewGroup.LayoutParams(-1, -2);
            this.stop.setLayoutParams(btnParameters);
            this.stop.setWidth(14);
            this.texto1.setLayoutParams(btnParameters);
            this.ll2.addView(this.texto1);
            this.ll.addView(this.view);
            this.wm.addView(this.ll, this.parameters);
            if (this.pref.getBoolean("example_switch_coords", true)) {
                this.wm2.addView(this.ll2, this.parameters2);
            }
            this.stop.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    Toast.makeText(VentanaFlotante.this.getApplicationContext(), "", 0).show();
                    return true;
                }
            });
            this.stop.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    VentanaFlotante.this.guardarUbicacion();
                    VentanaFlotante.this.wm.removeView(VentanaFlotante.this.ll);
                    VentanaFlotante.a(1, VentanaFlotante.this.getApplicationContext());
                    try {
                        if (Build.VERSION.SDK_INT >= 23) {
                            VentanaFlotante.this.onMockStop();
                        } else {
                            VentanaFlotante.this.locationManager.removeTestProvider(LocationManager.GPS_PROVIDER);
                            VentanaFlotante.this.locationManager.removeTestProvider(LocationManager.NETWORK_PROVIDER);
                        }
                        VentanaFlotante.a(0, VentanaFlotante.this.getApplicationContext());
                    } catch (Exception e3) {
                    }
                    VentanaFlotante.this.stopSelf();
                    System.exit(0);
                }
            });
        }
        inicializarGPS();
    }

    public void onMockStop() {
        this._handler.removeMessages(0);
        removeProvider();
    }

    private boolean ventanaIsMovible() {
        this.sharedpreferences.edit();
        return true;
    }

    private void inicializarAnalogo() {
        Button move = (Button) this.view.findViewById(R.id.b_move);
        Button stopEnabled = (Button) this.view.findViewById(R.id.b_newExit);
        Button newFunctions = (Button) this.view.findViewById(R.id.b_newOpen);
        newFunctions.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                VentanaFlotante.this.dialogNewFunctions();
            }
        });
        stopEnabled.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                VentanaFlotante.this.stoppedByButton = true;
                VentanaFlotante.a(1, VentanaFlotante.this.getApplicationContext());
                try {
                    if (Build.VERSION.SDK_INT >= 23) {
                        VentanaFlotante.this.onMockStop();
                    } else {
                        VentanaFlotante.this.locationManager.removeTestProvider(LocationManager.GPS_PROVIDER);
                        VentanaFlotante.this.locationManager.removeTestProvider(LocationManager.NETWORK_PROVIDER);
                    }
                    VentanaFlotante.a(0, VentanaFlotante.this.getApplicationContext());
                } catch (Exception e) {
                }
                VentanaFlotante.this.stopSelf();
            }
        });
        newFunctions.setVisibility(0);
        if (this.pref.getBoolean("example_switch_exit", false)) {
            stopEnabled.setVisibility(0);
        }
        this.speed = (Button) this.view.findViewById(R.id.b_speed);
        this.speed.setAlpha(50.0f);
        this.speed.setTextColor(-1);
        this.speed.setText("X1");
        this.itinerary = (Button) this.view.findViewById(R.id.b_itinerary);
        this.sniper = (Button) this.view.findViewById(R.id.b_sniper);
        DisplayMetrics display = displaySize();
        float densidad = display.density;
        this.js = new JoyStickClass(this, this.layout_joystick, R.drawable.image_button);
        this.js.setStickSize((int) (100.0d * this.escala), (int) (100.0d * this.escala));
        this.js.setLayoutSize((int) (300.0d * this.escala), (int) (300.0d * this.escala));
        this.js.setLayoutAlpha((int) (90.0d * this.escala));
        this.js.setStickAlpha((int) (70.0d * this.escala));
        this.js.setOffset((int) (50.0d * this.escala));
        this.js.setMinimumDistance((int) (20.0d * this.escala));
        this.speed.getBackground().setAlpha((int) (80.0d * this.escala));
        if (this.itinerary != null) {
            this.itinerary.getBackground().setAlpha((int) (80.0d * this.escala));
        }
        this.sniper.getBackground().setAlpha((int) (80.0d * this.escala));
        String valueOf = String.valueOf(densidad);
        char c = 65535;
        switch (valueOf.hashCode()) {
            case 48563:
                if (valueOf.equals("1.0")) {
                    c = 1;
                    break;
                }
                break;
            case 48568:
                if (valueOf.equals("1.5")) {
                    c = 2;
                    break;
                }
                break;
            case 49524:
                if (valueOf.equals("2.0")) {
                    c = 3;
                    break;
                }
                break;
            case 50485:
                if (valueOf.equals("3.0")) {
                    c = 4;
                    break;
                }
                break;
            case 51446:
                if (valueOf.equals("4.0")) {
                    c = 5;
                    break;
                }
                break;
            case 1475932:
                if (valueOf.equals("0.75")) {
                    c = 0;
                    break;
                }
                break;
        }
        switch (c) {
            case 0:
                this.js.setStickSize((int) (38.0d * this.escala), (int) (38.0d * this.escala));
                this.js.setLayoutSize((int) (113.0d * this.escala), (int) (113.0d * this.escala));
                this.js.setLayoutAlpha((int) (38.0d * this.escala));
                this.js.setStickAlpha((int) (26.0d * this.escala));
                this.js.setOffset((int) (18.0d * this.escala));
                this.js.setMinimumDistance((int) (8.0d * this.escala));
                break;
            case 1:
                this.js.setStickSize((int) (50.0d * this.escala), (int) (50.0d * this.escala));
                this.js.setLayoutSize((int) (150.0d * this.escala), (int) (150.0d * this.escala));
                this.js.setLayoutAlpha((int) (45.0d * this.escala));
                this.js.setStickAlpha((int) (35.0d * this.escala));
                this.js.setOffset((int) (25.0d * this.escala));
                this.js.setMinimumDistance((int) (10.0d * this.escala));
                break;
            case 2:
                this.js.setStickSize((int) (75.0d * this.escala), (int) (75.0d * this.escala));
                this.js.setLayoutSize((int) (225.0d * this.escala), (int) (225.0d * this.escala));
                this.js.setLayoutAlpha((int) (68.0d * this.escala));
                this.js.setStickAlpha((int) (53.0d * this.escala));
                this.js.setOffset((int) (38.0d * this.escala));
                this.js.setMinimumDistance((int) (15.0d * this.escala));
                break;
            case 3:
                this.js.setStickSize((int) (75.0d * this.escala), (int) (75.0d * this.escala));
                this.js.setLayoutSize((int) (225.0d * this.escala), (int) (225.0d * this.escala));
                this.js.setLayoutAlpha((int) (68.0d * this.escala));
                this.js.setStickAlpha((int) (53.0d * this.escala));
                this.js.setOffset((int) (38.0d * this.escala));
                this.js.setMinimumDistance((int) (15.0d * this.escala));
                break;
            case 4:
                this.js.setStickSize((int) (100.0d * this.escala), (int) (100.0d * this.escala));
                this.js.setLayoutSize((int) (300.0d * this.escala), (int) (300.0d * this.escala));
                this.js.setLayoutAlpha((int) (90.0d * this.escala));
                this.js.setStickAlpha((int) (70.0d * this.escala));
                this.js.setOffset((int) (50.0d * this.escala));
                this.js.setMinimumDistance((int) (20.0d * this.escala));
                break;
            case 5:
                this.js.setStickSize((int) (100.0d * this.escala), (int) (100.0d * this.escala));
                this.js.setLayoutSize((int) (380.0d * this.escala), (int) (380.0d * this.escala));
                this.js.setLayoutAlpha((int) (90.0d * this.escala));
                this.js.setStickAlpha((int) (70.0d * this.escala));
                this.js.setOffset((int) (50.0d * this.escala));
                this.js.setMinimumDistance((int) (20.0d * this.escala));
                break;
        }
        this.layout_joystick.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View arg0, MotionEvent arg1) {
                VentanaFlotante.this.js.drawStick(arg1);
                if (arg1.getAction() == 0 || arg1.getAction() == 2) {
                    int direction = VentanaFlotante.this.js.get8Direction();
                    VentanaFlotante.this.isAutoWalk = false;
                    if (direction == 1) {
                        VentanaFlotante.this.accion = "up";
                    } else if (direction == 2) {
                        VentanaFlotante.this.accion = "upright";
                    } else if (direction == 3) {
                        VentanaFlotante.this.accion = "right";
                    } else if (direction == 4) {
                        VentanaFlotante.this.accion = "downright";
                    } else if (direction == 5) {
                        VentanaFlotante.this.accion = "down";
                    } else if (direction == 6) {
                        VentanaFlotante.this.accion = "downleft";
                    } else if (direction == 7) {
                        VentanaFlotante.this.accion = "left";
                    } else if (direction == 8) {
                        VentanaFlotante.this.accion = "upleft";
                    } else if (direction == 0) {
                    }
                } else if (arg1.getAction() == 1) {
                    VentanaFlotante.this.lastDuration = System.currentTimeMillis() - VentanaFlotante.this.lastDown;
                    if (VentanaFlotante.this.newMethodSwitch) {
                        VentanaFlotante.this.mHandler.sendEmptyMessageDelayed(0, VentanaFlotante.this.MOCK_UPDATE_TIMER);
                    }
                    VentanaFlotante.this.accion = "";
                }
                VentanaFlotante.this.texto1.setText("Lat: " + ((float) VentanaFlotante.this.latitude) + ", Lng: " + ((float) VentanaFlotante.this.longitude));
                return true;
            }
        });
        move.setOnTouchListener(new View.OnTouchListener() {
            double pressedX;
            double pressedY;
            WindowManager.LayoutParams updatedParameters;
            double x;
            double y;

            {
                this.updatedParameters = VentanaFlotante.this.parameters;
            }

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                try {
                    switch (event.getAction()) {
                        case 0:
                            SharedPreferences.Editor editor = VentanaFlotante.this.sharedpreferences.edit();
                            editor.putString("x", String.valueOf(this.updatedParameters.x));
                            editor.putString("y", String.valueOf(this.updatedParameters.y));
                            editor.commit();
                            this.x = Double.parseDouble(VentanaFlotante.this.sharedpreferences.getString("x", ""));
                            this.y = Double.parseDouble(VentanaFlotante.this.sharedpreferences.getString("y", ""));
                            this.pressedX = event.getRawX();
                            this.pressedY = event.getRawY();
                            break;
                        case 2:
                            SharedPreferences.Editor editor2 = VentanaFlotante.this.sharedpreferences.edit();
                            this.updatedParameters.x = (int) (this.x + (event.getRawX() - this.pressedX));
                            this.updatedParameters.y = (int) (this.y + (event.getRawY() - this.pressedY));
                            editor2.putString("x", String.valueOf(this.updatedParameters.x));
                            editor2.putString("y", String.valueOf(this.updatedParameters.y));
                            editor2.commit();
                            VentanaFlotante.this.wm.updateViewLayout(VentanaFlotante.this.ll, this.updatedParameters);
                            break;
                    }
                    return false;
                } catch (Exception e) {
                    return false;
                }
            }
        });
        this.speed.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (VentanaFlotante.this.array != null) {
                    VentanaFlotante.this.createDialogKmPorHora();
                    VentanaFlotante.this.speed.setText("" + ((int) VentanaFlotante.this.speedKM));
                    return;
                }
                VentanaFlotante.access$1508(VentanaFlotante.this);
                if (VentanaFlotante.this.limite > 2) {
                    VentanaFlotante.this.limite = 0;
                }
                switch (VentanaFlotante.this.limite) {
                    case 0:
                        VentanaFlotante.this.velocidad = Double.parseDouble(VentanaFlotante.this.pref.getString("velocidadX1", "10"));
                        VentanaFlotante.this.speed.setText("X1");
                        Toast.makeText(VentanaFlotante.this, "Speed: X1", 0).show();
                        return;
                    case 1:
                        VentanaFlotante.this.velocidad = Double.parseDouble(VentanaFlotante.this.pref.getString("velocidadX2", "20"));
                        VentanaFlotante.this.speed.setText("X2");
                        Toast.makeText(VentanaFlotante.this, "Speed: X2", 0).show();
                        return;
                    case 2:
                        VentanaFlotante.this.velocidad = Double.parseDouble(VentanaFlotante.this.pref.getString("velocidadX3", "45"));
                        VentanaFlotante.this.speed.setText("X3");
                        Toast.makeText(VentanaFlotante.this, "Speed: X3", 0).show();
                        return;
                    default:
                        return;
                }
            }
        });
        if (this.itinerary != null) {
            this.itinerary.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    try {
                        VentanaFlotante.this.array = new Bundle(VentanaFlotante.this.intentService.getExtras()).getStringArray("Array");
                    } catch (Exception e) {
                        VentanaFlotante.this.array = null;
                    }
                    if (VentanaFlotante.this.array == null) {
                        if (!VentanaFlotante.this.oneTime) {
                            if (VentanaFlotante.this.isAutoWalk) {
                                VentanaFlotante.this.isAutoWalk = false;
                                VentanaFlotante.this.accion = "";
                                VentanaFlotante.this.isAutoWalk = false;
                                Toast.makeText(VentanaFlotante.this, VentanaFlotante.this.getResources().getString(R.string.stopWalkInCircle), 0).show();
                                return;
                            }
                            VentanaFlotante.this.isAutoWalk = true;
                            Toast.makeText(VentanaFlotante.this, VentanaFlotante.this.getResources().getString(R.string.walkInCircle), 0).show();
                            return;
                        }
                        VentanaFlotante.this.autoWalk.start();
                        VentanaFlotante.this.oneTime = false;
                        VentanaFlotante.this.isAutoWalk = true;
                        Toast.makeText(VentanaFlotante.this, VentanaFlotante.this.getResources().getString(R.string.walkInCircle), 0).show();
                        return;
                    }
                    if (VentanaFlotante.this.pause) {
                        VentanaFlotante.this.speed.setText("" + ((int) VentanaFlotante.this.speedKM));
                        VentanaFlotante.this.itinerary.setBackgroundResource(R.drawable.ic_pause);
                        VentanaFlotante.this.itinerary.getBackground().setAlpha((int) (VentanaFlotante.this.escala * 80.0d));
                        Toast.makeText(VentanaFlotante.this, VentanaFlotante.this.getResources().getString(R.string.playRoute), 0).show();
                        VentanaFlotante.this.pause = false;
                        Bundle b = VentanaFlotante.this.intentService.getExtras();
                        try {
                            VentanaFlotante.this.array = b.getStringArray("Array");
                            return;
                        } catch (NullPointerException e2) {
                            return;
                        }
                    }
                    VentanaFlotante.this.speed.setText("X1");
                    VentanaFlotante.this.itinerary.setBackgroundResource(R.drawable.ic_play);
                    VentanaFlotante.this.itinerary.getBackground().setAlpha((int) (VentanaFlotante.this.escala * 80.0d));
                    VentanaFlotante.this.array = null;
                    Toast.makeText(VentanaFlotante.this, VentanaFlotante.this.getResources().getString(R.string.stopRoute), 0).show();
                    VentanaFlotante.this.velocidad = Double.parseDouble(VentanaFlotante.this.pref.getString("velocidadX1", "10"));
                    VentanaFlotante.this.latitude = VentanaFlotante.this.test.getLatitude();
                    VentanaFlotante.this.longitude = VentanaFlotante.this.test.getLongitude();
                    VentanaFlotante.this.MperSec = 0.0f;
                    VentanaFlotante.this.pause = true;
                }
            });
        }
        if (this.sharedpreferences.getBoolean("pokeSniper", false)) {
            this.sniper.setVisibility(0);
            this.sniper.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    VentanaFlotante.this.crearDialogoIr();
                }
            });
            this.sniper.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    Handler handler = new Handler();
                    if (event.getAction() == 0) {
                        VentanaFlotante.this.then = System.currentTimeMillis();
                        VentanaFlotante.this.isLongPress = true;
                        handler.postDelayed(VentanaFlotante.this.action, VentanaFlotante.this.longClickDuration);
                    } else if (event.getAction() == 1) {
                        VentanaFlotante.this.isLongPress = false;
                        if (System.currentTimeMillis() - VentanaFlotante.this.then >= VentanaFlotante.this.longClickDuration) {
                            return false;
                        }
                        handler.removeCallbacks(VentanaFlotante.this.action);
                        VentanaFlotante.this.crearDialogoIr();
                        return false;
                    }
                    return true;
                }
            });
        }
    }

    private synchronized void cargarJsonToArrayList() {
        Gson gson = new Gson();
        String myLocationsJson = this.sharedpreferences.getString("myLocationsJson", "");
        ArrayList<Ubicacion> myLocationsJsonArr = (ArrayList) gson.fromJson(myLocationsJson, new TypeToken<List<Ubicacion>>() {
        }.getType());
        if (!myLocationsJson.isEmpty()) {
            this.resultsLocations = myLocationsJsonArr;
        }
        String myHistoryJson = this.sharedpreferences.getString("myHistoryJson", "");
        ArrayList<Ubicacion> myHistoryJsonArr = (ArrayList) gson.fromJson(myHistoryJson, new TypeToken<List<Ubicacion>>() {
        }.getType());
        if (!myHistoryJson.isEmpty()) {
            this.results = myHistoryJsonArr;
        }
        String myItinerariesJson = this.sharedpreferences.getString("myItinerariesJson", "");
        ArrayList<Itinerario> myItinerariesJsonArr = (ArrayList) gson.fromJson(myItinerariesJson, new TypeToken<List<Itinerario>>() {
        }.getType());
        if (!myItinerariesJson.isEmpty()) {
            this.resultsItinerarios = myItinerariesJsonArr;
        }
    }

    public static double round(double value, int places) {
        if (places < 0) {
            throw new IllegalArgumentException();
        }
        long factor = (long) Math.pow(10.0d, places);
        long tmp = Math.round(value * factor);
        return tmp / factor;
    }

    public void dialogNewFunctions() {
        cargarJsonToArrayList();
        LayoutInflater inflater = (LayoutInflater) getSystemService("layout_inflater");
        View dialogView = inflater.inflate(R.layout.dialog_new_functions, (ViewGroup) null);
        AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AlertDialogCustomThemeTres));
        builder.setView(dialogView);
        final AlertDialog alert = builder.create();
        TabHost host = (TabHost) dialogView.findViewById(R.id.tabHost);
        host.setup();
        List<Map<String, String>> list = new ArrayList<>();
        int count = this.resultsLocations.size();
        for (int i = 0; i < count; i++) {
            Map<String, String> map = new HashMap<>();
            map.put("Name", this.resultsLocations.get(i).getDescripcion());
            map.put("Coordinates", "Lat: " + round(this.resultsLocations.get(i).getLatitude(), 5) + ", Lng: " + round(this.resultsLocations.get(i).getLongitude(), 5));
            list.add(map);
        }
        List<Map<String, String>> list2 = new ArrayList<>();
        int count2 = this.results.size();
        for (int i2 = 0; i2 < count2; i2++) {
            Map<String, String> map2 = new HashMap<>();
            map2.put("Name", this.results.get(i2).getNombre());
            map2.put("Coordinates", "Lat: " + round(this.results.get(i2).getLatitude(), 5) + ", Lng: " + round(this.results.get(i2).getLongitude(), 5));
            list2.add(map2);
        }
        List<Map<String, String>> list3 = new ArrayList<>();
        int count3 = this.resultsItinerarios.size();
        for (int i3 = 0; i3 < count3; i3++) {
            Map<String, String> map3 = new HashMap<>();
            map3.put("Name", this.resultsItinerarios.get(i3).getDescripcion());
            map3.put("Date", "Date: " + this.resultsItinerarios.get(i3).getFecha());
            list3.add(map3);
        }
        TabHost.TabSpec spec = host.newTabSpec("Tab One");
        ListView mListView = (ListView) dialogView.findViewById(R.id.list_1);
        ListView mListView2 = (ListView) dialogView.findViewById(R.id.list_2);
        ListView mListView3 = (ListView) dialogView.findViewById(R.id.list_3);
        SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.lite_row_items, new String[]{"Name", "Coordinates"}, new int[]{R.id.titulo, R.id.coordenadastexto});
        SimpleAdapter adapter2 = new SimpleAdapter(this, list2, R.layout.lite_row_items, new String[]{"Name", "Coordinates"}, new int[]{R.id.titulo, R.id.coordenadastexto});
        SimpleAdapter adapter3 = new SimpleAdapter(this, list3, R.layout.lite_row_items, new String[]{"Name", "Date"}, new int[]{R.id.titulo, R.id.coordenadastexto});
        mListView.setAdapter((ListAdapter) adapter);
        mListView2.setAdapter((ListAdapter) adapter2);
        mListView3.setAdapter((ListAdapter) adapter3);
        spec.setContent(R.id.tab1);
        spec.setIndicator(getResources().getString(R.string.locationString));
        host.addTab(spec);
        TabHost.TabSpec spec2 = host.newTabSpec("Tab Two");
        spec2.setContent(R.id.tab2);
        spec2.setIndicator(getResources().getString(R.string.historyString));
        host.addTab(spec2);
        TabHost.TabSpec spec3 = host.newTabSpec("Tab Three");
        spec3.setContent(R.id.tab3);
        spec3.setIndicator(getResources().getString(R.string.itineraryString));
        host.addTab(spec3);
        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView parent, View view, int position, long id) {
                VentanaFlotante.this.latitude = ((Ubicacion) VentanaFlotante.this.resultsLocations.get(position)).getLatitude();
                VentanaFlotante.this.longitude = ((Ubicacion) VentanaFlotante.this.resultsLocations.get(position)).getLongitude();
                alert.dismiss();
                Toast.makeText(VentanaFlotante.this.context, "Position changed: " + ((Ubicacion) VentanaFlotante.this.resultsLocations.get(position)).getDescripcion(), 0).show();
            }
        });
        mListView2.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView parent, View view, int position, long id) {
                VentanaFlotante.this.latitude = ((Ubicacion) VentanaFlotante.this.results.get(position)).getLatitude();
                VentanaFlotante.this.longitude = ((Ubicacion) VentanaFlotante.this.results.get(position)).getLongitude();
                alert.dismiss();
                Toast.makeText(VentanaFlotante.this.context, "Position changed: " + ((Ubicacion) VentanaFlotante.this.results.get(position)).getDescripcion(), 0).show();
            }
        });
        mListView3.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView parent, View view, int position, long id) {
                String[] arrayd = new String[((Itinerario) VentanaFlotante.this.resultsItinerarios.get(position)).getPuntos().size() + 1];
                for (int i4 = 0; i4 <= ((Itinerario) VentanaFlotante.this.resultsItinerarios.get(position)).getPuntos().size(); i4++) {
                    if (i4 != ((Itinerario) VentanaFlotante.this.resultsItinerarios.get(position)).getPuntos().size()) {
                        arrayd[i4] = ((Itinerario) VentanaFlotante.this.resultsItinerarios.get(position)).getPuntos().get(i4).getPosition().getLatitude() + ", " + ((Itinerario) VentanaFlotante.this.resultsItinerarios.get(position)).getPuntos().get(i4).getPosition().getLongitude();
                    } else {
                        arrayd[i4] = arrayd[0];
                    }
                }
                Bundle b = new Bundle();
                b.putStringArray("Array", arrayd);
                VentanaFlotante.this.intentService.putExtras(b);
                VentanaFlotante.this.array = arrayd;
                VentanaFlotante.this.speed.setText("" + ((int) VentanaFlotante.this.speedKM));
                alert.dismiss();
                Toast.makeText(VentanaFlotante.this.context, "Route started: " + ((Itinerario) VentanaFlotante.this.resultsItinerarios.get(position)).getDescripcion(), 0).show();
            }
        });
        Button b1 = (Button) dialogView.findViewById(R.id.newdata);
        b1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                new Bundle();
                Bundle b = VentanaFlotante.this.intentService.getExtras();
                String displayName = null;
                try {
                    displayName = b.getString("displayName", "prueba");
                    b.getString("correo", "prueba");
                } catch (Exception e) {
                }
                if (!displayName.equals("prueba")) {
                    VentanaFlotante.this.dialogEnviarPokeStopGym(VentanaFlotante.this.latitude, VentanaFlotante.this.longitude);
                } else {
                    Toast.makeText(VentanaFlotante.this.context, VentanaFlotante.this.getResources().getString(R.string.cantrequest), 0).show();
                }
            }
        });
        Button b2 = (Button) dialogView.findViewById(R.id.cancelaroe);
        b2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                alert.dismiss();
            }
        });
        alert.getWindow().setType(2003);
        alert.show();
    }

    public void crearToast() {
        Toast.makeText(this, "Home replaced by your current location", 1).show();
    }

    public void dialogEnviarPokeStopGym(double latitude, double longitude) {
        LayoutInflater inflater = (LayoutInflater) getSystemService("layout_inflater");
        View dialogView = inflater.inflate(R.layout.dialod_insert_gym_or_pokestop_service, (ViewGroup) null);
        AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AlertDialogCustomThemeTres));
        builder.setView(dialogView);
        final AlertDialog alert = builder.create();
        TextView tituloAlert = (TextView) dialogView.findViewById(R.id.tituloAlert);
        final EditText textNombre = (EditText) dialogView.findViewById(R.id.input_nombre);
        final EditText textLatitude = (EditText) dialogView.findViewById(R.id.input_latitude);
        final EditText textLongitude = (EditText) dialogView.findViewById(R.id.input_longitude);
        final Spinner spinner = (Spinner) dialogView.findViewById(R.id.input_datos_enviar);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.datosEnviar, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        tituloAlert.setText(getResources().getString(R.string.newpokestoporym));
        tituloAlert.setTextColor(-1);
        textLatitude.setText(String.valueOf(latitude));
        textLongitude.setText(String.valueOf(longitude));
        spinner.setAdapter((SpinnerAdapter) adapter);
        Button b1 = (Button) dialogView.findViewById(R.id.boton1Alert);
        Button b2 = (Button) dialogView.findViewById(R.id.boton2Alert);
        b1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (textNombre.getText().toString().isEmpty()) {
                    Toast.makeText(VentanaFlotante.this.getApplicationContext(), VentanaFlotante.this.getResources().getString(R.string.writeaname), 0).show();
                    return;
                }
                if (textLatitude.getText().toString().isEmpty()) {
                    Toast.makeText(VentanaFlotante.this.getApplicationContext(), VentanaFlotante.this.getResources().getString(R.string.writelatitude), 0).show();
                    return;
                }
                if (textLongitude.getText().toString().isEmpty()) {
                    Toast.makeText(VentanaFlotante.this.getApplicationContext(), VentanaFlotante.this.getResources().getString(R.string.writelongitude), 0).show();
                    return;
                }
                if (spinner.getSelectedItemPosition() == 0) {
                    Toast.makeText(VentanaFlotante.this.getApplicationContext(), VentanaFlotante.this.getResources().getString(R.string.pleaseSelectType), 0).show();
                    return;
                }
                if (!textNombre.getText().toString().isEmpty() && !textLatitude.getText().toString().isEmpty() && !textLongitude.getText().toString().isEmpty() && spinner.getSelectedItemPosition() != 0) {
                    VentanaFlotante.this.sendData(textNombre.getText().toString(), textLatitude.getText().toString(), textLongitude.getText().toString(), (int) spinner.getSelectedItemId());
                    alert.dismiss();
                }
            }
        });
        b2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                alert.dismiss();
            }
        });
        alert.getWindow().setType(2003);
        alert.show();
    }

    public long cuantosDias() {
        if (!this.sharedpreferences.getBoolean("docInsertedMongoDB", false)) {
            return 1L;
        }
        Date d1 = new Date();
        Date d2 = new Date();
        SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy");
        String dtStart = this.sharedpreferences.getString("date", format.format(new Date()));
        try {
            d2 = format.parse(dtStart);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        long dif = d1.getTime() - d2.getTime();
        return TimeUnit.MILLISECONDS.toDays(dif);
    }

    public void sendData(String name, String lat, String lng, int selected) {
        if (this.sharedpreferences.getInt("soli", 0) == 10) {
            if (cuantosDias() > 0) {
                SharedPreferences.Editor ed = this.sharedpreferences.edit();
                ed.putInt("soli", 0);
                ed.commit();
            }
            Toast.makeText(this, getResources().getString(R.string.onlycansend), 0).show();
            return;
        }
        AsyncHttpClient requestUpdate = new AsyncHttpClient();
        String ua = new WebView(this).getSettings().getUserAgentString();
        requestUpdate.setUserAgent(ua);
        RequestParams params = new RequestParams();
        String uid = "";
        String displayName = "";
        String correo = "";
        Bundle b = this.intentService.getExtras();
        try {
            uid = b.getString("uid", "");
            displayName = b.getString("displayName", "prueba");
            correo = b.getString("correo", "prueba");
        } catch (Exception e) {
        }
        params.add("uid", uid);
        params.add("user", displayName);
        params.add("correo", correo);
        params.add(PokestopsContract.PokeStopEntry.nombre, name);
        params.add("tipo", String.valueOf(selected));
        params.add("lat", lat);
        params.add("lng", lng);
        requestUpdate.post("http://datacomputer.cl/rest/Sync/addPokestopOrGym.php", params, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                SharedPreferences.Editor ed2 = VentanaFlotante.this.sharedpreferences.edit();
                ed2.putInt("soli", VentanaFlotante.this.sharedpreferences.getInt("soli", 0) + 1);
                ed2.commit();
                Toast.makeText(VentanaFlotante.this.getApplicationContext(), VentanaFlotante.this.getResources().getString(R.string.requestAdd), 0).show();
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                if (statusCode == 404) {
                    Toast.makeText(VentanaFlotante.this.getApplicationContext(), "Requested resource not found", 1).show();
                } else if (statusCode == 500) {
                    Toast.makeText(VentanaFlotante.this.getApplicationContext(), "Something went wrong at server end", 1).show();
                } else {
                    Toast.makeText(VentanaFlotante.this.getApplicationContext(), "Unexpected Error occcured! [Most common Error: Device might not be connected to Internet]", 1).show();
                }
            }
        });
    }

    public void crearDialogoIr() {
        LayoutInflater inflater = (LayoutInflater) getSystemService("layout_inflater");
        View dialogView = inflater.inflate(R.layout.dialog_ir_a, (ViewGroup) null);
        AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AlertDialogCustomThemeTres));
        builder.setTitle("PokeSniper");
        builder.setIcon(R.drawable.mapicon);
        builder.setMessage(getResources().getString(R.string.setCoords));
        builder.setView(dialogView);
        final AlertDialog alert = builder.create();
        final EditText coordinates = (EditText) dialogView.findViewById(R.id.input_coordenadas);
        Button go = (Button) dialogView.findViewById(R.id.go);
        Button home = (Button) dialogView.findViewById(R.id.home);
        Button exit = (Button) dialogView.findViewById(R.id.exit);
        Button walk = (Button) dialogView.findViewById(R.id.walk);
        coordinates.setTextIsSelectable(false);
        if (this.pref.getBoolean("keyboardQwerty", false)) {
            coordinates.setRawInputType(2);
        }
        go.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (VentanaFlotante.this.array != null) {
                    SharedPreferences.Editor edit = VentanaFlotante.this.sharedpreferences.edit();
                    edit.putString("latHome", String.valueOf(VentanaFlotante.this.curLat));
                    edit.putString("longHome", String.valueOf(VentanaFlotante.this.curLng));
                    edit.commit();
                    VentanaFlotante.this.speed.setText("X1");
                    VentanaFlotante.this.itinerary.setBackgroundResource(R.drawable.ic_play);
                    VentanaFlotante.this.itinerary.getBackground().setAlpha((int) (80.0d * VentanaFlotante.this.escala));
                    VentanaFlotante.this.array = null;
                    Toast.makeText(VentanaFlotante.this, VentanaFlotante.this.getResources().getString(R.string.stopRoute), 0).show();
                    VentanaFlotante.this.velocidad = Double.parseDouble(VentanaFlotante.this.pref.getString("velocidadX1", "10"));
                    VentanaFlotante.this.MperSec = 0.0f;
                    VentanaFlotante.this.pause = true;
                }
                try {
                    String latlon = coordinates.getText().toString();
                    if (!latlon.equals("")) {
                        String latlon2 = coordinates.getText().toString();
                        Pattern compiledPattern2 = Pattern.compile("([+-]?\\d+\\.?\\d+)\\s*,\\s*([+-]?\\d+\\.?\\d+)", 2);
                        Matcher matcher2 = compiledPattern2.matcher(latlon2);
                        if (matcher2.find()) {
                            try {
                                String[] separated = matcher2.group().split(",");
                                Toast.makeText(VentanaFlotante.this, VentanaFlotante.this.getResources().getString(R.string.validMapCoords), 0).show();
                                VentanaFlotante.this.latitude = Double.valueOf(separated[0].trim()).doubleValue();
                                VentanaFlotante.this.longitude = Double.valueOf(separated[1].trim()).doubleValue();
                                if (VentanaFlotante.this.joy) {
                                    VentanaFlotante.this.texto1.setText("Lat: " + ((float) VentanaFlotante.this.latitude) + ", Lng: " + ((float) VentanaFlotante.this.longitude));
                                }
                            } catch (Exception e) {
                            }
                        } else {
                            Toast.makeText(VentanaFlotante.this, VentanaFlotante.this.getResources().getString(R.string.invalidMapCoords), 0).show();
                        }
                    } else {
                        Toast.makeText(VentanaFlotante.this, VentanaFlotante.this.getResources().getString(R.string.invalidMapCoords), 0).show();
                    }
                } catch (Exception e2) {
                }
                alert.dismiss();
            }
        });
        home.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                VentanaFlotante.this.latitude = Double.valueOf(VentanaFlotante.this.sharedpreferences.getString("latHome", "")).doubleValue();
                VentanaFlotante.this.longitude = Double.valueOf(VentanaFlotante.this.sharedpreferences.getString("longHome", "")).doubleValue();
                if (VentanaFlotante.this.joy) {
                    VentanaFlotante.this.texto1.setText("Lat: " + ((float) VentanaFlotante.this.latitude) + ", Lng: " + ((float) VentanaFlotante.this.longitude));
                }
                alert.dismiss();
            }
        });
        exit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                alert.dismiss();
            }
        });
        walk.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                AsyncHttpClient prueba = new AsyncHttpClient();
                String ua = new WebView(VentanaFlotante.this.context).getSettings().getUserAgentString();
                prueba.setUserAgent(ua);
                prueba.addHeader("User-Agent", ua);
                prueba.addHeader(HttpHeaders.ACCEPT, "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
                prueba.addHeader(HttpHeaders.ACCEPT_LANGUAGE, "zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3");
                prueba.addHeader("Accept-Encoding", "gzip, deflate");
                prueba.addHeader(HttpHeaders.REFERER, "http://datacomputer.cl");
                prueba.addHeader("Connection", "keep-alive");
                RequestParams params = new RequestParams();
                prueba.get("https://maps.googleapis.com/maps/api/directions/json?origin=" + VentanaFlotante.this.latitude + "," + VentanaFlotante.this.longitude + "&destination=" + coordinates.getText().toString() + "&key=" + VentanaFlotante.this.getResources().getString(R.string.google_directions_key), params, new AsyncHttpResponseHandler() {
                    @Override
                    public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                        try {
                            String asd = new String(responseBody, "UTF-8");
                            List<Route> a = VentanaFlotante.this.parseJSon(asd);
                            String[] arrayd = new String[a.get(0).points.size()];
                            for (int i = 0; i < a.get(0).points.size(); i++) {
                                arrayd[i] = a.get(0).points.get(i).latitude + ", " + a.get(0).points.get(i).longitude;
                            }
                            Bundle b = new Bundle();
                            VentanaFlotante.this.fromWalkTo = true;
                            b.putStringArray("Array", arrayd);
                            VentanaFlotante.this.intentService.putExtras(b);
                            VentanaFlotante.this.array = arrayd;
                            VentanaFlotante.this.speed.setText("" + ((int) VentanaFlotante.this.speedKM));
                            alert.dismiss();
                            VentanaFlotante.this.yes = true;
                            Toast.makeText(VentanaFlotante.this.context, "Walk to, started", 0).show();
                        } catch (UnsupportedEncodingException e) {
                            e.printStackTrace();
                        } catch (JSONException e2) {
                            e2.printStackTrace();
                        }
                    }

                    @Override
                    public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                        if (statusCode == 404) {
                            Toast.makeText(VentanaFlotante.this.getApplicationContext(), "Requested resource not found", 1).show();
                        } else if (statusCode == 500) {
                            Toast.makeText(VentanaFlotante.this.getApplicationContext(), "Something went wrong at server end", 1).show();
                        } else {
                            Toast.makeText(VentanaFlotante.this.getApplicationContext(), "Unexpected Error occcured! [Most common Error: Device might not be connected to Internet]", 1).show();
                        }
                    }
                });
            }
        });
        alert.getWindow().setType(2003);
        alert.getWindow().setSoftInputMode(5);
        alert.getWindow().setGravity(48);
        alert.show();
    }

    public List<Route> parseJSon(String data) throws JSONException {
        if (data == null) {
            return null;
        }
        List<Route> routes = new ArrayList<>();
        JSONObject jsonData = new JSONObject(data);
        JSONArray jsonRoutes = jsonData.getJSONArray("routes");
        for (int i = 0; i < jsonRoutes.length(); i++) {
            JSONObject jsonRoute = jsonRoutes.getJSONObject(i);
            Route route = new Route();
            JSONObject overview_polylineJson = jsonRoute.getJSONObject("overview_polyline");
            JSONArray jsonLegs = jsonRoute.getJSONArray("legs");
            JSONObject jsonLeg = jsonLegs.getJSONObject(0);
            JSONObject jsonDistance = jsonLeg.getJSONObject("distance");
            JSONObject jsonDuration = jsonLeg.getJSONObject("duration");
            JSONObject jsonEndLocation = jsonLeg.getJSONObject("end_location");
            JSONObject jsonStartLocation = jsonLeg.getJSONObject("start_location");
            route.distance = new Distance(jsonDistance.getString("text"), jsonDistance.getInt(FirebaseAnalytics.Param.VALUE));
            route.duration = new Duration(jsonDuration.getString("text"), jsonDuration.getInt(FirebaseAnalytics.Param.VALUE));
            route.endAddress = jsonLeg.getString("end_address");
            route.startAddress = jsonLeg.getString("start_address");
            route.startLocation = new LatLng(jsonStartLocation.getDouble("lat"), jsonStartLocation.getDouble("lng"));
            route.endLocation = new LatLng(jsonEndLocation.getDouble("lat"), jsonEndLocation.getDouble("lng"));
            route.points = decodePolyLine(overview_polylineJson.getString("points"));
            routes.add(route);
        }
        return routes;
    }

    public Boolean checkInternet() {
        ConnectivityManager conMgr = (ConnectivityManager) getSystemService("connectivity");
        NetworkInfo i = conMgr.getActiveNetworkInfo();
        if (i != null && i.isConnected() && i.isAvailable()) {
            return true;
        }
        return false;
    }

    private List<LatLng> decodePolyLine(String poly) {
        int index;
        int b;
        int len = poly.length();
        int index2 = 0;
        List<LatLng> decoded = new ArrayList<>();
        int lat = 0;
        int lng = 0;
        while (index2 < len) {
            int shift = 0;
            int result = 0;
            while (true) {
                index = index2 + 1;
                int b2 = poly.charAt(index2) - '?';
                result |= (b2 & 31) << shift;
                shift += 5;
                if (b2 < 32) {
                    break;
                }
                index2 = index;
            }
            int dlat = (result & 1) != 0 ? (result >> 1) ^ (-1) : result >> 1;
            lat += dlat;
            int shift2 = 0;
            int result2 = 0;
            do {
                int index3 = index;
                index = index3 + 1;
                b = poly.charAt(index3) - '?';
                result2 |= (b & 31) << shift2;
                shift2 += 5;
            } while (b >= 32);
            int dlng = (result2 & 1) != 0 ? (result2 >> 1) ^ (-1) : result2 >> 1;
            lng += dlng;
            decoded.add(new LatLng(lat / 100000.0d, lng / 100000.0d));
            index2 = index;
        }
        return decoded;
    }

    public void createDialog() {
        final EditText input = new EditText(this);
        input.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
            @Override
            public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            @Override
            public void onDestroyActionMode(ActionMode mode) {
            }

            @Override
            public boolean onCreateActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            @Override
            public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
                return false;
            }
        });
        input.setTextIsSelectable(false);
        if (this.pref.getBoolean("keyboardQwerty", false)) {
            input.setRawInputType(2);
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AlertDialogCustomThemeDos));
        builder.setTitle("PokeSniper");
        builder.setIcon(R.drawable.mapicon);
        builder.setMessage(getResources().getString(R.string.setCoords));
        builder.setView(input);
        builder.setPositiveButton(getResources().getString(R.string.go), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int i) {
                if (VentanaFlotante.this.array != null) {
                    SharedPreferences.Editor edit = VentanaFlotante.this.sharedpreferences.edit();
                    edit.putString("latHome", String.valueOf(VentanaFlotante.this.curLat));
                    edit.putString("longHome", String.valueOf(VentanaFlotante.this.curLng));
                    edit.commit();
                    VentanaFlotante.this.speed.setText("X1");
                    VentanaFlotante.this.itinerary.setBackgroundResource(R.drawable.ic_play);
                    VentanaFlotante.this.itinerary.getBackground().setAlpha((int) (80.0d * VentanaFlotante.this.escala));
                    VentanaFlotante.this.array = null;
                    Toast.makeText(VentanaFlotante.this, VentanaFlotante.this.getResources().getString(R.string.stopRoute), 0).show();
                    VentanaFlotante.this.velocidad = Double.parseDouble(VentanaFlotante.this.pref.getString("velocidadX1", "10"));
                    VentanaFlotante.this.MperSec = 0.0f;
                    VentanaFlotante.this.pause = true;
                }
                try {
                    String latlon = input.getText().toString();
                    if (!latlon.equals("")) {
                        String latlon2 = input.getText().toString();
                        Pattern compiledPattern2 = Pattern.compile("([+-]?\\d+\\.?\\d+)\\s*,\\s*([+-]?\\d+\\.?\\d+)", 2);
                        Matcher matcher2 = compiledPattern2.matcher(latlon2);
                        if (matcher2.find()) {
                            try {
                                String[] separated = matcher2.group().split(",");
                                Toast.makeText(VentanaFlotante.this, VentanaFlotante.this.getResources().getString(R.string.validMapCoords), 0).show();
                                VentanaFlotante.this.latitude = Double.valueOf(separated[0].trim()).doubleValue();
                                VentanaFlotante.this.longitude = Double.valueOf(separated[1].trim()).doubleValue();
                                if (VentanaFlotante.this.joy) {
                                    VentanaFlotante.this.texto1.setText("Lat: " + ((float) VentanaFlotante.this.latitude) + ", Lng: " + ((float) VentanaFlotante.this.longitude));
                                }
                            } catch (Exception e) {
                            }
                        } else {
                            Toast.makeText(VentanaFlotante.this, VentanaFlotante.this.getResources().getString(R.string.invalidMapCoords), 0).show();
                        }
                    } else {
                        Toast.makeText(VentanaFlotante.this, VentanaFlotante.this.getResources().getString(R.string.invalidMapCoords), 0).show();
                    }
                } catch (Exception e2) {
                }
                dialog.dismiss();
            }
        });
        builder.setNegativeButton(getResources().getString(R.string.close), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int i) {
                dialog.dismiss();
            }
        });
        builder.setNeutralButton(getResources().getString(R.string.goHome), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int id) {
                VentanaFlotante.this.latitude = Double.valueOf(VentanaFlotante.this.sharedpreferences.getString("latHome", "")).doubleValue();
                VentanaFlotante.this.longitude = Double.valueOf(VentanaFlotante.this.sharedpreferences.getString("longHome", "")).doubleValue();
                if (VentanaFlotante.this.joy) {
                    VentanaFlotante.this.texto1.setText("Lat: " + ((float) VentanaFlotante.this.latitude) + ", Lng: " + ((float) VentanaFlotante.this.longitude));
                }
                dialog.dismiss();
            }
        });
        AlertDialog alert = builder.create();
        input.requestFocus();
        alert.getWindow().setGravity(48);
        alert.getWindow().setSoftInputMode(4);
        alert.getWindow().setType(2003);
        alert.show();
    }

    public void createDialogKmPorHora() {
        final EditText input = new EditText(this);
        input.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
            @Override
            public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            @Override
            public void onDestroyActionMode(ActionMode mode) {
            }

            @Override
            public boolean onCreateActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            @Override
            public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
                return false;
            }
        });
        input.setTextIsSelectable(false);
        AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AlertDialogCustomThemeDos));
        builder.setTitle(getResources().getString(R.string.itiSpeed));
        builder.setIcon(R.drawable.ic_speed);
        builder.setMessage(getResources().getString(R.string.setSpeedInKM));
        builder.setView(input);
        builder.setPositiveButton(getResources().getString(R.string.go), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int i) {
                try {
                    VentanaFlotante.this.speedKM = Integer.valueOf(input.getText().toString()).intValue();
                    VentanaFlotante.this.speed.setText("" + ((int) VentanaFlotante.this.speedKM));
                } catch (Exception e) {
                    VentanaFlotante.this.speedKM = 10.0d;
                    VentanaFlotante.this.speed.setText("" + ((int) VentanaFlotante.this.speedKM));
                }
                VentanaFlotante.this.speedChanged = true;
                dialog.dismiss();
            }
        });
        builder.setNegativeButton(getResources().getString(R.string.close), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int i) {
                dialog.dismiss();
            }
        });
        AlertDialog alert = builder.create();
        input.requestFocus();
        alert.getWindow().setGravity(48);
        alert.getWindow().setSoftInputMode(4);
        alert.getWindow().setType(2003);
        alert.show();
    }

    private void inicializarGPS() {
        notificationExample();
        try {
            this.thread.start();
            this.unSegundo.start();
        } catch (Exception e) {
            Log.e("error en el TryCatch", e.toString());
        }
    }

    public void cerrarApp() {
        try {
            if (Build.VERSION.SDK_INT >= 23) {
                onMockStop();
            } else if (Build.VERSION.SDK_INT <= 22) {
                try {
                    this.locationManager.removeTestProvider(LocationManager.GPS_PROVIDER);
                    this.locationManager.removeTestProvider(LocationManager.NETWORK_PROVIDER);
                    au();
                    Settings.Secure.putInt(getContentResolver(), "mock_location", 0);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        } catch (Exception e2) {
        }
    }

    @Override
    public void onDestroy() {
        if (this.stoppedByButton) {
            cerrarApp();
            stopForeground(true);
            stopSelf();
            System.exit(0);
        } else {
            cerrarApp();
            stopForeground(true);
            stopSelf();
            System.exit(0);
        }
        super.onDestroy();
    }

    private int setMockLocationSettings() {
        int value = 1;
        try {
            value = Settings.Secure.getInt(getContentResolver(), "mock_location");
            Settings.Secure.putInt(getContentResolver(), "mock_location", 1);
            return value;
        } catch (Exception e) {
            e.printStackTrace();
            return value;
        }
    }

    private void restoreMockLocationSettings(int restore_value) {
        try {
            Settings.Secure.putInt(getContentResolver(), "mock_location", restore_value);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static boolean aa(Context context) {
        return context.checkCallingOrSelfPermission("android.permission.INSTALL_LOCATION_PROVIDER") == 0;
    }

    public void onMockStart() {
        if (this.pref.getBoolean("new_method_switch", false)) {
            this.mHandler.removeMessages(0);
            this.test = new Location(LocationManager.GPS_PROVIDER);
            removeProvider();
            this.mHandler.sendEmptyMessageDelayed(0, this.MOCK_UPDATE_TIMER);
            return;
        }
        this._handler.removeMessages(0);
        if (aa(getApplicationContext())) {
            try {
                Field declaredField = Class.forName(this.locationManager.getClass().getName()).getDeclaredField("mService");
                declaredField.setAccessible(true);
                this.m = (ILocationManager) declaredField.get(this.locationManager);
            } catch (Exception e) {
            }
        }
        this.test = new Location(LocationManager.GPS_PROVIDER);
        if (!comprobarSource(this)) {
            removeProvider();
            addProvider();
        }
        setLocation();
    }

    public void nuevoMetodo() {
        try {
            this.locationManager.addTestProvider(LocationManager.NETWORK_PROVIDER, true, true, false, false, false, false, false, 1, 1);
            if (!this.locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
                this.locationManager.setTestProviderEnabled(LocationManager.NETWORK_PROVIDER, true);
                this.locationManager.setTestProviderStatus(LocationManager.NETWORK_PROVIDER, 2, null, System.currentTimeMillis());
            }
            if (!this.onPause) {
                this.locationManager = (LocationManager) getSystemService("location");
                if (this.array != null) {
                    if (!this.ejecutado) {
                        this.itinerary.setBackgroundResource(R.drawable.ic_pause);
                        this.itinerary.getBackground().setAlpha((int) (80.0d * this.escala));
                        ejecutarItinerario();
                        this.ejecutado = true;
                    }
                } else {
                    this.test.setLatitude(this.latitude);
                    this.test.setLongitude(this.longitude);
                }
                this.test.setAltitude(0.0d);
                this.test.setBearing(this.curBearing);
                this.test.setAccuracy(new Random().nextInt(20) + 1);
                this.test.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
                this.test.setTime(System.currentTimeMillis());
                this.k = new Bundle();
                this.k.putString("networkLocationType", "cell");
                this.k.putInt("satellites", 99999);
                this.test.setExtras(this.k);
                try {
                    this.locationManager.setTestProviderStatus(LocationManager.NETWORK_PROVIDER, 2, null, System.currentTimeMillis());
                    this.locationManager.setTestProviderLocation(LocationManager.NETWORK_PROVIDER, this.test);
                } catch (Exception e) {
                }
            }
            removeProvider();
        } catch (Exception e2) {
        }
    }

    public void removeProvider() {
        for (String provider : MOCK_PROVIDER) {
            try {
                if (this.locationManager.isProviderEnabled(provider)) {
                    this.locationManager.removeTestProvider(provider);
                }
            } catch (Exception e) {
            }
        }
    }

    public void addProvider() {
        try {
            String provider = getProvider();
            this.method = Location.class.getMethod("makeComplete", new Class[0]);
            if (this.method != null) {
                try {
                    try {
                        this.method.invoke(this.test, new Object[0]);
                    } catch (IllegalArgumentException e) {
                        e.printStackTrace();
                    }
                } catch (IllegalAccessException e2) {
                    e2.printStackTrace();
                } catch (InvocationTargetException e3) {
                    e3.printStackTrace();
                }
            }
            this.locationManager.addTestProvider(provider, false, false, false, false, false, false, false, 1, 1);
            if (!this.locationManager.isProviderEnabled(provider)) {
                this.locationManager.setTestProviderEnabled(provider, true);
                this.locationManager.setTestProviderStatus(provider, 2, null, System.currentTimeMillis());
            }
        } catch (Exception e4) {
        }
    }

    public String getProvider() {
        return LocationManager.NETWORK_PROVIDER;
    }

    public void setLocation() {
        if (!this.onPause) {
            this.locationManager = (LocationManager) getSystemService("location");
            if (this.array != null) {
                if (!this.ejecutado) {
                    this.itinerary.setBackgroundResource(R.drawable.ic_pause);
                    this.itinerary.getBackground().setAlpha((int) (80.0d * this.escala));
                    ejecutarItinerario();
                    this.ejecutado = true;
                }
            } else {
                this.test.setLatitude(this.latitude);
                this.test.setLongitude(this.longitude);
            }
            this.test.setAltitude(0.0d);
            this.test.setBearing(this.curBearing);
            this.test.setAccuracy(new Random().nextInt(20) + 1);
            this.test.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
            this.test.setTime(System.currentTimeMillis());
            this.k = new Bundle();
            this.k.putString("networkLocationType", "cell");
            this.k.putInt("satellites", 10);
            this.test.setExtras(this.k);
            if (this.m == null) {
                for (String str : MOCK_PROVIDER) {
                    try {
                        this.locationManager.setTestProviderStatus(str, 2, null, System.currentTimeMillis());
                        this.locationManager.setTestProviderLocation(str, this.test);
                    } catch (Exception e) {
                    }
                }
            } else {
                try {
                    this.l = Location.class.getMethod("makeComplete", new Class[0]);
                    this.l.invoke(this.test, new Object[0]);
                } catch (Exception e2) {
                }
                try {
                    this.m.reportLocation(this.test, false);
                } catch (Exception e3) {
                }
            }
            this._handler.sendEmptyMessageDelayed(0, this.MOCK_UPDATE_TIMER);
        }
    }

    public void guardarUbicacion() {
        SharedPreferences.Editor editor = this.sharedpreferences.edit();
        SharedPreferences.Editor editor2 = this.mapStatePrefs.edit();
        editor.putString(PokestopsContract.PokeStopEntry.latitude, String.valueOf(this.latitude));
        editor.putString(PokestopsContract.PokeStopEntry.longitude, String.valueOf(this.longitude));
        editor2.putString(PokestopsContract.PokeStopEntry.latitude, String.valueOf(this.latitude));
        editor2.putString(PokestopsContract.PokeStopEntry.longitude, String.valueOf(this.longitude));
        editor.commit();
        editor2.commit();
    }

    public static boolean comprobarSource(Context context) {
        return (context.getApplicationInfo().flags & UrlQuerySanitizer.IllegalCharacterValueSanitizer.AMP_AND_SPACE_LEGAL) != 0;
    }

    public static boolean a(Context paramContext) {
        return paramContext.checkCallingOrSelfPermission("android.permission.INSTALL_LOCATION_PROVIDER") == 0;
    }

    protected static boolean a(int paramInt, Context paramContext) {
        try {
            return Settings.Secure.putInt(paramContext.getContentResolver(), "mock_location", paramInt);
        } catch (Exception e) {
            return false;
        }
    }

    public static boolean b(Context paramContext) {
        String localObject2 = paramContext.getPackageName();
        PackageManager localPackageManager = paramContext.getPackageManager();
        try {
            ApplicationInfo localObject22 = localPackageManager.getApplicationInfo(localObject2, 128);
            if (localObject22 == null) {
            }
            if (!localObject22.sourceDir.startsWith("/system/app/")) {
                ApplicationInfo localObject1 = localObject22;
                if (!localObject1.sourceDir.startsWith("/system/priv-app/") && !a(paramContext)) {
                    return false;
                }
            }
            return true;
        } catch (Throwable th) {
            while (true) {
            }
        }
    }

    protected static int e(Context paramContext) {
        try {
            return Settings.Secure.getInt(paramContext.getContentResolver(), "mock_location");
        } catch (Settings.SettingNotFoundException e) {
            return 0;
        }
    }

    public void au() {
        this.locationManager = (LocationManager) getSystemService("location");
        try {
            if (a(this)) {
                Field declaredField = Class.forName(this.locationManager.getClass().getName()).getDeclaredField("mService");
                declaredField.setAccessible(true);
                this.m = (ILocationManager) declaredField.get(this.locationManager);
            }
        } catch (ClassNotFoundException e2) {
            e2.printStackTrace();
        } catch (IllegalAccessException e4) {
            e4.printStackTrace();
        } catch (IllegalArgumentException e3) {
            e3.printStackTrace();
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (Exception e5) {
        }
    }

    public void testHoldSwipe() {
        try {
            Process process = Runtime.getRuntime().exec("su");
            DataOutputStream os = new DataOutputStream(process.getOutputStream());
            os.writeBytes("/system/bin/input swipe 200 200 900 200\n");
            os.writeBytes("exit\n");
            os.flush();
            os.close();
        } catch (Exception e) {
        }
    }

    public DisplayMetrics displaySize() {
        DisplayMetrics displaymetrics = new DisplayMetrics();
        this.wm = (WindowManager) getSystemService("window");
        this.wm.getDefaultDisplay().getMetrics(displaymetrics);
        return displaymetrics;
    }

    public void suTimer() {
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        try {
            if (this.unaVez) {
                this.unaVez = false;
                this.intentService = intent;
            }
            Bundle b = this.intentService.getExtras();
            this.array = b.getStringArray("Array");
            this.speedKM = b.getInt("speedKM");
            if (this.speedKM == 0.0d) {
                this.speedKM = 10.0d;
            }
            if (this.array != null) {
                this.itinerary.setBackgroundResource(R.drawable.ic_pause);
                this.itinerary.getBackground().setAlpha((int) (this.escala * 80.0d));
                this.speed.setText("" + ((int) this.speedKM));
            }
            if (!this.pref.getBoolean("circle_switch", false)) {
                if (new Bundle(this.intentService.getExtras()).getStringArray("Array") != null) {
                }
            }
        } catch (NullPointerException e) {
        }
        if (intent != null) {
            try {
                if (intent.getAction().toString().equals("STOP")) {
                    this.stoppedByButton = true;
                    a(1, getApplicationContext());
                    try {
                        if (Build.VERSION.SDK_INT >= 23) {
                            onMockStop();
                        } else {
                            this.locationManager.removeTestProvider(LocationManager.GPS_PROVIDER);
                            this.locationManager.removeTestProvider(LocationManager.NETWORK_PROVIDER);
                        }
                        a(0, getApplicationContext());
                    } catch (Exception e2) {
                    }
                    stopSelf();
                } else if (intent.getAction().toString().equals("PAUSE")) {
                    this.ll.setVisibility(4);
                    this.ll2.setVisibility(4);
                    if (!this.isAutoWalk || Build.VERSION.SDK_INT >= 23) {
                    }
                } else if (intent.getAction().toString().equals("PLAY")) {
                    this.ll.setVisibility(0);
                    this.ll2.setVisibility(0);
                    if (new Bundle(this.intentService.getExtras()).getStringArray("Array") != null) {
                        if (this.pause) {
                            this.speed.setText("X1");
                            this.itinerary.setBackgroundResource(R.drawable.ic_play);
                            this.itinerary.getBackground().setAlpha((int) (this.escala * 80.0d));
                            this.array = null;
                        } else {
                            this.speed.setText("" + ((int) this.speedKM));
                            this.itinerary.setBackgroundResource(R.drawable.ic_pause);
                            this.itinerary.getBackground().setAlpha((int) (this.escala * 80.0d));
                        }
                    }
                    if (Build.VERSION.SDK_INT >= 23) {
                    }
                    this.isAutoWalk = this.pref.getBoolean("isAutoWalkP", false);
                    if (this.isAutoWalk) {
                    }
                }
            } catch (Exception e3) {
            }
        }
        return 1;
    }

    public void ejecutarItinerario() {
        this.itinerario.start();
    }

    public void notificationExample() {
        Notification notification = null;
        Intent intentMain = new Intent(this, (Class<?>) MainActivity.class);
        intentMain.setFlags(603979776);
        Intent intentPause = new Intent(this, (Class<?>) VentanaFlotante.class);
        Intent intentStop = new Intent(this, (Class<?>) VentanaFlotante.class);
        Intent intentPlay = new Intent(this, (Class<?>) VentanaFlotante.class);
        intentStop.setAction("STOP");
        intentPause.setAction("PAUSE");
        intentPlay.setAction("PLAY");
        PendingIntent pendingIntentSt = PendingIntent.getService(this, 0, intentStop, 0);
        PendingIntent pendingIntentPs = PendingIntent.getService(this, 0, intentPause, 0);
        PendingIntent pendingIntentPl = PendingIntent.getService(this, 0, intentPlay, 268435456);
        PendingIntent pendIntent = PendingIntent.getActivity(this, 0, intentMain, 0);
        if (Build.VERSION.SDK_INT > 23) {
            NotificationCompat.Action stop = new NotificationCompat.Action.Builder(R.drawable.ic_close_dark, HTTP.CONN_CLOSE, pendingIntentSt).build();
            NotificationCompat.Action play = new NotificationCompat.Action.Builder(R.drawable.ic_media_play, "Play", pendingIntentPl).build();
            NotificationCompat.Action pause = new NotificationCompat.Action.Builder(R.drawable.ic_media_pause, "Pause", pendingIntentPs).build();
            NotificationCompat.Builder n = new NotificationCompat.Builder(this).setAutoCancel(false).setContentTitle("NewGPS!").setContentIntent(pendIntent).setStyle(new NotificationCompat.BigTextStyle().bigText("Service Started, Press here to open map")).setDefaults(2).setPriority(2).addAction(pause).addAction(play).addAction(stop);
            if (this.pref.getBoolean("icon_switch", false)) {
                n.setSmallIcon(R.drawable.ic_launcher_music);
            } else {
                n.setSmallIcon(R.drawable.ic_launcher);
            }
            notification = n.build();
        } else if (Build.VERSION.SDK_INT >= 18) {
            NotificationCompat.Action stop2 = new NotificationCompat.Action.Builder(R.drawable.ic_close_dark, "", pendingIntentSt).build();
            NotificationCompat.Action play2 = new NotificationCompat.Action.Builder(R.drawable.ic_media_play, "", pendingIntentPl).build();
            NotificationCompat.Action pause2 = new NotificationCompat.Action.Builder(R.drawable.ic_media_pause, "", pendingIntentPs).build();
            NotificationCompat.Builder n2 = new NotificationCompat.Builder(this).setAutoCancel(false).setContentTitle("NewGPS!").setContentIntent(pendIntent).setStyle(new NotificationCompat.BigTextStyle().bigText("Service Started, Press here to open map")).setDefaults(2).setPriority(2).addAction(pause2).addAction(play2).addAction(stop2);
            if (this.pref.getBoolean("icon_switch", false)) {
                n2.setSmallIcon(R.drawable.ic_launcher_music);
            } else {
                n2.setSmallIcon(R.drawable.ic_launcher);
            }
            notification = n2.build();
        }
        notification.flags |= 64;
        startForeground(myID, notification);
    }

    public void Pruebas() {
    }

    public double getDistanceFromLatLonInKm(double lat1, double lon1, double lat2, double lon2) {
        double dLat = deg2rad(lat2 - lat1);
        double dLon = deg2rad(lon2 - lon1);
        double a = (Math.sin(dLat / 2.0d) * Math.sin(dLat / 2.0d)) + (Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * Math.sin(dLon / 2.0d) * Math.sin(dLon / 2.0d));
        double c = 2.0d * Math.atan2(Math.sqrt(a), Math.sqrt(1.0d - a));
        double d = 6371 * c;
        return d;
    }

    public double deg2rad(double deg) {
        return 0.017453292519943295d * deg;
    }
}