Program: 35676
Project: 35676
Buggy source:
@Override protected void onAttach(@NonNull View view){
  super.onAttach(view);
  dispose(null);
  userEntity=userUtils.getCurrentUser();
  if ("String_Node_Str".equals(appPreferences.getProxyType()) || appPreferences.getProxyType() == null) {
    hideProxySettings();
  }
 else {
    showProxySettings();
  }
  if (appPreferences.getProxyCredentials()) {
    showProxyCredentials();
  }
 else {
    hideProxyCredentials();
  }
  if (userEntity != null) {
    baseUrlTextView.setText(userEntity.getBaseUrl());
    reauthorizeButton.setOnClickListener(view14 -> {
      reauthorizeButton.setEnabled(false);
      getParentController().getRouter().pushController(RouterTransaction.with(new WebViewLoginController(userEntity.getBaseUrl(),true)).pushChangeHandler(new VerticalChangeHandler()).popChangeHandler(new VerticalChangeHandler()));
      reauthorizeButton.setEnabled(true);
    }
);
    if (userEntity.getDisplayName() != null) {
      avatarImageView.setTextAndColorSeed(String.valueOf(userEntity.getDisplayName().toUpperCase().charAt(0)),ColorUtils.colorSeed);
      displayNameTextView.setText(userEntity.getDisplayName());
    }
    GlideUrl glideUrl=new GlideUrl(ApiHelper.getUrlForAvatarWithName(userEntity.getBaseUrl(),userEntity.getUsername()),new LazyHeaders.Builder().setHeader("String_Node_Str","String_Node_Str").setHeader("String_Node_Str",ApiHelper.getUserAgent()).build());
    GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext()).load(glideUrl).circleCrop().centerInside().into(avatarImageView);
    profileQueryDisposable=ncApi.getUserProfile(ApiHelper.getCredentials(userEntity.getUsername(),userEntity.getToken()),ApiHelper.getUrlForUserProfile(userEntity.getBaseUrl())).subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).subscribe(userProfileOverall -> {
      String displayName=null;
      if (!TextUtils.isEmpty(userProfileOverall.getOcs().getData().getDisplayName())) {
        displayName=userProfileOverall.getOcs().getData().getDisplayName();
      }
 else       if (!TextUtils.isEmpty(userProfileOverall.getOcs().getData().getDisplayNameAlt())) {
        displayName=userProfileOverall.getOcs().getData().getDisplayNameAlt();
      }
      if (!TextUtils.isEmpty(displayName) && !displayName.equals(userEntity.getDisplayName())) {
        dbQueryDisposable=userUtils.createOrUpdateUser(userEntity.getUsername(),userEntity.getToken(),userEntity.getBaseUrl(),displayName,null,true).subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).subscribe(userEntityResult -> {
          displayNameTextView.setText(userEntityResult.getDisplayName());
        }
,throwable -> {
          dispose(dbQueryDisposable);
        }
,() -> dispose(dbQueryDisposable));
      }
    }
,throwable -> {
      dispose(profileQueryDisposable);
    }
,() -> dispose(profileQueryDisposable));
    removeAccountButton.setEnabled(true);
    removeAccountButton.setOnClickListener(view1 -> {
      removeAccountButton.setEnabled(false);
      cookieManager.getCookieStore().removeAll();
      boolean otherUserExists=userUtils.scheduleUserForDeletionWithId(userEntity.getId());
      new JobRequest.Builder(AccountRemovalJob.TAG).setUpdateCurrent(true).startNow().build().schedule();
      if (otherUserExists && getView() != null) {
        onViewBound(getView());
        onAttach(getView());
      }
 else       if (!otherUserExists) {
        if (getParentController() == null || getParentController().getRouter() == null) {
          if (getActivity() != null) {
            getActivity().finish();
          }
        }
 else {
          getParentController().getRouter().setRoot(RouterTransaction.with(new ServerSelectionController()).pushChangeHandler(new VerticalChangeHandler()).popChangeHandler(new VerticalChangeHandler()));
        }
      }
    }
);
  }
  if (userUtils.getUsers().size() <= 1) {
    switchAccountButton.setVisibility(View.GONE);
  }
  if (ErrorMessageHolder.getInstance().getMessageType() != null) {
switch (ErrorMessageHolder.getInstance().getMessageType()) {
case ACCOUNT_UPDATED_NOT_ADDED:
      messageText.setTextColor(getResources().getColor(R.color.colorPrimary));
    messageText.setText(getResources().getString(R.string.nc_settings_account_updated));
  messageView.setVisibility(View.VISIBLE);
break;
case WRONG_ACCOUNT:
messageText.setTextColor(getResources().getColor(R.color.nc_darkRed));
messageText.setText(getResources().getString(R.string.nc_settings_wrong_account));
messageView.setVisibility(View.VISIBLE);
break;
default :
messageView.setVisibility(View.GONE);
break;
}
ErrorMessageHolder.getInstance().setMessageType(null);
messageView.animate().translationY(0).alpha(0.0f).setDuration(2500).setStartDelay(5000).setListener(new AnimatorListenerAdapter(){
@Override public void onAnimationEnd(Animator animation){
super.onAnimationEnd(animation);
messageView.setVisibility(View.GONE);
}
}
);
}
 else {
messageView.setVisibility(View.GONE);
}
}

Fixed version (ground truth):
@Override protected void onAttach(@NonNull View view){
  super.onAttach(view);
  dispose(null);
  userEntity=userUtils.getCurrentUser();
  if ("String_Node_Str".equals(appPreferences.getProxyType()) || appPreferences.getProxyType() == null) {
    hideProxySettings();
  }
 else {
    showProxySettings();
  }
  if (appPreferences.getProxyCredentials()) {
    showProxyCredentials();
  }
 else {
    hideProxyCredentials();
  }
  if (userEntity != null) {
    baseUrlTextView.setText(userEntity.getBaseUrl());
    reauthorizeButton.setOnClickListener(view14 -> {
      reauthorizeButton.setEnabled(false);
      getParentController().getRouter().pushController(RouterTransaction.with(new WebViewLoginController(userEntity.getBaseUrl(),true)).pushChangeHandler(new VerticalChangeHandler()).popChangeHandler(new VerticalChangeHandler()));
      reauthorizeButton.setEnabled(true);
    }
);
    if (userEntity.getDisplayName() != null) {
      avatarImageView.setTextAndColorSeed(String.valueOf(userEntity.getDisplayName().toUpperCase().charAt(0)),ColorUtils.colorSeed);
      displayNameTextView.setText(userEntity.getDisplayName());
    }
    GlideUrl glideUrl=new GlideUrl(ApiHelper.getUrlForAvatarWithName(userEntity.getBaseUrl(),userEntity.getUsername()),new LazyHeaders.Builder().setHeader("String_Node_Str","String_Node_Str").setHeader("String_Node_Str",ApiHelper.getUserAgent()).build());
    GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext()).load(glideUrl).circleCrop().centerInside().into(avatarImageView);
    profileQueryDisposable=ncApi.getUserProfile(ApiHelper.getCredentials(userEntity.getUsername(),userEntity.getToken()),ApiHelper.getUrlForUserProfile(userEntity.getBaseUrl())).subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).subscribe(userProfileOverall -> {
      String displayName=null;
      if (!TextUtils.isEmpty(userProfileOverall.getOcs().getData().getDisplayName())) {
        displayName=userProfileOverall.getOcs().getData().getDisplayName();
      }
 else       if (!TextUtils.isEmpty(userProfileOverall.getOcs().getData().getDisplayNameAlt())) {
        displayName=userProfileOverall.getOcs().getData().getDisplayNameAlt();
      }
      if (!TextUtils.isEmpty(displayName) && !displayName.equals(userEntity.getDisplayName())) {
        dbQueryDisposable=userUtils.createOrUpdateUser(userEntity.getUsername(),userEntity.getToken(),userEntity.getBaseUrl(),displayName,null,true).subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).subscribe(userEntityResult -> {
          displayNameTextView.setText(userEntityResult.getDisplayName());
        }
,throwable -> {
          dispose(dbQueryDisposable);
        }
,() -> dispose(dbQueryDisposable));
      }
    }
,throwable -> {
      dispose(profileQueryDisposable);
    }
,() -> dispose(profileQueryDisposable));
    removeAccountButton.setEnabled(true);
    removeAccountButton.setOnClickListener(view1 -> {
      removeAccountButton.setEnabled(false);
      cookieManager.getCookieStore().removeAll();
      boolean otherUserExists=userUtils.scheduleUserForDeletionWithId(userEntity.getId());
      new JobRequest.Builder(AccountRemovalJob.TAG).setUpdateCurrent(true).startNow().build().schedule();
      if (otherUserExists && getView() != null) {
        onViewBound(getView());
        onAttach(getView());
      }
 else       if (!otherUserExists) {
        if (getParentController() == null || getParentController().getRouter() == null) {
          if (getActivity() != null) {
            getActivity().finish();
          }
        }
 else {
          getParentController().getRouter().setRoot(RouterTransaction.with(new ServerSelectionController()).pushChangeHandler(new VerticalChangeHandler()).popChangeHandler(new VerticalChangeHandler()));
        }
      }
    }
);
  }
  if (userUtils.getUsers().size() <= 1) {
    switchAccountButton.setVisibility(View.GONE);
  }
  if (ErrorMessageHolder.getInstance().getMessageType() != null) {
switch (ErrorMessageHolder.getInstance().getMessageType()) {
case ACCOUNT_UPDATED_NOT_ADDED:
      messageText.setTextColor(getResources().getColor(R.color.colorPrimary));
    messageText.setText(getResources().getString(R.string.nc_settings_account_updated));
  messageView.setVisibility(View.VISIBLE);
break;
case WRONG_ACCOUNT:
messageText.setTextColor(getResources().getColor(R.color.nc_darkRed));
messageText.setText(getResources().getString(R.string.nc_settings_wrong_account));
messageView.setVisibility(View.VISIBLE);
break;
default :
messageView.setVisibility(View.GONE);
break;
}
ErrorMessageHolder.getInstance().setMessageType(null);
messageView.animate().translationY(0).alpha(0.0f).setDuration(2500).setStartDelay(5000).setListener(new AnimatorListenerAdapter(){
@Override public void onAnimationEnd(Animator animation){
super.onAnimationEnd(animation);
if (messageView != null) {
messageView.setVisibility(View.GONE);
}
}
}
);
}
 else {
if (messageView != null) {
messageView.setVisibility(View.GONE);
}
}
}