[android] fix: Code review fixes #2.

This commit is contained in:
Alexander Marchuk 2015-12-07 17:02:33 +03:00 committed by Constantin Shalnev
parent a0900807b3
commit eef36d0e43
6 changed files with 12 additions and 15 deletions

View file

@ -1,5 +1,4 @@
#include "Framework.hpp"
#include "../platform/Platform.hpp"
#include "std/chrono.hpp"

View file

@ -13,7 +13,7 @@ import com.mapswithme.util.concurrency.UiThread;
/**
* Helper class that detects when the application goes to background and back to foreground.
* <br/>Must be created as early as possible, i.e. in Application.Create().
* <br/>Must be created as early as possible, i.e. in Application.onCreate().
*/
public final class AppBackgroundTracker
{
@ -102,7 +102,7 @@ public final class AppBackgroundTracker
private void notifyListeners()
{
for (OnTransitionListener listener: mListeners)
for (OnTransitionListener listener : mListeners)
listener.onTransit(mForeground);
mListeners.finishIterate();
}

View file

@ -35,7 +35,7 @@ public class AndroidNativeProvider extends BaseLocationProvider
{
mIsActive = true;
for (final String provider : providers)
mLocationManager.requestLocationUpdates(provider, LocationHelper.INSTANCE.getUpdateInterval(), 0, this);
mLocationManager.requestLocationUpdates(provider, LocationHelper.getUpdateInterval(), 0, this);
LocationHelper.INSTANCE.registerSensorListeners();

View file

@ -36,8 +36,8 @@ public class GoogleFusedLocationProvider extends BaseLocationProvider
{
mLocationRequest = LocationRequest.create();
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationRequest.setInterval(LocationHelper.INSTANCE.getUpdateInterval());
mLocationRequest.setFastestInterval(LocationHelper.INSTANCE.getUpdateInterval() / 2);
mLocationRequest.setInterval(LocationHelper.getUpdateInterval());
mLocationRequest.setFastestInterval(LocationHelper.getUpdateInterval() / 2);
mGoogleApiClient.connect();
}

View file

@ -55,7 +55,6 @@ public enum LocationHelper implements SensorEventListener
private final Listeners<LocationListener> mListeners = new Listeners<>();
private boolean mActive;
private boolean mForegroundMode;
private Location mLastLocation;
private MapObject.MyPosition mMyPosition;
@ -104,7 +103,7 @@ public enum LocationHelper implements SensorEventListener
@Override
public void onTransit(boolean foreground)
{
setForegroundMode(foreground);
setForegroundMode();
}
});
}
@ -305,9 +304,8 @@ public enum LocationHelper implements SensorEventListener
}
}
private void setForegroundMode(boolean set)
private void setForegroundMode()
{
mForegroundMode = set;
if (!mActive)
return;
@ -316,13 +314,13 @@ public enum LocationHelper implements SensorEventListener
mLocationProvider.startUpdates();
}
public long getUpdateInterval()
public static long getUpdateInterval()
{
return (mForegroundMode ? UPDATE_INTERVAL_FOREGROUND_MS
: UPDATE_INTERVAL_BACKGROUND_MS);
return (MwmApplication.backgroundTracker().isForeground() ? UPDATE_INTERVAL_FOREGROUND_MS
: UPDATE_INTERVAL_BACKGROUND_MS);
}
public static void onLocationUpdated(Location location)
public static void onLocationUpdated(@NonNull Location location)
{
nativeLocationUpdated(location.getTime(),
location.getLatitude(),

View file

@ -56,7 +56,7 @@ public final class TrackRecorder
TrackRecorderWakeService.stop();
}
else
sAlarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + LocationHelper.INSTANCE.getUpdateInterval(), getAlarmIntent());
sAlarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + LocationHelper.getUpdateInterval(), getAlarmIntent());
}
private static PendingIntent getAlarmIntent()