diff --git a/app/src/main/java/org/hisp/dhis/android/dashboard/ui/fragments/dashboard/DashboardFragment.java b/app/src/main/java/org/hisp/dhis/android/dashboard/ui/fragments/dashboard/DashboardFragment.java index 27e523ac..268ad524 100644 --- a/app/src/main/java/org/hisp/dhis/android/dashboard/ui/fragments/dashboard/DashboardFragment.java +++ b/app/src/main/java/org/hisp/dhis/android/dashboard/ui/fragments/dashboard/DashboardFragment.java @@ -199,9 +199,7 @@ public void onContentClick(DashboardElement element) { @Override public void onContentDeleteClick(DashboardElement element) { if (element != null) { - // element.deleteDashboardElement(); - // Models.dashboardElements().delete(element); - + Dhis2.dashboardElements().remove(element); DhisService.getInstance().syncDashboards(); EventBusProvider.post(new UiEvent(UiEvent.UiEventType.SYNC_DASHBOARDS)); } @@ -210,9 +208,7 @@ public void onContentDeleteClick(DashboardElement element) { @Override public void onItemDeleteClick(DashboardItem item) { if (item != null) { - // item.deleteDashboardItem(); - // Models.dashboardItems().delete(item); - + Dhis2.dashboardItems().remove(item); DhisService.getInstance().syncDashboards(); EventBusProvider.post(new UiEvent(UiEvent.UiEventType.SYNC_DASHBOARDS)); } @@ -249,34 +245,5 @@ public List query(Context context) { } return dashboardItems; } - - /* private List getDashboardElementMap() { - List dashboardElements = Dhis2.dashboardElements().query(); - Map> dashboardElementMap = new HashMap<>(); - - if (dashboardElements != null && !dashboardElements.isEmpty()) { - for (DashboardElement dashboardElement : dashboardElements) { - DashboardItem dashboardItem = dashboardElement.getDashboardItem(); - - if (!DashboardItemContent.TYPE_MESSAGES.equals(dashboardItem.getType())) { - List elementsBag = dashboardElementMap.get(dashboardItem); - - if (elementsBag == null) { - elementsBag = new ArrayList<>(); - dashboardElementMap.put(dashboardItem, elementsBag); - } - - elementsBag.add(dashboardElement); - } - } - } - - List dashboardItems = new ArrayList<>(); - for (DashboardItem dashboardItem : dashboardElementMap.keySet()) { - dashboardItem.setDashboardElements(dashboardElementMap.get(dashboardItem)); - } - - return dashboardItems; - } */ } } \ No newline at end of file