<commit_before>package com.sanchez.fmf.util;

import java.util.Timer;
import java.util.TimerTask;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;

/**
 * Created by dakota on 9/8/15.
 */
public class LocationUtil {
    Timer timer1 = null;
    LocationManager lm = null;
    LocationResult locationResult;
    boolean gps_enabled = false;
    boolean network_enabled = false;

    public boolean getLocation(Context context, LocationResult result) {
        // Use LocationResult callback class to pass location value back to activity
        locationResult = result;

        lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);

        gps_enabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
        network_enabled = lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

        // don't start listeners if no provider is enabled
        if(!gps_enabled && !network_enabled) {
            return false;
        }

        try {
            if (gps_enabled) {
                lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListenerGps);
            }
            if (network_enabled) {
                lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListenerNetwork);
            }
        } catch (SecurityException e) {
            Log.e("LocationUtil", e.getMessage());
        }
        timer1 = new Timer();
        timer1.schedule(new GetLastLocation(), 5000);
        return true;
    }

    LocationListener locationListenerGps = new LocationListener() {<commit_msg>Little bit more time for fetching device coordinates<commit_after>package com.sanchez.fmf.util;

import java.util.Timer;
import java.util.TimerTask;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;

/**
 * Created by dakota on 9/8/15.
 */
public class LocationUtil {
    Timer timer1 = null;
    LocationManager lm = null;
    LocationResult locationResult;
    boolean gps_enabled = false;
    boolean network_enabled = false;

    public boolean getLocation(Context context, LocationResult result) {
        // Use LocationResult callback class to pass location value back to activity
        locationResult = result;

        lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);

        gps_enabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
        network_enabled = lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

        // don't start listeners if no provider is enabled
        if(!gps_enabled && !network_enabled) {
            return false;
        }

        try {
            if (gps_enabled) {
                lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListenerGps);
            }
            if (network_enabled) {
                lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListenerNetwork);
            }
        } catch (SecurityException e) {
            Log.e("LocationUtil", e.getMessage());
        }
        timer1 = new Timer();
        timer1.schedule(new GetLastLocation(), 7000);
        return true;
    }

    LocationListener locationListenerGps = new LocationListener() {
{'fraction_non_alphanumeric': 0.08484848484848485, 'fraction_numerical': 0.008658008658008658, 'mean_word_length': 2.9386363636363635, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4437897', 'n_tokens_mistral': 958, 'n_tokens_neox': 911, 'n_words': 223}