0

I am trying to show the cardview created programatically, that contains an image view and a text view of registered user, I'd like to order it by location, so the closest user to me will be shown first, I overridden the compare method, getting the location and subtracting the available user location, but it doesn't work properly. Anyone can help?

@Override
            public int compare(Users o1, Users o2) {
                return (int)(o1.getDistance()-o2.getDistance());
            }
        } );






public void getDistance(){
for(Users u: UsersResource.getInstance().getList()){
    float[] distance = new float[2];

Location.distanceBetween( loc.getLatitude(), loc.getLongitude(),
    u.getLatitude(), u.getLongtitude(), distance);

u.setDistance( distance[0] );
    System.out.println("distance "+ distance[0]);

     }}
Werokk
  • 89
  • 2
  • 14

1 Answers1

-2

you can use cardview.orderbylocation