private void setupListViewEvents() { int now = (int) (new Date().getTime() / 1000); if (setupListViewEventsFinished != null && setupListViewEventsFinished > now - 100) return; setupListViewEventsFinished = now; ListView lv = (ListView) findViewById(R.id.listview_events); lv.setEmptyView(findViewById(R.id.listview_events_empty)); lv.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View view, int arg2, long event__id) { contentSupport.onEventItemClick(MainActivitySmartphone.this, view); } }); contentSupport.setupListEventsAdapter(lv); AsyncQueryHandler queryHandler = new AsyncQueryHandler(getContentResolver()) { @Override protected void onQueryComplete(int token, Object cookie, Cursor cursor) { startManagingCursor(cursor); ListView lv = (ListView) findViewById(R.id.listview_events); ResourceCursorAdapter adapter = (ResourceCursorAdapter) lv.getAdapter(); adapter.changeCursor(cursor); hideLoading(); } }; queryHandler.startQuery( 0, null, ZabbixContentProvider.CONTENT_URI_EVENTS, null, null, null, null); showLoading(); }
public void setupListViewProblems() { int now = (int) (new Date().getTime() / 1000); if (setupListViewProblemsFinished != null && setupListViewProblemsFinished > now - 100) return; setupListViewProblemsFinished = now; ListView lv = (ListView) findViewById(R.id.listview_triggers); lv.setEmptyView(findViewById(R.id.listview_triggers_empty)); contentSupport.setupListProblemsAdapter(lv); lv.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View view, int arg2, long trigger__id) { contentSupport.onProblemItemClick(MainActivitySmartphone.this, view); } }); final HieraticalHostListView hlv = (HieraticalHostListView) findViewById(R.id.hosts_status); hlv.setEmptyView(findViewById(R.id.listview_triggers_empty)); hlv.setPriorityFilter(problemsFilterPriority); hlv.loadData(true, this); hlv.setOnChildEntryClickListener( new OnChildEntryClickListener() { @Override public void onChildEntryClick(final HieraticalHostListView hlv, final long host__id) { Uri uri = Uri.parse( ZabbixContentProvider.CONTENT_URI_HOSTS.toString() + "/" + host__id + "/triggers"); AsyncQueryHandler queryHandler = new AsyncQueryHandler(getContentResolver()) { @Override protected void onQueryComplete(int token, Object cookie, Cursor cursor) { startManagingCursor(cursor); ListView lv = (ListView) findViewById(R.id.listview_triggers); ResourceCursorAdapter adapter = (ResourceCursorAdapter) lv.getAdapter(); adapter.changeCursor(cursor); hlv.showNext(); hideLoading(); } }; queryHandler.startQuery(0, null, uri, null, null, null, null); showLoading(); } }); }