Skip to content

Commit

Permalink
Merge branch 'misc_fixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpoole committed Aug 16, 2023
2 parents d54b2b5 + 2340f2f commit 891c173
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
12 changes: 11 additions & 1 deletion src/main/java/de/blau/android/dialogs/BarometerCalibration.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package de.blau.android.dialogs;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
Expand Down Expand Up @@ -30,6 +33,8 @@ public class BarometerCalibration extends ImmersiveDialogFragment {

private static final String TAG = "fragment_calibration_form";

private static final Pattern FLOAT_PATTERN = Pattern.compile("[^0-9]*([0-9]+[.][0-9]*)[^0-9]*");

/**
* Display a dialog allowing barometer calibration
*
Expand Down Expand Up @@ -93,7 +98,12 @@ public AppCompatDialog onCreateDialog(Bundle savedInstanceState) {
intent.putExtra(TrackerService.CALIBRATE_HEIGHT_KEY, Integer.parseInt(calibrationValue));
break;
case 1: // reference pressure
intent.putExtra(TrackerService.CALIBRATE_P0_KEY, Float.parseFloat(calibrationValue.substring(0, calibrationValue.length() - 2).trim()));
Matcher matcher = FLOAT_PATTERN.matcher(calibrationValue);
if (matcher.find()) {
intent.putExtra(TrackerService.CALIBRATE_P0_KEY, Float.parseFloat(matcher.group(1)));
} else {
throw new NumberFormatException(calibrationValue);
}
break;
default: // GNSS
// this is the default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ protected void onPostExecute(SerializableState state) {
getMain().startSupportActionMode(cb);
return;
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException
| IllegalAccessException | IllegalArgumentException | InvocationTargetException exception) {
| IllegalAccessException | IllegalArgumentException | InvocationTargetException | NullPointerException exception) {
Log.e(DEBUG_TAG, "Restarting " + restartActionModeCallbackName + " received " + exception.getClass().getCanonicalName()
+ " " + exception.getMessage());
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/blau/android/resources/TileLayerSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -2252,7 +2252,7 @@ public int getMinZoom() {
*/
public void setMinZoom(int newZoomLevelMin) {
synchronized (this) {
if (offsets != null && zoomLevelMin != newZoomLevelMin) {
if (offsets != null && zoomLevelMin != newZoomLevelMin && zoomLevelMax > newZoomLevelMin) {
Offset[] tempOffsets = new Offset[zoomLevelMax - newZoomLevelMin + 1];
int destOffset = Math.max(0, zoomLevelMin - newZoomLevelMin);
System.arraycopy(offsets, Math.max(0, newZoomLevelMin - zoomLevelMin), tempOffsets, destOffset, tempOffsets.length - destOffset);
Expand Down Expand Up @@ -2280,7 +2280,7 @@ public int getMaxZoom() {
*/
public void setMaxZoom(int newZoomLevelMax) {
synchronized (this) {
if (offsets != null && zoomLevelMax != newZoomLevelMax) {
if (offsets != null && zoomLevelMax != newZoomLevelMax && newZoomLevelMax > zoomLevelMin) {
Offset[] tempOffsets = new Offset[newZoomLevelMax - zoomLevelMin + 1];
System.arraycopy(offsets, 0, tempOffsets, 0, Math.min(offsets.length, tempOffsets.length));
offsets = tempOffsets;
Expand Down

0 comments on commit 891c173

Please sign in to comment.