Program: 15210
Project: 15210
Buggy source:
public boolean loadPosts(boolean loadMore){
  Vector<?> loadedPosts;
  if (isPage) {
    loadedPosts=WordPress.wpDB.loadUploadedPosts(getActivity().getApplicationContext(),WordPress.currentBlog.getId(),true);
  }
 else {
    loadedPosts=WordPress.wpDB.loadUploadedPosts(getActivity().getApplicationContext(),WordPress.currentBlog.getId(),false);
  }
  if (loadedPosts != null) {
    titles=new String[loadedPosts.size()];
    postIDs=new String[loadedPosts.size()];
    dateCreated=new String[loadedPosts.size()];
    dateCreatedFormatted=new String[loadedPosts.size()];
    statuses=new String[loadedPosts.size()];
  }
 else {
    titles=new String[0];
    postIDs=new String[0];
    dateCreated=new String[0];
    dateCreatedFormatted=new String[0];
    statuses=new String[0];
    if (pla != null) {
      pla.notifyDataSetChanged();
    }
  }
  if (loadedPosts != null) {
    for (int i=0; i < loadedPosts.size(); i++) {
      HashMap<?,?> contentHash=(HashMap<?,?>)loadedPosts.get(i);
      titles[i]=EscapeUtils.unescapeHtml(contentHash.get("String_Node_Str").toString());
      postIDs[i]=contentHash.get("String_Node_Str").toString();
      dateCreated[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")) {
          statuses[i]=getResources().getText(R.string.published).toString();
        }
 else         if (api_status.equals("String_Node_Str")) {
          statuses[i]=getResources().getText(R.string.draft).toString();
        }
 else         if (api_status.equals("String_Node_Str")) {
          statuses[i]=getResources().getText(R.string.pending_review).toString();
        }
 else         if (api_status.equals("String_Node_Str")) {
          statuses[i]=getResources().getText(R.string.post_private).toString();
        }
      }
      int flags=0;
      flags|=android.text.format.DateUtils.FORMAT_SHOW_DATE;
      flags|=android.text.format.DateUtils.FORMAT_ABBREV_MONTH;
      flags|=android.text.format.DateUtils.FORMAT_SHOW_YEAR;
      flags|=android.text.format.DateUtils.FORMAT_SHOW_TIME;
      long localTime=(Long)contentHash.get("String_Node_Str") + TimeZone.getDefault().getOffset((Long)contentHash.get("String_Node_Str"));
      dateCreatedFormatted[i]=DateUtils.formatDateTime(getActivity().getApplicationContext(),localTime,flags);
    }
    List<String> postIDList=Arrays.asList(postIDs);
    List<String> newPostIDList=new ArrayList<String>();
    newPostIDList.add("String_Node_Str");
    newPostIDList.addAll(postIDList);
    postIDs=(String[])newPostIDList.toArray(new String[newPostIDList.size()]);
    List<String> postTitleList=Arrays.asList(titles);
    List<CharSequence> newPostTitleList=new ArrayList<CharSequence>();
    newPostTitleList.add(getResources().getText((isPage) ? R.string.tab_pages : R.string.tab_posts));
    newPostTitleList.addAll(postTitleList);
    titles=(String[])newPostTitleList.toArray(new String[newPostTitleList.size()]);
    List<String> dateList=Arrays.asList(dateCreated);
    List<String> newDateList=new ArrayList<String>();
    newDateList.add("String_Node_Str");
    newDateList.addAll(dateList);
    dateCreated=(String[])newDateList.toArray(new String[newDateList.size()]);
    List<String> dateFormattedList=Arrays.asList(dateCreatedFormatted);
    List<String> newDateFormattedList=new ArrayList<String>();
    newDateFormattedList.add("String_Node_Str");
    newDateFormattedList.addAll(dateFormattedList);
    dateCreatedFormatted=(String[])newDateFormattedList.toArray(new String[newDateFormattedList.size()]);
    List<String> statusList=Arrays.asList(statuses);
    List<String> newStatusList=new ArrayList<String>();
    newStatusList.add("String_Node_Str");
    newStatusList.addAll(statusList);
    statuses=(String[])newStatusList.toArray(new String[newStatusList.size()]);
  }
  boolean drafts=loadDrafts();
  if (drafts) {
    List<String> draftIDList=Arrays.asList(draftIDs);
    List<String> newDraftIDList=new ArrayList<String>();
    newDraftIDList.add("String_Node_Str");
    newDraftIDList.addAll(draftIDList);
    draftIDs=(String[])newDraftIDList.toArray(new String[newDraftIDList.size()]);
    List<String> titleList=Arrays.asList(draftTitles);
    List<CharSequence> newTitleList=new ArrayList<CharSequence>();
    newTitleList.add(getResources().getText(R.string.local_drafts));
    newTitleList.addAll(titleList);
    draftTitles=(String[])newTitleList.toArray(new String[newTitleList.size()]);
    List<String> draftDateList=Arrays.asList(draftDateCreated);
    List<String> newDraftDateList=new ArrayList<String>();
    newDraftDateList.add("String_Node_Str");
    newDraftDateList.addAll(draftDateList);
    draftDateCreated=(String[])newDraftDateList.toArray(new String[newDraftDateList.size()]);
    List<String> draftStatusList=Arrays.asList(draftStatuses);
    List<String> newDraftStatusList=new ArrayList<String>();
    newDraftStatusList.add("String_Node_Str");
    newDraftStatusList.addAll(draftStatusList);
    draftStatuses=(String[])newDraftStatusList.toArray(new String[newDraftStatusList.size()]);
    postIDs=StringHelper.mergeStringArrays(draftIDs,postIDs);
    titles=StringHelper.mergeStringArrays(draftTitles,titles);
    dateCreatedFormatted=StringHelper.mergeStringArrays(draftDateCreated,dateCreatedFormatted);
    statuses=StringHelper.mergeStringArrays(draftStatuses,statuses);
  }
 else {
    if (pla != null) {
      pla.notifyDataSetChanged();
    }
  }
  if (loadedPosts != null || drafts == true) {
    ListView listView=getListView();
    listView.removeFooterView(switcher);
    if (!isPage) {
      if (loadedPosts != null) {
        if (loadedPosts.size() >= 20) {
          listView.addFooterView(switcher);
        }
      }
    }
    if (loadMore) {
      pla.notifyDataSetChanged();
    }
 else {
      pla=new PostListAdapter(getActivity().getApplicationContext());
      listView.setAdapter(pla);
      listView.setOnItemClickListener(new OnItemClickListener(){
        public void onItemClick(        AdapterView<?> arg0,        View v,        int position,        long id){
          if (v != null && !postIDs[position].equals("String_Node_Str") && !postIDs[position].equals("String_Node_Str")) {
            selectedPosition=position;
            selectedID=v.getId();
            Post post=new Post(WordPress.currentBlog.getId(),selectedID,isPage,getActivity().getApplicationContext());
            WordPress.currentPost=post;
            onPostSelectedListener.onPostSelected(post);
            pla.notifyDataSetChanged();
          }
        }
      }
);
      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;
          }
          Object[] args={R.id.row_post_id};
          try {
            Method m=android.view.View.class.getMethod("String_Node_Str");
            m.invoke(selectedID,args);
          }
 catch (          NoSuchMethodException e) {
            selectedID=info.targetView.getId();
          }
catch (          IllegalArgumentException e) {
            selectedID=info.targetView.getId();
          }
catch (          IllegalAccessException e) {
            selectedID=info.targetView.getId();
          }
catch (          InvocationTargetException e) {
            selectedID=info.targetView.getId();
          }
          rowID=info.position;
          if (totalDrafts > 0 && rowID <= totalDrafts && rowID != 0) {
            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           if (rowID == 1 || ((rowID != (totalDrafts + 1)) && rowID != 0)) {
            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));
            }
 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 (this.shouldSelectAfterLoad) {
      if (postIDs != null) {
        if (postIDs.length >= 1) {
          Post post=new Post(WordPress.currentBlog.getId(),Integer.valueOf(postIDs[1]),isPage,getActivity().getApplicationContext());
          WordPress.currentPost=post;
          onPostSelectedListener.onPostSelected(post);
          selectedPosition=1;
          pla.notifyDataSetChanged();
        }
      }
      shouldSelectAfterLoad=false;
    }
    if (loadedPosts == null) {
      refreshPosts(false);
    }
    return true;
  }
 else {
    if (loadedPosts == null) {
      refreshPosts(false);
    }
    return false;
  }
}

Fixed version (ground truth):
public boolean loadPosts(boolean loadMore){
  Vector<?> loadedPosts;
  if (isPage) {
    loadedPosts=WordPress.wpDB.loadUploadedPosts(getActivity().getApplicationContext(),WordPress.currentBlog.getId(),true);
  }
 else {
    loadedPosts=WordPress.wpDB.loadUploadedPosts(getActivity().getApplicationContext(),WordPress.currentBlog.getId(),false);
  }
  if (loadedPosts != null) {
    titles=new String[loadedPosts.size()];
    postIDs=new String[loadedPosts.size()];
    dateCreated=new String[loadedPosts.size()];
    dateCreatedFormatted=new String[loadedPosts.size()];
    statuses=new String[loadedPosts.size()];
  }
 else {
    titles=new String[0];
    postIDs=new String[0];
    dateCreated=new String[0];
    dateCreatedFormatted=new String[0];
    statuses=new String[0];
    if (pla != null) {
      pla.notifyDataSetChanged();
    }
  }
  if (loadedPosts != null) {
    for (int i=0; i < loadedPosts.size(); i++) {
      HashMap<?,?> contentHash=(HashMap<?,?>)loadedPosts.get(i);
      titles[i]=EscapeUtils.unescapeHtml(contentHash.get("String_Node_Str").toString());
      postIDs[i]=contentHash.get("String_Node_Str").toString();
      dateCreated[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")) {
          statuses[i]=getResources().getText(R.string.published).toString();
        }
 else         if (api_status.equals("String_Node_Str")) {
          statuses[i]=getResources().getText(R.string.draft).toString();
        }
 else         if (api_status.equals("String_Node_Str")) {
          statuses[i]=getResources().getText(R.string.pending_review).toString();
        }
 else         if (api_status.equals("String_Node_Str")) {
          statuses[i]=getResources().getText(R.string.post_private).toString();
        }
      }
      int flags=0;
      flags|=android.text.format.DateUtils.FORMAT_SHOW_DATE;
      flags|=android.text.format.DateUtils.FORMAT_ABBREV_MONTH;
      flags|=android.text.format.DateUtils.FORMAT_SHOW_YEAR;
      flags|=android.text.format.DateUtils.FORMAT_SHOW_TIME;
      long localTime=(Long)contentHash.get("String_Node_Str");
      dateCreatedFormatted[i]=DateUtils.formatDateTime(getActivity().getApplicationContext(),localTime,flags);
    }
    List<String> postIDList=Arrays.asList(postIDs);
    List<String> newPostIDList=new ArrayList<String>();
    newPostIDList.add("String_Node_Str");
    newPostIDList.addAll(postIDList);
    postIDs=(String[])newPostIDList.toArray(new String[newPostIDList.size()]);
    List<String> postTitleList=Arrays.asList(titles);
    List<CharSequence> newPostTitleList=new ArrayList<CharSequence>();
    newPostTitleList.add(getResources().getText((isPage) ? R.string.tab_pages : R.string.tab_posts));
    newPostTitleList.addAll(postTitleList);
    titles=(String[])newPostTitleList.toArray(new String[newPostTitleList.size()]);
    List<String> dateList=Arrays.asList(dateCreated);
    List<String> newDateList=new ArrayList<String>();
    newDateList.add("String_Node_Str");
    newDateList.addAll(dateList);
    dateCreated=(String[])newDateList.toArray(new String[newDateList.size()]);
    List<String> dateFormattedList=Arrays.asList(dateCreatedFormatted);
    List<String> newDateFormattedList=new ArrayList<String>();
    newDateFormattedList.add("String_Node_Str");
    newDateFormattedList.addAll(dateFormattedList);
    dateCreatedFormatted=(String[])newDateFormattedList.toArray(new String[newDateFormattedList.size()]);
    List<String> statusList=Arrays.asList(statuses);
    List<String> newStatusList=new ArrayList<String>();
    newStatusList.add("String_Node_Str");
    newStatusList.addAll(statusList);
    statuses=(String[])newStatusList.toArray(new String[newStatusList.size()]);
  }
  boolean drafts=loadDrafts();
  if (drafts) {
    List<String> draftIDList=Arrays.asList(draftIDs);
    List<String> newDraftIDList=new ArrayList<String>();
    newDraftIDList.add("String_Node_Str");
    newDraftIDList.addAll(draftIDList);
    draftIDs=(String[])newDraftIDList.toArray(new String[newDraftIDList.size()]);
    List<String> titleList=Arrays.asList(draftTitles);
    List<CharSequence> newTitleList=new ArrayList<CharSequence>();
    newTitleList.add(getResources().getText(R.string.local_drafts));
    newTitleList.addAll(titleList);
    draftTitles=(String[])newTitleList.toArray(new String[newTitleList.size()]);
    List<String> draftDateList=Arrays.asList(draftDateCreated);
    List<String> newDraftDateList=new ArrayList<String>();
    newDraftDateList.add("String_Node_Str");
    newDraftDateList.addAll(draftDateList);
    draftDateCreated=(String[])newDraftDateList.toArray(new String[newDraftDateList.size()]);
    List<String> draftStatusList=Arrays.asList(draftStatuses);
    List<String> newDraftStatusList=new ArrayList<String>();
    newDraftStatusList.add("String_Node_Str");
    newDraftStatusList.addAll(draftStatusList);
    draftStatuses=(String[])newDraftStatusList.toArray(new String[newDraftStatusList.size()]);
    postIDs=StringHelper.mergeStringArrays(draftIDs,postIDs);
    titles=StringHelper.mergeStringArrays(draftTitles,titles);
    dateCreatedFormatted=StringHelper.mergeStringArrays(draftDateCreated,dateCreatedFormatted);
    statuses=StringHelper.mergeStringArrays(draftStatuses,statuses);
  }
 else {
    if (pla != null) {
      pla.notifyDataSetChanged();
    }
  }
  if (loadedPosts != null || drafts == true) {
    ListView listView=getListView();
    listView.removeFooterView(switcher);
    if (!isPage) {
      if (loadedPosts != null) {
        if (loadedPosts.size() >= 20) {
          listView.addFooterView(switcher);
        }
      }
    }
    if (loadMore) {
      pla.notifyDataSetChanged();
    }
 else {
      pla=new PostListAdapter(getActivity().getApplicationContext());
      listView.setAdapter(pla);
      listView.setOnItemClickListener(new OnItemClickListener(){
        public void onItemClick(        AdapterView<?> arg0,        View v,        int position,        long id){
          if (v != null && !postIDs[position].equals("String_Node_Str") && !postIDs[position].equals("String_Node_Str")) {
            selectedPosition=position;
            selectedID=v.getId();
            Post post=new Post(WordPress.currentBlog.getId(),selectedID,isPage,getActivity().getApplicationContext());
            WordPress.currentPost=post;
            onPostSelectedListener.onPostSelected(post);
            pla.notifyDataSetChanged();
          }
        }
      }
);
      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;
          }
          Object[] args={R.id.row_post_id};
          try {
            Method m=android.view.View.class.getMethod("String_Node_Str");
            m.invoke(selectedID,args);
          }
 catch (          NoSuchMethodException e) {
            selectedID=info.targetView.getId();
          }
catch (          IllegalArgumentException e) {
            selectedID=info.targetView.getId();
          }
catch (          IllegalAccessException e) {
            selectedID=info.targetView.getId();
          }
catch (          InvocationTargetException e) {
            selectedID=info.targetView.getId();
          }
          rowID=info.position;
          if (totalDrafts > 0 && rowID <= totalDrafts && rowID != 0) {
            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           if (rowID == 1 || ((rowID != (totalDrafts + 1)) && rowID != 0)) {
            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));
            }
 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 (this.shouldSelectAfterLoad) {
      if (postIDs != null) {
        if (postIDs.length >= 1) {
          Post post=new Post(WordPress.currentBlog.getId(),Integer.valueOf(postIDs[1]),isPage,getActivity().getApplicationContext());
          WordPress.currentPost=post;
          onPostSelectedListener.onPostSelected(post);
          selectedPosition=1;
          pla.notifyDataSetChanged();
        }
      }
      shouldSelectAfterLoad=false;
    }
    if (loadedPosts == null) {
      refreshPosts(false);
    }
    return true;
  }
 else {
    if (loadedPosts == null) {
      refreshPosts(false);
    }
    return false;
  }
}