Merge branch 'bg-fused-done' of s416084/find-my-tutor-android into develop
This commit is contained in:
commit
a908623064
@ -142,7 +142,7 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
|
|
||||||
if (!stopService && !PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
|
if (!stopService && !PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
|
||||||
createFusedLocationClient();
|
createFusedLocationClient();
|
||||||
}else if (!stopService &&
|
} else if (!stopService &&
|
||||||
PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
|
PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
|
||||||
mStatusChecker = () -> {
|
mStatusChecker = () -> {
|
||||||
try {
|
try {
|
||||||
@ -184,25 +184,26 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void changeBackgroundMode() {
|
private void changeBackgroundMode() {
|
||||||
if (coordinatesHistory.size() > 4) {
|
|
||||||
Integer prevInterval = notify_interval;
|
Integer prevInterval = notify_interval;
|
||||||
Boolean shouldExtendTimeInterval = Stream.of(coordinatesHistory)
|
Boolean shouldExtendTimeInterval = Stream.of(coordinatesHistory)
|
||||||
.map(MapUtils::checkIfCoordinateIsValid).takeWhile(s -> !s).toList().size() == coordinatesHistory.size();
|
.map(MapUtils::checkIfCoordinateIsValid).takeWhile(s -> !s).toList().size() == coordinatesHistory.size();
|
||||||
|
|
||||||
Boolean shouldAbbreviateTimeInterval = Stream.of(coordinatesHistory).
|
Boolean shouldAbbreviateTimeInterval = Stream.of(coordinatesHistory).
|
||||||
filter(MapUtils::checkIfCoordinateIsValid).toList().size() > 0;
|
map(MapUtils::checkIfCoordinateIsValid).filter(x -> x).toList().size() > 0;
|
||||||
|
|
||||||
if (shouldExtendTimeInterval) {
|
if (shouldAbbreviateTimeInterval) {
|
||||||
notify_interval = notify_interval_outside_building;
|
|
||||||
} else if (shouldAbbreviateTimeInterval) {
|
|
||||||
notify_interval = notify_interval_inside_building;
|
notify_interval = notify_interval_inside_building;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (coordinatesHistory.size() > 4 && shouldExtendTimeInterval) {
|
||||||
|
notify_interval = notify_interval_outside_building;
|
||||||
|
}
|
||||||
|
|
||||||
Integer changedMode = Long.valueOf(prevInterval).compareTo(Long.valueOf(notify_interval));
|
Integer changedMode = Long.valueOf(prevInterval).compareTo(Long.valueOf(notify_interval));
|
||||||
if (changedMode != 0) {
|
if (changedMode != 0) {
|
||||||
updateListeners();
|
updateListeners();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||||
|
Loading…
Reference in New Issue
Block a user