From d6d122c8d8a58c545ef01ef7997cf954ed5cfea3 Mon Sep 17 00:00:00 2001 From: Araz Abishov Date: Wed, 30 Sep 2015 12:13:43 +0200 Subject: [PATCH] Adapted DashboardItemAddFragment to use Dhis2 as main API. --- .../dashboard/DashboardItemAddFragment.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/hisp/dhis/android/dashboard/ui/fragments/dashboard/DashboardItemAddFragment.java b/app/src/main/java/org/hisp/dhis/android/dashboard/ui/fragments/dashboard/DashboardItemAddFragment.java index b52fbd45..6d92d3fb 100644 --- a/app/src/main/java/org/hisp/dhis/android/dashboard/ui/fragments/dashboard/DashboardItemAddFragment.java +++ b/app/src/main/java/org/hisp/dhis/android/dashboard/ui/fragments/dashboard/DashboardItemAddFragment.java @@ -164,8 +164,8 @@ public void onButtonClick(View v) { @OnItemClick(R.id.listview_simple) public void onItemClick(AdapterView parent, View view, int position, long id) { OptionAdapterValue adapterValue = mAdapter.getItem(position); - // DashboardItemContent resource = Models.dashboardItemContent().query(adapterValue.id); - // Dhis2.dashboards().addDashboardContent(mDashboard, resource); + DashboardItemContent resource = Dhis2.dashboardItemContents().query(adapterValue.id); + Dhis2.dashboards().addDashboardContent(mDashboard, resource); DhisService.getInstance().syncDashboards(); EventBusProvider.post(new UiEvent(UiEvent.UiEventType.SYNC_DASHBOARDS)); @@ -207,6 +207,12 @@ public void onLoaderReset(Loader> loader) { } } + @Override + public void onDestroyView() { + super.onDestroyView(); + ButterKnife.unbind(this); + } + private void queryApiResources() { getLoaderManager().restartLoader(LOADER_ID, getArguments(), this); } @@ -258,15 +264,14 @@ public List query(Context context) { return new ArrayList<>(); } - /* List resources = Models.dashboardItemContent().query(mTypes); + List resources = Dhis2.dashboardItemContents().query(mTypes); List adapterValues = new ArrayList<>(); for (DashboardItemContent dashboardItemContent : resources) { adapterValues.add(new OptionAdapterValue(dashboardItemContent.getUId(), dashboardItemContent.getDisplayName())); } - return adapterValues; */ - return null; + return adapterValues; } } }