@Override protected void onPostExecute(Boolean result) { super.onPostExecute(result); if (result) { Toast.makeText( getActivity().getApplicationContext(), getString(R.string.adjustments_successful), Toast.LENGTH_LONG) .show(); dismiss(); FragmentActivity activity = getActivity(); if (activity != null) { activity.finish(); startActivity( adjustmentReasonIsPhysicalCount() ? new Intent(context, HomeActivity.class) : activity.getIntent()); } } else { Toast.makeText( getActivity().getApplicationContext(), "Failed to save Adjustments", Toast.LENGTH_LONG) .show(); } dialog.dismiss(); }
/** * Overrides the onCreateView method inherited from Fragment to get references to the components. * * @param inflater * @param container a component that stores other components * @param savedInstanceState an instance of the activity * @return a view layout to create the activity */ @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for the Messages fragment View view = inflater.inflate(R.layout.activity_profile_fragment, container, false); // Get references to the text boxes userFirstNameInputField = (EditText) view.findViewById(R.id.firstNameTextBox); userLastNameInputField = (EditText) view.findViewById(R.id.lastNameTextBox); userAgeInputField = (EditText) view.findViewById(R.id.ageTextBox); userUserNameInputField = (EditText) view.findViewById(R.id.userNameTextBox); userPassWordInputField = (EditText) view.findViewById(R.id.passWordTextBox); userCertificationNumberInputField = (EditText) view.findViewById(R.id.certificationNumberTextBox); userInsuranceNumberInputField = (EditText) view.findViewById(R.id.insuranceNumberTextBox); trainerNameInputField = (EditText) view.findViewById(R.id.trainerFirstNameTextBox); trainerCertificationNumberInputField = (EditText) view.findViewById(R.id.trainerCertificationTextBox); trainerInsuranceNumberInputField = (EditText) view.findViewById(R.id.trainerInsuranceNumberTextBox); // Get references to the text labels userCertificationNumberTextLabel = (TextView) view.findViewById(R.id.certificationNumberTextLabel); userInsuranceNumberTextLabel = (TextView) view.findViewById(R.id.insuranceNumberTextLabel); yourTrainerTextLabel = (TextView) view.findViewById(R.id.yourTrainerTextLabel); trainerNameTextLabel = (TextView) view.findViewById(R.id.trainerNameTextLabel); trainerCertificationNumberTextLabel = (TextView) view.findViewById(R.id.trainerCertificationTextLabel); trainerInsuranceNumberTextLabel = (TextView) view.findViewById(R.id.trainerInsuranceNumberTextLabel); errorMessageLabel = (TextView) view.findViewById(R.id.errorMessageTextLabel); // Get references to the buttons editButton = (Button) view.findViewById(R.id.editButton); deleteAccountButton = (Button) view.findViewById(R.id.deleteAccountButton); cancelButton = (Button) view.findViewById(R.id.cancelButton); updateButton = (Button) view.findViewById(R.id.updateButton); // Set onClickListeners for the buttons editButton.setOnClickListener(this); deleteAccountButton.setOnClickListener(this); cancelButton.setOnClickListener(this); updateButton.setOnClickListener(this); // Get the user id and the reason for use from the intent Bundle extras = activity.getIntent().getExtras(); userID = extras.getInt("userID"); reasonForUse = extras.getInt("userRole"); // Configure the layout the user sees based on the reason for use if (reasonForUse == 1) { // Set the user certification number and insurance number fields invisible userCertificationNumberTextLabel.setVisibility(View.INVISIBLE); userCertificationNumberInputField.setVisibility(View.INVISIBLE); userInsuranceNumberTextLabel.setVisibility(View.INVISIBLE); userInsuranceNumberInputField.setVisibility(View.INVISIBLE); // Initialize the user account manager object with the user id of the user that is the // client userAccountManager = new AccountManager(userID, "", "", "", "", 0, reasonForUse, 0, 0, 0); // Start the background thread of loading the user's account information new LoadAccount().execute(); } else { // Set the your trainer fields invisible because the user is a trainer yourTrainerTextLabel.setVisibility(View.INVISIBLE); trainerNameTextLabel.setVisibility(View.INVISIBLE); trainerNameInputField.setVisibility(View.INVISIBLE); trainerCertificationNumberTextLabel.setVisibility(View.INVISIBLE); trainerCertificationNumberInputField.setVisibility(View.INVISIBLE); trainerInsuranceNumberTextLabel.setVisibility(View.INVISIBLE); trainerInsuranceNumberInputField.setVisibility(View.INVISIBLE); // Initialize the user account manager object with the user id of the user that is the // trainer userAccountManager = new AccountManager(userID, "", "", "", "", 0, reasonForUse, 0, 0, 0); // Start the background thread of loading the user's account information new LoadAccount().execute(); } return view; }