From 2cdc07c601c2158ac40bb4c0b5532e45ba9b3ebc Mon Sep 17 00:00:00 2001 From: misaochan Date: Fri, 26 Aug 2016 18:31:48 +1200 Subject: [PATCH] Check sorted list - location not working --- .../java/fr/free/nrw/commons/nearby/NearbyActivity.java | 3 +-- .../fr/free/nrw/commons/nearby/NearbyListFragment.java | 8 +++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/nearby/NearbyActivity.java b/app/src/main/java/fr/free/nrw/commons/nearby/NearbyActivity.java index 3d9ebefc3..5d985df34 100644 --- a/app/src/main/java/fr/free/nrw/commons/nearby/NearbyActivity.java +++ b/app/src/main/java/fr/free/nrw/commons/nearby/NearbyActivity.java @@ -31,8 +31,6 @@ public class NearbyActivity extends AppCompatActivity { setContentView(R.layout.activity_nearby); getSupportActionBar().setDisplayHomeAsUpEnabled(true); - registerLocationManager(); - // Begin the transaction FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); NearbyListFragment fragment = new NearbyListFragment(); @@ -70,6 +68,7 @@ public class NearbyActivity extends AppCompatActivity { try { locationManager.requestLocationUpdates(provider, 400, 1, myLocationListener); Location location = locationManager.getLastKnownLocation(provider); + Log.d(TAG, "Checking for location..."); if (location != null) { myLocationListener.onLocationChanged(location); } diff --git a/app/src/main/java/fr/free/nrw/commons/nearby/NearbyListFragment.java b/app/src/main/java/fr/free/nrw/commons/nearby/NearbyListFragment.java index 4b5149dff..2bca37d91 100644 --- a/app/src/main/java/fr/free/nrw/commons/nearby/NearbyListFragment.java +++ b/app/src/main/java/fr/free/nrw/commons/nearby/NearbyListFragment.java @@ -61,11 +61,12 @@ public class NearbyListFragment extends ListFragment { return view; } + //TODO: Do asynchronously? @Override public void onViewCreated(View view, Bundle savedInstanceState) { //Load from data source (NearbyPlaces.java) - //TODO: Do asynchronously? + //FIXME: mLatestLocation not set. Hardcode it first for testing places = loadAttractionsFromLocation(mLatestLocation); final ListView listview = (ListView) view.findViewById(R.id.listview); @@ -81,6 +82,7 @@ public class NearbyListFragment extends ListFragment { List places = NearbyPlaces.get(); if (curLatLng != null) { + Log.d(TAG, "Sorting places by distance..."); Collections.sort(places, new Comparator() { @Override @@ -94,6 +96,10 @@ public class NearbyListFragment extends ListFragment { } ); } + //FIXME: This doesn't sort appropriately + for(int i = 0; i < places.size(); i++) { + System.out.println("Sorted " + places.get(i).name); + } return places; }