<commit_before>package com.mapzen.android.sdk.sample;

import com.mapzen.android.graphics.FeaturePickListener;
import com.mapzen.android.graphics.MapFragment;
import com.mapzen.android.graphics.MapzenMap;
import com.mapzen.android.graphics.OnMapReadyCallback;
import com.mapzen.tangram.LngLat;

import android.os.Bundle;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Demonstrates how to use the {@link FeaturePickListener}.
 */
public class FeaturePickListenerActivity extends BaseDemoActivity {

  private static final String PROP_SEARCH_INDEX = "searchIndex";
  private static final String PROP_STATE = "state";
  private static final String PROP_NAME = "name";

  MapzenMap map;

  FeaturePickListener listener = new FeaturePickListener() {
    @Override
    public void onFeaturePick(Map<String, String> properties, float positionX, float positionY) {
      String title;
      if (properties.containsKey(PROP_SEARCH_INDEX)) {
        title =
            getString(R.string.feature) + " " + properties.get(PROP_SEARCH_INDEX) + " " + properties
                .get(PROP_STATE);
      } else {
        title = properties.get(PROP_NAME);
      }
      Toast.makeText(FeaturePickListenerActivity.this, title, Toast.LENGTH_SHORT).show();
    }
  };

  @Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample_mapzen);

    final MapFragment mapFragment =
        (MapFragment) getSupportFragmentManager().findFragmentById(R.id.fragment);
    mapFragment.getMapAsync(new OnMapReadyCallback() {
      @Override public void onMapReady(MapzenMap map) {
        FeaturePickListenerActivity.this.map = map;
        map.setZoom(15f);
        map.setPosition(new LngLat(-122.394046, 37.789747));
        map.setFeaturePickListener(listener);
        showSearchResults();
      }
    });
  }

  private void showSearchResults() {
    LngLat result3 = new LngLat(-122.392799, 37.782511);
    LngLat result4 = new LngLat(-122.397477, 37.788243);
    LngLat result5 = new LngLat(-122.393528, 37.789227);
    List<LngLat> results = new ArrayList();
    results.add(result3);<commit_msg>Dont show empty toast in feature pick example (#379)<commit_after>package com.mapzen.android.sdk.sample;

import com.mapzen.android.graphics.FeaturePickListener;
import com.mapzen.android.graphics.MapFragment;
import com.mapzen.android.graphics.MapzenMap;
import com.mapzen.android.graphics.OnMapReadyCallback;
import com.mapzen.tangram.LngLat;

import android.os.Bundle;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Demonstrates how to use the {@link FeaturePickListener}.
 */
public class FeaturePickListenerActivity extends BaseDemoActivity {

  private static final String PROP_SEARCH_INDEX = "searchIndex";
  private static final String PROP_STATE = "state";
  private static final String PROP_NAME = "name";

  MapzenMap map;

  FeaturePickListener listener = new FeaturePickListener() {
    @Override
    public void onFeaturePick(Map<String, String> properties, float positionX, float positionY) {
      String title;
      if (properties.containsKey(PROP_SEARCH_INDEX)) {
        title =
            getString(R.string.feature) + " " + properties.get(PROP_SEARCH_INDEX) + " " + properties
                .get(PROP_STATE);
      } else {
        title = properties.get(PROP_NAME);
      }
      if (title != null && !title.isEmpty()) {
        Toast.makeText(FeaturePickListenerActivity.this, title, Toast.LENGTH_SHORT).show();
      }
    }
  };

  @Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample_mapzen);

    final MapFragment mapFragment =
        (MapFragment) getSupportFragmentManager().findFragmentById(R.id.fragment);
    mapFragment.getMapAsync(new OnMapReadyCallback() {
      @Override public void onMapReady(MapzenMap map) {
        FeaturePickListenerActivity.this.map = map;
        map.setZoom(15f);
        map.setPosition(new LngLat(-122.394046, 37.789747));
        map.setFeaturePickListener(listener);
        showSearchResults();
      }
    });
  }

  private void showSearchResults() {
    LngLat result3 = new LngLat(-122.392799, 37.782511);
    LngLat result4 = new LngLat(-122.397477, 37.788243);
    LngLat result5 = new LngLat(-122.393528, 37.789227);
    List<LngLat> results = new ArrayList();
    results.add(result3);
{'fraction_non_alphanumeric': 0.10566783831282953, 'fraction_numerical': 0.03317223198594024, 'mean_word_length': 3.8027426160337554, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1122464', 'n_tokens_mistral': 1486, 'n_tokens_neox': 1345, 'n_words': 277}