mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-04 09:17:29 +01:00
Garmin: Throttle notification updates on fit parsing
This commit is contained in:
parent
6f5f944235
commit
904c995a3e
@ -520,15 +520,20 @@ public class GarminSupport extends AbstractBTLEDeviceSupport implements ICommuni
|
||||
final FitAsyncProcessor fitAsyncProcessor = new FitAsyncProcessor(getContext(), getDevice());
|
||||
final List <File> filesToProcessClone = new ArrayList<>(filesToProcess);
|
||||
filesToProcess.clear();
|
||||
final long[] lastNotificationUpdateTs = new long[]{System.currentTimeMillis()};
|
||||
fitAsyncProcessor.process(filesToProcessClone, new FitAsyncProcessor.Callback() {
|
||||
@Override
|
||||
public void onProgress(final int i) {
|
||||
final long now = System.currentTimeMillis();
|
||||
if (now - lastNotificationUpdateTs[0] > 1500L) {
|
||||
lastNotificationUpdateTs[0] = now;
|
||||
GB.updateTransferNotification(
|
||||
"Parsing fit files", "File " + i + " of " + filesToProcessClone.size(),
|
||||
true,
|
||||
(i * 100) / filesToProcessClone.size(), getContext()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
@ -791,16 +796,21 @@ public class GarminSupport extends AbstractBTLEDeviceSupport implements ICommuni
|
||||
GB.toast(getContext(), "Error deleting activity data", Toast.LENGTH_LONG, GB.ERROR, e);
|
||||
}
|
||||
|
||||
final long[] lastNotificationUpdateTs = new long[]{System.currentTimeMillis()};
|
||||
final FitAsyncProcessor fitAsyncProcessor = new FitAsyncProcessor(getContext(), getDevice());
|
||||
fitAsyncProcessor.process(Arrays.asList(fitFiles), new FitAsyncProcessor.Callback() {
|
||||
@Override
|
||||
public void onProgress(final int i) {
|
||||
final long now = System.currentTimeMillis();
|
||||
if (now - lastNotificationUpdateTs[0] > 1500L) {
|
||||
lastNotificationUpdateTs[0] = now;
|
||||
GB.updateTransferNotification(
|
||||
"Parsing fit files", "File " + i + " of " + fitFiles.length,
|
||||
true,
|
||||
(i * 100) / fitFiles.length, getContext()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
|
Loading…
Reference in New Issue
Block a user