Search in sources :

Example 1 with LimitedQueue

use of nodomain.freeyourgadget.gadgetbridge.util.LimitedQueue in project Gadgetbridge by Freeyourgadget.

the class AbstractWeekChartFragment method getActivityAmountsForDay.

private ActivityAmounts getActivityAmountsForDay(DBHandler db, Calendar day, GBDevice device) {
    LimitedQueue activityAmountCache = null;
    ActivityAmounts amounts = null;
    Activity activity = getActivity();
    int key = (int) (day.getTimeInMillis() / 1000) + (mOffsetHours * 3600);
    if (activity != null) {
        activityAmountCache = ((ChartsActivity) activity).mActivityAmountCache;
        amounts = (ActivityAmounts) (activityAmountCache.lookup(key));
    }
    if (amounts == null) {
        ActivityAnalysis analysis = new ActivityAnalysis();
        amounts = analysis.calculateActivityAmounts(getSamplesOfDay(db, day, mOffsetHours, device));
        if (activityAmountCache != null) {
            activityAmountCache.add(key, amounts);
        }
    }
    return amounts;
}
Also used : ActivityAmounts(nodomain.freeyourgadget.gadgetbridge.model.ActivityAmounts) LimitedQueue(nodomain.freeyourgadget.gadgetbridge.util.LimitedQueue) Activity(android.app.Activity)

Aggregations

Activity (android.app.Activity)1 ActivityAmounts (nodomain.freeyourgadget.gadgetbridge.model.ActivityAmounts)1 LimitedQueue (nodomain.freeyourgadget.gadgetbridge.util.LimitedQueue)1