Пример #1
0
  public UsersAdapter(List<QBUser> dataSource, Context ctx) {
    this.dataSource = dataSource;
    this.inflater = LayoutInflater.from(ctx);
    filtered = new ArrayList<>();
    final QBUser self = ChatService.getInstance().getCurrentUser();
    String location = self.getCustomData().toString();
    String[] latLong = location.split(";");
    double myLat = Double.parseDouble(latLong[0]);
    double myLon = Double.parseDouble(latLong[1]);

    for (QBUser u : dataSource) {
      try {
        location = u.getCustomData().toString();
        latLong = location.split(";");
        if (directDistance(
                myLat, myLon, Double.parseDouble(latLong[0]), Double.parseDouble(latLong[1]))
            > 100) {
          continue;
        }
      } catch (Exception e) {
        continue;
      }
      filtered.add(u);
    }
  }