private void handleViews(int level) {
   mAdapter.swapData(null);
   switch (level) {
     case 0:
       mRegisterEventButton.hide();
       mUpcomingEventsButton.hide();
       break;
     case 1:
       mRegisterEventButton.show();
       mUpcomingEventsButton.show();
   }
 }
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    mPrefs = new SelectProgramFragmentPreferences(getActivity().getApplicationContext());

    mListView = (ListView) view.findViewById(R.id.event_listview);
    mAdapter = new TrackedEntityInstanceAdapter(getLayoutInflater(savedInstanceState));
    View header =
        getLayoutInflater(savedInstanceState)
            .inflate(R.layout.fragment_select_program_header, mListView, false);
    mProgressBar = (ProgressBar) header.findViewById(R.id.progress_bar);
    mProgressBar.setVisibility(View.GONE);

    mListView.addHeaderView(header, TAG, false);
    mListView.setAdapter(mAdapter);

    mOrgUnitButton = (CardTextViewButton) header.findViewById(R.id.select_organisation_unit);
    mProgramButton = (CardTextViewButton) header.findViewById(R.id.select_program);
    mRegisterEventButton = (FloatingActionButton) header.findViewById(R.id.register_new_event);
    mUpcomingEventsButton = (FloatingActionButton) header.findViewById(R.id.upcoming_events_button);
    mOrgUnitButton.setOnClickListener(this);
    mProgramButton.setOnClickListener(this);
    mRegisterEventButton.setOnClickListener(this);
    mUpcomingEventsButton.setOnClickListener(this);

    mOrgUnitButton.setEnabled(true);
    mProgramButton.setEnabled(false);
    mRegisterEventButton.hide();
    mUpcomingEventsButton.hide();

    if (savedInstanceState != null && savedInstanceState.getParcelable(STATE) != null) {
      mState = savedInstanceState.getParcelable(STATE);
    }

    if (mState == null) {
      // restoring last selection of program
      Pair<String, String> orgUnit = mPrefs.getOrgUnit();
      Pair<String, String> program = mPrefs.getProgram();
      mState = new SelectProgramFragmentState();
      if (orgUnit != null) {
        mState.setOrgUnit(orgUnit.first, orgUnit.second);
        if (program != null) {
          mState.setProgram(program.first, program.second);
        }
      }
    }

    onRestoreState(true);
  }