1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 22:09:06 +00:00

Update pedometer to jni and jnigen:0.5.0 (#1863)

Updates the pedometer sample to the latest version of jni and jnigen.
This commit is contained in:
Hossein Yousefi
2023-06-02 09:12:44 +02:00
committed by GitHub
parent d4c470e9c1
commit aff3b0979e
9 changed files with 7661 additions and 7906 deletions

View File

@@ -141,22 +141,19 @@ class _AndroidStepsRepo implements StepsRepo {
final end =
DateTime(now.year, now.month, now.day, h + 1).millisecondsSinceEpoch;
final request = hc.AggregateRequest(
hc.Set.of1(
hc.AggregateMetric.type(hc.Long.type),
hc.StepsRecord.COUNT_TOTAL,
),
{hc.StepsRecord.COUNT_TOTAL}
.toJSet(hc.AggregateMetric.type(jni.JLong.type)),
hc.TimeRangeFilter.between(
hc.Instant.ofEpochMilli(start),
hc.Instant.ofEpochMilli(end),
),
hc.Set.of(jni.JObject.type),
jni.JSet.hash(jni.JObject.type),
);
futures.add(client.aggregate(request));
}
final data = await Future.wait(futures);
return data.asMap().entries.map((entry) {
final stepsLong =
entry.value.get0(hc.Long.type, hc.StepsRecord.COUNT_TOTAL);
final stepsLong = entry.value.get0(hc.StepsRecord.COUNT_TOTAL);
final steps = stepsLong.isNull ? 0 : stepsLong.intValue();
return Steps(entry.key.toString().padLeft(2, '0'), steps);
}).toList();