mirror of
https://gitlab.com/oeffi/oeffi.git
synced 2025-07-07 06:08:51 +00:00
Constants: Split location update timeout into constant for background and constant for foreground.
This commit is contained in:
parent
6c5fcbaae4
commit
45653b9926
6 changed files with 8 additions and 7 deletions
|
@ -43,7 +43,8 @@ public class Constants {
|
|||
|
||||
public static final long LOCATION_UPDATE_FREQ_MS = 10 * DateUtils.SECOND_IN_MILLIS;
|
||||
public static final int LOCATION_UPDATE_DISTANCE = 3;
|
||||
public static final long LOCATION_TIMEOUT_MS = 2 * DateUtils.MINUTE_IN_MILLIS;
|
||||
public static final long LOCATION_FOREGROUND_UPDATE_TIMEOUT_MS = 1 * DateUtils.MINUTE_IN_MILLIS;
|
||||
public static final long LOCATION_BACKGROUND_UPDATE_TIMEOUT_MS = 5 * DateUtils.MINUTE_IN_MILLIS;
|
||||
public static final long STALE_UPDATE_MS = 2 * DateUtils.MINUTE_IN_MILLIS;
|
||||
public static final int MAX_NUMBER_OF_STOPS = 150;
|
||||
public static final int MAX_HISTORY_ENTRIES = 50;
|
||||
|
|
|
@ -133,7 +133,7 @@ public class DirectionsShortcutActivity extends OeffiActivity
|
|||
final Criteria criteria = new Criteria();
|
||||
criteria.setPowerRequirement(Criteria.POWER_MEDIUM);
|
||||
criteria.setAccuracy(Criteria.ACCURACY_COARSE);
|
||||
locationHelper.startLocation(criteria, false, Constants.LOCATION_TIMEOUT_MS);
|
||||
locationHelper.startLocation(criteria, false, Constants.LOCATION_FOREGROUND_UPDATE_TIMEOUT_MS);
|
||||
}
|
||||
|
||||
public void stopLocation() {
|
||||
|
|
|
@ -280,7 +280,7 @@ public class LocationView extends FrameLayout implements LocationHelper.Callback
|
|||
final Criteria criteria = new Criteria();
|
||||
criteria.setPowerRequirement(Criteria.POWER_MEDIUM);
|
||||
criteria.setAccuracy(Criteria.ACCURACY_COARSE);
|
||||
locationHelper.startLocation(criteria, false, Constants.LOCATION_TIMEOUT_MS);
|
||||
locationHelper.startLocation(criteria, false, Constants.LOCATION_FOREGROUND_UPDATE_TIMEOUT_MS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -246,7 +246,7 @@ public class NetworkPickerActivity extends Activity implements ActivityCompat.On
|
|||
|
||||
final Criteria criteria = new Criteria();
|
||||
criteria.setPowerRequirement(Criteria.POWER_LOW);
|
||||
locationHelper.startLocation(criteria, true, Constants.LOCATION_TIMEOUT_MS);
|
||||
locationHelper.startLocation(criteria, true, Constants.LOCATION_FOREGROUND_UPDATE_TIMEOUT_MS);
|
||||
}
|
||||
|
||||
public void stopLocation() {
|
||||
|
|
|
@ -203,7 +203,7 @@ public class PlansPickerActivity extends OeffiMainActivity implements ActivityCo
|
|||
|
||||
final Criteria criteria = new Criteria();
|
||||
criteria.setPowerRequirement(Criteria.POWER_LOW);
|
||||
locationHelper.startLocation(criteria, true, Constants.LOCATION_TIMEOUT_MS);
|
||||
locationHelper.startLocation(criteria, true, Constants.LOCATION_FOREGROUND_UPDATE_TIMEOUT_MS);
|
||||
}
|
||||
|
||||
public void stopLocation() {
|
||||
|
|
|
@ -151,12 +151,12 @@ public class NearestFavoriteStationWidgetService extends JobIntentService {
|
|||
}, backgroundHandler.getLooper());
|
||||
|
||||
try {
|
||||
final Location here = future.get(Constants.LOCATION_TIMEOUT_MS, TimeUnit.MILLISECONDS);
|
||||
final Location here = future.get(Constants.LOCATION_BACKGROUND_UPDATE_TIMEOUT_MS, TimeUnit.MILLISECONDS);
|
||||
log.info("Widgets: {}, location: {}", Arrays.toString(appWidgetIds), here);
|
||||
handleLocation(appWidgetIds, here);
|
||||
} catch (final TimeoutException x) {
|
||||
log.info("Widgets: {}, location timed out after {} ms", Arrays.toString(appWidgetIds),
|
||||
Constants.LOCATION_TIMEOUT_MS);
|
||||
Constants.LOCATION_BACKGROUND_UPDATE_TIMEOUT_MS);
|
||||
widgetsHeader(appWidgetIds, getString(R.string.acquire_location_timeout));
|
||||
} catch (final InterruptedException | ExecutionException x) {
|
||||
throw new RuntimeException(x);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue