Program: 13971
Project: 13971
Buggy source:
private void toggleHtmlMode(final ToggleButton toggleButton){
  if (!isAdded()) {
    return;
  }
  mEditorFragmentListener.onTrackableEvent(TrackableEvent.HTML_BUTTON_TAPPED);
  if (!mUploadingMedia.isEmpty() || isActionInProgress()) {
    toggleButton.setChecked(false);
    ToastUtils.showToast(getActivity(),R.string.alert_action_while_uploading,ToastUtils.Duration.LONG);
    return;
  }
  clearFormatBarButtons();
  updateFormatBarEnabledState(true);
  if (toggleButton.isChecked()) {
    Thread thread=new Thread(new Runnable(){
      @Override public void run(){
        if (!isAdded()) {
          return;
        }
        getTitle();
        getContent();
        getActivity().runOnUiThread(new Runnable(){
          @Override public void run(){
            mSourceViewTitle.setText(mTitle);
            SpannableString spannableContent=new SpannableString(mContentHtml);
            HtmlStyleUtils.styleHtmlForDisplay(spannableContent);
            mSourceViewContent.setText(spannableContent);
            mWebView.setVisibility(View.GONE);
            mSourceView.setVisibility(View.VISIBLE);
            mSourceViewContent.requestFocus();
            mSourceViewContent.setSelection(0);
            InputMethodManager imm=((InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE));
            imm.showSoftInput(mSourceViewContent,InputMethodManager.SHOW_IMPLICIT);
          }
        }
);
      }
    }
);
    thread.start();
  }
 else {
    mWebView.setVisibility(View.VISIBLE);
    mSourceView.setVisibility(View.GONE);
    mTitle=mSourceViewTitle.getText().toString();
    mContentHtml=mSourceViewContent.getText().toString();
    updateVisualEditorFields();
    mWebView.execJavaScriptFromString("String_Node_Str");
    mWebView.execJavaScriptFromString("String_Node_Str");
  }
}

Fixed version (ground truth):
private void toggleHtmlMode(final ToggleButton toggleButton){
  if (!isAdded()) {
    return;
  }
  mEditorFragmentListener.onTrackableEvent(TrackableEvent.HTML_BUTTON_TAPPED);
  if (!mUploadingMedia.isEmpty() || isActionInProgress()) {
    toggleButton.setChecked(false);
    ToastUtils.showToast(getActivity(),R.string.alert_action_while_uploading,ToastUtils.Duration.LONG);
    return;
  }
  clearFormatBarButtons();
  updateFormatBarEnabledState(true);
  if (toggleButton.isChecked()) {
    Thread thread=new Thread(new Runnable(){
      @Override public void run(){
        if (!isAdded()) {
          return;
        }
        try {
          getTitle();
          getContent();
        }
 catch (        IllegalEditorStateException e) {
          AppLog.e(T.EDITOR,"String_Node_Str");
          return;
        }
        getActivity().runOnUiThread(new Runnable(){
          @Override public void run(){
            mSourceViewTitle.setText(mTitle);
            SpannableString spannableContent=new SpannableString(mContentHtml);
            HtmlStyleUtils.styleHtmlForDisplay(spannableContent);
            mSourceViewContent.setText(spannableContent);
            mWebView.setVisibility(View.GONE);
            mSourceView.setVisibility(View.VISIBLE);
            mSourceViewContent.requestFocus();
            mSourceViewContent.setSelection(0);
            InputMethodManager imm=((InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE));
            imm.showSoftInput(mSourceViewContent,InputMethodManager.SHOW_IMPLICIT);
          }
        }
);
      }
    }
);
    thread.start();
  }
 else {
    mWebView.setVisibility(View.VISIBLE);
    mSourceView.setVisibility(View.GONE);
    mTitle=mSourceViewTitle.getText().toString();
    mContentHtml=mSourceViewContent.getText().toString();
    updateVisualEditorFields();
    mWebView.execJavaScriptFromString("String_Node_Str");
    mWebView.execJavaScriptFromString("String_Node_Str");
  }
}