Example #1
0
  @Override
  public void onBackPressed() {
    // if we are in hieratical list, go back one level
    HieraticalHostListView hlv = null;
    if (getTabHost().getCurrentTabTag().equals("tab_status")) {
      hlv = (HieraticalHostListView) findViewById(R.id.hosts_status);
    } else if (getTabHost().getCurrentTabTag().equals("tab_checks")) {
      hlv = (HieraticalHostListView) findViewById(R.id.hosts_checks);
    }

    ViewFlipper vf_screens = (ViewFlipper) findViewById(R.id.view_switcher_screens);

    if (hlv != null && hlv.getDisplayedChild() > 0) {
      hlv.showPrevious();
    } else if (getTabHost().getCurrentTabTag().equals("tab_graphs")) {
      // if we are at graphs, jump to the previsous tab
      getTabHost().setCurrentTabByTag(prevTabTag != null ? prevTabTag : "tab_checks");
    } else if (getTabHost().getCurrentTabTag().equals("tab_screens")
        && vf_screens.getDisplayedChild() == 1) {
      // if we are at screens, jump back to the list
      vf_screens.showPrevious();
      // hide empty view for sure
      findViewById(R.id.listview_screens_empty).setVisibility(View.GONE);
      lastShowScreen_screen__id = -1;
    } else {
      super.onBackPressed();
    }
  }
Example #2
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();
          }
        });
  }
Example #3
0
  @Override
  protected void onResume() {
    super.onResume();
    support.onResume();

    // workaround for a strange bug: if you go to second level in the HieraticalHostListView,
    // then open the Preferences-Activity and close it again, the 2 lists will show overlapped.
    HieraticalHostListView hlv = (HieraticalHostListView) findViewById(R.id.hosts_status);
    if (hlv != null) {
      hlv.setDisplayedChild(0);
    }
    hlv = (HieraticalHostListView) findViewById(R.id.hosts_checks);
    if (hlv != null) {
      hlv.setDisplayedChild(0);
    }
    ViewFlipper vf_screens = (ViewFlipper) findViewById(R.id.view_switcher_screens);
    if (vf_screens != null) {
      vf_screens.setDisplayedChild(0);
    }
  }
Example #4
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();
          }
        });
  }