From b3f854469d84f3eb7abc3e4ed83dbfa5ad6429b6 Mon Sep 17 00:00:00 2001 From: Araz Abishov Date: Wed, 30 Sep 2015 12:21:14 +0200 Subject: [PATCH] Adapted DashboardFragment to use Dhis2 as main API. --- .../dashboard/DashboardFragment.java | 37 +------------------ 1 file changed, 2 insertions(+), 35 deletions(-) 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