Extend history

This commit is contained in:
Mieszko Wrzeszczyński 2019-01-04 11:11:55 +01:00
parent 87e0be8e79
commit 35ef25b2b7
4 changed files with 9 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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));
}

View File

@ -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;