mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-25 19:36:50 +01:00
Show ongoing activity snackbar only 'today'
This commit is contained in:
parent
0bf86584e1
commit
dc42faa6fb
@ -39,6 +39,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
@ -152,15 +153,34 @@ public class ActivityListingChartFragment extends AbstractChartFragment {
|
|||||||
getChartsHost().enableSwipeRefresh(false); //disable pull to refresh as it collides with swipable view
|
getChartsHost().enableSwipeRefresh(false); //disable pull to refresh as it collides with swipable view
|
||||||
}
|
}
|
||||||
|
|
||||||
stepsDateView.setText(DateTimeUtils.formatDate(new Date(tsDateTo * 1000L)));
|
Date activityDate = new Date(tsDateTo * 1000L);
|
||||||
|
stepsDateView.setText(DateTimeUtils.formatDate(activityDate));
|
||||||
|
|
||||||
if (GBApplication.getPrefs().getBoolean("charts_show_ongoing_activity", true)) {
|
if (GBApplication.getPrefs().getBoolean("charts_show_ongoing_activity", true)) {
|
||||||
if (mcd.getOngoingSession() != null) {
|
if (mcd.getOngoingSession() != null && isActivityToday(activityDate)) {
|
||||||
showOngoingActivitySnackbar(mcd.getOngoingSession());
|
showOngoingActivitySnackbar(mcd.getOngoingSession());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stepListAdapter.setItems(mcd.getStepSessions(), true);
|
stepListAdapter.setItems(mcd.getStepSessions(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isActivityToday(Date activityDate) {
|
||||||
|
Calendar calendarActivity = GregorianCalendar.getInstance();
|
||||||
|
calendarActivity.setTime(activityDate);
|
||||||
|
calendarActivity.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
calendarActivity.set(Calendar.MINUTE, 0);
|
||||||
|
calendarActivity.set(Calendar.SECOND, 0);
|
||||||
|
calendarActivity.set(Calendar.MILLISECOND, 0);
|
||||||
|
|
||||||
|
Calendar calendarToday = GregorianCalendar.getInstance();
|
||||||
|
calendarToday.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
calendarToday.set(Calendar.MINUTE, 0);
|
||||||
|
calendarToday.set(Calendar.SECOND, 0);
|
||||||
|
calendarToday.set(Calendar.MILLISECOND, 0);
|
||||||
|
|
||||||
|
return calendarToday.equals(calendarActivity);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderCharts() {
|
protected void renderCharts() {
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user