Program: 13869
Project: 13869
Buggy source:
@Override public void onViewCreated(View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  mUsernamesContainer=(ViewGroup)view.findViewById(R.id.usernames);
  mUsernamesContainer.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      EditTextUtils.showSoftInput(mUsernameEditText);
    }
  }
);
  Role role=mRole;
  if (role == null) {
    role=getDefaultRole();
  }
  mUsernameEditText=(MultiUsernameEditText)view.findViewById(R.id.invite_usernames);
  mUsernameEditText.setOnKeyListener(new View.OnKeyListener(){
    @Override public boolean onKey(    View view,    int i,    KeyEvent keyEvent){
      return keyEvent.getKeyCode() == KeyEvent.KEYCODE_DEL && keyEvent.getAction() == KeyEvent.ACTION_DOWN && removeLastEnteredUsername();
    }
  }
);
  mUsernameEditText.setOnBackspacePressedListener(new MultiUsernameEditText.OnBackspacePressedListener(){
    @Override public boolean onBackspacePressed(){
      return removeLastEnteredUsername();
    }
  }
);
  mUsernameEditText.addTextChangedListener(new TextWatcher(){
    private boolean shouldIgnoreChanges=false;
    @Override public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    @Override public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
      if (shouldIgnoreChanges) {
        return;
      }
      shouldIgnoreChanges=true;
      if (mUsernameButtons.size() >= MAX_NUMBER_OF_INVITEES && !TextUtils.isEmpty(s)) {
        resetEditTextContent(mUsernameEditText);
      }
 else       if (endsWithDelimiter(mUsernameEditText.getText().toString())) {
        addUsername(mUsernameEditText,null);
      }
      shouldIgnoreChanges=false;
    }
    @Override public void afterTextChanged(    Editable s){
    }
  }
);
  mUsernameEditText.setOnEditorActionListener(new TextView.OnEditorActionListener(){
    @Override public boolean onEditorAction(    TextView v,    int actionId,    KeyEvent event){
      if (actionId == EditorInfo.IME_ACTION_DONE || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
        addUsername(mUsernameEditText,null);
        return true;
      }
 else {
        return false;
      }
    }
  }
);
  mUsernameEditText.setOnFocusChangeListener(new View.OnFocusChangeListener(){
    @Override public void onFocusChange(    View v,    boolean hasFocus){
      if (!hasFocus && mUsernameEditText.getText().toString().length() > 0) {
        addUsername(mUsernameEditText,null);
      }
    }
  }
);
  if (mUsernameButtons.size() > 0) {
    ArrayList<String> usernames=new ArrayList<>(mUsernameButtons.keySet());
    populateUsernameButtons(usernames);
  }
  mRoleTextView=(TextView)view.findViewById(R.id.role);
  setRole(role);
  ImageView imgRoleInfo=(ImageView)view.findViewById(R.id.imgRoleInfo);
  imgRoleInfo.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      ActivityLauncher.openUrlExternal(v.getContext(),URL_USER_ROLES_DOCUMENTATION);
    }
  }
);
  if (Role.inviteRoles(mSite).length > 1) {
    view.findViewById(R.id.role_container).setOnClickListener(new View.OnClickListener(){
      @Override public void onClick(      View v){
        RoleSelectDialogFragment.show(PeopleInviteFragment.this,0,mSite);
      }
    }
);
  }
 else {
    mRoleTextView.setCompoundDrawablesWithIntrinsicBounds(0,0,0,0);
  }
  final int MAX_CHARS=getResources().getInteger(R.integer.invite_message_char_limit);
  final TextView remainingCharsTextView=(TextView)view.findViewById(R.id.message_remaining);
  mCustomMessageEditText=(EditText)view.findViewById(R.id.message);
  mCustomMessageEditText.addTextChangedListener(new TextWatcher(){
    @Override public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    @Override public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
      mCustomMessage=mCustomMessageEditText.getText().toString();
      updateRemainingCharsView(remainingCharsTextView,mCustomMessage,MAX_CHARS);
    }
    @Override public void afterTextChanged(    Editable s){
    }
  }
);
  updateRemainingCharsView(remainingCharsTextView,mCustomMessage,MAX_CHARS);
}

Fixed version (ground truth):
@Override public void onViewCreated(View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  mUsernamesContainer=(ViewGroup)view.findViewById(R.id.usernames);
  mUsernamesContainer.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      EditTextUtils.showSoftInput(mUsernameEditText);
    }
  }
);
  Role role=mRole;
  if (role == null) {
    role=getDefaultRole();
  }
  mUsernameEditText=(MultiUsernameEditText)view.findViewById(R.id.invite_usernames);
  mUsernameEditText.setOnKeyListener(new View.OnKeyListener(){
    @Override public boolean onKey(    View view,    int i,    KeyEvent keyEvent){
      return keyEvent.getKeyCode() == KeyEvent.KEYCODE_DEL && keyEvent.getAction() == KeyEvent.ACTION_DOWN && removeLastEnteredUsername();
    }
  }
);
  mUsernameEditText.setOnBackspacePressedListener(new MultiUsernameEditText.OnBackspacePressedListener(){
    @Override public boolean onBackspacePressed(){
      return removeLastEnteredUsername();
    }
  }
);
  mUsernameEditText.addTextChangedListener(new TextWatcher(){
    private boolean shouldIgnoreChanges=false;
    @Override public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    @Override public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
      if (shouldIgnoreChanges) {
        return;
      }
      shouldIgnoreChanges=true;
      if (mUsernameButtons.size() >= MAX_NUMBER_OF_INVITEES && !TextUtils.isEmpty(s)) {
        resetEditTextContent(mUsernameEditText);
      }
 else       if (endsWithDelimiter(mUsernameEditText.getText().toString())) {
        addUsername(mUsernameEditText,null);
      }
      shouldIgnoreChanges=false;
    }
    @Override public void afterTextChanged(    Editable s){
    }
  }
);
  mUsernameEditText.setOnEditorActionListener(new TextView.OnEditorActionListener(){
    @Override public boolean onEditorAction(    TextView v,    int actionId,    KeyEvent event){
      if (actionId == EditorInfo.IME_ACTION_DONE || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
        addUsername(mUsernameEditText,null);
        return true;
      }
 else {
        return false;
      }
    }
  }
);
  mUsernameEditText.setOnFocusChangeListener(new View.OnFocusChangeListener(){
    @Override public void onFocusChange(    View v,    boolean hasFocus){
      if (!hasFocus && mUsernameEditText.getText().toString().length() > 0) {
        addUsername(mUsernameEditText,null);
      }
    }
  }
);
  if (!mUsernameButtons.isEmpty()) {
    mUsernameErrorViews.clear();
    populateUsernameButtons(new ArrayList<>(mUsernameButtons.keySet()));
  }
 else   if (!mUsernames.isEmpty()) {
    populateUsernameButtons(new ArrayList<>(mUsernames));
  }
  mRoleTextView=(TextView)view.findViewById(R.id.role);
  setRole(role);
  ImageView imgRoleInfo=(ImageView)view.findViewById(R.id.imgRoleInfo);
  imgRoleInfo.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      ActivityLauncher.openUrlExternal(v.getContext(),URL_USER_ROLES_DOCUMENTATION);
    }
  }
);
  if (Role.inviteRoles(mSite).length > 1) {
    view.findViewById(R.id.role_container).setOnClickListener(new View.OnClickListener(){
      @Override public void onClick(      View v){
        RoleSelectDialogFragment.show(PeopleInviteFragment.this,0,mSite);
      }
    }
);
  }
 else {
    mRoleTextView.setCompoundDrawablesWithIntrinsicBounds(0,0,0,0);
  }
  final int MAX_CHARS=getResources().getInteger(R.integer.invite_message_char_limit);
  final TextView remainingCharsTextView=(TextView)view.findViewById(R.id.message_remaining);
  mCustomMessageEditText=(EditText)view.findViewById(R.id.message);
  mCustomMessageEditText.addTextChangedListener(new TextWatcher(){
    @Override public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    @Override public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
      mCustomMessage=mCustomMessageEditText.getText().toString();
      updateRemainingCharsView(remainingCharsTextView,mCustomMessage,MAX_CHARS);
    }
    @Override public void afterTextChanged(    Editable s){
    }
  }
);
  updateRemainingCharsView(remainingCharsTextView,mCustomMessage,MAX_CHARS);
}