Program: 13890
Project: 13890
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  ((WordPress)getApplication()).component().inject(this);
  mDispatcher.register(this);
  setContentView(R.layout.new_edit_post_activity);
  if (savedInstanceState == null) {
    mSite=(SiteModel)getIntent().getSerializableExtra(WordPress.SITE);
  }
 else {
    mSite=(SiteModel)savedInstanceState.getSerializable(WordPress.SITE);
  }
  PreferenceManager.setDefaultValues(this,R.xml.account_settings,false);
  mShowAztecEditor=AppPrefs.isAztecEditorEnabled();
  mShowNewEditor=AppPrefs.isVisualEditorEnabled();
  final ActionBar actionBar=getSupportActionBar();
  if (actionBar != null) {
    actionBar.setDisplayHomeAsUpEnabled(true);
  }
  FragmentManager fragmentManager=getFragmentManager();
  Bundle extras=getIntent().getExtras();
  String action=getIntent().getAction();
  if (savedInstanceState == null) {
    if (!getIntent().hasExtra(EXTRA_POST) || Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)|| NEW_MEDIA_POST.equals(action)|| getIntent().hasExtra(EXTRA_IS_QUICKPRESS)) {
      if (getIntent().hasExtra(EXTRA_QUICKPRESS_BLOG_ID)) {
        int localSiteId=getIntent().getIntExtra(EXTRA_QUICKPRESS_BLOG_ID,-1);
        mSite=mSiteStore.getSiteByLocalId(localSiteId);
      }
      if (extras != null) {
        mIsPage=extras.getBoolean(EXTRA_IS_PAGE);
      }
      mIsNewPost=true;
      if (mSite == null) {
        showErrorAndFinish(R.string.blog_not_found);
        return;
      }
      if (!mSite.isVisible()) {
        showErrorAndFinish(R.string.error_blog_hidden);
        return;
      }
      List<Long> categories=new ArrayList<>();
      categories.add((long)SiteSettingsInterface.getDefaultCategory(WordPress.getContext()));
      String postFormat=SiteSettingsInterface.getDefaultFormat(WordPress.getContext());
      mPost=mPostStore.instantiatePostModel(mSite,mIsPage,categories,postFormat);
    }
 else     if (extras != null) {
      mPost=(PostModel)extras.getSerializable(EXTRA_POST);
      if (mPost != null) {
        mOriginalPost=mPost.clone();
        mIsPage=mPost.isPage();
      }
    }
 else {
      showErrorAndFinish(R.string.post_not_found);
      return;
    }
  }
 else {
    mDroppedMediaUris=savedInstanceState.getParcelable(STATE_KEY_DROPPED_MEDIA_URIS);
    if (savedInstanceState.containsKey(STATE_KEY_ORIGINAL_POST)) {
      try {
        mPost=(PostModel)savedInstanceState.getSerializable(STATE_KEY_CURRENT_POST);
        mOriginalPost=(PostModel)savedInstanceState.getSerializable(STATE_KEY_ORIGINAL_POST);
      }
 catch (      ClassCastException e) {
        mPost=null;
      }
    }
    mEditorFragment=(EditorFragmentAbstract)fragmentManager.getFragment(savedInstanceState,STATE_KEY_EDITOR_FRAGMENT);
    if (mEditorFragment instanceof EditorMediaUploadListener) {
      mEditorMediaUploadListener=(EditorMediaUploadListener)mEditorFragment;
    }
  }
  if (mSite == null) {
    ToastUtils.showToast(this,R.string.blog_not_found,ToastUtils.Duration.SHORT);
    finish();
    return;
  }
  if (mHasSetPostContent=mEditorFragment != null) {
    mEditorFragment.setImageLoader(mImageLoader);
  }
  if (mPost == null) {
    showErrorAndFinish(R.string.post_not_found);
    return;
  }
  if (mIsNewPost) {
    trackEditorCreatedPost(action,getIntent());
  }
  setTitle(StringUtils.unescapeHTML(SiteUtils.getSiteNameOrHomeURL(mSite)));
  mSectionsPagerAdapter=new SectionsPagerAdapter(fragmentManager);
  mViewPager=(WPViewPager)findViewById(R.id.pager);
  mViewPager.setAdapter(mSectionsPagerAdapter);
  mViewPager.setOffscreenPageLimit(2);
  mViewPager.setPagingEnabled(false);
  mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener(){
    @Override public void onPageSelected(    int position){
      invalidateOptionsMenu();
      if (position == PAGE_CONTENT) {
        setTitle(StringUtils.unescapeHTML(SiteUtils.getSiteNameOrHomeURL(mSite)));
      }
 else       if (position == PAGE_SETTINGS) {
        setTitle(mPost.isPage() ? R.string.page_settings : R.string.post_settings);
        hidePhotoChooser();
      }
 else       if (position == PAGE_PREVIEW) {
        setTitle(mPost.isPage() ? R.string.preview_page : R.string.preview_post);
        hidePhotoChooser();
        savePostAsync(new AfterSavePostListener(){
          @Override public void onPostSave(){
            if (mEditPostPreviewFragment != null) {
              runOnUiThread(new Runnable(){
                @Override public void run(){
                  if (mEditPostPreviewFragment != null) {
                    mEditPostPreviewFragment.loadPost();
                  }
                }
              }
);
            }
          }
        }
);
      }
    }
  }
);
  ActivityId.trackLastActivity(ActivityId.POST_EDITOR);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  ((WordPress)getApplication()).component().inject(this);
  mDispatcher.register(this);
  setContentView(R.layout.new_edit_post_activity);
  if (savedInstanceState == null) {
    mSite=(SiteModel)getIntent().getSerializableExtra(WordPress.SITE);
  }
 else {
    mSite=(SiteModel)savedInstanceState.getSerializable(WordPress.SITE);
  }
  PreferenceManager.setDefaultValues(this,R.xml.account_settings,false);
  mShowAztecEditor=AppPrefs.isAztecEditorEnabled();
  mShowNewEditor=AppPrefs.isVisualEditorEnabled();
  final ActionBar actionBar=getSupportActionBar();
  if (actionBar != null) {
    actionBar.setDisplayHomeAsUpEnabled(true);
  }
  FragmentManager fragmentManager=getFragmentManager();
  Bundle extras=getIntent().getExtras();
  String action=getIntent().getAction();
  if (savedInstanceState == null) {
    if (!getIntent().hasExtra(EXTRA_POST) || Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)|| NEW_MEDIA_POST.equals(action)|| getIntent().hasExtra(EXTRA_IS_QUICKPRESS)) {
      if (getIntent().hasExtra(EXTRA_QUICKPRESS_BLOG_ID)) {
        int localSiteId=getIntent().getIntExtra(EXTRA_QUICKPRESS_BLOG_ID,-1);
        mSite=mSiteStore.getSiteByLocalId(localSiteId);
      }
      if (extras != null) {
        mIsPage=extras.getBoolean(EXTRA_IS_PAGE);
      }
      mIsNewPost=true;
      if (mSite == null) {
        showErrorAndFinish(R.string.blog_not_found);
        return;
      }
      if (!mSite.isVisible()) {
        showErrorAndFinish(R.string.error_blog_hidden);
        return;
      }
      List<Long> categories=new ArrayList<>();
      String postFormat="String_Node_Str";
      if (mSite.isWPCom() || mSite.isJetpackConnected()) {
        categories.add((long)SiteSettingsInterface.getDefaultCategory(WordPress.getContext()));
        postFormat=SiteSettingsInterface.getDefaultFormat(WordPress.getContext());
      }
      mPost=mPostStore.instantiatePostModel(mSite,mIsPage,categories,postFormat);
    }
 else     if (extras != null) {
      mPost=(PostModel)extras.getSerializable(EXTRA_POST);
      if (mPost != null) {
        mOriginalPost=mPost.clone();
        mIsPage=mPost.isPage();
      }
    }
 else {
      showErrorAndFinish(R.string.post_not_found);
      return;
    }
  }
 else {
    mDroppedMediaUris=savedInstanceState.getParcelable(STATE_KEY_DROPPED_MEDIA_URIS);
    if (savedInstanceState.containsKey(STATE_KEY_ORIGINAL_POST)) {
      try {
        mPost=(PostModel)savedInstanceState.getSerializable(STATE_KEY_CURRENT_POST);
        mOriginalPost=(PostModel)savedInstanceState.getSerializable(STATE_KEY_ORIGINAL_POST);
      }
 catch (      ClassCastException e) {
        mPost=null;
      }
    }
    mEditorFragment=(EditorFragmentAbstract)fragmentManager.getFragment(savedInstanceState,STATE_KEY_EDITOR_FRAGMENT);
    if (mEditorFragment instanceof EditorMediaUploadListener) {
      mEditorMediaUploadListener=(EditorMediaUploadListener)mEditorFragment;
    }
  }
  if (mSite == null) {
    ToastUtils.showToast(this,R.string.blog_not_found,ToastUtils.Duration.SHORT);
    finish();
    return;
  }
  if (mHasSetPostContent=mEditorFragment != null) {
    mEditorFragment.setImageLoader(mImageLoader);
  }
  if (mPost == null) {
    showErrorAndFinish(R.string.post_not_found);
    return;
  }
  if (mIsNewPost) {
    trackEditorCreatedPost(action,getIntent());
  }
  setTitle(StringUtils.unescapeHTML(SiteUtils.getSiteNameOrHomeURL(mSite)));
  mSectionsPagerAdapter=new SectionsPagerAdapter(fragmentManager);
  mViewPager=(WPViewPager)findViewById(R.id.pager);
  mViewPager.setAdapter(mSectionsPagerAdapter);
  mViewPager.setOffscreenPageLimit(2);
  mViewPager.setPagingEnabled(false);
  mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener(){
    @Override public void onPageSelected(    int position){
      invalidateOptionsMenu();
      if (position == PAGE_CONTENT) {
        setTitle(StringUtils.unescapeHTML(SiteUtils.getSiteNameOrHomeURL(mSite)));
      }
 else       if (position == PAGE_SETTINGS) {
        setTitle(mPost.isPage() ? R.string.page_settings : R.string.post_settings);
        hidePhotoChooser();
      }
 else       if (position == PAGE_PREVIEW) {
        setTitle(mPost.isPage() ? R.string.preview_page : R.string.preview_post);
        hidePhotoChooser();
        savePostAsync(new AfterSavePostListener(){
          @Override public void onPostSave(){
            if (mEditPostPreviewFragment != null) {
              runOnUiThread(new Runnable(){
                @Override public void run(){
                  if (mEditPostPreviewFragment != null) {
                    mEditPostPreviewFragment.loadPost();
                  }
                }
              }
);
            }
          }
        }
);
      }
    }
  }
);
  ActivityId.trackLastActivity(ActivityId.POST_EDITOR);
}