use of nodomain.freeyourgadget.gadgetbridge.entities.BaseActivitySummaryDao in project Gadgetbridge by Freeyourgadget.
the class ActivitySummariesAdapter method loadItems.
@Override
public void loadItems() {
try (DBHandler handler = GBApplication.acquireDB()) {
BaseActivitySummaryDao summaryDao = handler.getDaoSession().getBaseActivitySummaryDao();
Device dbDevice = DBHelper.findDevice(device, handler.getDaoSession());
QueryBuilder<BaseActivitySummary> qb = summaryDao.queryBuilder();
if (deviceFilter == ALL_DEVICES) {
qb.orderDesc(BaseActivitySummaryDao.Properties.StartTime);
} else if (deviceFilter != 0) {
qb.where(BaseActivitySummaryDao.Properties.DeviceId.eq(deviceFilter)).orderDesc(BaseActivitySummaryDao.Properties.StartTime);
} else {
qb.where(BaseActivitySummaryDao.Properties.DeviceId.eq(dbDevice.getId())).orderDesc(BaseActivitySummaryDao.Properties.StartTime);
}
if (activityKindFilter != 0) {
qb.where(BaseActivitySummaryDao.Properties.ActivityKind.eq(activityKindFilter));
}
if (dateFromFilter != 0) {
qb.where(BaseActivitySummaryDao.Properties.StartTime.gt(new Date(dateFromFilter)));
}
if (dateToFilter != 0) {
qb.where(BaseActivitySummaryDao.Properties.EndTime.lt(new Date(dateToFilter)));
}
if (nameContainsFilter != null && nameContainsFilter.length() > 0) {
qb.where(BaseActivitySummaryDao.Properties.Name.like("%" + nameContainsFilter + "%"));
}
if (itemsFilter != null) {
qb.where(BaseActivitySummaryDao.Properties.Id.in(itemsFilter));
}
List<BaseActivitySummary> allSummaries = new ArrayList<>();
allSummaries.add(new BaseActivitySummary());
allSummaries.addAll(qb.build().list());
setItems(allSummaries, true);
} catch (Exception e) {
GB.toast("Error loading activity summaries.", Toast.LENGTH_SHORT, GB.ERROR, e);
}
}
Aggregations