Program: 15119
Project: 15119
Buggy source:
public boolean loadPosts(boolean loadMore){
  List<Map<String,Object>> loadedPosts;
  try {
    if (isPage) {
      loadedPosts=WordPress.wpDB.loadUploadedPosts(WordPress.currentBlog.getId(),true);
    }
 else {
      loadedPosts=WordPress.wpDB.loadUploadedPosts(WordPress.currentBlog.getId(),false);
    }
  }
 catch (  Exception e1) {
    return false;
  }
  if (loadedPosts != null) {
    numRecords=loadedPosts.size();
    mTitles=new String[loadedPosts.size()];
    mPostIDs=new String[loadedPosts.size()];
    mDateCreated=new String[loadedPosts.size()];
    mDateCreatedFormatted=new String[loadedPosts.size()];
    mStatuses=new String[loadedPosts.size()];
  }
 else {
    mTitles=new String[0];
    mPostIDs=new String[0];
    mDateCreated=new String[0];
    mDateCreatedFormatted=new String[0];
    mStatuses=new String[0];
    if (mPostListAdapter != null) {
      mPostListAdapter.notifyDataSetChanged();
    }
  }
  if (loadedPosts != null) {
    Date d=new Date();
    for (int i=0; i < loadedPosts.size(); i++) {
      Map<String,Object> contentHash=loadedPosts.get(i);
      mTitles[i]=EscapeUtils.unescapeHtml(contentHash.get("String_Node_Str").toString());
      mPostIDs[i]=contentHash.get("String_Node_Str").toString();
      mDateCreated[i]=contentHash.get("String_Node_Str").toString();
      if (contentHash.get("String_Node_Str") != null) {
        String api_status=contentHash.get("String_Node_Str").toString();
        if (api_status.equals("String_Node_Str")) {
          mStatuses[i]=getResources().getText(R.string.published).toString();
        }
 else         if (api_status.equals("String_Node_Str")) {
          mStatuses[i]=getResources().getText(R.string.draft).toString();
        }
 else         if (api_status.equals("String_Node_Str")) {
          mStatuses[i]=getResources().getText(R.string.pending_review).toString();
        }
 else         if (api_status.equals("String_Node_Str")) {
          mStatuses[i]=getResources().getText(R.string.post_private).toString();
        }
        if ((Long)contentHash.get("String_Node_Str") > d.getTime() && api_status.equals("String_Node_Str")) {
          mStatuses[i]=getResources().getText(R.string.scheduled).toString();
        }
      }
      long localTime=(Long)contentHash.get("String_Node_Str");
      mDateCreatedFormatted[i]=getFormattedDate(localTime);
    }
  }
  boolean drafts=loadDrafts();
  if (drafts) {
    mPostIDs=StringUtils.mergeStringArrays(mDraftIDs,mPostIDs);
    mTitles=StringUtils.mergeStringArrays(mDraftTitles,mTitles);
    mDateCreatedFormatted=StringUtils.mergeStringArrays(mDraftDateCreated,mDateCreatedFormatted);
    mStatuses=StringUtils.mergeStringArrays(mDraftStatuses,mStatuses);
  }
 else {
    if (mPostListAdapter != null) {
      mPostListAdapter.notifyDataSetChanged();
    }
  }
  if (loadedPosts != null || drafts == true) {
    ListView listView=getListView();
    listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    listView.setBackgroundColor(getResources().getColor(R.color.list_row_bg));
    listView.setDivider(getResources().getDrawable(R.drawable.list_divider));
    listView.setDividerHeight(1);
    listView.removeFooterView(switcher);
    if (loadedPosts != null) {
      if (loadedPosts.size() >= 20) {
        listView.addFooterView(switcher);
      }
    }
    if (loadMore) {
      mPostListAdapter.notifyDataSetChanged();
    }
 else {
      mPostListAdapter=new PostListAdapter(getActivity().getBaseContext());
      listView.setAdapter(mPostListAdapter);
      listView.setOnItemClickListener(new OnItemClickListener(){
        public void onItemClick(        AdapterView<?> arg0,        View v,        int position,        long id){
          if (position < mPostIDs.length) {
            if (v != null && !mParentActivity.isRefreshing) {
              mSelectedID=v.getId();
              Post post=new Post(WordPress.currentBlog.getId(),mSelectedID,isPage);
              if (post.getId() >= 0) {
                WordPress.currentPost=post;
                mOnPostSelectedListener.onPostSelected(post);
                mPostListAdapter.notifyDataSetChanged();
              }
 else {
                if (!getActivity().isFinishing()) {
                  FragmentTransaction ft=getFragmentManager().beginTransaction();
                  WPAlertDialogFragment alert=WPAlertDialogFragment.newInstance(getString(R.string.post_not_found));
                  alert.show(ft,"String_Node_Str");
                }
              }
            }
          }
        }
      }
);
      listView.setOnCreateContextMenuListener(new OnCreateContextMenuListener(){
        public void onCreateContextMenu(        ContextMenu menu,        View v,        ContextMenuInfo menuInfo){
          AdapterView.AdapterContextMenuInfo info;
          try {
            info=(AdapterView.AdapterContextMenuInfo)menuInfo;
          }
 catch (          ClassCastException e) {
            return;
          }
          if (mParentActivity.isRefreshing)           return;
          Object[] args={R.id.row_post_id};
          try {
            Method m=android.view.View.class.getMethod("String_Node_Str");
            m.invoke(mSelectedID,args);
          }
 catch (          NoSuchMethodException e) {
            mSelectedID=info.targetView.getId();
          }
catch (          IllegalArgumentException e) {
            mSelectedID=info.targetView.getId();
          }
catch (          IllegalAccessException e) {
            mSelectedID=info.targetView.getId();
          }
catch (          InvocationTargetException e) {
            mSelectedID=info.targetView.getId();
          }
          boolean allowComments=false;
          Post post=new Post(WordPress.currentBlog.getId(),mSelectedID,isPage);
          if (post.getId() >= 0) {
            allowComments=post.isMt_allow_comments();
          }
          mRowID=info.position;
          if (totalDrafts > 0 && mRowID < totalDrafts) {
            menu.clear();
            menu.setHeaderTitle(getResources().getText(R.string.draft_actions));
            menu.add(1,0,0,getResources().getText(R.string.edit_draft));
            menu.add(1,1,0,getResources().getText(R.string.delete_draft));
          }
 else {
            menu.clear();
            if (isPage) {
              menu.setHeaderTitle(getResources().getText(R.string.page_actions));
              menu.add(2,0,0,getResources().getText(R.string.edit_page));
              menu.add(2,1,0,getResources().getText(R.string.delete_page));
              menu.add(2,2,0,getResources().getText(R.string.share_url_page));
              if (allowComments)               menu.add(2,3,0,getResources().getText(R.string.add_comment));
            }
 else {
              menu.setHeaderTitle(getResources().getText(R.string.post_actions));
              menu.add(0,0,0,getResources().getText(R.string.edit_post));
              menu.add(0,1,0,getResources().getText(R.string.delete_post));
              menu.add(0,2,0,getResources().getText(R.string.share_url));
              if (allowComments)               menu.add(0,3,0,getResources().getText(R.string.add_comment));
            }
          }
        }
      }
);
    }
    if (this.shouldSelectAfterLoad) {
      if (mPostIDs != null) {
        if (mPostIDs.length >= 1) {
          Post post=new Post(WordPress.currentBlog.getId(),Integer.valueOf(mPostIDs[0]),isPage);
          if (post.getId() >= 0) {
            WordPress.currentPost=post;
            mOnPostSelectedListener.onPostSelected(post);
            FragmentManager fm=getActivity().getSupportFragmentManager();
            ViewPostFragment f=(ViewPostFragment)fm.findFragmentById(R.id.postDetail);
            if (f != null && f.isInLayout())             getListView().setItemChecked(0,true);
          }
        }
      }
      shouldSelectAfterLoad=false;
    }
    if (loadedPosts == null) {
      refreshPosts(false);
    }
    return true;
  }
 else {
    if (loadedPosts == null) {
      refreshPosts(false);
      if (!isPage)       new ApiHelper.RefreshBlogContentTask(getActivity(),WordPress.getCurrentBlog()).execute(false);
    }
    return false;
  }
}

Fixed version (ground truth):
public boolean loadPosts(boolean loadMore){
  List<Map<String,Object>> loadedPosts;
  try {
    if (isPage) {
      loadedPosts=WordPress.wpDB.loadUploadedPosts(WordPress.currentBlog.getId(),true);
    }
 else {
      loadedPosts=WordPress.wpDB.loadUploadedPosts(WordPress.currentBlog.getId(),false);
    }
  }
 catch (  Exception e1) {
    return false;
  }
  if (loadedPosts != null) {
    numRecords=loadedPosts.size();
    mTitles=new String[loadedPosts.size()];
    mPostIDs=new String[loadedPosts.size()];
    mDateCreated=new String[loadedPosts.size()];
    mDateCreatedFormatted=new String[loadedPosts.size()];
    mStatuses=new String[loadedPosts.size()];
  }
 else {
    mTitles=new String[0];
    mPostIDs=new String[0];
    mDateCreated=new String[0];
    mDateCreatedFormatted=new String[0];
    mStatuses=new String[0];
    if (mPostListAdapter != null) {
      mPostListAdapter.notifyDataSetChanged();
    }
  }
  if (loadedPosts != null) {
    Date d=new Date();
    for (int i=0; i < loadedPosts.size(); i++) {
      Map<String,Object> contentHash=loadedPosts.get(i);
      mTitles[i]=StringUtils.unescapeHTML(contentHash.get("String_Node_Str").toString());
      mPostIDs[i]=contentHash.get("String_Node_Str").toString();
      mDateCreated[i]=contentHash.get("String_Node_Str").toString();
      if (contentHash.get("String_Node_Str") != null) {
        String api_status=contentHash.get("String_Node_Str").toString();
        if (api_status.equals("String_Node_Str")) {
          mStatuses[i]=getResources().getText(R.string.published).toString();
        }
 else         if (api_status.equals("String_Node_Str")) {
          mStatuses[i]=getResources().getText(R.string.draft).toString();
        }
 else         if (api_status.equals("String_Node_Str")) {
          mStatuses[i]=getResources().getText(R.string.pending_review).toString();
        }
 else         if (api_status.equals("String_Node_Str")) {
          mStatuses[i]=getResources().getText(R.string.post_private).toString();
        }
        if ((Long)contentHash.get("String_Node_Str") > d.getTime() && api_status.equals("String_Node_Str")) {
          mStatuses[i]=getResources().getText(R.string.scheduled).toString();
        }
      }
      long localTime=(Long)contentHash.get("String_Node_Str");
      mDateCreatedFormatted[i]=getFormattedDate(localTime);
    }
  }
  boolean drafts=loadDrafts();
  if (drafts) {
    mPostIDs=StringUtils.mergeStringArrays(mDraftIDs,mPostIDs);
    mTitles=StringUtils.mergeStringArrays(mDraftTitles,mTitles);
    mDateCreatedFormatted=StringUtils.mergeStringArrays(mDraftDateCreated,mDateCreatedFormatted);
    mStatuses=StringUtils.mergeStringArrays(mDraftStatuses,mStatuses);
  }
 else {
    if (mPostListAdapter != null) {
      mPostListAdapter.notifyDataSetChanged();
    }
  }
  if (loadedPosts != null || drafts == true) {
    ListView listView=getListView();
    listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    listView.setBackgroundColor(getResources().getColor(R.color.list_row_bg));
    listView.setDivider(getResources().getDrawable(R.drawable.list_divider));
    listView.setDividerHeight(1);
    listView.removeFooterView(switcher);
    if (loadedPosts != null) {
      if (loadedPosts.size() >= 20) {
        listView.addFooterView(switcher);
      }
    }
    if (loadMore) {
      mPostListAdapter.notifyDataSetChanged();
    }
 else {
      mPostListAdapter=new PostListAdapter(getActivity().getBaseContext());
      listView.setAdapter(mPostListAdapter);
      listView.setOnItemClickListener(new OnItemClickListener(){
        public void onItemClick(        AdapterView<?> arg0,        View v,        int position,        long id){
          if (position < mPostIDs.length) {
            if (v != null && !mParentActivity.isRefreshing) {
              mSelectedID=v.getId();
              Post post=new Post(WordPress.currentBlog.getId(),mSelectedID,isPage);
              if (post.getId() >= 0) {
                WordPress.currentPost=post;
                mOnPostSelectedListener.onPostSelected(post);
                mPostListAdapter.notifyDataSetChanged();
              }
 else {
                if (!getActivity().isFinishing()) {
                  FragmentTransaction ft=getFragmentManager().beginTransaction();
                  WPAlertDialogFragment alert=WPAlertDialogFragment.newInstance(getString(R.string.post_not_found));
                  alert.show(ft,"String_Node_Str");
                }
              }
            }
          }
        }
      }
);
      listView.setOnCreateContextMenuListener(new OnCreateContextMenuListener(){
        public void onCreateContextMenu(        ContextMenu menu,        View v,        ContextMenuInfo menuInfo){
          AdapterView.AdapterContextMenuInfo info;
          try {
            info=(AdapterView.AdapterContextMenuInfo)menuInfo;
          }
 catch (          ClassCastException e) {
            return;
          }
          if (mParentActivity.isRefreshing)           return;
          Object[] args={R.id.row_post_id};
          try {
            Method m=android.view.View.class.getMethod("String_Node_Str");
            m.invoke(mSelectedID,args);
          }
 catch (          NoSuchMethodException e) {
            mSelectedID=info.targetView.getId();
          }
catch (          IllegalArgumentException e) {
            mSelectedID=info.targetView.getId();
          }
catch (          IllegalAccessException e) {
            mSelectedID=info.targetView.getId();
          }
catch (          InvocationTargetException e) {
            mSelectedID=info.targetView.getId();
          }
          boolean allowComments=false;
          Post post=new Post(WordPress.currentBlog.getId(),mSelectedID,isPage);
          if (post.getId() >= 0) {
            allowComments=post.isMt_allow_comments();
          }
          mRowID=info.position;
          if (totalDrafts > 0 && mRowID < totalDrafts) {
            menu.clear();
            menu.setHeaderTitle(getResources().getText(R.string.draft_actions));
            menu.add(1,0,0,getResources().getText(R.string.edit_draft));
            menu.add(1,1,0,getResources().getText(R.string.delete_draft));
          }
 else {
            menu.clear();
            if (isPage) {
              menu.setHeaderTitle(getResources().getText(R.string.page_actions));
              menu.add(2,0,0,getResources().getText(R.string.edit_page));
              menu.add(2,1,0,getResources().getText(R.string.delete_page));
              menu.add(2,2,0,getResources().getText(R.string.share_url_page));
              if (allowComments)               menu.add(2,3,0,getResources().getText(R.string.add_comment));
            }
 else {
              menu.setHeaderTitle(getResources().getText(R.string.post_actions));
              menu.add(0,0,0,getResources().getText(R.string.edit_post));
              menu.add(0,1,0,getResources().getText(R.string.delete_post));
              menu.add(0,2,0,getResources().getText(R.string.share_url));
              if (allowComments)               menu.add(0,3,0,getResources().getText(R.string.add_comment));
            }
          }
        }
      }
);
    }
    if (this.shouldSelectAfterLoad) {
      if (mPostIDs != null) {
        if (mPostIDs.length >= 1) {
          Post post=new Post(WordPress.currentBlog.getId(),Integer.valueOf(mPostIDs[0]),isPage);
          if (post.getId() >= 0) {
            WordPress.currentPost=post;
            mOnPostSelectedListener.onPostSelected(post);
            FragmentManager fm=getActivity().getSupportFragmentManager();
            ViewPostFragment f=(ViewPostFragment)fm.findFragmentById(R.id.postDetail);
            if (f != null && f.isInLayout())             getListView().setItemChecked(0,true);
          }
        }
      }
      shouldSelectAfterLoad=false;
    }
    if (loadedPosts == null) {
      refreshPosts(false);
    }
    return true;
  }
 else {
    if (loadedPosts == null) {
      refreshPosts(false);
      if (!isPage)       new ApiHelper.RefreshBlogContentTask(getActivity(),WordPress.getCurrentBlog()).execute(false);
    }
    return false;
  }
}