Ejemplo n.º 1
0
  @Override
  public void onItemClick(
      final AdapterView<?> parent, final View view, final int position, final long id) {

    final SectionListAdapter sectionListAdapter = (SectionListAdapter) parent.getAdapter();

    final MapListSectionAdapter mapListSectionAdapter =
        (MapListSectionAdapter) sectionListAdapter.getAdapter(position);

    // /
    final Object item = sectionListAdapter.getItem(position);
    if (item instanceof MapListEntry) {
      final MapListEntry clickedEntry = (MapListEntry) item;

      final List<MapListEntry> mapListEntryList =
          mapListSectionAdapter.mapListSection.getMapListEntryList();

      // uncheck all entries in section:
      for (final MapListEntry mapListEntry : mapListEntryList) mapListEntry.setChecked(false);

      // recheck checked entry:
      clickedEntry.setChecked(true);

      // handle sat differently
      final String value = clickedEntry.getValue();
      final RMBTMainActivity activity = getRMBTMainActivity();
      if (MapProperties.MAP_SAT_KEY.equals(clickedEntry.getKey()))
        activity.setMapTypeSatellite(MapProperties.MAP_SAT_VALUE.equals(value));
      else if (MapProperties.MAP_OVERLAY_KEY.equals(clickedEntry.getKey())) {
        if (MapProperties.MAP_AUTO_VALUE.equals(value))
          activity.setMapOverlayType(MapProperties.MAP_OVERLAY_TYPE_AUTO);
        else if (MapProperties.MAP_HEATMAP_VALUE.equals(value))
          activity.setMapOverlayType(MapProperties.MAP_OVERLAY_TYPE_HEATMAP);
        else if (MapProperties.MAP_POINTS_VALUE.equals(value))
          activity.setMapOverlayType(MapProperties.MAP_OVERLAY_TYPE_POINTS);
        else if (MapProperties.MAP_SHAPES_VALUE.equals(value))
          activity.setMapOverlayType(MapProperties.MAP_OVERLAY_TYPE_SHAPES);
      } else
        // set new filter options:
        activity.updateMapFilter();

      // reload list view:
      ((SectionListAdapter) parent.getAdapter()).notifyDataSetChanged();
    }
  }
Ejemplo n.º 2
0
  protected void populateList() {
    final RMBTMainActivity activity = getRMBTMainActivity();
    final SectionListAdapter sectionListAdapter =
        new SectionListAdapter(activity, R.layout.preferences_category);

    // add filter options

    for (final MapListSection mapListSection : activity.getMapFilterListSelectionList())
      sectionListAdapter.addSection(
          mapListSection.getTitle(), new MapListSectionAdapter(activity, mapListSection));

    // /

    final ListView listView = (ListView) view.findViewById(R.id.valueList);

    listView.setAdapter(sectionListAdapter);

    listView.setItemsCanFocus(true);
    listView.setOnItemClickListener(this);
  }