// Path: lib/src/main/java/com/miguelbcr/io/rx_gps_service/lib/entities/LatLong.java
// @AutoValue public abstract class LatLong {
//   public abstract double latitude();
// 
//   public abstract double longitude();
// 
//   public abstract float altitude();
// 
//   public abstract boolean isCheckPoint();
// 
//   public static LatLong create(double latitude, double longitude) {
//     return create(latitude, longitude, 0, false);
//   }
// 
//   public static LatLong create(double latitude, double longitude, float altitude,
//       boolean isCheckPoint) {
//     return new AutoValue_LatLong(latitude, longitude, altitude, isCheckPoint);
//   }
// }
// 
// Path: lib/src/main/java/com/miguelbcr/io/rx_gps_service/lib/entities/LatLongDetailed.java
// @AutoValue public abstract class LatLongDetailed {
//   public abstract Location location();
// 
//   public abstract boolean isCheckPoint();
// 
//   public static LatLongDetailed create(Location location) {
//     return create(location, false);
//   }
// 
//   public static LatLongDetailed create(Location location, boolean isCheckPoint) {
//     return new AutoValue_LatLongDetailed(location, isCheckPoint);
//   }
// }
// 
// Path: lib/src/main/java/com/miguelbcr/io/rx_gps_service/lib/entities/RouteStats.java
// @AutoValue public abstract class RouteStats {
// 
//   public abstract long time();
// 
//   public abstract long distance();
// 
//   public abstract float speedMax();
// 
//   public abstract float speedMin();
// 
//   public abstract float speedAverage();
// 
//   public abstract float speed();
// 
//   public abstract LatLongDetailed currentLocation();
// 
//   public abstract List<LatLong> latLongs();
// 
//   public abstract List<LatLongDetailed> latLongsDetailed();
// 
//   public static RouteStats create(long time, long distance, float speedMax, float speedMin,
//       float speedAverage, float speed, LatLongDetailed currentLocation, List<LatLong> latLongs,
//       List<LatLongDetailed> latLongsDetailed) {
//     return new AutoValue_RouteStats(time, distance, speedMax, speedMin, speedAverage, speed,
//         currentLocation, latLongs, latLongsDetailed);
//   }
// 
//   public LatLong getLastLatLong() {
//     return latLongs() != null && !latLongs().isEmpty() ? latLongs().get(latLongs().size() - 1)
//         : LatLong.create(0, 0);
//   }
// 
//   public LatLongDetailed getLastLatLongDetailed() {
//     int size = latLongsDetailed().size();
//     return latLongsDetailed() != null && !latLongsDetailed().isEmpty() ? latLongsDetailed().get(
//         size - 1) : LatLongDetailed.create(new Location("Location-" + size));
//   }
// 
//   @Override public String toString() {
//     return " time="
//         + time()
//         + " distance="
//         + distance()
//         + " speed="
//         + speed()
//         + " latLong="
//         + "("
//         + currentLocation().location().getLatitude()
//         + ", "
//         + currentLocation().location().getLongitude()
//         + ") checkpoint="
//         + currentLocation().isCheckPoint()
//         + " waypoints="
//         + (latLongs() != null && !latLongs().isEmpty() ? latLongs().size()
//         : latLongsDetailed() != null && !latLongsDetailed().isEmpty() ? latLongsDetailed().size()
//             : 0);
//   }
// }


import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.location.Location;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
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.BitmapDescriptor;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
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 com.miguelbcr.io.rx_gps_service.lib.entities.LatLong;
import com.miguelbcr.io.rx_gps_service.lib.entities.LatLongDetailed;
import com.miguelbcr.io.rx_gps_service.lib.entities.RouteStats;
import com.miguelbcr.rx_gpsservice.R;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.Target;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
    }

    public void disableNavigationControls() {
        if (googleMap == null) return;
        googleMap.getUiSettings().setMapToolbarEnabled(false);
    }

    public void navigateTo(double latitude, double longitude) {
        Uri gmmIntentUri = Uri.parse("google.navigation:q=" + latitude + ", " + longitude);
        Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
        mapIntent.setPackage("com.google.android.apps.maps");
        startActivity(mapIntent);
    }

    public void drawPathUser(List<LatLong> waypoints) {
        if (googleMap == null) return;
        if (polylineUser != null && polylineUser.getPoints().size() == waypoints.size()) return;

        polylineUser = removePath(polylineUser);
        polylineUserLastPath = removePath(polylineUserLastPath);
        polylineUser = drawPath(waypoints, ContextCompat.getColor(getContext(), R.color.blue), 2f, polylineUser);

        if (waypoints != null && !waypoints.isEmpty()) {
            showCheckpoints(waypoints);
            LatLong lastLatLong = waypoints.get(waypoints.size() - 1);
            LatLng latLng = new LatLng(lastLatLong.latitude(), lastLatLong.longitude());
            drawSegmentPathUser(latLng);
        }
    }

// Path: lib/src/main/java/com/miguelbcr/io/rx_gps_service/lib/entities/LatLong.java
// @AutoValue public abstract class LatLong {
//   public abstract double latitude();
// 
//   public abstract double longitude();
// 
//   public abstract float altitude();
// 
//   public abstract boolean isCheckPoint();
// 
//   public static LatLong create(double latitude, double longitude) {
//     return create(latitude, longitude, 0, false);
//   }
// 
//   public static LatLong create(double latitude, double longitude, float altitude,
//       boolean isCheckPoint) {
//     return new AutoValue_LatLong(latitude, longitude, altitude, isCheckPoint);
//   }
// }
// 
// Path: lib/src/main/java/com/miguelbcr/io/rx_gps_service/lib/entities/LatLongDetailed.java
// @AutoValue public abstract class LatLongDetailed {
//   public abstract Location location();
// 
//   public abstract boolean isCheckPoint();
// 
//   public static LatLongDetailed create(Location location) {
//     return create(location, false);
//   }
// 
//   public static LatLongDetailed create(Location location, boolean isCheckPoint) {
//     return new AutoValue_LatLongDetailed(location, isCheckPoint);
//   }
// }
// 
// Path: lib/src/main/java/com/miguelbcr/io/rx_gps_service/lib/entities/RouteStats.java
// @AutoValue public abstract class RouteStats {
// 
//   public abstract long time();
// 
//   public abstract long distance();
// 
//   public abstract float speedMax();
// 
//   public abstract float speedMin();
// 
//   public abstract float speedAverage();
// 
//   public abstract float speed();
// 
//   public abstract LatLongDetailed currentLocation();
// 
//   public abstract List<LatLong> latLongs();
// 
//   public abstract List<LatLongDetailed> latLongsDetailed();
// 
//   public static RouteStats create(long time, long distance, float speedMax, float speedMin,
//       float speedAverage, float speed, LatLongDetailed currentLocation, List<LatLong> latLongs,
//       List<LatLongDetailed> latLongsDetailed) {
//     return new AutoValue_RouteStats(time, distance, speedMax, speedMin, speedAverage, speed,
//         currentLocation, latLongs, latLongsDetailed);
//   }
// 
//   public LatLong getLastLatLong() {
//     return latLongs() != null && !latLongs().isEmpty() ? latLongs().get(latLongs().size() - 1)
//         : LatLong.create(0, 0);
//   }
// 
//   public LatLongDetailed getLastLatLongDetailed() {
//     int size = latLongsDetailed().size();
//     return latLongsDetailed() != null && !latLongsDetailed().isEmpty() ? latLongsDetailed().get(
//         size - 1) : LatLongDetailed.create(new Location("Location-" + size));
//   }
// 
//   @Override public String toString() {
//     return " time="
//         + time()
//         + " distance="
//         + distance()
//         + " speed="
//         + speed()
//         + " latLong="
//         + "("
//         + currentLocation().location().getLatitude()
//         + ", "
//         + currentLocation().location().getLongitude()
//         + ") checkpoint="
//         + currentLocation().isCheckPoint()
//         + " waypoints="
//         + (latLongs() != null && !latLongs().isEmpty() ? latLongs().size()
//         : latLongsDetailed() != null && !latLongsDetailed().isEmpty() ? latLongsDetailed().size()
//             : 0);
//   }
// }


// Path: app/src/main/java/com/miguelbcr/rx_gpsservice/app/PlaceMapFragment.java
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.location.Location;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
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.BitmapDescriptor;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
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 com.miguelbcr.io.rx_gps_service.lib.entities.LatLong;
import com.miguelbcr.io.rx_gps_service.lib.entities.LatLongDetailed;
import com.miguelbcr.io.rx_gps_service.lib.entities.RouteStats;
import com.miguelbcr.rx_gpsservice.R;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.Target;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

    }

    public void disableNavigationControls() {
        if (googleMap == null) return;
        googleMap.getUiSettings().setMapToolbarEnabled(false);
    }

    public void navigateTo(double latitude, double longitude) {
        Uri gmmIntentUri = Uri.parse("google.navigation:q=" + latitude + ", " + longitude);
        Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
        mapIntent.setPackage("com.google.android.apps.maps");
        startActivity(mapIntent);
    }

    public void drawPathUser(List<LatLong> waypoints) {
        if (googleMap == null) return;
        if (polylineUser != null && polylineUser.getPoints().size() == waypoints.size()) return;

        polylineUser = removePath(polylineUser);
        polylineUserLastPath = removePath(polylineUserLastPath);
        polylineUser = drawPath(waypoints, ContextCompat.getColor(getContext(), R.color.blue), 2f, polylineUser);

        if (waypoints != null && !waypoints.isEmpty()) {
            showCheckpoints(waypoints);
            LatLong lastLatLong = waypoints.get(waypoints.size() - 1);
            LatLng latLng = new LatLng(lastLatLong.latitude(), lastLatLong.longitude());
            drawSegmentPathUser(latLng);
        }
    }

    public void updateUserLocation(RouteStats routeStats, boolean goToUserLocation) {