@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); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { listView = (ListView) view.findViewById(R.id.listview); View header = getLayoutInflater(savedInstanceState) .inflate(R.layout.fragment_programoverview_header, listView, false); mProgressBar = (ProgressBar) header.findViewById(R.id.progress_bar); mProgressBar.setVisibility(View.GONE); adapter = new ProgramStageAdapter(getLayoutInflater(savedInstanceState)); listView.addHeaderView(header, CLASS_TAG, false); listView.setAdapter(adapter); listView.setOnItemClickListener(this); enrollmentLayout = (LinearLayout) header.findViewById(R.id.enrollmentLayout); enrollmentDateLabel = (TextView) header.findViewById(R.id.dateOfEnrollmentLabel); enrollmentDateValue = (TextView) header.findViewById(R.id.dateOfEnrollmentValue); incidentDateLabel = (TextView) header.findViewById(R.id.dateOfIncidentLabel); incidentDateValue = (TextView) header.findViewById(R.id.dateOfIncidentValue); profileCardView = (CardView) header.findViewById(R.id.profile_cardview); enrollmentCardview = (CardView) header.findViewById(R.id.enrollment_cardview); completeButton = (Button) header.findViewById(R.id.complete); terminateButton = (Button) header.findViewById(R.id.terminate); followupButton = (ImageButton) header.findViewById(R.id.followupButton); profileButton = (ImageButton) header.findViewById(R.id.profile_button); completeButton.setOnClickListener(null); terminateButton.setOnClickListener(null); followupButton.setOnClickListener(null); profileButton.setOnClickListener(this); profileCardView.setOnClickListener(this); missingEnrollmentLayout = (LinearLayout) header.findViewById(R.id.missingenrollmentlayout); newEnrollmentButton = (FloatingActionButton) header.findViewById(R.id.newenrollmentbutton); newEnrollmentButton.setOnClickListener(this); attribute1Label = (TextView) header.findViewById(R.id.headerItem1label); attribute1Value = (TextView) header.findViewById(R.id.headerItem1value); attribute2Label = (TextView) header.findViewById(R.id.headerItem2label); attribute2Value = (TextView) header.findViewById(R.id.headerItem2value); Bundle fragmentArguments = getArguments(); Log.d(CLASS_TAG, "program: " + fragmentArguments.getString(PROGRAM_ID)); attachSpinner(); mSpinnerAdapter.swapData( MetaDataController.getProgramsForOrganisationUnit( fragmentArguments.getString(ORG_UNIT_ID), Program.SINGLE_EVENT_WITH_REGISTRATION, Program.MULTIPLE_EVENTS_WITH_REGISTRATION)); if (savedInstanceState != null && savedInstanceState.getParcelable(STATE) != null) { mState = savedInstanceState.getParcelable(STATE); } if (mState == null) { mState = new ProgramOverviewFragmentState(); OrganisationUnit ou = MetaDataController.getOrganisationUnit(fragmentArguments.getString(ORG_UNIT_ID)); Program program = MetaDataController.getProgram(fragmentArguments.getString(PROGRAM_ID)); mState.setOrgUnit(ou.getId(), ou.getLabel()); mState.setProgram(program.getId(), program.getName()); mState.setTrackedEntityInstance(fragmentArguments.getLong(TRACKEDENTITYINSTANCE_ID, -1)); } onRestoreState(true); }