<commit_before>package com.contexthub.boundaries.fragments;

import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.Nullable;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;

import com.chaione.contexthub.sdk.ContextHub;
import com.chaione.contexthub.sdk.GeofenceProxy;
import com.chaione.contexthub.sdk.SensorPipelineEvent;
import com.chaione.contexthub.sdk.SensorPipelineListener;
import com.chaione.contexthub.sdk.callbacks.Callback;
import com.chaione.contexthub.sdk.dev.MockLocationProvider;
import com.chaione.contexthub.sdk.model.Geofence;
import com.contexthub.boundaries.BoundariesApp;
import com.contexthub.boundaries.R;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.Circle;
import com.google.android.gms.maps.model.CircleOptions;
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.squareup.otto.Subscribe;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.List;

/**
 * Created by andy on 10/24/14.
 */
public class GeofencesMapFragment extends SupportMapFragment implements SensorPipelineListener, Callback<List<Geofence>>, GoogleMap.OnMapClickListener {

    private static final int ZOOM_LEVEL = 13;

    private MockLocationProvider mockLocationProvider;
    private Marker currentLocation;
    private GeofenceProxy proxy = new GeofenceProxy();
    private HashMap<Long, Circle> circlesMap = new HashMap<Long, Circle>();

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setRetainInstance(true);
        setHasOptionsMenu(true);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        mockLocationProvider = new MockLocationProvider(getActivity());
        getMap().setOnMapClickListener(this);

        proxy.listGeofences(this);
    }

    @Override
    public void onSuccess(List<Geofence> result) {
        for(Geofence geofence: result) {
            drawGeofence(geofence);
        }
    }

    private void drawGeofence(Geofence geofence) {
        LatLng coordinates = new LatLng(geofence.getLatitude(), geofence.getLongitude());
        Circle circle = getMap().addCircle(new CircleOptions().center(coordinates)
                .radius(geofence.getRadius()).strokeWidth(0)
                .fillColor(getResources().getColor(R.color.circle_fill)));
        circlesMap.put(geofence.getId(), circle);
    }

    @Override
    public void onFailure(Exception e) {
        Toast.makeText(getActivity(), "Error: " + e.getMessage(), Toast.LENGTH_SHORT).show();<commit_msg>Set initial location to ChaiOne office when map loads<commit_after>package com.contexthub.boundaries.fragments;

import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.Nullable;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;

import com.chaione.contexthub.sdk.ContextHub;
import com.chaione.contexthub.sdk.GeofenceProxy;
import com.chaione.contexthub.sdk.SensorPipelineEvent;
import com.chaione.contexthub.sdk.SensorPipelineListener;
import com.chaione.contexthub.sdk.callbacks.Callback;
import com.chaione.contexthub.sdk.dev.MockLocationProvider;
import com.chaione.contexthub.sdk.model.Geofence;
import com.contexthub.boundaries.BoundariesApp;
import com.contexthub.boundaries.R;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.Circle;
import com.google.android.gms.maps.model.CircleOptions;
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.squareup.otto.Subscribe;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.List;

/**
 * Created by andy on 10/24/14.
 */
public class GeofencesMapFragment extends SupportMapFragment implements SensorPipelineListener, Callback<List<Geofence>>, GoogleMap.OnMapClickListener {

    private static final int ZOOM_LEVEL = 13;
    private static final LatLng LOCATION_CHAIONE_WOODWAY = new LatLng(29.763553,-95.461784);

    private MockLocationProvider mockLocationProvider;
    private Marker currentLocation;
    private GeofenceProxy proxy = new GeofenceProxy();
    private HashMap<Long, Circle> circlesMap = new HashMap<Long, Circle>();

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setRetainInstance(true);
        setHasOptionsMenu(true);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        mockLocationProvider = new MockLocationProvider(getActivity());
        setCurrentLocation(LOCATION_CHAIONE_WOODWAY);

        getMap().setOnMapClickListener(this);

        proxy.listGeofences(this);
    }

    @Override
    public void onSuccess(List<Geofence> result) {
        for(Geofence geofence: result) {
            drawGeofence(geofence);
        }
    }

    private void drawGeofence(Geofence geofence) {
        LatLng coordinates = new LatLng(geofence.getLatitude(), geofence.getLongitude());
        Circle circle = getMap().addCircle(new CircleOptions().center(coordinates)
                .radius(geofence.getRadius()).strokeWidth(0)
                .fillColor(getResources().getColor(R.color.circle_fill)));
        circlesMap.put(geofence.getId(), circle);
    }

    @Override
    public void onFailure(Exception e) {
        Toast.makeText(getActivity(), "Error: " + e.getMessage(), Toast.LENGTH_SHORT).show();
{'fraction_non_alphanumeric': 0.10369544440904747, 'fraction_numerical': 0.00541573749601784, 'mean_word_length': 4.44107452339688, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '6277234', 'n_tokens_mistral': 1942, 'n_tokens_neox': 1889, 'n_words': 335}