Android Open Source - MentorMe Edit Profile Experiences Fragment






From Project

Back to project page MentorMe.

License

The source code is released under:

MIT License

If you think the Android project MentorMe listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.codepath.wwcmentorme.fragments;
//w  ww  .  ja v a 2  s  .  c om
import android.os.Bundle;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;

import com.codepath.wwcmentorme.R;
import com.codepath.wwcmentorme.helpers.Async;
import com.codepath.wwcmentorme.helpers.UIUtils;
import com.codepath.wwcmentorme.models.User;

public class EditProfileExperiencesFragment extends AbstractEditProfileFragment {
  private EditText etJobTitle;
  private EditText etCompany;
  private EditText etYearsExperience;
  private Button btnGoToAddSkills;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_edit_profile_experience, container, false);
    setupViews(v);
    return v;
  }
  
  private void setupViews(View v) {
    v.setFocusableInTouchMode(true);
    v.requestFocus();
    etJobTitle = (EditText) v.findViewById(R.id.etJobTitle);
    etCompany = (EditText) v.findViewById(R.id.etCompany);
    etYearsExperience = (EditText) v.findViewById(R.id.etYearsExperience);
    btnGoToAddSkills = (Button) v.findViewById(R.id.btnGoToAddSkills);
    OnEditorActionListener listener = new OnEditorActionListener() {
      @Override
      public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_NEXT) {
          saveUserData();
          return true;
        }
        return false;
      }
    };
    etJobTitle.setOnEditorActionListener(listener);
    etCompany.setOnEditorActionListener(listener);
    etYearsExperience.setOnEditorActionListener(listener);
  }
  
  @Override
  protected void updateProfile(final User profileUser) {
    profileUser.setJobTitle(etJobTitle.getText().toString().trim());
    profileUser.setCompanyName(etCompany.getText().toString().trim());
    String yearsInput = etYearsExperience.getText().toString().trim();
    int years = 0; 
    try {
      years = Integer.valueOf(yearsInput);
    } catch (Exception e) {
    }
    if (!TextUtils.isEmpty(yearsInput)) {
      profileUser.setYearsExperience(years);
    }
  }

  @Override
  public void validateInputs(final Async.Block<View> invalidView) {
    View view = null;
    if (TextUtils.getTrimmedLength(etJobTitle.getText().toString()) == 0) view = etJobTitle;
    if (view == null && TextUtils.getTrimmedLength(etCompany.getText().toString()) == 0) view = etCompany;
    if (view == null && TextUtils.getTrimmedLength(etYearsExperience.getText().toString()) == 0) view = etYearsExperience;
    if (invalidView != null) {
      invalidView.call(view);
    }
  }
  
  @Override
  void updateViews(User profileUser) {
    etJobTitle.setText(profileUser.getJobTitle());
    etCompany.setText(profileUser.getCompanyName());
    int years = profileUser.getYearsExperience();
    if (years > 0) {
      etYearsExperience.setText(String.valueOf(years));
    }
  }
}




Java Source Code List

com.codepath.wwcmentorme.activities.AppActivity.java
com.codepath.wwcmentorme.activities.ChatActivity.java
com.codepath.wwcmentorme.activities.EditProfileActivity.java
com.codepath.wwcmentorme.activities.HomeActivity.java
com.codepath.wwcmentorme.activities.MapActivity.java
com.codepath.wwcmentorme.activities.MentorListActivity.java
com.codepath.wwcmentorme.activities.ThankMentorActivity.java
com.codepath.wwcmentorme.activities.UserListActivity.java
com.codepath.wwcmentorme.activities.ViewProfileActivity.java
com.codepath.wwcmentorme.adapters.ChatAdapter.java
com.codepath.wwcmentorme.adapters.DrawerListAdapter.java
com.codepath.wwcmentorme.adapters.MentorListAdapter.java
com.codepath.wwcmentorme.app.MentorMeApp.java
com.codepath.wwcmentorme.data.DataService.java
com.codepath.wwcmentorme.fragments.AbstractEditProfileFragment.java
com.codepath.wwcmentorme.fragments.EditProfileExperiencesFragment.java
com.codepath.wwcmentorme.fragments.EditProfileLocationFragment.java
com.codepath.wwcmentorme.fragments.EditProfileSkillsFragment.java
com.codepath.wwcmentorme.fragments.RefineResultsDialogFragment.java
com.codepath.wwcmentorme.helpers.Async.java
com.codepath.wwcmentorme.helpers.Constants.java
com.codepath.wwcmentorme.helpers.MentorMeReceiver.java
com.codepath.wwcmentorme.helpers.NotificationCenter.java
com.codepath.wwcmentorme.helpers.RoundedImageView.java
com.codepath.wwcmentorme.helpers.UIUtils.java
com.codepath.wwcmentorme.helpers.Utils.java
com.codepath.wwcmentorme.helpers.ViewHolder.java
com.codepath.wwcmentorme.models.Message.java
com.codepath.wwcmentorme.models.Rating.java
com.codepath.wwcmentorme.models.Request.java
com.codepath.wwcmentorme.models.User.java