// Path: adal-location/src/main/java/com/massivedisaster/location/listener/OnLocationManager.java
// public interface OnLocationManager {
// 
//     /**
//      * Called if location manager retrieve the user position
//      *
//      * @param location           The user location
//      * @param isLastKnowLocation True if a location its given from the last know position
//      */
//     void onLocationFound(Location location, boolean isLastKnowLocation);
// 
//     /**
//      * Called if the request gives an error
//      *
//      * @param locationError The location error
//      */
//     void onLocationError(LocationError locationError);
// 
//     /**
//      * Called if user don't permissions to get location
//      */
//     void onPermissionsDenied();
// 
//     /**
//      * Called if provider is enabled
//      */
//     void onProviderEnabled();
// 
//     /**
//      * Called if provider is disabled
//      */
//     void onProviderDisabled();
// 
//     /**
//      * Called if location manager stop request update
//      */
//     void onStopRequestUpdate();
// }
// 
// Path: adal-location/src/main/java/com/massivedisaster/location/utils/LocationError.java
// public enum LocationError {
//     TIMEOUT,
//     DISABLED,
//     REQUEST_NEEDED,
//     REQUEST_UPDATES_ENABLED
// }


import com.google.android.gms.common.api.ApiException;
import com.google.android.gms.common.api.ResolvableApiException;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationSettingsResponse;
import com.google.android.gms.location.LocationSettingsStatusCodes;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.massivedisaster.location.listener.OnLocationManager;
import com.massivedisaster.location.utils.LocationError;
import android.content.IntentSender;
import android.os.Looper;
import android.support.annotation.NonNull;
import android.util.Log;

        mLocationRequest = locationRequest;

        buildRequest(mLocationRequest);
    }

    /**
     * Start the request location updates
     */
    @Override
    protected void startRequestLocation() {
        if (mLocationSettingsRequest == null || mLocationRequest == null) {
            if (mOnLocationManager != null) {
                mOnLocationManager.onLocationError(LocationError.REQUEST_NEEDED);
            }
            return;
        }

        mSettingsClient.checkLocationSettings(mLocationSettingsRequest)
                .addOnSuccessListener(new OnSuccessListener<LocationSettingsResponse>() {
                    @Override
                    public void onSuccess(LocationSettingsResponse locationSettingsResponse) {
                        try {
                            if (mLocationRequest.getNumUpdates() != 1) {
                                mRequestingLocationUpdates = true;
                            }
                            mFusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback, Looper.myLooper());
                        } catch (SecurityException e) {
                            mRequestingLocationUpdates = false;
                            if (mOnLocationManager != null) {
// Path: adal-location/src/main/java/com/massivedisaster/location/listener/OnLocationManager.java
// public interface OnLocationManager {
// 
//     /**
//      * Called if location manager retrieve the user position
//      *
//      * @param location           The user location
//      * @param isLastKnowLocation True if a location its given from the last know position
//      */
//     void onLocationFound(Location location, boolean isLastKnowLocation);
// 
//     /**
//      * Called if the request gives an error
//      *
//      * @param locationError The location error
//      */
//     void onLocationError(LocationError locationError);
// 
//     /**
//      * Called if user don't permissions to get location
//      */
//     void onPermissionsDenied();
// 
//     /**
//      * Called if provider is enabled
//      */
//     void onProviderEnabled();
// 
//     /**
//      * Called if provider is disabled
//      */
//     void onProviderDisabled();
// 
//     /**
//      * Called if location manager stop request update
//      */
//     void onStopRequestUpdate();
// }
// 
// Path: adal-location/src/main/java/com/massivedisaster/location/utils/LocationError.java
// public enum LocationError {
//     TIMEOUT,
//     DISABLED,
//     REQUEST_NEEDED,
//     REQUEST_UPDATES_ENABLED
// }


// Path: adal-location/src/main/java/com/massivedisaster/location/LocationManager.java
import com.google.android.gms.common.api.ApiException;
import com.google.android.gms.common.api.ResolvableApiException;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationSettingsResponse;
import com.google.android.gms.location.LocationSettingsStatusCodes;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.massivedisaster.location.listener.OnLocationManager;
import com.massivedisaster.location.utils.LocationError;
import android.content.IntentSender;
import android.os.Looper;
import android.support.annotation.NonNull;
import android.util.Log;


        mLocationRequest = locationRequest;

        buildRequest(mLocationRequest);
    }

    /**
     * Start the request location updates
     */
    @Override
    protected void startRequestLocation() {
        if (mLocationSettingsRequest == null || mLocationRequest == null) {
            if (mOnLocationManager != null) {
                mOnLocationManager.onLocationError(LocationError.REQUEST_NEEDED);
            }
            return;
        }

        mSettingsClient.checkLocationSettings(mLocationSettingsRequest)
                .addOnSuccessListener(new OnSuccessListener<LocationSettingsResponse>() {
                    @Override
                    public void onSuccess(LocationSettingsResponse locationSettingsResponse) {
                        try {
                            if (mLocationRequest.getNumUpdates() != 1) {
                                mRequestingLocationUpdates = true;
                            }
                            mFusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback, Looper.myLooper());
                        } catch (SecurityException e) {
                            mRequestingLocationUpdates = false;
                            if (mOnLocationManager != null) {
                                mOnLocationManager.onLocationError(LocationError.DISABLED);