<commit_before>package com.andela.motustracker.helper;

import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.location.LocationSettingsRequest;
import com.google.android.gms.location.LocationSettingsResult;
import com.google.android.gms.location.LocationSettingsStates;
import com.google.android.gms.location.LocationSettingsStatusCodes;

/**
 * Created by Spykins on 31/03/16.
 */
public class LocationRequestHelper {
    private PendingResult<LocationSettingsResult> result;
    private boolean requestingLocationUpdates;

    public LocationRequestHelper(){
    }
    public LocationRequest createLocationRequest() {
        //create the location request and set the parameters as shown in this code sample
        LocationRequest mLocationRequest = new LocationRequest();
        mLocationRequest.setInterval(10000);
        mLocationRequest.setFastestInterval(5000);
        mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

        //get the current location settings of a user's device
        LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder()
                .addLocationRequest(mLocationRequest);

        //Next check whether the current location settings are satisfied:
        //mGoogleClient = GoogleClient.getInstance()
        if(GoogleClient.getGoogleApiClient() != null)
        result = LocationServices.SettingsApi.checkLocationSettings(GoogleClient.getGoogleApiClient(), builder.build());
        return mLocationRequest;
    }

    //vhanging user Location settings

    public boolean checkUserLocationSettings() {

        result.setResultCallback(new ResultCallback<LocationSettingsResult>() {
            @Override<commit_msg>[#116529451] Fix location handler connection error with GoogleApi client by initializing GoogleApi client in LocationHandler<commit_after>package com.andela.motustracker.helper;

import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.location.LocationSettingsRequest;
import com.google.android.gms.location.LocationSettingsResult;
import com.google.android.gms.location.LocationSettingsStates;
import com.google.android.gms.location.LocationSettingsStatusCodes;

/**
 * Created by Spykins on 31/03/16.
 */
public class LocationRequestHelper {
    private PendingResult<LocationSettingsResult> result;
    private boolean requestingLocationUpdates;
    private GoogleApiClient googleApiClient;

    public LocationRequestHelper(GoogleApiClient googleApiClient){
        this.googleApiClient = googleApiClient;
    }
    public LocationRequest createLocationRequest() {
        //create the location request and set the parameters as shown in this code sample
        LocationRequest mLocationRequest = new LocationRequest();
        mLocationRequest.setInterval(10000);
        mLocationRequest.setFastestInterval(5000);
        mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

        //get the current location settings of a user's device
        LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder()
                .addLocationRequest(mLocationRequest);

        //Next check whether the current location settings are satisfied:
        //if(GoogleClient.getGoogleApiClient() != null)
        result = LocationServices.SettingsApi.checkLocationSettings(googleApiClient, builder.build());
        return mLocationRequest;
    }

    //vhanging user Location settings

    public boolean checkUserLocationSettings() {

        result.setResultCallback(new ResultCallback<LocationSettingsResult>() {
            @Override
{'fraction_non_alphanumeric': 0.0791767554479419, 'fraction_numerical': 0.009443099273607748, 'mean_word_length': 4.37890625, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3405207', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1008, 'n_words': 223}