1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-02 15:02:56 +01:00
Gadgetbridge/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityAmounts.java
cpfeiffer 7c597b325a Big refactoring: move classes and packages around to get a better structure
- 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
2015-08-03 23:09:49 +02:00

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));
}
}
}