mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-02 15:02:56 +01:00
7c597b325a
- model package contains mostly shared interfaces (UI+service), not named GB* - impl package contains implementations of those interfaces, named GB* the impl classes should not be used by the service (not completely done) - the service classes should mostly use classes inside the service and deviceevents packages (tbd) Every device now has two packages: - devices/[device name] for UI related functionality - service[device name] for lowlevel communication
30 lines
760 B
Java
30 lines
760 B
Java
package nodomain.freeyourgadget.gadgetbridge.model;
|
|
|
|
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));
|
|
}
|
|
}
|
|
}
|