1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2025-01-24 08:37:32 +01:00

Bangle.js:Activity traks attempt (un-)setBusyTask

This commit is contained in:
Ganblejs 2023-07-13 01:40:43 +02:00 committed by José Rebelo
parent 6faa4452e2
commit 517f9ac214

View File

@ -740,7 +740,7 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
JSONArray tracksList = json.getJSONArray("list"); JSONArray tracksList = json.getJSONArray("list");
LOG.info("New recorder logs since last fetch: " + String.valueOf(tracksList)); LOG.info("New recorder logs since last fetch: " + String.valueOf(tracksList));
for (int i = 0; i < tracksList.length(); i ++) { for (int i = 0; i < tracksList.length(); i ++) {
requestActivityTrackLog(tracksList.getString(i)); requestActivityTrackLog(tracksList.getString(i), i==tracksList.length()-1);
} }
} }
@ -930,6 +930,9 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
LOG.warn("Could not write to file", e); LOG.warn("Could not write to file", e);
} }
} }
if (json.getString("last").equals("true")) {
getDevice().unsetBusyTask();
}
} }
/** /**
@ -1610,11 +1613,12 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
} }
} }
private void requestActivityTrackLog(String id) { private void requestActivityTrackLog(String id, Boolean isLastId) {
try { try {
JSONObject o = new JSONObject(); JSONObject o = new JSONObject();
o.put("t", "fetchRec"); o.put("t", "fetchRec");
o.put("id", id); o.put("id", id);
o.put("last", String.valueOf(isLastId));
uartTxJSON("requestActivityTrackLog", o); uartTxJSON("requestActivityTrackLog", o);
} catch (JSONException e) { } catch (JSONException e) {
LOG.info("JSONException: " + e.getLocalizedMessage()); LOG.info("JSONException: " + e.getLocalizedMessage());
@ -1635,6 +1639,7 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
} }
if (dataTypes == RecordedDataTypes.TYPE_GPS_TRACKS) { if (dataTypes == RecordedDataTypes.TYPE_GPS_TRACKS) {
getDevice().setBusyTask("Fetch Activity Tracks");
GB.toast("TYPE_GPS_TRACKS says hi!", Toast.LENGTH_LONG, GB.INFO); GB.toast("TYPE_GPS_TRACKS says hi!", Toast.LENGTH_LONG, GB.INFO);
File dir; File dir;
try { try {