Fix elevation api updates and refresh onResume

master
Piotro 2023-07-08 22:52:31 +02:00
rodzic 21e0fb19b7
commit 6c0ecc972f
2 zmienionych plików z 5 dodań i 5 usunięć

Wyświetl plik

@ -335,14 +335,11 @@ public class DataCollector implements Runnable {
public void onResume() {
locationProvider.startLocationProvider(null);
elapi.pause = false;
if (elapi_thread != null)
elapi_thread.interrupt();
refresh();
}
public void onPause() {
elapi.pause = true;
if (elapi_thread != null)
elapi_thread.interrupt();
locationProvider.stopLocationProvider();
}

Wyświetl plik

@ -28,6 +28,7 @@ public class ElevationApi implements Runnable {
StringBuilder resp = new StringBuilder();
for (String line; (line = br.readLine()) != null; resp.append(line));
String data = resp.toString();
JSONObject json = new JSONObject(data);
alt = json.getJSONArray("elevation").getInt(0);
System.out.println("alt"+alt);
@ -39,9 +40,11 @@ public class ElevationApi implements Runnable {
e.printStackTrace();
}
try {
while (!Thread.currentThread().isInterrupted())
do {
Thread.sleep(30000);
} while (pause);
} catch (InterruptedException ignored) {}
boolean ignored = Thread.interrupted();
}
}
}