Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AL4AL/ebb2fc630df0351c5a13afc469934588 to your computer and use it in GitHub Desktop.
Save AL4AL/ebb2fc630df0351c5a13afc469934588 to your computer and use it in GitHub Desktop.
private static CurrentLocationProvider.OnLocationSuccessReceiveListener getLocationSuccessListener(Context context){
if (locationSuccessReceiveListener == null)
locationSuccessReceiveListener = location -> {
if (!shouldStopSending) {
if (isNotSoClose(location)){
IntentFilter batteryIntentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
Intent batteryStatus = context.registerReceiver(null, batteryIntentFilter);
int level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
new InsertLocationViewModel(MyApplication.getInstance())
.insert(new WorkerLocation(location.getTime(), location.getLatitude(), location.getLongitude(), false));
}
}
};
return locationSuccessReceiveListener;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment