From 35ef25b2b79bec57d83e7a27a9ad38be4a5572fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mieszko=20Wrzeszczy=C5=84ski?= Date: Fri, 4 Jan 2019 11:11:55 +0100 Subject: [PATCH] Extend history --- app/build.gradle | 2 +- .../java/com/uam/wmi/findmytutor/activity/MapActivity.java | 6 ++++-- .../findmytutor/service/BackgroundLocalizationService.java | 6 +++--- app/src/main/java/com/uam/wmi/findmytutor/utils/Const.java | 1 + 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 6bb70c6..019ca68 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,7 +10,7 @@ android { applicationId "com.uam.wmi.findmytutor" minSdkVersion 22 targetSdkVersion 27 - versionCode 30 + versionCode 33 versionName "0.9.6-beta" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java index e0d4309..2b16107 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java @@ -70,6 +70,8 @@ import io.reactivex.schedulers.Schedulers; import okhttp3.ResponseBody; import timber.log.Timber; +import static com.uam.wmi.findmytutor.utils.Const.mapRefreshInterval; + public class MapActivity extends BaseActivity implements PermissionsListener, OnMapReadyCallback { @@ -80,7 +82,7 @@ public class MapActivity extends BaseActivity private UserService userService; private CompositeDisposable disposable = new CompositeDisposable(); - private int mInterval = 10000; + private int mInterval = mapRefreshInterval; private Handler mHandler = new Handler(); private Runnable mStatusChecker; private MapView mapView; @@ -603,7 +605,6 @@ public class MapActivity extends BaseActivity } } - // Add the mapView lifecycle to the activity's lifecycle methods @Override public void onResume() { super.onResume(); @@ -615,6 +616,7 @@ public class MapActivity extends BaseActivity protected void onStart() { super.onStart(); mapView.onStart(); + shouldFetchNewCoords = true; } @Override diff --git a/app/src/main/java/com/uam/wmi/findmytutor/service/BackgroundLocalizationService.java b/app/src/main/java/com/uam/wmi/findmytutor/service/BackgroundLocalizationService.java index c05680c..81fecf3 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/service/BackgroundLocalizationService.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/service/BackgroundLocalizationService.java @@ -62,7 +62,7 @@ public class BackgroundLocalizationService extends Service { private static Integer notify_interval = onlineBackgroundLocationInterval; private static Integer notify_interval_inside_building = onlineBackgroundLocationInterval; private static Integer notify_interval_outside_building = offlineBackgroundLocationInterval; - private static int coordinatesHistoryLength = 5; + private static int coordinatesHistoryLength = 10; private Boolean highAccuracyMode; private Location mLastLocation; private Boolean stopService = false; @@ -195,7 +195,7 @@ public class BackgroundLocalizationService extends Service { notify_interval = notify_interval_inside_building; } - if (coordinatesHistory.size() > 4 && shouldExtendTimeInterval) { + if (coordinatesHistory.size() > coordinatesHistoryLength && shouldExtendTimeInterval) { notify_interval = notify_interval_outside_building; } @@ -203,7 +203,6 @@ public class BackgroundLocalizationService extends Service { if (changedMode != 0) { updateListeners(); } - } @RequiresApi(api = Build.VERSION_CODES.O) @@ -294,6 +293,7 @@ public class BackgroundLocalizationService extends Service { latitude = location.getLatitude(); longitude = location.getLongitude(); altitude = location.getAltitude(); + approximatedLocalization = new ApproximatedLocalization(MapUtils.loadJsonFromAsset(getApplicationContext(), "building.geojson")); approximatedBuildingPart = approximatedLocalization.getNameOfBuildingPart(Point.fromLngLat(longitude, latitude)); } diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/Const.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/Const.java index 0590a2f..d15ed63 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/utils/Const.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/Const.java @@ -7,6 +7,7 @@ import java.util.List; public class Const { public final static String BASE_URL = "https://s416084.projektstudencki.pl/master/"; + public final static Integer mapRefreshInterval = 5000; public final static Integer onlineBackgroundLocationInterval = 7000; public final static Integer offlineBackgroundLocationInterval = 360000; public final static Integer defaultMapZoom = 17;