<commit_before>package com.ecomhack.riddle.estimote;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;

import com.ecomhack.riddle.ConstantsStateKeys;
import com.estimote.sdk.Beacon;

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;

/**
 * Created by stephanwels1 on 09.05.15.
 */
public class NearbyProductDiscovery {

    // should be retrieved dynamically from a database...
    private static HashMap<Integer, String> beaconMajorToProduct;

    static {
        beaconMajorToProduct = new HashMap<>();
        beaconMajorToProduct.put(38286, "Product X");
        beaconMajorToProduct.put(33910, "Product Y");
    }

    private final Context context;

    public NearbyProductDiscovery(final Context context){
        this.context = Objects.requireNonNull(context, "context must not be null");
    }

    public void discoverProducts(List<Beacon> nearbyBeacons){
        Set<String> nearProducts = new HashSet<>();
        for (Beacon beacon : nearbyBeacons){

            if (beaconMajorToProduct.containsKey(beacon.getMajor())){
                nearProducts.add(beaconMajorToProduct.get(beacon.getMajor()));
            }
        }
        storeNearProducts(nearProducts);
    }

    private void storeNearProducts(Set<String> nearProducts) {
        Log.i("riddle", "Nearby Products: " + nearProducts.toString());

        SharedPreferences pref = context.getSharedPreferences("MyPref", 0); // 0 - for private mode
        SharedPreferences.Editor editor = pref.edit();
        editor.putStringSet(ConstantsStateKeys.KEY_NEAR_PRODUCTS, nearProducts);
        editor.commit(); // commit changes
    }
}
<commit_msg>added white beacon. Limited distance for "near" objects to 2 meters<commit_after>package com.ecomhack.riddle.estimote;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;

import com.ecomhack.riddle.ConstantsStateKeys;
import com.estimote.sdk.Beacon;
import com.estimote.sdk.Utils;

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;

/**
 * Created by stephanwels1 on 09.05.15.
 */
public class NearbyProductDiscovery {

    // should be retrieved dynamically from a database...
    private static HashMap<Integer, String> beaconMajorToProduct;

    static {
        beaconMajorToProduct = new HashMap<>();
        beaconMajorToProduct.put(38286, "Product Blue");
        beaconMajorToProduct.put(33910, "Product Light Green");
        beaconMajorToProduct.put(46775, "Product White");
    }

    private final Context context;

    public NearbyProductDiscovery(final Context context){
        this.context = Objects.requireNonNull(context, "context must not be null");
    }

    public void discoverProducts(List<Beacon> nearbyBeacons){
        Set<String> nearProducts = new HashSet<>();
        for (Beacon beacon : nearbyBeacons){

            if (beaconMajorToProduct.containsKey(beacon.getMajor())){
                double distanceMeters = Utils.computeAccuracy(beacon);
                if (distanceMeters<2){
                    // If we are less than 2 meters away from the beacon, we got it
                    nearProducts.add(beaconMajorToProduct.get(beacon.getMajor()));
                }
            }
        }
        storeNearProducts(nearProducts);
    }

    private void storeNearProducts(Set<String> nearProducts) {
        Log.d("riddle", "Nearby Products: " + nearProducts.toString());

        SharedPreferences pref = context.getSharedPreferences("MyPref", 0); // 0 - for private mode
        SharedPreferences.Editor editor = pref.edit();
        editor.putStringSet(ConstantsStateKeys.KEY_NEAR_PRODUCTS, nearProducts);
        editor.commit(); // commit changes
    }
}

{'fraction_non_alphanumeric': 0.10315843097300051, 'fraction_numerical': 0.011716760061130923, 'mean_word_length': 3.282442748091603, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 15, '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': '5110465', 'n_tokens_mistral': 1190, 'n_tokens_neox': 1085, 'n_words': 253}