コード例 #1
0
  @SuppressLint("NewApi")
  @Override
  public void onValueSelected(Entry e, Highlight h) {
    int selectedDifficulty = (int) e.getX();

    clearSelectedRoutes();

    for (ClimbingRoute route : selectedArea.getRoutes()) {
      if (Utils.trimUIAARank(route.getUIAARank()) == selectedDifficulty) selectedRoutes.add(route);
    }
    // recyclerViewAdapter.notifyItemRangeChanged(0, selectedRoutes.size());
    recyclerViewAdapter.notifyItemRangeRemoved(0, selectedArea.getRoutes().size());
    recList.invalidate();

    if (selectedRoutes.isEmpty()) onNothingSelected();
  }
コード例 #2
0
  private void setChartData(ClimbingArea ClimbingArea) {

    HashMap<Integer, Integer> difficultyMap = new HashMap<>();
    for (int i = AppConstants.MIN_UIAA_LEVEL; i <= AppConstants.MAX_UIAA_LEVEL; ++i) {
      difficultyMap.put(i, 0);
    }

    for (ClimbingRoute route : ClimbingArea.getRoutes()) {
      String difficulty = route.getUIAARank();
      int routeDifficulty = Utils.trimUIAARank(difficulty);
      if (difficultyMap.containsKey(routeDifficulty)) {
        difficultyMap.put(routeDifficulty, difficultyMap.get(routeDifficulty) + 1);
      }
    }

    ArrayList<BarEntry> routeDifficulties = new ArrayList<BarEntry>();

    String[] xVals = new String[difficultyMap.size()];
    List<Integer> orderedList = new ArrayList<>(difficultyMap.keySet());
    Collections.sort(orderedList);
    int indexCounter = 0;
    for (Integer difficulty : orderedList) {
      xVals[indexCounter] = difficulty + "";
      // BarEntry entry = new BarEntry(difficultyMap.get(difficulty), indexCounter++ , difficulty
      // +"");
      BarEntry entry = new BarEntry(difficulty, difficultyMap.get(difficulty), indexCounter++);
      routeDifficulties.add(entry);
    }
    mChart.getXAxis().setLabelCount(xVals.length);

    BarDataSet set1 = new BarDataSet(routeDifficulties, "Schwierigkeiten");
    // set1.setColor(getResources().getColor(R.color.primary_700));
    int[] uiaaChartColors = new int[AppConstants.UIAA_CHART_COLORS.length];
    for (int i = 0; i < uiaaChartColors.length; ++i) {
      uiaaChartColors[i] = getResources().getColor(AppConstants.UIAA_CHART_COLORS[i]);
    }
    set1.setColors(uiaaChartColors);

    ArrayList<IBarDataSet> dataSets = new ArrayList<>();
    dataSets.add(set1);

    BarData data = new BarData(dataSets);
    data.setValueFormatter(new MyValueFormatter());
    data.setValueTextSize(10f);

    mChart.setData(data);

    mChart.animateX(1000);
    mChart.animateY(1000);
  }
コード例 #3
0
  @Override
  public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    // Replace the result Cursor displayed by the Cursor Adapter with
    // the new result set.

    // This handler is not synchonrized with the UI thread, so you
    // will need to synchronize it before modiyfing any UI elements
    // directly.
    switch (loader.getId()) {
      case URL_ROUTES_LOADER_ALL:
        while (data.moveToNext()) {

          int climbingRouteIdColumnIndex = data.getColumnIndex(ClimbingDBHelper.COLUMN_ROUTES_ID);
          int climbingRouteNameColumnIndex =
              data.getColumnIndex(ClimbingDBHelper.COLUMN_ROUTES_NAME);
          int climbingRouteLatitudeColumnIndex =
              data.getColumnIndex(ClimbingDBHelper.COLUMN_ROUTES_LATITUDE);
          int climbingRouteLongitudeColumnIndex =
              data.getColumnIndex(ClimbingDBHelper.COLUMN_ROUTES_LONGITUDE);
          int climbingRouteRankingColumnIndex =
              data.getColumnIndex(ClimbingDBHelper.COLUMN_ROUTES_RANKING);
          int climbingRouteImageColumnIndex =
              data.getColumnIndex(ClimbingDBHelper.COLUMN_ROUTES_IMAGE_URL);
          int climbingRouteDifficultyColumnIndex =
              data.getColumnIndex(ClimbingDBHelper.COLUMN_ROUTES_UIAA);
          int climbingRouteFollowClimbColumnIndex =
              data.getColumnIndex(ClimbingDBHelper.COLUMN_ROUTES_FOLLOW_CLIMB_ACCOMPLISHED);
          int climbingRouteLeadingClimbColumnIndex =
              data.getColumnIndex(ClimbingDBHelper.COLUMN_ROUTES_LEADING_CLIMB_ACCOMPLISHED);
          int climbingRouteRouteAccomplishedColumnIndex =
              data.getColumnIndex(ClimbingDBHelper.COLUMN_ROUTES_ROUTE_ACCOMPLISHED);
          int climbingRouteClimbingAreaColumnIndex =
              data.getColumnIndex(ClimbingDBHelper.COLUMN_ROUTES_CLIMBINGAREA_ID);

          int id = data.getInt(climbingRouteIdColumnIndex);
          String name = data.getString(climbingRouteNameColumnIndex);
          float latitude = data.getFloat(climbingRouteLatitudeColumnIndex);
          float longitude = data.getFloat(climbingRouteLongitudeColumnIndex);
          float ranking = data.getFloat(climbingRouteRankingColumnIndex);
          String difficulty = data.getString(climbingRouteDifficultyColumnIndex);
          String imageUrl = data.getString(climbingRouteImageColumnIndex);
          boolean followClimbAccomplished = data.getInt(climbingRouteFollowClimbColumnIndex) > 0;
          boolean leadClimbAccomplished = data.getInt(climbingRouteLeadingClimbColumnIndex) > 0;
          boolean routeAccomplished = data.getInt(climbingRouteRouteAccomplishedColumnIndex) > 0;
          int climbingArea = data.getInt(climbingRouteClimbingAreaColumnIndex);

          ClimbingRoute climbingRoute = new ClimbingRoute();
          climbingRoute.setId(id);
          climbingRoute.setName(name);
          climbingRoute.setLatitude(latitude);
          climbingRoute.setLongitude(longitude);
          climbingRoute.setRanking(ranking);
          climbingRoute.setDrawableUrl(imageUrl);
          climbingRoute.setUIAARank(difficulty);
          climbingRoute.setFollowClimbAccomplished(followClimbAccomplished);
          climbingRoute.setLeadClimbAccomplished(leadClimbAccomplished);
          climbingRoute.setRouteAccomplished(routeAccomplished);

          Log.d(TAG, "Climbing Area loaded: " + climbingArea);
          selectedArea.getRoutes().add(climbingRoute);
        }
        break;
      default:
    }

    int size = selectedRoutes.size();
    clearSelectedRoutes();
    selectedRoutes.addAll(selectedArea.getRoutes());
    recyclerViewAdapter.notifyItemRangeRemoved(0, size);
    setChartData(selectedArea);
    setShareIntent(selectedArea);
    // TextView sumRoutes = (TextView) findViewById(R.id.textView_sum_routes);
    // sumRoutes.setText(selectedArea.getRoutes().size() + "");
  }
コード例 #4
0
 public void onNothingSelected() {
   clearSelectedRoutes();
   selectedRoutes.addAll(selectedArea.getRoutes());
   recyclerViewAdapter.notifyItemRangeRemoved(0, selectedArea.getRoutes().size());
 };
コード例 #5
0
 private void clearSelectedRoutes() {
   int size = selectedRoutes.size();
   selectedRoutes.clear();
   recyclerViewAdapter.notifyItemRangeRemoved(0, selectedArea.getRoutes().size());
 }