Skip to content

Commit

Permalink
Adapted DashboardFragment to use Dhis2 as main API.
Browse files Browse the repository at this point in the history
  • Loading branch information
arazabishov committed Sep 30, 2015
1 parent d6d122c commit b3f8544
Showing 1 changed file with 2 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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));
}
Expand Down Expand Up @@ -249,34 +245,5 @@ public List<DashboardItem> query(Context context) {
}
return dashboardItems;
}

/* private List<DashboardItem> getDashboardElementMap() {
List<DashboardElement> dashboardElements = Dhis2.dashboardElements().query();
Map<DashboardItem, List<DashboardElement>> dashboardElementMap = new HashMap<>();
if (dashboardElements != null && !dashboardElements.isEmpty()) {
for (DashboardElement dashboardElement : dashboardElements) {
DashboardItem dashboardItem = dashboardElement.getDashboardItem();
if (!DashboardItemContent.TYPE_MESSAGES.equals(dashboardItem.getType())) {
List<DashboardElement> elementsBag = dashboardElementMap.get(dashboardItem);
if (elementsBag == null) {
elementsBag = new ArrayList<>();
dashboardElementMap.put(dashboardItem, elementsBag);
}
elementsBag.add(dashboardElement);
}
}
}
List<DashboardItem> dashboardItems = new ArrayList<>();
for (DashboardItem dashboardItem : dashboardElementMap.keySet()) {
dashboardItem.setDashboardElements(dashboardElementMap.get(dashboardItem));
}
return dashboardItems;
} */
}
}

0 comments on commit b3f8544

Please sign in to comment.