Updated Location Service to use Google Play Location Service

This commit is contained in:
2014-09-17 20:27:13 -04:00
parent 6f42994da5
commit aa69f23600
2 changed files with 25 additions and 6 deletions

View File

@@ -42,8 +42,7 @@ public class LocationService extends com.TwentyCodes.android.location.LocationSe
* @author ricky barrette
*/
public static Intent getSingleShotServiceIntent(final Context context) {
return new Intent(context, LocationService.class).putExtra(LocationLibraryConstants.INTENT_EXTRA_REQUIRED_ACCURACY, Constraints.ACCURACY).setAction(
LocationLibraryConstants.INTENT_ACTION_UPDATE);
return new Intent(context, LocationService.class).putExtra(LocationLibraryConstants.INTENT_EXTRA_REQUIRED_ACCURACY, Constraints.ACCURACY).setAction( LocationLibraryConstants.INTENT_ACTION_UPDATE);
}
/**

View File

@@ -145,17 +145,37 @@ public class LocationInformationFragment extends Fragment implements LatLngListe
mProgress = (ProgressBar) view.findViewById(R.id.map_progress);
if (mInfo.get(RingerDatabase.KEY_RADIUS) != null) {
mRadius.setProgress(mInfo.getAsInteger(RingerDatabase.KEY_RADIUS));
}
if (mInfo.get(RingerDatabase.KEY_LOCATION) != null) {
final String[] point = mInfo.getAsString(RingerDatabase.KEY_LOCATION).split(",");
final LatLng location = new LatLng(Double.parseDouble(point[0]), Double.parseDouble(point[1]));
mCircle.setCenter(location);
mMarker.setPosition(location);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(location, 14));
mMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
@Override
public void onMapLoaded() {
if(Constraints.DEBUG)
Log.d(TAG,"onMapLoaded()");
final LatLngBounds.Builder builder = LatLngBounds.builder();
builder.include(location);
builder.include(GeoUtils.distanceFrom(location, mRadius.getProgress(), 90));
mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(builder.build(),25, 25, 5));
// mMap.moveCamera(CameraUpdateFactory.newLatLng(location));
if(Constraints.DEBUG){
final MarkerOptions marker = new MarkerOptions();
marker.position(location);
marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_CYAN));
mMap.addMarker(marker);
}
if (mInfo.get(RingerDatabase.KEY_RADIUS) != null) {
mRadius.setProgress(mInfo.getAsInteger(RingerDatabase.KEY_RADIUS));
}
});
}
view.findViewById(R.id.my_location).setOnClickListener(this);