<commit_before>/*
 * Copyright 2016–2017 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.nicoco007.jeuxdelaesd.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.location.LocationSource;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.offline.OfflineManager;
import com.mapbox.mapboxsdk.offline.OfflineRegion;
import com.mapbox.mapboxsdk.offline.OfflineRegionError;
import com.mapbox.mapboxsdk.offline.OfflineRegionStatus;
import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition;
import com.mapbox.services.android.telemetry.location.LocationEngine;
import com.mapbox.services.android.telemetry.permissions.PermissionsListener;
import com.mapbox.services.android.telemetry.permissions.PermissionsManager;
import com.nicoco007.jeuxdelaesd.R;
import com.nicoco007.jeuxdelaesd.events.EventListener;
import com.nicoco007.jeuxdelaesd.events.LocationsUpdatedEventArgs;
import com.nicoco007.jeuxdelaesd.events.ShowMapCoordsEvent;
import com.nicoco007.jeuxdelaesd.helper.APICommunication;
import com.nicoco007.jeuxdelaesd.helper.NotificationHelper;
import com.nicoco007.jeuxdelaesd.model.Activity;
import com.nicoco007.jeuxdelaesd.model.Location;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.json.JSONException;
import org.json.JSONObject;

import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;

public class MapFragment extends Fragment implements PermissionsListener {
    public static final String TAG = "MapFragment";

    private MapView mapView;
    private MapboxMap map;
    private OfflineManager offlineManager;

    // robin hood
    private static final double minLat = 43.92336814129122;
    private static final double maxLat = 43.92806636084152;
    private static final double minLong = -79.22172546386719;
    private static final double maxLong = -79.21623229980469;

    public static final Charset JSON_CHARSET = Charset.forName("UTF-8");
    public static final String JSON_FIELD_REGION_ID = "field_region_id";
    public static final String JSON_FIELD_REGION_NAME = "field_region_name";

    public MapFragment() {
        EventBus eventBus = EventBus.getDefault();
        eventBus.register(this);
    }

    @Subscribe
    public void onShowMapCoordsEvent(ShowMapCoordsEvent event) {
        map.deselectMarkers();

        for (Marker marker : map.getMarkers()) {
            if (marker.getPosition().getLatitude() == event.getPosition().getLatitude() && marker.getPosition().getLongitude() == event.getPosition().getLongitude()) {
                map.selectMarker(marker);

                if (!map.getProjection().getVisibleRegion().latLngBounds.contains(marker.getPosition())) {
                    CameraPosition position = new CameraPosition.Builder()
                            .target(event.getPosition())
                            .build();

                    map.moveCamera(CameraUpdateFactory.newCameraPosition(position));
                }
            }
        }
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        NotificationHelper.loadNotifications(getContext());
    }
<commit_msg>Fix nullpointerexception<commit_after>/*
 * Copyright 2016–2017 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.nicoco007.jeuxdelaesd.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.location.LocationSource;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.offline.OfflineManager;
import com.mapbox.mapboxsdk.offline.OfflineRegion;
import com.mapbox.mapboxsdk.offline.OfflineRegionError;
import com.mapbox.mapboxsdk.offline.OfflineRegionStatus;
import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition;
import com.mapbox.services.android.telemetry.location.LocationEngine;
import com.mapbox.services.android.telemetry.permissions.PermissionsListener;
import com.mapbox.services.android.telemetry.permissions.PermissionsManager;
import com.nicoco007.jeuxdelaesd.R;
import com.nicoco007.jeuxdelaesd.events.EventListener;
import com.nicoco007.jeuxdelaesd.events.LocationsUpdatedEventArgs;
import com.nicoco007.jeuxdelaesd.events.ShowMapCoordsEvent;
import com.nicoco007.jeuxdelaesd.helper.APICommunication;
import com.nicoco007.jeuxdelaesd.helper.NotificationHelper;
import com.nicoco007.jeuxdelaesd.model.Activity;
import com.nicoco007.jeuxdelaesd.model.Location;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.json.JSONException;
import org.json.JSONObject;

import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;

public class MapFragment extends Fragment implements PermissionsListener {
    public static final String TAG = "MapFragment";

    private MapView mapView;
    private MapboxMap map;
    private OfflineManager offlineManager;

    // robin hood
    private static final double minLat = 43.92336814129122;
    private static final double maxLat = 43.92806636084152;
    private static final double minLong = -79.22172546386719;
    private static final double maxLong = -79.21623229980469;

    public static final Charset JSON_CHARSET = Charset.forName("UTF-8");
    public static final String JSON_FIELD_REGION_ID = "field_region_id";
    public static final String JSON_FIELD_REGION_NAME = "field_region_name";

    public MapFragment() {
        EventBus eventBus = EventBus.getDefault();
        eventBus.register(this);
    }

    @Subscribe
    public void onShowMapCoordsEvent(ShowMapCoordsEvent event) {
        if (map != null) {
            map.deselectMarkers();

            for (Marker marker : map.getMarkers()) {
                if (marker.getPosition().getLatitude() == event.getPosition().getLatitude() && marker.getPosition().getLongitude() == event.getPosition().getLongitude()) {
                    map.selectMarker(marker);

                    CameraPosition position = new CameraPosition.Builder()
                            .target(event.getPosition())
                            .zoom(16)
                            .build();

                    map.moveCamera(CameraUpdateFactory.newCameraPosition(position));
                }
            }
        }
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        NotificationHelper.loadNotifications(getContext());
    }

{'fraction_non_alphanumeric': 0.0901258360730076, 'fraction_numerical': 0.02403355628613536, 'mean_word_length': 4.073030477285797, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '17143', 'n_tokens_mistral': 2703, 'n_tokens_neox': 2523, 'n_words': 547}