mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-15 03:21:13 +01:00
30 lines
761 B
Java
30 lines
761 B
Java
|
package nodomain.freeyourgadget.gadgetbridge.charts;
|
||
|
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.List;
|
||
|
|
||
|
public class ActivityAmounts {
|
||
|
private List<ActivityAmount> amounts = new ArrayList<>(4);
|
||
|
private long totalSeconds;
|
||
|
|
||
|
public void addAmount(ActivityAmount amount) {
|
||
|
amounts.add(amount);
|
||
|
totalSeconds += amount.getTotalSeconds();
|
||
|
}
|
||
|
|
||
|
public List<ActivityAmount> getAmounts() {
|
||
|
return amounts;
|
||
|
}
|
||
|
|
||
|
public long getTotalSeconds() {
|
||
|
return totalSeconds;
|
||
|
}
|
||
|
|
||
|
public void calculatePercentages() {
|
||
|
for (ActivityAmount amount : amounts) {
|
||
|
float fraction = amount.getTotalSeconds() / (float) totalSeconds;
|
||
|
amount.setPercent((short) (fraction * 100));
|
||
|
}
|
||
|
}
|
||
|
}
|