mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Pass location to NearbyListFragment
This commit is contained in:
parent
2cdc07c601
commit
5953395fa2
2 changed files with 10 additions and 2 deletions
|
|
@ -19,6 +19,7 @@ public class NearbyActivity extends AppCompatActivity {
|
||||||
private LocationManager locationManager;
|
private LocationManager locationManager;
|
||||||
private String provider;
|
private String provider;
|
||||||
private Criteria criteria;
|
private Criteria criteria;
|
||||||
|
private LatLng mLatestLocation;
|
||||||
|
|
||||||
private double currentLatitude, currentLongitude;
|
private double currentLatitude, currentLongitude;
|
||||||
//private String gpsCoords;
|
//private String gpsCoords;
|
||||||
|
|
@ -30,6 +31,7 @@ public class NearbyActivity extends AppCompatActivity {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_nearby);
|
setContentView(R.layout.activity_nearby);
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
registerLocationManager();
|
||||||
|
|
||||||
// Begin the transaction
|
// Begin the transaction
|
||||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||||
|
|
@ -50,12 +52,14 @@ public class NearbyActivity extends AppCompatActivity {
|
||||||
protected void onResume(){
|
protected void onResume(){
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
registerLocationManager();
|
|
||||||
//TODO: Check if we need String or double coords, and in what format
|
//TODO: Check if we need String or double coords, and in what format
|
||||||
//gpsCoords = String.valueOf(currentLatitude) + "|" + String.valueOf(currentLongitude);
|
//gpsCoords = String.valueOf(currentLatitude) + "|" + String.valueOf(currentLongitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected LatLng getmLatestLocation() {
|
||||||
|
return mLatestLocation;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Registers a LocationManager to listen for current location
|
* Registers a LocationManager to listen for current location
|
||||||
*/
|
*/
|
||||||
|
|
@ -68,6 +72,7 @@ public class NearbyActivity extends AppCompatActivity {
|
||||||
try {
|
try {
|
||||||
locationManager.requestLocationUpdates(provider, 400, 1, myLocationListener);
|
locationManager.requestLocationUpdates(provider, 400, 1, myLocationListener);
|
||||||
Location location = locationManager.getLastKnownLocation(provider);
|
Location location = locationManager.getLastKnownLocation(provider);
|
||||||
|
//Location works, just need to 'send' GPS coords via emulator extended controls if testing on emulator
|
||||||
Log.d(TAG, "Checking for location...");
|
Log.d(TAG, "Checking for location...");
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
myLocationListener.onLocationChanged(location);
|
myLocationListener.onLocationChanged(location);
|
||||||
|
|
@ -97,6 +102,8 @@ public class NearbyActivity extends AppCompatActivity {
|
||||||
currentLatitude = location.getLatitude();
|
currentLatitude = location.getLatitude();
|
||||||
currentLongitude = location.getLongitude();
|
currentLongitude = location.getLongitude();
|
||||||
Log.d(TAG, "Latitude: " + String.valueOf(currentLatitude) + " Longitude: " + String.valueOf(currentLongitude));
|
Log.d(TAG, "Latitude: " + String.valueOf(currentLatitude) + " Longitude: " + String.valueOf(currentLongitude));
|
||||||
|
|
||||||
|
mLatestLocation = new LatLng(currentLatitude, currentLongitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ public class NearbyListFragment extends ListFragment {
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
|
|
||||||
//Load from data source (NearbyPlaces.java)
|
//Load from data source (NearbyPlaces.java)
|
||||||
|
LatLng mLatestLocation = ((NearbyActivity) getActivity()).getmLatestLocation();
|
||||||
//FIXME: mLatestLocation not set. Hardcode it first for testing
|
//FIXME: mLatestLocation not set. Hardcode it first for testing
|
||||||
places = loadAttractionsFromLocation(mLatestLocation);
|
places = loadAttractionsFromLocation(mLatestLocation);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue