<commit_before>/**
 * Copyright 2016 <NAME>
 * <p/>
 * 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
 * <p/>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * 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 fr.cph.chicago.util;

import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Point;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.util.TypedValue;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.widget.Toast;

import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;
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 org.apache.commons.collections4.MultiValuedMap;
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap;

import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Properties;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;

import fr.cph.chicago.App;
import fr.cph.chicago.R;
import fr.cph.chicago.data.Preferences;
import fr.cph.chicago.entity.BikeStation;
import fr.cph.chicago.entity.Position;
import fr.cph.chicago.entity.enumeration.TrainLine;
import fr.cph.chicago.task.GlobalConnectTask;

/**
 * Util class
 *
 * @author <NAME>
 * @version 1
 */
public final class Util {

    private static final String TAG = Util.class.getSimpleName();

    public static final LatLng CHICAGO = new LatLng(41.8819, -87.6278);

    private static final AtomicInteger sNextGeneratedId = new AtomicInteger(1);

    public static final String NETWORK_ERROR = "No network connection detected!";

    private static final String ADDED_TO_FAVORITES = "Added to favorites!";

    private static final String REMOVED_FROM_FAVORITES = "Removed from favorites!";

    private Util(){
    }

    public static int generateViewId() {
        for (; ; ) {
            final int result = sNextGeneratedId.get();
            // aapt-generated IDs have the high byte nonzero; clamp to the range under that.
            int newValue = result + 1;
            if (newValue > 0x00FFFFFF)
                newValue = 1; // Roll over to 1, not 0.
            if (sNextGeneratedId.compareAndSet(result, newValue)) {
                return result;
            }
        }
    }

    /**
     * Get property from file
     *
     * @param property the property to get
     * @return the value of the property
     */
    @NonNull
    public static String getProperty(@NonNull final String property) {
        final Properties prop = new Properties();
        try {
            prop.load(App.getContext().getAssets().open("app.properties"));
        } catch (IOException e) {
            Log.e(TAG, e.getMessage(), e);
            return null;
        }
        return prop.getProperty(property, null);
    }

    /**
     * Add to train favorites
     *
     * @param stationId  the station id
     * @param preference the preference
     */
    public static void addToTrainFavorites(@NonNull final Integer stationId, @NonNull final String preference, @NonNull final View view) {
        final List<Integer> favorites = Preferences.getTrainFavorites(preference);
        if (!favorites.contains(stationId)) {
            favorites.add(stationId);
            Preferences.saveTrainFavorites(App.PREFERENCE_FAVORITES_TRAIN, favorites);
            showSnackBar(view, ADDED_TO_FAVORITES);
        }
    }

    /**
     * Remove train from favorites
     *
     * @param stationId  the station id
     * @param preference the preference
     */
    public static void removeFromTrainFavorites(@NonNull final Integer stationId, @NonNull final String preference, @NonNull final View view) {
        final List<Integer> favorites = Preferences.getTrainFavorites(preference);
        favorites.remove(stationId);<commit_msg>Delete unused getProperty<commit_after>/**
 * Copyright 2016 <NAME>
 * <p/>
 * 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
 * <p/>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * 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 fr.cph.chicago.util;

import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Point;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.Toolbar;
import android.util.TypedValue;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.widget.Toast;

import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;
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 org.apache.commons.collections4.MultiValuedMap;
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;

import fr.cph.chicago.App;
import fr.cph.chicago.R;
import fr.cph.chicago.data.Preferences;
import fr.cph.chicago.entity.BikeStation;
import fr.cph.chicago.entity.Position;
import fr.cph.chicago.entity.enumeration.TrainLine;
import fr.cph.chicago.task.GlobalConnectTask;

/**
 * Util class
 *
 * @author <NAME>
 * @version 1
 */
public final class Util {

    private static final String TAG = Util.class.getSimpleName();

    public static final LatLng CHICAGO = new LatLng(41.8819, -87.6278);

    private static final AtomicInteger sNextGeneratedId = new AtomicInteger(1);

    public static final String NETWORK_ERROR = "No network connection detected!";

    private static final String ADDED_TO_FAVORITES = "Added to favorites!";

    private static final String REMOVED_FROM_FAVORITES = "Removed from favorites!";

    private Util(){
    }

    public static int generateViewId() {
        for (; ; ) {
            final int result = sNextGeneratedId.get();
            // aapt-generated IDs have the high byte nonzero; clamp to the range under that.
            int newValue = result + 1;
            if (newValue > 0x00FFFFFF)
                newValue = 1; // Roll over to 1, not 0.
            if (sNextGeneratedId.compareAndSet(result, newValue)) {
                return result;
            }
        }
    }

    /**
     * Add to train favorites
     *
     * @param stationId  the station id
     * @param preference the preference
     */
    public static void addToTrainFavorites(@NonNull final Integer stationId, @NonNull final String preference, @NonNull final View view) {
        final List<Integer> favorites = Preferences.getTrainFavorites(preference);
        if (!favorites.contains(stationId)) {
            favorites.add(stationId);
            Preferences.saveTrainFavorites(App.PREFERENCE_FAVORITES_TRAIN, favorites);
            showSnackBar(view, ADDED_TO_FAVORITES);
        }
    }

    /**
     * Remove train from favorites
     *
     * @param stationId  the station id
     * @param preference the preference
     */
    public static void removeFromTrainFavorites(@NonNull final Integer stationId, @NonNull final String preference, @NonNull final View view) {
        final List<Integer> favorites = Preferences.getTrainFavorites(preference);
        favorites.remove(stationId);
{'fraction_non_alphanumeric': 0.09442643521907351, 'fraction_numerical': 0.007110739307748614, 'mean_word_length': 3.5848513902205177, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, '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': '5755331', 'n_tokens_mistral': 2765, 'n_tokens_neox': 2714, 'n_words': 747}