mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Huawei: Show pace summery before table. More summary.
This commit is contained in:
parent
af64ff3a79
commit
15f550d5a8
@ -671,33 +671,36 @@ public class HuaweiWorkoutGbParser implements ActivitySummaryParser {
|
|||||||
|
|
||||||
String measurementSystem = GBApplication.getPrefs().getString(SettingsActivity.PREF_MEASUREMENT_SYSTEM, "metric");
|
String measurementSystem = GBApplication.getPrefs().getString(SettingsActivity.PREF_MEASUREMENT_SYSTEM, "metric");
|
||||||
|
|
||||||
byte unitType = (byte) (measurementSystem.equals("metric")?0:1);
|
byte unitType = (byte) (measurementSystem.equals("metric") ? 0 : 1);
|
||||||
try (CloseableListIterator<HuaweiWorkoutPaceSample> it = qbPace.build().listIterator()) {
|
try (CloseableListIterator<HuaweiWorkoutPaceSample> it = qbPace.build().listIterator()) {
|
||||||
HashMap<Byte, Integer> typeCount = new HashMap<>();
|
|
||||||
HashMap<Byte, Integer> typePace = new HashMap<>();
|
int paceCount = 0;
|
||||||
|
int paceSum = 0;
|
||||||
|
int paceFastest = Integer.MAX_VALUE;
|
||||||
|
int paceSlowest = 0;
|
||||||
|
|
||||||
int currentIndex = 1;
|
int currentIndex = 1;
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
int index = it.nextIndex();
|
int index = it.nextIndex();
|
||||||
HuaweiWorkoutPaceSample sample = it.next();
|
HuaweiWorkoutPaceSample sample = it.next();
|
||||||
|
|
||||||
if(sample.getType() != unitType)
|
if (sample.getType() != unitType)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int pace = sample.getPace();
|
int pace = sample.getPace();
|
||||||
int count = 1;
|
|
||||||
|
|
||||||
Integer previousCount = typeCount.get(sample.getType());
|
paceCount++;
|
||||||
Integer previousPace = typePace.get(sample.getType());
|
paceSum += pace;
|
||||||
if (previousCount != null)
|
|
||||||
count += previousCount;
|
if (pace < paceFastest)
|
||||||
if (previousPace != null)
|
paceFastest = pace;
|
||||||
pace += previousPace;
|
|
||||||
typeCount.put(sample.getType(), count);
|
if (pace > paceSlowest)
|
||||||
typePace.put(sample.getType(), pace);
|
paceSlowest = pace;
|
||||||
|
|
||||||
double distance = sample.getDistance();
|
double distance = sample.getDistance();
|
||||||
|
|
||||||
if(sample.getCorrection() != null) {
|
if (sample.getCorrection() != null) {
|
||||||
distance += sample.getCorrection() / 10000d;
|
distance += sample.getCorrection() / 10000d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -717,24 +720,38 @@ public class HuaweiWorkoutGbParser implements ActivitySummaryParser {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (paceCount != 0 && paceSum != 0) {
|
||||||
|
summaryData.add(
|
||||||
|
ActivitySummaryEntries.GROUP_PACE,
|
||||||
|
GBApplication.getContext().getString(R.string.fmtPaceAverage),
|
||||||
|
paceSum / (float) paceCount,
|
||||||
|
ActivitySummaryEntries.UNIT_SECONDS_PER_KM
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (paceFastest != Integer.MAX_VALUE) {
|
||||||
|
summaryData.add(
|
||||||
|
ActivitySummaryEntries.GROUP_PACE,
|
||||||
|
GBApplication.getContext().getString(R.string.maxPace),
|
||||||
|
paceFastest,
|
||||||
|
ActivitySummaryEntries.UNIT_SECONDS_PER_KM
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (paceSlowest != 0) {
|
||||||
|
summaryData.add(
|
||||||
|
ActivitySummaryEntries.GROUP_PACE,
|
||||||
|
GBApplication.getContext().getString(R.string.minPace),
|
||||||
|
paceSlowest,
|
||||||
|
ActivitySummaryEntries.UNIT_SECONDS_PER_KM
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (pacesTable.size() > 1) {
|
if (pacesTable.size() > 1) {
|
||||||
for (final Map.Entry<String, ActivitySummaryTableRowEntry> e : pacesTable.entrySet()) {
|
for (final Map.Entry<String, ActivitySummaryTableRowEntry> e : pacesTable.entrySet()) {
|
||||||
summaryData.add(e.getKey(), e.getValue());
|
summaryData.add(e.getKey(), e.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Byte key : typeCount.keySet()) {
|
|
||||||
Integer count = typeCount.get(key);
|
|
||||||
Integer pace = typePace.get(key);
|
|
||||||
if (count == null || pace == null || count == 0)
|
|
||||||
continue;
|
|
||||||
summaryData.add(
|
|
||||||
ActivitySummaryEntries.GROUP_PACE,
|
|
||||||
GBApplication.getContext().getString(R.string.fmtPaceTypeAverage, key),
|
|
||||||
pace / (float) count,
|
|
||||||
ActivitySummaryEntries.UNIT_SECONDS_PER_KM
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unknownData) {
|
if (unknownData) {
|
||||||
|
@ -2238,6 +2238,7 @@
|
|||||||
<string name="fmtPaceCorrection">Pace %d correction</string>
|
<string name="fmtPaceCorrection">Pace %d correction</string>
|
||||||
<string name="paceCorrection">Correction</string>
|
<string name="paceCorrection">Correction</string>
|
||||||
<string name="fmtPaceTypeAverage">Pace Type %d average</string>
|
<string name="fmtPaceTypeAverage">Pace Type %d average</string>
|
||||||
|
<string name="fmtPaceAverage">Pace average</string>
|
||||||
<string name="unknownDataEncountered">Unknown data encountered</string>
|
<string name="unknownDataEncountered">Unknown data encountered</string>
|
||||||
<string name="cyclingPowerAverage">Average cycling power</string>
|
<string name="cyclingPowerAverage">Average cycling power</string>
|
||||||
<string name="cyclingPowerMin">Min cycling power</string>
|
<string name="cyclingPowerMin">Min cycling power</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user