mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-09-08 15:35:24 +02:00
Fix trailing activity 0 duration
Hide intensity if not present in data
This commit is contained in:
parent
a5c5629a44
commit
92407d3490
@ -63,7 +63,7 @@ public class ActivityListingAdapter extends AbstractActivityListingAdapter<StepA
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean hasHR(StepAnalysis.StepSession item) {
|
public boolean hasHR(StepAnalysis.StepSession item) {
|
||||||
if (item.getHeartRateAverage() > 0) {
|
if (item.getHeartRateAverage() > 0) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -71,6 +71,15 @@ public class ActivityListingAdapter extends AbstractActivityListingAdapter<StepA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasIntensity(StepAnalysis.StepSession item) {
|
||||||
|
if (item.getIntensity() > 0) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getIcon(StepAnalysis.StepSession item) {
|
protected int getIcon(StepAnalysis.StepSession item) {
|
||||||
int activityKind = item.getActivityKind();
|
int activityKind = item.getActivityKind();
|
||||||
|
@ -64,7 +64,8 @@ public class StepAnalysis {
|
|||||||
|
|
||||||
|
|
||||||
for (ActivitySample sample : samples) {
|
for (ActivitySample sample : samples) {
|
||||||
if (sample.getKind() != ActivityKind.TYPE_SLEEP) { //anything but sleep counts
|
if (sample.getKind() != ActivityKind.TYPE_SLEEP //anything but sleep counts
|
||||||
|
&& !(sample instanceof TrailingActivitySample)) { //trailing samples have wrong date and make trailing activity have 0 duration
|
||||||
if (sample.getHeartRate() != 255 && sample.getHeartRate() != -1) {
|
if (sample.getHeartRate() != 255 && sample.getHeartRate() != -1) {
|
||||||
heartRateToAdd = sample.getHeartRate();
|
heartRateToAdd = sample.getHeartRate();
|
||||||
activeHrSamplesToAdd = 1;
|
activeHrSamplesToAdd = 1;
|
||||||
@ -122,7 +123,8 @@ public class StepAnalysis {
|
|||||||
previousSample = sample;
|
previousSample = sample;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//make sure we show the last portion of the data as well in case no further activity is recorded yet
|
//trailing activity: make sure we show the last portion of the data as well in case no further activity is recorded yet
|
||||||
|
|
||||||
if (sessionStart != null && previousSample != null) {
|
if (sessionStart != null && previousSample != null) {
|
||||||
int current = previousSample.getTimestamp();
|
int current = previousSample.getTimestamp();
|
||||||
int starting = (int) (sessionStart.getTime() / 1000);
|
int starting = (int) (sessionStart.getTime() / 1000);
|
||||||
@ -131,7 +133,6 @@ public class StepAnalysis {
|
|||||||
if (session_length >= MIN_SESSION_LENGTH) {
|
if (session_length >= MIN_SESSION_LENGTH) {
|
||||||
int heartRateAverage = activeHrSamplesForAverage > 0 ? heartRateForAverage / activeHrSamplesForAverage : 0;
|
int heartRateAverage = activeHrSamplesForAverage > 0 ? heartRateForAverage / activeHrSamplesForAverage : 0;
|
||||||
float distance = (float) (activeSteps * STEP_SIZE);
|
float distance = (float) (activeSteps * STEP_SIZE);
|
||||||
|
|
||||||
sessionEnd = getDateFromSample(previousSample);
|
sessionEnd = getDateFromSample(previousSample);
|
||||||
activityKind = detect_activity_kind(session_length, activeSteps, heartRateAverage, activeIntensity);
|
activityKind = detect_activity_kind(session_length, activeSteps, heartRateAverage, activeIntensity);
|
||||||
result.add(new StepSession(sessionStart, sessionEnd, activeSteps, heartRateAverage, activeIntensity, distance, activityKind));
|
result.add(new StepSession(sessionStart, sessionEnd, activeSteps, heartRateAverage, activeIntensity, distance, activityKind));
|
||||||
|
@ -36,8 +36,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
|
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.activities.charts.ActivityAnalysis.LOG;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter for displaying generic ItemWithDetails instances.
|
* Adapter for displaying generic ItemWithDetails instances.
|
||||||
*/
|
*/
|
||||||
@ -108,9 +106,17 @@ public abstract class AbstractActivityListingAdapter<T> extends ArrayAdapter<T>
|
|||||||
hrLayout.setVisibility(View.VISIBLE);
|
hrLayout.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!hasIntensity(item)) {
|
||||||
|
intensityLayout.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
intensityLayout.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
activityIcon.setImageResource(getIcon(item));
|
activityIcon.setImageResource(getIcon(item));
|
||||||
|
|
||||||
if (position % 2 == 0) {parentLayout.setBackgroundColor(alternateColor);}
|
if (position % 2 == 0) {
|
||||||
|
parentLayout.setBackgroundColor(alternateColor);
|
||||||
|
}
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
@ -131,7 +137,9 @@ public abstract class AbstractActivityListingAdapter<T> extends ArrayAdapter<T>
|
|||||||
|
|
||||||
protected abstract String getDurationLabel(T item);
|
protected abstract String getDurationLabel(T item);
|
||||||
|
|
||||||
protected abstract Boolean hasHR(T item);
|
protected abstract boolean hasHR(T item);
|
||||||
|
|
||||||
|
protected abstract boolean hasIntensity(T item);
|
||||||
|
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
protected abstract int getIcon(T item);
|
protected abstract int getIcon(T item);
|
||||||
|
Loading…
Reference in New Issue
Block a user