Ejemplo n.º 1
0
  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();
          }
        });
  }
Ejemplo n.º 2
0
  private void setupListViewChecks() {
    int now = (int) (new Date().getTime() / 1000);
    if (setupListViewChecksFinished != null && setupListViewChecksFinished > now - 200) return;
    setupListViewChecksFinished = now;

    HieraticalHostListView hlv = (HieraticalHostListView) findViewById(R.id.hosts_checks);
    hlv.setEmptyView(findViewById(R.id.listview_checks_empty));
    hlv.loadData(false, 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
                        + "/applications");
            AsyncQueryHandler queryHandler =
                new AsyncQueryHandler(getContentResolver()) {
                  @Override
                  protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
                    startManagingCursor(cursor);
                    ExpandableListView lv = (ExpandableListView) findViewById(R.id.listview_checks);
                    lv.setEmptyView(findViewById(R.id.listview_checks_empty));
                    ResourceCursorTreeAdapter adapter =
                        new ResourceCursorTreeAdapter(
                            getApplicationContext(),
                            cursor,
                            R.layout.list_checks_group_entry,
                            R.layout.list_checks_child_entry) {
                          @Override
                          protected void bindChildView(
                              View view, Context arg1, Cursor cursor, boolean arg3) {
                            contentSupport.setupListChecksItemsAdapterBindView(view, arg1, cursor);
                          }

                          @Override
                          protected void bindGroupView(
                              View view, Context arg1, Cursor cursor, boolean arg3) {
                            TextView tv =
                                (TextView) view.findViewById(R.id.checks_group_entry_name);
                            tv.setText(
                                cursor.getString(
                                    cursor.getColumnIndex(ApplicationData.COLUMN_NAME)));
                          }

                          @Override
                          protected Cursor getChildrenCursor(Cursor arg0) {
                            Uri uri =
                                Uri.parse(
                                    ZabbixContentProvider.CONTENT_URI_HOSTS.toString()
                                        + "/"
                                        + host__id
                                        + "/applications"
                                        + "/"
                                        + arg0.getLong(
                                            arg0.getColumnIndex(
                                                ApplicationData.COLUMN_APPLICATIONID))
                                        + "/items");
                            Cursor cursor = getContentResolver().query(uri, null, null, null, null);
                            startManagingCursor(cursor);
                            return cursor;
                          }
                        };
                    lv.setAdapter(adapter);
                    lv.setOnChildClickListener(
                        new OnChildClickListener() {
                          @Override
                          public boolean onChildClick(
                              ExpandableListView parent,
                              View v,
                              int groupPosition,
                              int childPosition,
                              long id) {
                            contentSupport.onChecksItemClick(MainActivitySmartphone.this, v);
                            return true;
                          }
                        });
                    hlv.showNext();
                    hideLoading();
                  }
                };
            queryHandler.startQuery(0, null, uri, null, null, null, null);
            showLoading();
          }
        });
  }