Mew v1.1.3版本的 MD5 值为:2c97fc89b634adccdf2e096067417e16
以下内容为反编译后的 MapsIntineraryViewActivity.java 源代码,内容仅作参考
package cl.datacomputer.alejandrob.newgpsjoysticl;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.location.Location;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v4.internal.view.SupportMenu;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.Toast;
import cl.datacomputer.alejandrob.newgpsjoysticl.sqlite.data.PokestopsContract;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
import cz.msebera.android.httpclient.client.methods.HttpPost;
import cz.msebera.android.httpclient.client.utils.URLEncodedUtils;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class MapsIntineraryViewActivity extends Fragment implements OnMapReadyCallback, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
private static final String PREFS_NAME = "mapCameraState";
private GoogleApiClient mGoogleApiClient;
private Location mLastLocation;
private double mLatitude;
private double mLongitude;
private SharedPreferences mapStatePrefs;
private JSONArray pokestops = null;
private JSONArray gyms = null;
private boolean first = true;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
try {
if (this.mGoogleApiClient == null) {
this.mGoogleApiClient = new GoogleApiClient.Builder(getActivity().getApplicationContext()).addConnectionCallbacks(this).addOnConnectionFailedListener(this).addApi(LocationServices.API).build();
}
} catch (Exception e) {
}
View view = inflater.inflate(R.layout.content_maps, container, false);
SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
setupMapIfNeeded();
return view;
}
@Override
public void onMapReady(GoogleMap googleMap) {
if (((MainActivity) getActivity()).historyActions != null) {
((MainActivity) getActivity()).historyActions.hide();
}
if (((MainActivity) getActivity()).fab != null) {
((MainActivity) getActivity()).fab.show();
}
if (((MainActivity) getActivity()).save != null) {
((MainActivity) getActivity()).save.show();
}
((MainActivity) getActivity()).setmMap(googleMap);
((MainActivity) getActivity()).getmMap().getUiSettings().setZoomControlsEnabled(true);
((MainActivity) getActivity()).getmMap().getUiSettings().setMapToolbarEnabled(true);
if (ContextCompat.checkSelfPermission(getContext(), "android.permission.ACCESS_FINE_LOCATION") == 0) {
((MainActivity) getActivity()).getmMap().setMyLocationEnabled(true);
}
if (this.first) {
cargarFavoritos(((MainActivity) getActivity()).getmMap());
this.first = false;
}
}
public void markers() {
boolean ll;
float color;
if (((MainActivity) getActivity()).isReEditItineraries()) {
((MainActivity) getActivity()).setDesdeCardView(false);
((MainActivity) getActivity()).setReEditItineraries(false);
((MainActivity) getActivity()).getMarkers().size();
((MainActivity) getActivity()).setFirst(false);
int i = 0;
((MainActivity) getActivity()).setTemporal(new LatLng(((MainActivity) getActivity()).getResultsItinerarios().get(((MainActivity) getActivity()).getIdNuevo()).getPuntos().get(0).getPosition().getLatitude(), ((MainActivity) getActivity()).getResultsItinerarios().get(((MainActivity) getActivity()).getIdNuevo()).getPuntos().get(0).getPosition().getLongitude()));
for (Punto next : ((MainActivity) getActivity()).getResultsItinerarios().get(((MainActivity) getActivity()).getIdNuevo()).getPuntos()) {
Marker protocolo = ((MainActivity) getActivity()).getmMap().addMarker(new MarkerOptions().position(new LatLng(next.getPosition().getLatitude(), next.getPosition().getLongitude())).title("Marker Nº" + i).draggable(true));
((MainActivity) getActivity()).getMarkers().add(protocolo);
protocolo.showInfoWindow();
this.mLatitude = protocolo.getPosition().latitude;
this.mLongitude = protocolo.getPosition().longitude;
if (i > 0) {
Polyline polyline = ((MainActivity) getActivity()).getmMap().addPolyline(new PolylineOptions().add(((MainActivity) getActivity()).getTemporal(), new LatLng(next.getPosition().getLatitude(), next.getPosition().getLongitude())).width(5.0f).color(SupportMenu.CATEGORY_MASK));
((MainActivity) getActivity()).getPolylines().add(polyline);
((MainActivity) getActivity()).getPolylines().size();
((MainActivity) getActivity()).setTemporal(new LatLng(((MainActivity) getActivity()).getResultsItinerarios().get(((MainActivity) getActivity()).getIdNuevo()).getPuntos().get(i).getPosition().getLatitude(), ((MainActivity) getActivity()).getResultsItinerarios().get(((MainActivity) getActivity()).getIdNuevo()).getPuntos().get(i).getPosition().getLongitude()));
}
i++;
}
} else {
((MainActivity) getActivity()).setDesdeCardView(false);
((MainActivity) getActivity()).setReEditItineraries(false);
if (((MainActivity) getActivity()).getMarkersFromKML() != null) {
List<LatLng> temp = ((MainActivity) getActivity()).getMarkersFromKML();
int i2 = 0;
((MainActivity) getActivity()).setTemporal(((MainActivity) getActivity()).getMarkersFromKML().get(0));
for (LatLng marker : temp) {
if (temp.get(0).equals(marker) || temp.get(temp.size() - 1).equals(marker)) {
ll = true;
color = 30.0f;
} else {
color = 240.0f;
ll = false;
}
Marker protocolo2 = ((MainActivity) getActivity()).getmMap().addMarker(new MarkerOptions().position(new LatLng(marker.latitude, marker.longitude)).title("Marker Nº" + i2).draggable(true).visible(ll).icon(BitmapDescriptorFactory.defaultMarker(color)));
((MainActivity) getActivity()).getMarkers().add(protocolo2);
protocolo2.showInfoWindow();
this.mLatitude = protocolo2.getPosition().latitude;
this.mLongitude = protocolo2.getPosition().longitude;
if (i2 > 0) {
Polyline polyline2 = ((MainActivity) getActivity()).getmMap().addPolyline(new PolylineOptions().add(((MainActivity) getActivity()).getTemporal(), new LatLng(marker.latitude, marker.longitude)).width(5.0f).color(-16776961));
((MainActivity) getActivity()).getPolylines().add(polyline2);
((MainActivity) getActivity()).getPolylines().size();
((MainActivity) getActivity()).setTemporal(((MainActivity) getActivity()).getMarkersFromKML().get(i2));
}
i2++;
}
((MainActivity) getActivity()).setMarkersFromKML(null);
}
}
LatLng mapCenter = new LatLng(this.mLatitude, this.mLongitude);
((MainActivity) getActivity()).getmMap().moveCamera(CameraUpdateFactory.newLatLngZoom(mapCenter, 17.0f));
((MainActivity) getActivity()).getmMap().setOnCameraIdleListener(new GoogleMap.OnCameraIdleListener() {
@Override
public void onCameraIdle() {
ArrayList<HashMap<String, String>> latLnglocations;
ArrayList<HashMap<String, String>> latLnggyms;
if (!MapsIntineraryViewActivity.this.first) {
MapsIntineraryViewActivity.this.cargarFavoritos(((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getmMap());
}
if (((MainActivity) MapsIntineraryViewActivity.this.getActivity()).switchButton.isChecked()) {
Iterator<Marker> it = ((MainActivity) MapsIntineraryViewActivity.this.getActivity()).markersToClear.iterator();
while (it.hasNext()) {
Marker marker2 = it.next();
marker2.remove();
}
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).markersToClear.clear();
if (((MainActivity) MapsIntineraryViewActivity.this.getActivity()).sharedpreferences.getBoolean("switchGymStops", false)) {
latLnglocations = ((MainActivity) MapsIntineraryViewActivity.this.getActivity()).controller.getLocationsCooperativeWithLatLngBounds(((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getmMap().getProjection().getVisibleRegion().latLngBounds);
latLnggyms = ((MainActivity) MapsIntineraryViewActivity.this.getActivity()).gymController.getLocationsCooperativeWithLatLngBounds(((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getmMap().getProjection().getVisibleRegion().latLngBounds);
} else {
latLnglocations = ((MainActivity) MapsIntineraryViewActivity.this.getActivity()).controller.getLocationsWithLatLngBounds(((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getmMap().getProjection().getVisibleRegion().latLngBounds);
latLnggyms = ((MainActivity) MapsIntineraryViewActivity.this.getActivity()).gymController.getLocationsWithLatLngBounds(((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getmMap().getProjection().getVisibleRegion().latLngBounds);
}
LatLngBounds latLngBounds = ((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getmMap().getProjection().getVisibleRegion().latLngBounds;
if (latLnglocations != null && ((MainActivity) MapsIntineraryViewActivity.this.getActivity()).sharedpreferences.getBoolean("pokestops", false)) {
for (int i3 = 0; i3 < latLnglocations.size(); i3++) {
try {
HashMap<String, String> stop = latLnglocations.get(i3);
Marker asd = ((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getmMap().addMarker(new MarkerOptions().title(stop.get(PokestopsContract.PokeStopEntry.nombre) + ", (" + stop.get(PokestopsContract.PokeStopEntry.pokestop_id) + ")").snippet("Lat: " + stop.get(PokestopsContract.PokeStopEntry.latitude) + ", Long: " + stop.get(PokestopsContract.PokeStopEntry.longitude)).position(new LatLng(Double.valueOf(stop.get(PokestopsContract.PokeStopEntry.latitude)).doubleValue(), Double.valueOf(stop.get(PokestopsContract.PokeStopEntry.longitude)).doubleValue())).icon(BitmapDescriptorFactory.fromResource(R.drawable.stop)));
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).markersToClear.add(asd);
} catch (Exception e) {
e.printStackTrace();
}
}
}
if (latLnggyms != null && ((MainActivity) MapsIntineraryViewActivity.this.getActivity()).sharedpreferences.getBoolean("gyms", false)) {
for (int i4 = 0; i4 < latLnggyms.size(); i4++) {
try {
HashMap<String, String> gym = latLnggyms.get(i4);
Marker asd2 = ((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getmMap().addMarker(new MarkerOptions().title(gym.get(PokestopsContract.PokeStopEntry.nombre) + ", (" + gym.get("gym_id") + ")").snippet("Lat: " + gym.get(PokestopsContract.PokeStopEntry.latitude) + ", Long: " + gym.get(PokestopsContract.PokeStopEntry.longitude)).position(new LatLng(Double.valueOf(gym.get(PokestopsContract.PokeStopEntry.latitude)).doubleValue(), Double.valueOf(gym.get(PokestopsContract.PokeStopEntry.longitude)).doubleValue())).icon(BitmapDescriptorFactory.fromResource(R.drawable.gym)));
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).markersToClear.add(asd2);
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
}
}
});
((MainActivity) getActivity()).getmMap().setOnMapClickListener(new GoogleMap.OnMapClickListener() {
@Override
public void onMapClick(LatLng latLng) {
if (((MainActivity) MapsIntineraryViewActivity.this.getActivity()).switchButton.isChecked()) {
}
if (((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getFirst()) {
Marker marker2 = ((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getmMap().addMarker(new MarkerOptions().position(latLng).title("Marker Nº0").draggable(true));
marker2.showInfoWindow();
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getMarkers().add(marker2);
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getMarkers().size();
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).setFirst(false);
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).setTemporal(latLng);
return;
}
int n = ((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getMarkers().size();
Marker marker3 = ((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getmMap().addMarker(new MarkerOptions().position(latLng).title("Marker Nº" + n).draggable(true));
marker3.showInfoWindow();
int i3 = n + 1;
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getMarkers().add(marker3);
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getMarkers().size();
Polyline polyline3 = ((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getmMap().addPolyline(new PolylineOptions().add(((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getTemporal(), marker3.getPosition()).width(5.0f).color(SupportMenu.CATEGORY_MASK));
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getPolylines().add(polyline3);
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getPolylines().size();
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).setTemporal(latLng);
}
});
((MainActivity) getActivity()).getmMap().setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker2) {
if (((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getFirst()) {
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getMarkers().add(marker2);
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getMarkers().size();
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).setFirst(false);
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).setTemporal(marker2.getPosition());
} else {
int n = ((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getMarkers().size();
int i3 = n + 1;
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getMarkers().add(marker2);
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getMarkers().size();
Polyline polyline3 = ((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getmMap().addPolyline(new PolylineOptions().add(((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getTemporal(), marker2.getPosition()).width(5.0f).color(SupportMenu.CATEGORY_MASK));
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getPolylines().add(polyline3);
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getPolylines().size();
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).setTemporal(marker2.getPosition());
}
return true;
}
});
((MainActivity) getActivity()).getmMap().setOnMarkerDragListener(new GoogleMap.OnMarkerDragListener() {
@Override
public void onMarkerDragStart(Marker marker2) {
try {
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getPolylines().get(Integer.parseInt(marker2.getTitle().replace("Marker Nº", ""))).setVisible(false);
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getPolylines().get(Integer.parseInt(marker2.getTitle().replace("Marker Nº", "")) - 1).setVisible(false);
} catch (Exception e) {
try {
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getPolylines().get(Integer.parseInt(marker2.getTitle().replace("Marker Nº", "")) - 1).setVisible(false);
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getPolylines().get(Integer.parseInt(marker2.getTitle().replace("Marker Nº", ""))).setVisible(false);
} catch (Exception e2) {
}
}
}
@Override
public void onMarkerDrag(Marker marker2) {
}
@Override
public void onMarkerDragEnd(Marker marker2) {
if (Integer.parseInt(marker2.getTitle().replace("Marker Nº", "")) == ((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getMarkers().size() - 1) {
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).setTemporal(marker2.getPosition());
}
try {
List<LatLng> asd2 = new ArrayList<>();
asd2.add(marker2.getPosition());
asd2.add(((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getPolylines().get(Integer.parseInt(marker2.getTitle().replace("Marker Nº", ""))).getPoints().get(1));
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getPolylines().get(Integer.parseInt(marker2.getTitle().replace("Marker Nº", ""))).setPoints(asd2);
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getPolylines().get(Integer.parseInt(marker2.getTitle().replace("Marker Nº", ""))).setVisible(true);
List<LatLng> asd = new ArrayList<>();
asd.add(((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getPolylines().get(Integer.parseInt(marker2.getTitle().replace("Marker Nº", "")) - 1).getPoints().get(0));
asd.add(marker2.getPosition());
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getPolylines().get(Integer.parseInt(marker2.getTitle().replace("Marker Nº", "")) - 1).setPoints(asd);
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getPolylines().get(Integer.parseInt(marker2.getTitle().replace("Marker Nº", "")) - 1).setVisible(true);
} catch (Exception e) {
try {
List<LatLng> asd3 = new ArrayList<>();
asd3.add(((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getPolylines().get(Integer.parseInt(marker2.getTitle().replace("Marker Nº", "")) - 1).getPoints().get(0));
asd3.add(marker2.getPosition());
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getPolylines().get(Integer.parseInt(marker2.getTitle().replace("Marker Nº", "")) - 1).setPoints(asd3);
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getPolylines().get(Integer.parseInt(marker2.getTitle().replace("Marker Nº", "")) - 1).setVisible(true);
List<LatLng> asd22 = new ArrayList<>();
asd22.add(marker2.getPosition());
asd22.add(((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getPolylines().get(Integer.parseInt(marker2.getTitle().replace("Marker Nº", ""))).getPoints().get(1));
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getPolylines().get(Integer.parseInt(marker2.getTitle().replace("Marker Nº", ""))).setPoints(asd22);
((MainActivity) MapsIntineraryViewActivity.this.getActivity()).getPolylines().get(Integer.parseInt(marker2.getTitle().replace("Marker Nº", ""))).setVisible(true);
} catch (Exception e2) {
}
}
}
});
}
@Override
public void onPause() {
super.onPause();
}
@Override
public void onResume() {
super.onResume();
setupMapIfNeeded();
}
public void setupMapIfNeeded() {
if (((MainActivity) getActivity()).getmMap() == null) {
SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
}
@Override
public void onConnected(Bundle connectionHint) {
this.mLastLocation = LocationServices.FusedLocationApi.getLastLocation(this.mGoogleApiClient);
if (this.mLastLocation != null) {
this.mLatitude = this.mLastLocation.getLatitude();
this.mLongitude = this.mLastLocation.getLongitude();
if (((MainActivity) getActivity()).switchButton.isChecked()) {
}
}
markers();
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
}
@Override
public void onStart() {
this.mGoogleApiClient.connect();
super.onStart();
}
@Override
public void onStop() {
this.mGoogleApiClient.disconnect();
super.onStop();
}
protected void getPokeStops() {
String parameters = "latitude=" + this.mLatitude + "&longitude=" + this.mLongitude;
try {
URL url = new URL("http://datacomputer.cl/rest/pokeparadas.php");
try {
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", URLEncodedUtils.CONTENT_TYPE);
connection.setRequestMethod(HttpPost.METHOD_NAME);
OutputStreamWriter request = new OutputStreamWriter(connection.getOutputStream());
try {
request.write(parameters);
request.flush();
request.close();
InputStreamReader isr = new InputStreamReader(connection.getInputStream());
BufferedReader reader = new BufferedReader(isr);
StringBuilder sb = new StringBuilder();
while (true) {
String line = reader.readLine();
if (line != null) {
sb.append(line + "\n");
} else {
String response = sb.toString();
decodePokeStops(response);
isr.close();
reader.close();
return;
}
}
} catch (IOException e) {
}
} catch (IOException e2) {
}
} catch (IOException e3) {
}
}
protected void getGyms() {
String parameters = "latitude=" + this.mLatitude + "&longitude=" + this.mLongitude;
try {
URL url = new URL("http://datacomputer.cl/rest/gimnasios.php");
try {
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", URLEncodedUtils.CONTENT_TYPE);
connection.setRequestMethod(HttpPost.METHOD_NAME);
OutputStreamWriter request = new OutputStreamWriter(connection.getOutputStream());
try {
request.write(parameters);
request.flush();
request.close();
InputStreamReader isr = new InputStreamReader(connection.getInputStream());
BufferedReader reader = new BufferedReader(isr);
StringBuilder sb = new StringBuilder();
while (true) {
String line = reader.readLine();
if (line != null) {
sb.append(line + "\n");
} else {
String response = sb.toString();
decodeGyms(response);
isr.close();
reader.close();
return;
}
}
} catch (IOException e) {
}
} catch (IOException e2) {
}
} catch (IOException e3) {
}
}
protected InputStream getPokeStopsToKml() {
InputStream is = null;
String parameters = "latitude=" + this.mLastLocation.getLatitude() + "&longitude=" + this.mLastLocation.getLongitude();
try {
URL url = new URL("http://datacomputer.cl/rest/tokml.php");
try {
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", URLEncodedUtils.CONTENT_TYPE);
connection.setRequestMethod(HttpPost.METHOD_NAME);
OutputStreamWriter request = new OutputStreamWriter(connection.getOutputStream());
try {
request.write(parameters);
request.flush();
request.close();
InputStreamReader isr = new InputStreamReader(connection.getInputStream());
BufferedReader reader = new BufferedReader(isr);
StringBuilder sb = new StringBuilder();
while (true) {
String line = reader.readLine();
if (line == null) {
break;
}
sb.append(line + "\n");
}
String response = sb.toString();
if (Build.VERSION.SDK_INT >= 19) {
is = new ByteArrayInputStream(response.getBytes(StandardCharsets.UTF_8));
}
isr.close();
reader.close();
} catch (IOException e) {
}
} catch (IOException e2) {
}
} catch (IOException e3) {
}
return is;
}
public void decodePokeStops(CharSequence result) {
try {
JSONObject obj = new JSONObject(result.toString());
this.pokestops = obj.getJSONArray("info");
} catch (JSONException e) {
e.printStackTrace();
}
}
public void decodeGyms(CharSequence result) {
try {
JSONObject obj = new JSONObject(result.toString());
this.gyms = obj.getJSONArray("info");
} catch (JSONException e) {
e.printStackTrace();
}
}
private void createAlertMaterialDesign(String title, String message, String posButton, String negButton) {
String html = String.format("<html><body style=\"text-align: center; background-color: #5fa3d0;\"><img src = \"%s\"/></body></html>", "file:///android_res/drawable/devgif.gif");
AlertDialog.Builder builder = new AlertDialog.Builder((MainActivity) getActivity(), R.style.AppCompatAlertDialogStyle);
WebView view = new WebView((MainActivity) getActivity());
builder.setTitle(title);
builder.setView(view);
builder.setMessage(message);
builder.setPositiveButton(posButton, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
MapsIntineraryViewActivity.this.startActivity(new Intent().setClassName("com.android.settings", "com.android.settings.DevelopmentSettings"));
}
});
builder.setNegativeButton(negButton, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Toast.makeText((MainActivity) MapsIntineraryViewActivity.this.getActivity(), "If you don't enable NewGPS! as mock location app, it doesn't work...", 1).show();
}
});
builder.show();
view.getSettings().setUseWideViewPort(true);
view.getSettings().setLoadWithOverviewMode(true);
view.loadDataWithBaseURL("", html, "text/html", "UTF-8", "");
}
public void pokeStopsAndGymsToMap() {
if (this.pokestops != null) {
for (int i = 0; i < this.pokestops.length(); i++) {
try {
JSONObject stop = this.pokestops.getJSONObject(i);
if (!((MainActivity) getActivity()).getStopsAndGyms().contains(new MarkerOptions().position(new LatLng(Double.valueOf(stop.getString(PokestopsContract.PokeStopEntry.latitude)).doubleValue(), Double.valueOf(stop.getString(PokestopsContract.PokeStopEntry.longitude)).doubleValue())).icon(BitmapDescriptorFactory.fromResource(R.drawable.stop)).getPosition())) {
Marker asd = ((MainActivity) getActivity()).getmMap().addMarker(new MarkerOptions().position(new LatLng(Double.valueOf(stop.getString(PokestopsContract.PokeStopEntry.latitude)).doubleValue(), Double.valueOf(stop.getString(PokestopsContract.PokeStopEntry.longitude)).doubleValue())).icon(BitmapDescriptorFactory.fromResource(R.drawable.stop)));
((MainActivity) getActivity()).getStopsAndGyms().add(asd.getPosition());
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
if (this.gyms != null) {
for (int i2 = 0; i2 < this.gyms.length(); i2++) {
try {
JSONObject gym = this.gyms.getJSONObject(i2);
if (!((MainActivity) getActivity()).getStopsAndGyms().contains(new MarkerOptions().position(new LatLng(Double.valueOf(gym.getString(PokestopsContract.PokeStopEntry.latitude)).doubleValue(), Double.valueOf(gym.getString(PokestopsContract.PokeStopEntry.longitude)).doubleValue())).icon(BitmapDescriptorFactory.fromResource(R.drawable.gym)).getPosition())) {
Marker asd2 = ((MainActivity) getActivity()).getmMap().addMarker(new MarkerOptions().position(new LatLng(Double.valueOf(gym.getString(PokestopsContract.PokeStopEntry.latitude)).doubleValue(), Double.valueOf(gym.getString(PokestopsContract.PokeStopEntry.longitude)).doubleValue())).icon(BitmapDescriptorFactory.fromResource(R.drawable.gym)));
((MainActivity) getActivity()).getStopsAndGyms().add(asd2.getPosition());
}
} catch (JSONException e2) {
e2.printStackTrace();
}
}
}
}
public void cargarFavoritos(GoogleMap googleMap) {
if (((MainActivity) getActivity()).getResultsLocations() != null) {
for (int i = 0; i < ((MainActivity) getActivity()).getResultsLocations().size(); i++) {
googleMap.addMarker(new MarkerOptions().position(new LatLng(((MainActivity) getActivity()).getResultsLocations().get(i).getLatitude(), ((MainActivity) getActivity()).getResultsLocations().get(i).getLongitude())).title(((MainActivity) getActivity()).getResultsLocations().get(i).getDescripcion()).snippet(((MainActivity) getActivity()).getResultsLocations().get(i).getNombre()).icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_favoritelocation))).showInfoWindow();
}
}
}
}