Add distance field

This commit is contained in:
misaochan 2016-08-29 19:29:49 +12:00
parent fa85e14943
commit 271df17db9
2 changed files with 30 additions and 25 deletions

View file

@ -104,8 +104,10 @@ public class NearbyListFragment extends ListFragment {
}
for(int i = 0; i < places.size(); i++) {
String distance = formatDistanceBetween(mLatestLocation, places.get(i).location);
System.out.println("Sorted " + places.get(i).name + " at " + distance + " away.");
Place place = places.get(i);
String distance = formatDistanceBetween(mLatestLocation, place.location);
System.out.println("Sorted " + place.name + " at " + distance + " away.");
place.setDistance(distance);
}
return places;
}
@ -125,7 +127,6 @@ public class NearbyListFragment extends ListFragment {
public View getView(int position, View convertView, ViewGroup parent) {
// Get the data item for this position
Place place = (Place) getItem(position);
//FIXME: This never gets called
Log.d(TAG, "Place " + place.name);
// Check if an existing view is being reused, otherwise inflate the view
@ -136,10 +137,12 @@ public class NearbyListFragment extends ListFragment {
// Lookup view for data population
TextView tvName = (TextView) convertView.findViewById(R.id.tvName);
TextView tvDesc = (TextView) convertView.findViewById(R.id.tvDesc);
TextView distance = (TextView) convertView.findViewById(R.id.distance);
// Populate the data into the template view using the data object
tvName.setText(place.name);
tvDesc.setText(place.description);
distance.setText(place.distance);
// Return the completed view to render on screen
return convertView;

View file

@ -3,31 +3,33 @@ package fr.free.nrw.commons.nearby;
import android.graphics.Bitmap;
import android.net.Uri;
/**
* Created by misao on 22-Aug-16.
*/
public class Place {
public String name;
public String description;
public String longDescription;
public Uri imageUrl;
public Uri secondaryImageUrl;
public LatLng location;
public String name;
public String description;
public String longDescription;
public Uri imageUrl;
public Uri secondaryImageUrl;
public LatLng location;
public Bitmap image;
public Bitmap secondaryImage;
public String distance;
public Bitmap image;
public Bitmap secondaryImage;
public String distance;
public Place() {}
public Place() {}
public Place(String name, String description, String longDescription, Uri imageUrl,
Uri secondaryImageUrl, LatLng location) {
this.name = name;
this.description = description;
this.longDescription = longDescription;
this.imageUrl = imageUrl;
this.secondaryImageUrl = secondaryImageUrl;
this.location = location;
}
public void setDistance(String distance) {
this.distance = distance;
}
public Place(String name, String description, String longDescription, Uri imageUrl,
Uri secondaryImageUrl, LatLng location) {
this.name = name;
this.description = description;
this.longDescription = longDescription;
this.imageUrl = imageUrl;
this.secondaryImageUrl = secondaryImageUrl;
this.location = location;
}
}