<commit_before>package com.upmoon.alexanderbean.barcrawlr.fragments;


import android.graphics.Color;
import android.location.Location;
import android.os.Bundle;
import android.support.v4.app.Fragment;

import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
import com.upmoon.alexanderbean.barcrawlr.model.User;
import com.upmoon.alexanderbean.barcrawlr.singletons.CurrentPlan;
import com.upmoon.alexanderbean.barcrawlr.singletons.CurrentUsers;

import java.util.ArrayList;

import static com.google.android.gms.location.LocationServices.API;

/**
 * A simple {@link Fragment} subclass.
 */
public class MapFragment extends SupportMapFragment {
    private static final String TAG = "MapFragment";

    private GoogleApiClient mClient;
    private GoogleMap mMap;
    private Polyline mLine;
    private Location mCurrentLocation;

    public MapFragment() {
        // Required empty public constructor
    }

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

        mClient = new GoogleApiClient.Builder(getActivity()).addApi(API).build();

        getMapAsync(new OnMapReadyCallback() {
            @Override
            public void onMapReady(GoogleMap googleMap) {
                mMap = googleMap;
                updateUI(mMap);
            }
        });
    }

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if(isVisibleToUser) {
            updateUI(mMap);
        }
    }

    public void update(){
        updateUI(mMap);
    }

    private void updateUI(GoogleMap map) {
        if (mMap == null) {
            return;
        }

        try {
            mCurrentLocation = LocationServices.FusedLocationApi.getLastLocation(mClient);
        } catch(SecurityException e) {
            System.out.print(TAG + " : Unable to retrieve CurrentLocation.");
        }

        if((mCurrentLocation != null) || (CurrentPlan.getInstance().getNumPlaces() != 0)) {<commit_msg>Clear existing Markers on mMap before drawing new ones.<commit_after>package com.upmoon.alexanderbean.barcrawlr.fragments;


import android.graphics.Color;
import android.location.Location;
import android.os.Bundle;
import android.support.v4.app.Fragment;

import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
import com.upmoon.alexanderbean.barcrawlr.model.User;
import com.upmoon.alexanderbean.barcrawlr.singletons.CurrentPlan;
import com.upmoon.alexanderbean.barcrawlr.singletons.CurrentUsers;

import java.util.ArrayList;

import static com.google.android.gms.location.LocationServices.API;

/**
 * A simple {@link Fragment} subclass.
 */
public class MapFragment extends SupportMapFragment {
    private static final String TAG = "MapFragment";

    private GoogleApiClient mClient;
    private GoogleMap mMap;
    private Polyline mLine;
    private Location mCurrentLocation;

    public MapFragment() {
        // Required empty public constructor
    }

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

        mClient = new GoogleApiClient.Builder(getActivity()).addApi(API).build();

        getMapAsync(new OnMapReadyCallback() {
            @Override
            public void onMapReady(GoogleMap googleMap) {
                mMap = googleMap;
                updateUI(mMap);
            }
        });
    }

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if(isVisibleToUser) {
            updateUI(mMap);
        }
    }

    public void update(){
        updateUI(mMap);
    }

    private void updateUI(GoogleMap map) {
        if (mMap == null) {
            return;
        }

        try {
            mCurrentLocation = LocationServices.FusedLocationApi.getLastLocation(mClient);
        } catch(SecurityException e) {
            System.out.print(TAG + " : Unable to retrieve CurrentLocation.");
        }

        if((mCurrentLocation != null) || (CurrentPlan.getInstance().getNumPlaces() != 0)) {
            // Remove all existing markers.
            mMap.clear();

{'fraction_non_alphanumeric': 0.10150444081928585, 'fraction_numerical': 0.0007250317201377561, 'mean_word_length': 3.27420604182804, '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': '421958', 'n_tokens_mistral': 1636, 'n_tokens_neox': 1580, 'n_words': 283}