// Path: adal-location/src/main/java/com/massivedisaster/location/broadcast/LocationStatusBroadcastReceiver.java
// public class LocationStatusBroadcastReceiver extends BroadcastReceiver {
// 
//     private static final int PROVIDER_ENABLED = 1;
//     private static final int PROVIDER_DISABLED = 0;
//     private static final int PROVIDER_NONE = -1;
// 
//     protected int mStatus = PROVIDER_NONE;
//     protected OnLocationStatusProviderListener mOnLocationStatusProviderListener;
// 
//     @Override
//     public void onReceive(Context context, Intent intent) {
//         if (intent.getAction().matches("android.location.PROVIDERS_CHANGED")) {
//             checkGPSStatus(context);
//         }
//     }
// 
//     /**
//      * Listener to check provider status
//      *
//      * @param onLocationStatusProviderListener the listener
//      */
//     public void setOnLocationStatusProviderListener(OnLocationStatusProviderListener onLocationStatusProviderListener) {
//         this.mOnLocationStatusProviderListener = onLocationStatusProviderListener;
//     }
// 
//     /**
//      * Check the GPS status
//      *
//      * @param context the context from BroadcasteReceiver
//      */
//     private void checkGPSStatus(Context context) {
//         android.location.LocationManager locationManager =
//                 (android.location.LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
//         if (locationManager != null) {
//             boolean isLocationEnabled = LocationUtils.isLocationEnabled(locationManager);
//             if (isLocationEnabled && mStatus != PROVIDER_ENABLED) {
//                 mStatus = PROVIDER_ENABLED;
//                 Log.w(LocationStatusBroadcastReceiver.class.getSimpleName(), "PROVIDER PROVIDER_ENABLED");
//                 if (mOnLocationStatusProviderListener != null) {
//                     mOnLocationStatusProviderListener.onProviderEnabled();
//                 }
//             } else if (!isLocationEnabled && mStatus != PROVIDER_DISABLED) {
//                 mStatus = PROVIDER_DISABLED;
//                 Log.w(LocationStatusBroadcastReceiver.class.getSimpleName(), "PROVIDER PROVIDER_DISABLED");
//                 if (mOnLocationStatusProviderListener != null) {
//                     mOnLocationStatusProviderListener.onProviderDisabled();
//                 }
//             }
//         } else {
//             Log.w(LocationManager.class.getSimpleName(), "PROVIDER ERROR");
//         }
//     }
// }
// 
// Path: adal-location/src/main/java/com/massivedisaster/location/listener/OnLocationStatusProviderListener.java
// public interface OnLocationStatusProviderListener {
// 
//     /**
//      * Called if provider is enabled
//      */
//     void onProviderEnabled();
// 
//     /**
//      * Called if provider is disabled
//      */
//     void onProviderDisabled();
// }
// 
// Path: adal-location/src/main/java/com/massivedisaster/location/utils/LocationError.java
// public enum LocationError {
//     TIMEOUT,
//     DISABLED,
//     REQUEST_NEEDED,
//     REQUEST_UPDATES_ENABLED
// }


import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.location.Location;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.util.Log;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationAvailability;
import com.google.android.gms.location.LocationCallback;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationResult;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.location.LocationSettingsRequest;
import com.google.android.gms.location.SettingsClient;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.massivedisaster.location.broadcast.LocationStatusBroadcastReceiver;
import com.massivedisaster.location.listener.OnLocationStatusProviderListener;
import com.massivedisaster.location.utils.LocationError;
     */
    public void onCreate(Context context) {
        mContext = context;

        initialize();
    }

    /**
     * Stop and destroy location requests
     */
    public void onDestroy() {
        if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
                && ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
            stopRequestLocation();
        }

        mHandler.removeCallbacksAndMessages(null);

        if (mActivity != null) {
            mActivity.unregisterReceiver(mLocationStatusBroadcastReceiver);
        }
    }

    /**
     * Initialize location manager.
     */
    private void initialize() {
        mHandler = new Handler();

        if (mActivity != null) {
// Path: adal-location/src/main/java/com/massivedisaster/location/broadcast/LocationStatusBroadcastReceiver.java
// public class LocationStatusBroadcastReceiver extends BroadcastReceiver {
// 
//     private static final int PROVIDER_ENABLED = 1;
//     private static final int PROVIDER_DISABLED = 0;
//     private static final int PROVIDER_NONE = -1;
// 
//     protected int mStatus = PROVIDER_NONE;
//     protected OnLocationStatusProviderListener mOnLocationStatusProviderListener;
// 
//     @Override
//     public void onReceive(Context context, Intent intent) {
//         if (intent.getAction().matches("android.location.PROVIDERS_CHANGED")) {
//             checkGPSStatus(context);
//         }
//     }
// 
//     /**
//      * Listener to check provider status
//      *
//      * @param onLocationStatusProviderListener the listener
//      */
//     public void setOnLocationStatusProviderListener(OnLocationStatusProviderListener onLocationStatusProviderListener) {
//         this.mOnLocationStatusProviderListener = onLocationStatusProviderListener;
//     }
// 
//     /**
//      * Check the GPS status
//      *
//      * @param context the context from BroadcasteReceiver
//      */
//     private void checkGPSStatus(Context context) {
//         android.location.LocationManager locationManager =
//                 (android.location.LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
//         if (locationManager != null) {
//             boolean isLocationEnabled = LocationUtils.isLocationEnabled(locationManager);
//             if (isLocationEnabled && mStatus != PROVIDER_ENABLED) {
//                 mStatus = PROVIDER_ENABLED;
//                 Log.w(LocationStatusBroadcastReceiver.class.getSimpleName(), "PROVIDER PROVIDER_ENABLED");
//                 if (mOnLocationStatusProviderListener != null) {
//                     mOnLocationStatusProviderListener.onProviderEnabled();
//                 }
//             } else if (!isLocationEnabled && mStatus != PROVIDER_DISABLED) {
//                 mStatus = PROVIDER_DISABLED;
//                 Log.w(LocationStatusBroadcastReceiver.class.getSimpleName(), "PROVIDER PROVIDER_DISABLED");
//                 if (mOnLocationStatusProviderListener != null) {
//                     mOnLocationStatusProviderListener.onProviderDisabled();
//                 }
//             }
//         } else {
//             Log.w(LocationManager.class.getSimpleName(), "PROVIDER ERROR");
//         }
//     }
// }
// 
// Path: adal-location/src/main/java/com/massivedisaster/location/listener/OnLocationStatusProviderListener.java
// public interface OnLocationStatusProviderListener {
// 
//     /**
//      * Called if provider is enabled
//      */
//     void onProviderEnabled();
// 
//     /**
//      * Called if provider is disabled
//      */
//     void onProviderDisabled();
// }
// 
// 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/AbstractLocationManager.java
import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.location.Location;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.util.Log;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationAvailability;
import com.google.android.gms.location.LocationCallback;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationResult;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.location.LocationSettingsRequest;
import com.google.android.gms.location.SettingsClient;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.massivedisaster.location.broadcast.LocationStatusBroadcastReceiver;
import com.massivedisaster.location.listener.OnLocationStatusProviderListener;
import com.massivedisaster.location.utils.LocationError;

     */
    public void onCreate(Context context) {
        mContext = context;

        initialize();
    }

    /**
     * Stop and destroy location requests
     */
    public void onDestroy() {
        if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
                && ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
            stopRequestLocation();
        }

        mHandler.removeCallbacksAndMessages(null);

        if (mActivity != null) {
            mActivity.unregisterReceiver(mLocationStatusBroadcastReceiver);
        }
    }

    /**
     * Initialize location manager.
     */
    private void initialize() {
        mHandler = new Handler();

        if (mActivity != null) {
            mLocationStatusBroadcastReceiver.setOnLocationStatusProviderListener(new OnLocationStatusProviderListener() {