@Subscribe
  public void onItemClick(OnTrackerItemClick eventClick) {
    if (eventClick.isOnDescriptionClick()) {

      ProgramOverviewFragment fragment =
          ProgramOverviewFragment.newInstance(
              mState.getOrgUnitId(), mState.getProgramId(), eventClick.getItem().getLocalId());

      mNavigationHandler.switchFragment(fragment, ProgramOverviewFragment.CLASS_TAG, true);
    } else {
      showStatusDialog(eventClick.getItem());
    }
  }
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info =
        (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

    final TrackedEntityInstanceItemRow itemRow =
        (TrackedEntityInstanceItemRow) mListView.getItemAtPosition(info.position);

    Log.d(TAG, "" + itemRow.getTrackedEntityInstance().getTrackedEntityInstance());

    if (item.getTitle()
        .toString()
        .equals(
            getResources()
                .getString(org.hisp.dhis.android.sdk.R.string.go_to_programoverview_fragment))) {
      mNavigationHandler.switchFragment(
          ProgramOverviewFragment.newInstance(
              mState.getOrgUnitId(),
              mState.getProgramId(),
              itemRow.getTrackedEntityInstance().getLocalId()),
          TAG,
          true);
    } else if (item.getTitle()
        .toString()
        .equals(getResources().getString(org.hisp.dhis.android.sdk.R.string.delete))) {
      if (!(itemRow
          .getStatus()
          .equals(OnRowClick.ITEM_STATUS.SENT))) // if not sent to server, present dialog to user
      {
        UiUtils.showConfirmDialog(
            getActivity(),
            getActivity().getString(R.string.confirm),
            getActivity().getString(R.string.warning_delete_unsent_tei),
            getActivity().getString(R.string.delete),
            getActivity().getString(R.string.cancel),
            (R.drawable.ic_event_error),
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                performSoftDeleteOfTrackedEntityInstance(itemRow.getTrackedEntityInstance());
                dialog.dismiss();
              }
            });
      } else {
        // if sent to server, be able to soft delete without annoying the user
        performSoftDeleteOfTrackedEntityInstance(itemRow.getTrackedEntityInstance());
      }
    }
    return true;
  }
  @Subscribe
  public void onItemClick(OnTrackedEntityInstanceClick eventClick) {
    if (eventClick.isOnDescriptionClick()) {

      ProgramOverviewFragment fragment =
          ProgramOverviewFragment.newInstance(
              mState.getOrgUnitId(),
              mState.getProgramId(),
              eventClick.getTrackedEntityInstance().localId);

      mNavigationHandler.switchFragment(fragment, ProgramOverviewFragment.CLASS_TAG, true);
    } else {
      switch (eventClick.getStatus()) {
        case SENT:
          Dhis2.getInstance()
              .showErrorDialog(
                  getActivity(),
                  getString(R.string.event_sent),
                  getString(R.string.status_sent_description),
                  R.drawable.ic_from_server);
          break;
        case OFFLINE:
          Dhis2.getInstance()
              .showErrorDialog(
                  getActivity(),
                  getString(R.string.event_offline),
                  getString(R.string.status_offline_description),
                  R.drawable.ic_offline);
          break;
        case ERROR:
          {
            String message = getErrorDescription(eventClick.getTrackedEntityInstance());
            Dhis2.getInstance()
                .showErrorDialog(
                    getActivity(),
                    getString(R.string.event_error),
                    message,
                    R.drawable.ic_event_error);
            break;
          }
      }
    }
  }