- fixed problem with filtering in #69

This commit is contained in:
Andy Rozman 2020-02-14 20:27:45 +00:00
parent 3e12a7df5a
commit e7e8cac81b
2 changed files with 42 additions and 33 deletions

View file

@ -31,6 +31,7 @@ import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpHistoryEntryGroup;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
import info.nightscout.androidaps.plugins.pump.common.utils.ProfileUtil;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodHistory;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
@ -73,29 +74,24 @@ public class PodHistoryActivity extends NoSplashActivity {
this.filteredHistoryList.clear();
LOG.debug("Items on full list: {}", fullHistoryList.size());
//LOG.debug("Items on full list: {}", list.size());
this.filteredHistoryList.addAll(fullHistoryList);
// TODO grouping
// if (group == PumpHistoryEntryGroup.All) {
// this.filteredHistoryList.addAll(list);
// } else {
// for (PumpHistoryEntry pumpHistoryEntry : list) {
// if (pumpHistoryEntry.getEntryType().getGroup() == group) {
// this.filteredHistoryList.add(pumpHistoryEntry);
// }
// }
// }
if (group == PumpHistoryEntryGroup.All) {
this.filteredHistoryList.addAll(fullHistoryList);
} else {
for (PodHistory pumpHistoryEntry : fullHistoryList) {
if (pumpHistoryEntry.getPodDbEntryType().getGroup() == group) {
this.filteredHistoryList.add(pumpHistoryEntry);
}
}
}
if (this.recyclerViewAdapter != null) {
this.recyclerViewAdapter.setHistoryList(this.filteredHistoryList);
this.recyclerViewAdapter.notifyDataSetChanged();
}
//LOG.debug("Items on filtered list: {}", filteredHistoryList.size());
LOG.debug("Items on filtered list: {}", filteredHistoryList.size());
}

View file

@ -7,35 +7,36 @@ import java.util.HashMap;
import java.util.Map;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpHistoryEntryGroup;
/**
* Created by andy on 24.11.2019
*/
public enum PodHistoryEntryType {
PairAndPrime(1, R.string.omnipod_init_pod_wizard_step2_title),
FillCannulaSetBasalProfile(2, R.string.omnipod_init_pod_wizard_step4_title),
DeactivatePod(3, R.string.omnipod_cmd_deactivate_pod),
ResetPodState(4, R.string.omnipod_cmd_reset_pod),
PairAndPrime(1, R.string.omnipod_init_pod_wizard_step2_title, PumpHistoryEntryGroup.Prime),
FillCannulaSetBasalProfile(2, R.string.omnipod_init_pod_wizard_step4_title, PumpHistoryEntryGroup.Prime),
DeactivatePod(3, R.string.omnipod_cmd_deactivate_pod, PumpHistoryEntryGroup.Prime),
ResetPodState(4, R.string.omnipod_cmd_reset_pod, PumpHistoryEntryGroup.Prime),
SetTemporaryBasal(10, R.string.omnipod_cmd_set_tbr),
CancelTemporaryBasal(11, R.string.omnipod_cmd_cancel_tbr),
CancelTemporaryBasalForce(12, R.string.omnipod_cmd_cancel_tbr_forced),
SetTemporaryBasal(10, R.string.omnipod_cmd_set_tbr, PumpHistoryEntryGroup.Basal),
CancelTemporaryBasal(11, R.string.omnipod_cmd_cancel_tbr, PumpHistoryEntryGroup.Basal),
CancelTemporaryBasalForce(12, R.string.omnipod_cmd_cancel_tbr_forced, PumpHistoryEntryGroup.Basal),
SetBasalSchedule(20, R.string.omnipod_cmd_set_basal_schedule),
SetBasalSchedule(20, R.string.omnipod_cmd_set_basal_schedule, PumpHistoryEntryGroup.Basal),
GetPodStatus(30, R.string.omnipod_cmd_get_pod_status),
GetPodInfo(31, R.string.omnipod_cmd_get_pod_info),
SetTime(32, R.string.omnipod_cmd_set_time),
GetPodStatus(30, R.string.omnipod_cmd_get_pod_status, PumpHistoryEntryGroup.Configuration),
GetPodInfo(31, R.string.omnipod_cmd_get_pod_info, PumpHistoryEntryGroup.Configuration),
SetTime(32, R.string.omnipod_cmd_set_time, PumpHistoryEntryGroup.Configuration),
SetBolus(40, R.string.omnipod_cmd_set_bolus),
CancelBolus(41, R.string.omnipod_cmd_cancel_bolus),
SetBolus(40, R.string.omnipod_cmd_set_bolus, PumpHistoryEntryGroup.Bolus),
CancelBolus(41, R.string.omnipod_cmd_cancel_bolus, PumpHistoryEntryGroup.Bolus),
ConfigureAlerts(50, R.string.omnipod_cmd_configure_alerts),
AcknowledgeAlerts(51, R.string.omnipod_cmd_acknowledge_alerts),
ConfigureAlerts(50, R.string.omnipod_cmd_configure_alerts, PumpHistoryEntryGroup.Alarm),
AcknowledgeAlerts(51, R.string.omnipod_cmd_acknowledge_alerts, PumpHistoryEntryGroup.Alarm),
SuspendDelivery(60, R.string.omnipod_cmd_suspend_delivery),
ResumeDelivery(61, R.string.omnipod_cmd_resume_delivery),
SuspendDelivery(60, R.string.omnipod_cmd_suspend_delivery, PumpHistoryEntryGroup.Basal),
ResumeDelivery(61, R.string.omnipod_cmd_resume_delivery, PumpHistoryEntryGroup.Basal),
UnknownEntryType(99, R.string.omnipod_cmd_unknown_entry)
;
@ -46,6 +47,8 @@ public enum PodHistoryEntryType {
@StringRes
private int resourceId;
private PumpHistoryEntryGroup group;
static {
instanceMap = new HashMap<>();
@ -61,10 +64,20 @@ public enum PodHistoryEntryType {
this.resourceId = resourceId;
}
PodHistoryEntryType(int code, @StringRes int resourceId, PumpHistoryEntryGroup group) {
this.code = code;
this.resourceId = resourceId;
this.group = group;
}
public int getCode() {
return code;
}
public PumpHistoryEntryGroup getGroup() {
return this.group;
}
public static PodHistoryEntryType getByCode(int code) {
if (instanceMap.containsKey(code)) {