nus-yam/ex-repair huggingface dataset:
Program: 15059
Project: 15059
Buggy source:
public void refreshMediaFromDB(){
  setFilter(mFilter);
  if (mGridAdapter == null) {
    mGridAdapter=new MediaGridAdapter(getActivity(),null,0,mCheckedItems);
    mGridAdapter.setCallback(this);
    mGridView.setAdapter(mGridAdapter);
    mGridView.setSelection(mSavedFirstVisiblePosition);
  }
  if (mCursor != null && mCursor.getCount() == 0 && !mHasRetrievedAllMedia) {
    refreshMediaFromServer(0,true);
  }
  mGridAdapter.swapCursor(mCursor);
}

Fixed version (ground truth):
public void refreshMediaFromDB(){
  setFilter(mFilter);
  if (mGridAdapter.getCount() == 0 && !mHasRetrievedAllMedia) {
    refreshMediaFromServer(0,true);
  }
}
Program: 15060
Project: 15060
Buggy source:
public void search(String searchTerm){
  Blog blog=WordPress.getCurrentBlog();
  if (blog != null) {
    String blogId=String.valueOf(blog.getBlogId());
    mCursor=WordPress.wpDB.getMediaFilesForBlog(blogId,searchTerm);
    mGridAdapter.changeCursor(mCursor);
  }
}

Fixed version (ground truth):
public void search(String searchTerm){
  Blog blog=WordPress.getCurrentBlog();
  if (blog != null) {
    String blogId=String.valueOf(blog.getBlogId());
    Cursor cursor=WordPress.wpDB.getMediaFilesForBlog(blogId,searchTerm);
    mGridAdapter.changeCursor(cursor);
  }
}
Program: 15061
Project: 15061
Buggy source:
@Override public void onResume(){
  super.onResume();
  setupSpinnerAdapter();
  refreshMediaFromDB();
}

Fixed version (ground truth):
@Override public void onResume(){
  super.onResume();
  refreshSpinnerAdapter();
  refreshMediaFromDB();
}
Program: 15062
Project: 15062
Buggy source:
public void setFilter(Filter filter){
  mFilter=filter;
  mCursor=filterItems(mFilter);
  if (mGridAdapter != null && mCursor != null) {
    mGridAdapter.swapCursor(mCursor);
    mResultView.setVisibility(View.GONE);
  }
 else {
    if (filter != Filter.CUSTOM_DATE) {
      mResultView.setVisibility(View.VISIBLE);
      mResultView.setText(getResources().getString(R.string.empty_fields));
    }
  }
}

Fixed version (ground truth):
public void setFilter(Filter filter){
  mFilter=filter;
  Cursor cursor=filterItems(mFilter);
  if (cursor != null) {
    mGridAdapter.swapCursor(cursor);
    mResultView.setVisibility(View.GONE);
  }
 else {
    if (filter != Filter.CUSTOM_DATE) {
      mResultView.setVisibility(View.VISIBLE);
      mResultView.setText(getResources().getString(R.string.empty_fields));
    }
  }
}
Program: 15063
Project: 15063
Buggy source:
public void reset(){
  mCheckedItems.clear();
  mGridView.setSelection(0);
  mGridView.requestFocusFromTouch();
  mGridView.setSelection(0);
  if (mGridAdapter != null) {
    mGridAdapter.swapCursor(null);
  }
  resetSpinnerAdapter();
  clearCheckedItems();
  mHasRetrievedAllMedia=false;
}

Fixed version (ground truth):
public void reset(){
  mCheckedItems.clear();
  mGridView.setSelection(0);
  mGridView.requestFocusFromTouch();
  mGridView.setSelection(0);
  mGridAdapter.swapCursor(null);
  resetSpinnerAdapter();
  clearCheckedItems();
  mHasRetrievedAllMedia=false;
}
Program: 15064
Project: 15064
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  super.onCreateView(inflater,container,savedInstanceState);
  View view=inflater.inflate(R.layout.media_grid_fragment,container);
  mGridView=(MultiSelectGridView)view.findViewById(R.id.media_gridview);
  mGridView.setOnItemClickListener(this);
  mGridView.setRecyclerListener(this);
  mGridView.setMultiSelectListener(this);
  mResultView=(TextView)view.findViewById(R.id.media_filter_result_text);
  mSpinnerContainer=view.findViewById(R.id.media_filter_spinner_container);
  mSpinnerContainer.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      if (mSpinner != null && !isInMultiSelect()) {
        mSpinner.performClick();
      }
    }
  }
);
  mFiltersText=new String[Filter.values().length];
  mSpinner=(CustomSpinner)view.findViewById(R.id.media_filter_spinner);
  mSpinner.setOnItemSelectedListener(mFilterSelectedListener);
  mSpinner.setOnItemSelectedEvenIfUnchangedListener(mFilterSelectedListener);
  setupSpinnerAdapter();
  mCheckedItems=new ArrayList<String>();
  restoreState(savedInstanceState);
  return view;
}

Fixed version (ground truth):
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  super.onCreateView(inflater,container,savedInstanceState);
  mCheckedItems=new ArrayList<String>();
  mFiltersText=new String[Filter.values().length];
  mGridAdapter=new MediaGridAdapter(getActivity(),null,0,mCheckedItems);
  mGridAdapter.setCallback(this);
  View view=inflater.inflate(R.layout.media_grid_fragment,container);
  mGridView=(MultiSelectGridView)view.findViewById(R.id.media_gridview);
  mGridView.setOnItemClickListener(this);
  mGridView.setRecyclerListener(this);
  mGridView.setMultiSelectListener(this);
  mGridView.setAdapter(mGridAdapter);
  mResultView=(TextView)view.findViewById(R.id.media_filter_result_text);
  mSpinner=(CustomSpinner)view.findViewById(R.id.media_filter_spinner);
  mSpinner.setOnItemSelectedListener(mFilterSelectedListener);
  mSpinner.setOnItemSelectedEvenIfUnchangedListener(mFilterSelectedListener);
  mSpinnerContainer=view.findViewById(R.id.media_filter_spinner_container);
  mSpinnerContainer.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      if (!isInMultiSelect()) {
        mSpinner.performClick();
      }
    }
  }
);
  restoreState(savedInstanceState);
  setupSpinnerAdapter();
  return view;
}
Program: 15065
Project: 15065
Buggy source:
private void updateSelectedCategoryList(){
  SparseBooleanArray selectedItems=mListView.getCheckedItemPositions();
  for (int i=0; i < selectedItems.size(); i++) {
    if (selectedItems.get(selectedItems.keyAt(i))) {
      mSelectedCategories.add(mCategoryLevels.get(selectedItems.keyAt(i)).getName());
    }
 else {
      mSelectedCategories.remove(mCategoryLevels.get(selectedItems.keyAt(i)).getName());
    }
  }
}

Fixed version (ground truth):
private void updateSelectedCategoryList(){
  SparseBooleanArray selectedItems=mListView.getCheckedItemPositions();
  for (int i=0; i < selectedItems.size(); i++) {
    String currentName=StringUtils.unescapeHTML(mCategoryLevels.get(selectedItems.keyAt(i)).getName());
    if (selectedItems.get(selectedItems.keyAt(i))) {
      mSelectedCategories.add(currentName);
    }
 else {
      mSelectedCategories.remove(currentName);
    }
  }
}
Program: 15066
Project: 15066
Buggy source:
private void populateCategoryList(){
  mCategoryLevels=CategoryNode.getSortedListOfCategoriesFromRoot(mCategories);
  for (int i=0; i < mCategoryLevels.size(); i++) {
    mCategoryNames.put(mCategoryLevels.get(i).getName(),i);
  }
  CategoryArrayAdapter categoryAdapter=new CategoryArrayAdapter(this,R.layout.categories_row,mCategoryLevels);
  this.setListAdapter(categoryAdapter);
  if (mSelectedCategories != null) {
    ListView lv=getListView();
    for (    String selectedCategory : mSelectedCategories) {
      if (mCategoryNames.keySet().contains(selectedCategory)) {
        lv.setItemChecked(mCategoryNames.get(selectedCategory),true);
      }
    }
  }
  restoreScrollOffset();
}

Fixed version (ground truth):
private void populateCategoryList(){
  mCategoryLevels=CategoryNode.getSortedListOfCategoriesFromRoot(mCategories);
  for (int i=0; i < mCategoryLevels.size(); i++) {
    mCategoryNames.put(StringUtils.unescapeHTML(mCategoryLevels.get(i).getName()),i);
  }
  CategoryArrayAdapter categoryAdapter=new CategoryArrayAdapter(this,R.layout.categories_row,mCategoryLevels);
  this.setListAdapter(categoryAdapter);
  if (mSelectedCategories != null) {
    ListView lv=getListView();
    for (    String selectedCategory : mSelectedCategories) {
      if (mCategoryNames.keySet().contains(selectedCategory)) {
        lv.setItemChecked(mCategoryNames.get(selectedCategory),true);
      }
    }
  }
  restoreScrollOffset();
}
Program: 15067
Project: 15067
Buggy source:
public static synchronized SQLTable getSQLTable(Uri uri){
  int uriMatch=sUriMatcher.match(uri);
  if (sUriMatchToSQLTableMap.indexOfKey(uriMatch) >= 0)   return sUriMatchToSQLTableMap.get(uriMatch);
  return null;
}

Fixed version (ground truth):
private static synchronized SQLTable getSQLTable(Uri uri){
  int uriMatch=sUriMatcher.match(uri);
  if (sUriMatchToSQLTableMap.indexOfKey(uriMatch) >= 0)   return sUriMatchToSQLTableMap.get(uriMatch);
  return null;
}
Program: 15068
Project: 15068
Buggy source:
@Override public void onAttach(Activity activity){
  super.onAttach(activity);
  try {
    mCallback=(MediaAddFragmentCallback)activity;
  }
 catch (  ClassCastException e) {
    throw new ClassCastException(activity.toString() + "String_Node_Str" + MediaAddFragment.class.getSimpleName());
  }
}

Fixed version (ground truth):
@Override public void onAttach(Activity activity){
  super.onAttach(activity);
  try {
    mCallback=(MediaAddFragmentCallback)activity;
  }
 catch (  ClassCastException e) {
    throw new ClassCastException(activity.toString() + "String_Node_Str" + MediaAddFragmentCallback.class.getSimpleName());
  }
}
Program: 15069
Project: 15069
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  if (savedInstanceState != null) {
    if (savedInstanceState.getString("String_Node_Str") != null)     mMediaCapturePath=savedInstanceState.getString("String_Node_Str");
  }
  return inflater.inflate(R.layout.actionbar_add_media_cell,container,false);
}

Fixed version (ground truth):
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  if (savedInstanceState != null && savedInstanceState.getString(BUNDLE_MEDIA_CAPTURE_PATH) != null)   mMediaCapturePath=savedInstanceState.getString(BUNDLE_MEDIA_CAPTURE_PATH);
  return inflater.inflate(R.layout.actionbar_add_media_cell,container,false);
}
Program: 15070
Project: 15070
Buggy source:
@Override public void onSaveInstanceState(Bundle outState){
  super.onSaveInstanceState(outState);
  if (mMediaCapturePath != null && !mMediaCapturePath.equals("String_Node_Str"))   outState.putString("String_Node_Str",mMediaCapturePath);
}

Fixed version (ground truth):
@Override public void onSaveInstanceState(Bundle outState){
  super.onSaveInstanceState(outState);
  if (mMediaCapturePath != null && !mMediaCapturePath.equals("String_Node_Str"))   outState.putString(BUNDLE_MEDIA_CAPTURE_PATH,mMediaCapturePath);
}
Program: 15071
Project: 15071
Buggy source:
@Override public void onBlogChanged(){
  super.onBlogChanged();
  if (mMediaGridFragment != null && !mMediaGridFragment.hasRetrievedAllMediaFromServer()) {
    mMediaGridFragment.refreshMediaFromServer(0,false);
    startAnimatingRefreshButton();
  }
  getFeatureSet();
}

Fixed version (ground truth):
@Override public void onBlogChanged(){
  super.onBlogChanged();
  if (mMediaEditFragment != null) {
    mMediaEditFragment.loadMedia(null);
    if (!mMediaEditFragment.isInLayout() && mMediaEditFragment.isVisible())     getSupportFragmentManager().popBackStack();
  }
  getSupportFragmentManager().executePendingTransactions();
  if (mMediaItemFragment != null && mMediaItemFragment.isVisible())   getSupportFragmentManager().popBackStack();
  if (mMediaGridFragment != null) {
    mMediaGridFragment.reset();
    if (!mMediaGridFragment.hasRetrievedAllMediaFromServer()) {
      mMediaGridFragment.refreshMediaFromServer(0,false);
      startAnimatingRefreshButton();
    }
  }
  getFeatureSet();
}
Program: 15073
Project: 15073
Buggy source:
@Override public void onClick(View v){
  if (!inMultiSelect()) {
    stateTextView.setText("String_Node_Str");
    stateTextView.setOnClickListener(null);
    mCallback.onRetryUpload(mediaId);
  }
}

Fixed version (ground truth):
@Override public void onClick(View v){
  if (!inMultiSelect()) {
    ((TextView)v).setText("String_Node_Str");
    v.setOnClickListener(null);
    mCallback.onRetryUpload(mediaId);
  }
}
Program: 15074
Project: 15074
Buggy source:
@Override public Cursor swapCursor(Cursor newCursor){
  if (newCursor == null)   return super.swapCursor(newCursor);
  mCursorDataCount=newCursor.getCount();
  MatrixCursor matrixCursor=new MatrixCursor(new String[]{"String_Node_Str"});
  int columnCount=getColumnCount(mContext);
  int remainder=newCursor.getCount() % columnCount;
  if (remainder > 0) {
    int spaceCount=columnCount - remainder;
    for (int i=0; i < spaceCount; i++) {
      int id=i - spaceCount;
      matrixCursor.addRow(new Object[]{id + "String_Node_Str"});
    }
  }
  matrixCursor.addRow(new Object[]{Integer.MIN_VALUE});
  MergeCursor mergeCursor=new MergeCursor(new Cursor[]{newCursor,matrixCursor});
  return super.swapCursor(mergeCursor);
}

Fixed version (ground truth):
@Override public Cursor swapCursor(Cursor newCursor){
  if (newCursor == null) {
    mCursorDataCount=0;
    return super.swapCursor(newCursor);
  }
  mCursorDataCount=newCursor.getCount();
  MatrixCursor matrixCursor=new MatrixCursor(new String[]{"String_Node_Str"});
  int columnCount=getColumnCount(mContext);
  int remainder=newCursor.getCount() % columnCount;
  if (remainder > 0) {
    int spaceCount=columnCount - remainder;
    for (int i=0; i < spaceCount; i++) {
      int id=i - spaceCount;
      matrixCursor.addRow(new Object[]{id + "String_Node_Str"});
    }
  }
  matrixCursor.addRow(new Object[]{Integer.MIN_VALUE});
  MergeCursor mergeCursor=new MergeCursor(new Cursor[]{newCursor,matrixCursor});
  return super.swapCursor(mergeCursor);
}
Program: 15075
Project: 15075
Buggy source:
public void setRefreshing(boolean refreshing){
  mIsRefreshing=refreshing;
  if (mProgressBar != null) {
    if (mIsRefreshing) {
      mProgressBar.setVisibility(View.VISIBLE);
    }
 else {
      mProgressBar.setVisibility(View.GONE);
    }
  }
}

Fixed version (ground truth):
public void setRefreshing(boolean refreshing){
  mIsRefreshing=refreshing;
  notifyDataSetChanged();
}
Program: 15076
Project: 15076
Buggy source:
private void updateFilterText(){
  if (WordPress.currentBlog == null)   return;
  String blogId=String.valueOf(WordPress.getCurrentBlog().getBlogId());
  int countAll=WordPress.wpDB.getMediaCountAll(blogId);
  int countImages=WordPress.wpDB.getMediaCountImages(blogId);
  int countUnattached=WordPress.wpDB.getMediaCountUnattached(blogId);
  mFiltersText[0]=getResources().getString(R.string.all) + "String_Node_Str" + countAll+ "String_Node_Str";
  mFiltersText[1]=getResources().getString(R.string.images) + "String_Node_Str" + countImages+ "String_Node_Str";
  mFiltersText[2]=getResources().getString(R.string.unattached) + "String_Node_Str" + countUnattached+ "String_Node_Str";
  mFiltersText[3]=getResources().getString(R.string.custom_date) + "String_Node_Str";
}

Fixed version (ground truth):
private void updateFilterText(){
  if (WordPress.currentBlog == null)   return;
  String blogId=String.valueOf(WordPress.getCurrentBlog().getBlogId());
  int countAll=WordPress.wpDB.getMediaCountAll(blogId);
  int countImages=WordPress.wpDB.getMediaCountImages(blogId);
  int countUnattached=WordPress.wpDB.getMediaCountUnattached(blogId);
  setFiltersText(countAll,countImages,countUnattached);
}
Program: 15077
Project: 15077
Buggy source:
private void loadNetworkImage(Cursor cursor,NetworkImageView imageView){
  String thumbnailURL=cursor.getString(cursor.getColumnIndex("String_Node_Str"));
  if (thumbnailURL != null) {
    imageView.setTag(thumbnailURL);
    imageView.setImageUrl(thumbnailURL,WordPress.imageLoader);
  }
}

Fixed version (ground truth):
private void loadNetworkImage(Cursor cursor,NetworkImageView imageView){
  String thumbnailURL=cursor.getString(cursor.getColumnIndex("String_Node_Str"));
  Uri uri=Uri.parse(thumbnailURL);
  if (thumbnailURL != null && MediaUtils.isValidImage(uri.getLastPathSegment())) {
    imageView.setTag(thumbnailURL);
    imageView.setImageUrl(thumbnailURL,WordPress.imageLoader);
  }
}
Program: 15079
Project: 15079
Buggy source:
private String getRealPathFromURI(Uri contentUri){
  String[] proj={MediaStore.Images.Media.DATA};
  CursorLoader loader=new CursorLoader(getActivity(),contentUri,proj,null,null,null);
  Cursor cursor=loader.loadInBackground();
  int column_index=cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
  cursor.moveToFirst();
  String path=cursor.getString(column_index);
  cursor.close();
  return path;
}

Fixed version (ground truth):
private String getRealPathFromURI(Uri contentUri){
  if (contentUri == null)   return null;
  String[] proj={MediaStore.Images.Media.DATA};
  CursorLoader loader=new CursorLoader(getActivity(),contentUri,proj,null,null,null);
  Cursor cursor=loader.loadInBackground();
  int column_index=cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
  cursor.moveToFirst();
  String path=cursor.getString(column_index);
  cursor.close();
  return path;
}
Program: 15081
Project: 15081
Buggy source:
private boolean inMultiSelect(){
  return mCheckedItems.size() > 0;
}

Fixed version (ground truth):
private boolean inMultiSelect(){
  return mCallback.isInMultiSelect();
}
Program: 15082
Project: 15082
Buggy source:
public boolean isInMultiSelect(){
  return mGridView.isInMultiSelectMode();
}

Fixed version (ground truth):
@Override public boolean isInMultiSelect(){
  return mGridView.isInMultiSelectMode();
}
Program: 15084
Project: 15084
Buggy source:
@Override public void onFailure(){
  mIsRefreshing=false;
  mListener.onMediaItemListDownloaded();
  mGridAdapter.setRefreshing(false);
}

Fixed version (ground truth):
@Override public void onFailure(int errorCode){
  if (errorCode == SyncMediaLibraryTask.NO_UPLOAD_FILES_CAP) {
    Toast.makeText(getActivity(),"String_Node_Str",Toast.LENGTH_SHORT).show();
    MediaGridAdapter adapter=(MediaGridAdapter)mGridView.getAdapter();
    mHasRetrievedAllMedia=true;
    adapter.setHasRetrieviedAll(mHasRetrievedAllMedia);
  }
  if (getActivity() != null && MediaGridFragment.this.isVisible()) {
    getActivity().runOnUiThread(new Runnable(){
      @Override public void run(){
        mIsRefreshing=false;
        mListener.onMediaItemListDownloaded();
        mGridAdapter.setRefreshing(false);
      }
    }
);
  }
}
Program: 15085
Project: 15085
Buggy source:
@Override public void run(){
  mGridView.setSelection(0);
}

Fixed version (ground truth):
@Override public void run(){
  mIsRefreshing=false;
  mListener.onMediaItemListDownloaded();
  mGridAdapter.setRefreshing(false);
}
Program: 15086
Project: 15086
Buggy source:
@Override public void onSuccess(int count){
  MediaGridAdapter adapter=(MediaGridAdapter)mGridView.getAdapter();
  mHasRetrievedAllMedia=(count == 0);
  adapter.setHasRetrieviedAll(mHasRetrievedAllMedia);
  mIsRefreshing=false;
  if (MediaGridFragment.this.isVisible()) {
    refreshSpinnerAdapter();
    setFilter(mFilter);
    if (!auto)     mGridView.post(new Runnable(){
      @Override public void run(){
        mGridView.setSelection(0);
      }
    }
);
  }
  mListener.onMediaItemListDownloaded();
  mGridAdapter.setRefreshing(false);
}

Fixed version (ground truth):
@Override public void onSuccess(int count){
  MediaGridAdapter adapter=(MediaGridAdapter)mGridView.getAdapter();
  mHasRetrievedAllMedia=(count == 0);
  adapter.setHasRetrieviedAll(mHasRetrievedAllMedia);
  mIsRefreshing=false;
  if (getActivity() != null && MediaGridFragment.this.isVisible()) {
    getActivity().runOnUiThread(new Runnable(){
      @Override public void run(){
        refreshSpinnerAdapter();
        setFilter(mFilter);
        if (!auto)         mGridView.setSelection(0);
        mListener.onMediaItemListDownloaded();
        mGridAdapter.setRefreshing(false);
      }
    }
);
  }
}
Program: 15087
Project: 15087
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
  int itemId=item.getItemId();
  if (itemId == R.id.menu_delete) {
    Builder builder=new AlertDialog.Builder(getActivity()).setMessage(R.string.confirm_delete_media).setCancelable(true).setPositiveButton(R.string.delete,new OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int which){
        ArrayList<String> ids=new ArrayList<String>(1);
        ids.add(getMediaId());
        mCallback.onDeleteMedia(ids);
      }
    }
).setNegativeButton(R.string.cancel,null);
    AlertDialog dialog=builder.create();
    dialog.show();
  }
  return super.onOptionsItemSelected(item);
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
  int itemId=item.getItemId();
  if (itemId == R.id.menu_delete) {
    Builder builder=new AlertDialog.Builder(getActivity()).setMessage(R.string.confirm_delete_media).setCancelable(true).setPositiveButton(R.string.delete,new OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int which){
        ArrayList<String> ids=new ArrayList<String>(1);
        ids.add(getMediaId());
        mCallback.onDeleteMedia(ids);
      }
    }
).setNegativeButton(R.string.cancel,null);
    AlertDialog dialog=builder.create();
    dialog.show();
    return true;
  }
  return super.onOptionsItemSelected(item);
}
Program: 15088
Project: 15088
Buggy source:
public static void launchPictureVideoLibrary(Fragment fragment){
  Intent videoPickerIntent=new Intent(Intent.ACTION_PICK);
  videoPickerIntent.setType("String_Node_Str");
  fragment.startActivityForResult(videoPickerIntent,RequestCode.ACTIVITY_REQUEST_CODE_PICTURE_VIDEO_LIBRARY);
}

Fixed version (ground truth):
public static void launchPictureVideoLibrary(Fragment fragment){
  Intent intent=new Intent(Intent.ACTION_PICK);
  intent.setType("String_Node_Str");
  intent.putExtra(Intent.EXTRA_LOCAL_ONLY,true);
  fragment.startActivityForResult(intent,RequestCode.ACTIVITY_REQUEST_CODE_PICTURE_VIDEO_LIBRARY);
}
Program: 15089
Project: 15089
Buggy source:
public static void launchVideoLibrary(Fragment fragment){
  Intent videoPickerIntent=new Intent(Intent.ACTION_PICK);
  videoPickerIntent.setType("String_Node_Str");
  fragment.startActivityForResult(videoPickerIntent,RequestCode.ACTIVITY_REQUEST_CODE_VIDEO_LIBRARY);
}

Fixed version (ground truth):
public static void launchVideoLibrary(Fragment fragment){
  Intent intent=new Intent(Intent.ACTION_PICK);
  intent.setType("String_Node_Str");
  intent.putExtra(Intent.EXTRA_LOCAL_ONLY,true);
  fragment.startActivityForResult(intent,RequestCode.ACTIVITY_REQUEST_CODE_VIDEO_LIBRARY);
}
Program: 15090
Project: 15090
Buggy source:
public static void launchPictureLibrary(Fragment fragment){
  Intent photoPickerIntent=new Intent(Intent.ACTION_PICK);
  photoPickerIntent.setType("String_Node_Str");
  fragment.startActivityForResult(photoPickerIntent,RequestCode.ACTIVITY_REQUEST_CODE_PICTURE_LIBRARY);
}

Fixed version (ground truth):
public static void launchPictureLibrary(Fragment fragment){
  Intent intent=new Intent(Intent.ACTION_PICK);
  intent.setType("String_Node_Str");
  intent.putExtra(Intent.EXTRA_LOCAL_ONLY,true);
  fragment.startActivityForResult(intent,RequestCode.ACTIVITY_REQUEST_CODE_PICTURE_LIBRARY);
}
Program: 15091
Project: 15091
Buggy source:
protected void onPostExecute(Boolean result){
  if (isCancelled() || !result) {
    mOnRefreshListener.onRefresh(false);
    if (getActivity() == null)     return;
    if (errorMsg != "String_Node_Str" && !getActivity().isFinishing()) {
      FragmentTransaction ft=getFragmentManager().beginTransaction();
      WPAlertDialogFragment alert=WPAlertDialogFragment.newInstance(String.format(getResources().getString(R.string.error_refresh),(isPage) ? getResources().getText(R.string.pages) : getResources().getText(R.string.posts)),errorMsg);
      try {
        alert.show(ft,"String_Node_Str");
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
      errorMsg="String_Node_Str";
    }
    return;
  }
  if (loadMore)   switcher.showPrevious();
  mOnRefreshListener.onRefresh(false);
  if (isAdded())   loadPosts(loadMore);
}

Fixed version (ground truth):
protected void onPostExecute(Boolean result){
  if (isCancelled() || !result) {
    mOnRefreshListener.onRefresh(false);
    if (getActivity() == null)     return;
    if (errorMsg != "String_Node_Str" && !getActivity().isFinishing()) {
      FragmentTransaction ft=getFragmentManager().beginTransaction();
      WPAlertDialogFragment alert=WPAlertDialogFragment.newInstance(String.format(getResources().getString(R.string.error_refresh),(isPage) ? getResources().getText(R.string.pages) : getResources().getText(R.string.posts)),errorMsg);
      try {
        alert.show(ft,"String_Node_Str");
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
      errorMsg="String_Node_Str";
    }
    return;
  }
  if (loadMore)   switcher.showPrevious();
  mOnRefreshListener.onRefresh(false);
  if (isAdded()) {
    if (getActivity() != null) {
      getActivity().runOnUiThread(new Runnable(){
        @Override public void run(){
          loadPosts(loadMore);
        }
      }
);
    }
  }
}
Program: 15092
Project: 15092
Buggy source:
private void fetchThemes(){
  if (mFetchingThemes)   return;
  String siteId=getBlogId();
  mFetchingThemes=true;
  mProgressBar.setVisibility(View.VISIBLE);
  startAnimatingRefreshButton();
  WordPress.restClient.getThemes(siteId,0,0,new Listener(){
    @Override public void onResponse(    JSONObject response){
      new FetchThemesTask().execute(response);
    }
  }
,new ErrorListener(){
    @Override public void onErrorResponse(    VolleyError response){
      if (response.toString().equals(AuthFailureError.class.getName())) {
        String errorTitle=getString(R.string.theme_auth_error_title);
        String errorMsg=getString(R.string.theme_auth_error_message);
        FragmentTransaction ft=getSupportFragmentManager().beginTransaction();
        WPAlertDialogFragment fragment=WPAlertDialogFragment.newInstance(errorMsg,errorTitle,false);
        ft.add(fragment,"String_Node_Str");
        ft.commitAllowingStateLoss();
        Log.d("String_Node_Str","String_Node_Str");
      }
 else {
        Toast.makeText(ThemeBrowserActivity.this,R.string.theme_fetch_failed,Toast.LENGTH_LONG).show();
        Log.d("String_Node_Str","String_Node_Str" + response.toString());
      }
      mFetchingThemes=false;
      mProgressBar.setVisibility(View.GONE);
      stopAnimatingRefreshButton();
      refreshViewPager();
    }
  }
);
}

Fixed version (ground truth):
private void fetchThemes(){
  if (mFetchingThemes)   return;
  String siteId=getBlogId();
  mFetchingThemes=true;
  mProgressBar.setVisibility(View.VISIBLE);
  startAnimatingRefreshButton();
  WordPress.restClient.getThemes(siteId,0,0,new Listener(){
    @Override public void onResponse(    JSONObject response){
      new FetchThemesTask().execute(response);
    }
  }
,new ErrorListener(){
    @Override public void onErrorResponse(    VolleyError response){
      if (response.toString().equals(AuthFailureError.class.getName())) {
        String errorTitle=getString(R.string.theme_auth_error_title);
        String errorMsg=getString(R.string.theme_auth_error_message);
        if (!isDestroyed()) {
          FragmentTransaction ft=getSupportFragmentManager().beginTransaction();
          WPAlertDialogFragment fragment=WPAlertDialogFragment.newInstance(errorMsg,errorTitle,false);
          ft.add(fragment,"String_Node_Str");
          ft.commitAllowingStateLoss();
        }
        Log.d("String_Node_Str","String_Node_Str");
      }
 else {
        Toast.makeText(ThemeBrowserActivity.this,R.string.theme_fetch_failed,Toast.LENGTH_LONG).show();
        Log.d("String_Node_Str","String_Node_Str" + response.toString());
      }
      mFetchingThemes=false;
      mProgressBar.setVisibility(View.GONE);
      stopAnimatingRefreshButton();
      refreshViewPager();
    }
  }
);
}
Program: 15093
Project: 15093
Buggy source:
@Override protected void onPostExecute(ArrayList<Theme> result){
  mFetchingThemes=false;
  mProgressBar.setVisibility(View.GONE);
  stopAnimatingRefreshButton();
  if (result == null) {
    Toast.makeText(ThemeBrowserActivity.this,R.string.theme_fetch_failed,Toast.LENGTH_SHORT).show();
  }
 else {
    Toast.makeText(ThemeBrowserActivity.this,R.string.theme_fetch_success,Toast.LENGTH_SHORT).show();
  }
  refreshViewPager();
}

Fixed version (ground truth):
@Override protected void onPostExecute(final ArrayList<Theme> result){
  runOnUiThread(new Runnable(){
    @Override public void run(){
      mFetchingThemes=false;
      mProgressBar.setVisibility(View.GONE);
      stopAnimatingRefreshButton();
      if (result == null) {
        Toast.makeText(ThemeBrowserActivity.this,R.string.theme_fetch_failed,Toast.LENGTH_SHORT).show();
      }
 else {
        Toast.makeText(ThemeBrowserActivity.this,R.string.theme_fetch_success,Toast.LENGTH_SHORT).show();
      }
      refreshViewPager();
    }
  }
);
}
Program: 15094
Project: 15094
Buggy source:
public long savePost(Post post,int blogID){
  long returnValue=-1;
  if (post != null) {
    ContentValues values=new ContentValues();
    values.put("String_Node_Str",blogID);
    values.put("String_Node_Str",post.getTitle());
    values.put("String_Node_Str",post.getDate_created_gmt());
    values.put("String_Node_Str",post.getDescription());
    values.put("String_Node_Str",post.getMt_text_more());
    if (post.getJSONCategories() != null) {
      JSONArray jsonArray=null;
      try {
        jsonArray=new JSONArray(post.getJSONCategories().toString());
        values.put("String_Node_Str",jsonArray.toString());
      }
 catch (      JSONException e) {
        e.printStackTrace();
      }
    }
    values.put("String_Node_Str",post.isLocalDraft());
    values.put("String_Node_Str",post.getMediaPaths());
    values.put("String_Node_Str",post.getMt_keywords());
    values.put("String_Node_Str",post.getWP_password());
    values.put("String_Node_Str",post.getPost_status());
    values.put("String_Node_Str",post.isUploaded());
    values.put("String_Node_Str",post.isPage());
    values.put("String_Node_Str",post.getWP_post_format());
    values.put("String_Node_Str",post.getLatitude());
    values.put("String_Node_Str",post.getLongitude());
    values.put("String_Node_Str",post.isLocalChange());
    values.put("String_Node_Str",post.getMt_excerpt());
    returnValue=db.insert(POSTS_TABLE,null,values);
  }
  return (returnValue);
}

Fixed version (ground truth):
public long savePost(Post post,int blogID){
  long returnValue=-1;
  if (post != null) {
    ContentValues values=new ContentValues();
    values.put("String_Node_Str",blogID);
    values.put("String_Node_Str",post.getTitle());
    values.put("String_Node_Str",post.getDate_created_gmt());
    values.put("String_Node_Str",post.getDescription());
    values.put("String_Node_Str",post.getMt_text_more());
    JSONArray categoriesJsonArray=post.getJSONCategories();
    if (categoriesJsonArray != null) {
      values.put("String_Node_Str",categoriesJsonArray.toString());
    }
    values.put("String_Node_Str",post.isLocalDraft());
    values.put("String_Node_Str",post.getMediaPaths());
    values.put("String_Node_Str",post.getMt_keywords());
    values.put("String_Node_Str",post.getWP_password());
    values.put("String_Node_Str",post.getPost_status());
    values.put("String_Node_Str",post.isUploaded());
    values.put("String_Node_Str",post.isPage());
    values.put("String_Node_Str",post.getWP_post_format());
    values.put("String_Node_Str",post.getLatitude());
    values.put("String_Node_Str",post.getLongitude());
    values.put("String_Node_Str",post.isLocalChange());
    values.put("String_Node_Str",post.getMt_excerpt());
    returnValue=db.insert(POSTS_TABLE,null,values);
  }
  return (returnValue);
}
Program: 15095
Project: 15095
Buggy source:
public int updatePost(Post post,int blogID){
  int success=0;
  if (post != null) {
    ContentValues values=new ContentValues();
    values.put("String_Node_Str",blogID);
    values.put("String_Node_Str",post.getTitle());
    values.put("String_Node_Str",post.getDate_created_gmt());
    values.put("String_Node_Str",post.getDescription());
    if (post.getMt_text_more() != null)     values.put("String_Node_Str",post.getMt_text_more());
    values.put("String_Node_Str",post.isUploaded());
    if (post.getJSONCategories() != null) {
      JSONArray jsonArray=null;
      try {
        jsonArray=new JSONArray(post.getJSONCategories().toString());
        values.put("String_Node_Str",jsonArray.toString());
      }
 catch (      JSONException e) {
        e.printStackTrace();
      }
    }
    values.put("String_Node_Str",post.isLocalDraft());
    values.put("String_Node_Str",post.getMediaPaths());
    values.put("String_Node_Str",post.getMt_keywords());
    values.put("String_Node_Str",post.getWP_password());
    values.put("String_Node_Str",post.getPost_status());
    values.put("String_Node_Str",post.isPage());
    values.put("String_Node_Str",post.getWP_post_format());
    values.put("String_Node_Str",post.isLocalChange());
    values.put("String_Node_Str",post.getMt_excerpt());
    int pageInt=0;
    if (post.isPage())     pageInt=1;
    success=db.update(POSTS_TABLE,values,"String_Node_Str" + post.getBlogID() + "String_Node_Str"+ post.getId()+ "String_Node_Str"+ pageInt,null);
  }
  return (success);
}

Fixed version (ground truth):
public int updatePost(Post post,int blogID){
  int success=0;
  if (post != null) {
    ContentValues values=new ContentValues();
    values.put("String_Node_Str",blogID);
    values.put("String_Node_Str",post.getTitle());
    values.put("String_Node_Str",post.getDate_created_gmt());
    values.put("String_Node_Str",post.getDescription());
    if (post.getMt_text_more() != null)     values.put("String_Node_Str",post.getMt_text_more());
    values.put("String_Node_Str",post.isUploaded());
    JSONArray categoriesJsonArray=post.getJSONCategories();
    if (categoriesJsonArray != null) {
      values.put("String_Node_Str",categoriesJsonArray.toString());
    }
    values.put("String_Node_Str",post.isLocalDraft());
    values.put("String_Node_Str",post.getMediaPaths());
    values.put("String_Node_Str",post.getMt_keywords());
    values.put("String_Node_Str",post.getWP_password());
    values.put("String_Node_Str",post.getPost_status());
    values.put("String_Node_Str",post.isPage());
    values.put("String_Node_Str",post.getWP_post_format());
    values.put("String_Node_Str",post.isLocalChange());
    values.put("String_Node_Str",post.getMt_excerpt());
    int pageInt=0;
    if (post.isPage())     pageInt=1;
    success=db.update(POSTS_TABLE,values,"String_Node_Str" + post.getBlogID() + "String_Node_Str"+ post.getId()+ "String_Node_Str"+ pageInt,null);
  }
  return (success);
}
Program: 15096
Project: 15096
Buggy source:
public JSONArray getJSONCategories(){
  JSONArray jArray=null;
  if (categories == null)   categories="String_Node_Str";
  try {
    categories=StringUtils.unescapeHTML(categories);
    jArray=new JSONArray(categories);
  }
 catch (  JSONException e) {
  }
  return jArray;
}

Fixed version (ground truth):
public JSONArray getJSONCategories(){
  JSONArray jArray=null;
  if (categories == null)   categories="String_Node_Str";
  try {
    categories=StringUtils.unescapeHTML(categories);
    jArray=new JSONArray(categories);
  }
 catch (  JSONException e) {
    Log.e("String_Node_Str",e.getLocalizedMessage());
  }
  return jArray;
}
Program: 15099
Project: 15099
Buggy source:
/** 
 * Get the feature set for a wordpress.com hosted blog 
 */
private void getFeatureSet(){
  ApiHelper.GetFeatures task=new ApiHelper.GetFeatures(new Callback(){
    @Override public void onResult(    FeatureSet featureSet){
      mFeatureSet=featureSet;
    }
  }
);
  List<Object> apiArgs=new ArrayList<Object>();
  apiArgs.add(WordPress.getCurrentBlog());
  task.execute(apiArgs);
}

Fixed version (ground truth):
/** 
 * Get the feature set for a wordpress.com hosted blog 
 */
private void getFeatureSet(){
  if (WordPress.getCurrentBlog() == null || !WordPress.getCurrentBlog().isDotcomFlag())   return;
  ApiHelper.GetFeatures task=new ApiHelper.GetFeatures(new Callback(){
    @Override public void onResult(    FeatureSet featureSet){
      mFeatureSet=featureSet;
    }
  }
);
  List<Object> apiArgs=new ArrayList<Object>();
  apiArgs.add(WordPress.getCurrentBlog());
  task.execute(apiArgs);
}
Program: 15100
Project: 15100
Buggy source:
@Override public void onBlogChanged(){
  super.onBlogChanged();
  if (mMediaGridFragment != null && !mMediaGridFragment.hasRetrievedAllMediaFromServer()) {
    mMediaGridFragment.refreshMediaFromServer(0,false);
    startAnimatingRefreshButton();
  }
}

Fixed version (ground truth):
@Override public void onBlogChanged(){
  super.onBlogChanged();
  if (mMediaGridFragment != null && !mMediaGridFragment.hasRetrievedAllMediaFromServer()) {
    mMediaGridFragment.refreshMediaFromServer(0,false);
    startAnimatingRefreshButton();
  }
  getFeatureSet();
}
Program: 15101
Project: 15101
Buggy source:
private void loadNetworkImage(Cursor cursor,NetworkImageView imageView){
  String thumbnailURL=cursor.getString(cursor.getColumnIndex("String_Node_Str"));
  Uri uri=Uri.parse(thumbnailURL);
  if (thumbnailURL != null && MediaUtils.isValidImage(uri.getLastPathSegment())) {
    imageView.setTag(thumbnailURL);
    imageView.setImageUrl(thumbnailURL,WordPress.imageLoader);
  }
}

Fixed version (ground truth):
private void loadNetworkImage(Cursor cursor,NetworkImageView imageView){
  String thumbnailURL=cursor.getString(cursor.getColumnIndex("String_Node_Str"));
  Uri uri=Uri.parse(thumbnailURL);
  if (thumbnailURL != null && MediaUtils.isValidImage(uri.getLastPathSegment())) {
    imageView.setTag(thumbnailURL);
    imageView.setImageUrl(thumbnailURL,WordPress.imageLoader);
  }
 else {
    imageView.setImageUrl(null,null);
  }
}
Program: 15102
Project: 15102
Buggy source:
@Override public void onItemClick(AdapterView<?> parent,View view,int position,long id){
  CheckableFrameLayout frameLayout=((CheckableFrameLayout)view.findViewById(R.id.media_grid_frame_layout));
  if (!isInMultiSelectMode()) {
    getSelectedItems().clear();
    notifyMultiSelectCountChanged();
    frameLayout.setChecked(true);
    mOnItemClickListener.onItemClick(parent,view,position,id);
    mAdapter.notifyDataSetChanged();
    return;
  }
  Cursor cursor=((CursorAdapter)parent.getAdapter()).getCursor();
  String mediaId=cursor.getString(cursor.getColumnIndex("String_Node_Str"));
  if (getSelectedItems().contains(mediaId)) {
    frameLayout.setChecked(false);
  }
 else {
    frameLayout.setChecked(true);
  }
  notifyMultiSelectCountChanged();
}

Fixed version (ground truth):
@Override public void onItemClick(AdapterView<?> parent,View view,int position,long id){
  CheckableFrameLayout frameLayout=((CheckableFrameLayout)view.findViewById(R.id.media_grid_frame_layout));
  Cursor cursor=((CursorAdapter)parent.getAdapter()).getCursor();
  String mediaId=cursor.getString(cursor.getColumnIndex("String_Node_Str"));
  if (!isInMultiSelectMode()) {
    getSelectedItems().clear();
    getSelectedItems().add(mediaId);
    frameLayout.setChecked(true);
    mOnItemClickListener.onItemClick(parent,view,position,id);
    mAdapter.notifyDataSetChanged();
    return;
  }
  if (getSelectedItems().contains(mediaId)) {
    frameLayout.setChecked(false);
  }
 else {
    frameLayout.setChecked(true);
  }
  notifyMultiSelectCountChanged();
}
Program: 15103
Project: 15103
Buggy source:
private void restoreState(Bundle savedInstanceState){
  if (savedInstanceState == null)   return;
  if (savedInstanceState.containsKey(BUNDLE_CHECKED_STATES)) {
    boolean isInMultiSelectMode=savedInstanceState.getBoolean(BUNDLE_IN_MULTI_SELECT_MODE);
    mCheckedItems=savedInstanceState.getStringArrayList(BUNDLE_CHECKED_STATES);
    if (isInMultiSelectMode)     mListener.onMultiSelectChange(mCheckedItems.size());
    mGridView.setMultiSelectModeEnabled(isInMultiSelectMode);
  }
  mSavedFirstVisiblePosition=savedInstanceState.getInt(BUNDLE_SCROLL_POSITION,0);
  mHasRetrievedAllMedia=savedInstanceState.getBoolean(BUNDLE_HAS_RETREIEVED_ALL_MEDIA,false);
}

Fixed version (ground truth):
private void restoreState(Bundle savedInstanceState){
  if (savedInstanceState == null)   return;
  boolean isInMultiSelectMode=savedInstanceState.getBoolean(BUNDLE_IN_MULTI_SELECT_MODE);
  if (savedInstanceState.containsKey(BUNDLE_CHECKED_STATES)) {
    mCheckedItems=savedInstanceState.getStringArrayList(BUNDLE_CHECKED_STATES);
    if (isInMultiSelectMode) {
      mListener.onMultiSelectChange(mCheckedItems.size());
      onMultiSelectChange(mCheckedItems.size());
    }
    mGridView.setMultiSelectModeEnabled(isInMultiSelectMode);
  }
  mSavedFirstVisiblePosition=savedInstanceState.getInt(BUNDLE_SCROLL_POSITION,0);
  mHasRetrievedAllMedia=savedInstanceState.getBoolean(BUNDLE_HAS_RETREIEVED_ALL_MEDIA,false);
}
Program: 15104
Project: 15104
Buggy source:
public void setDateFilter(){
  Blog blog=WordPress.getCurrentBlog();
  if (blog == null)   return;
  String blogId=String.valueOf(blog.getBlogId());
  GregorianCalendar startDate=new GregorianCalendar(startYear,startMonth,startDay);
  GregorianCalendar endDate=new GregorianCalendar(endYear,endMonth,endDay);
  mCursor=WordPress.wpDB.getMediaFilesForBlog(blogId,startDate.getTimeInMillis(),endDate.getTimeInMillis());
  mGridAdapter.swapCursor(mCursor);
  if (mCursor != null && mCursor.getCount() > 0 && mGridAdapter != null) {
    mResultView.setVisibility(View.VISIBLE);
    SimpleDateFormat fmt=new SimpleDateFormat("String_Node_Str");
    fmt.setCalendar(startDate);
    String formattedStart=fmt.format(startDate.getTime());
    String formattedEnd=fmt.format(endDate.getTime());
    mResultView.setText("String_Node_Str" + formattedStart + "String_Node_Str"+ formattedEnd);
  }
 else {
    mResultView.setVisibility(View.VISIBLE);
    mResultView.setText(getResources().getString(R.string.empty_fields));
  }
}

Fixed version (ground truth):
public void setDateFilter(){
  Blog blog=WordPress.getCurrentBlog();
  if (blog == null)   return;
  String blogId=String.valueOf(blog.getBlogId());
  GregorianCalendar startDate=new GregorianCalendar(startYear,startMonth,startDay);
  GregorianCalendar endDate=new GregorianCalendar(endYear,endMonth,endDay);
  long one_day=24 * 60 * 60* 1000;
  mCursor=WordPress.wpDB.getMediaFilesForBlog(blogId,startDate.getTimeInMillis(),endDate.getTimeInMillis() + one_day);
  mGridAdapter.swapCursor(mCursor);
  if (mCursor != null && mCursor.getCount() > 0 && mGridAdapter != null) {
    mResultView.setVisibility(View.VISIBLE);
    SimpleDateFormat fmt=new SimpleDateFormat("String_Node_Str");
    fmt.setCalendar(startDate);
    String formattedStart=fmt.format(startDate.getTime());
    String formattedEnd=fmt.format(endDate.getTime());
    mResultView.setText("String_Node_Str" + formattedStart + "String_Node_Str"+ formattedEnd);
  }
 else {
    mResultView.setVisibility(View.VISIBLE);
    mResultView.setText(getResources().getString(R.string.empty_fields));
  }
}
Program: 15105
Project: 15105
Buggy source:
@Override public void onLoadFinished(Loader<Cursor> loader,Cursor cursor){
  if (!cursor.moveToFirst())   return;
  int numPoints=Math.min(30,cursor.getCount());
  GraphViewData[] views=new GraphViewData[numPoints];
  GraphViewData[] visitors=new GraphViewData[numPoints];
  String[] horLabels=new String[numPoints];
  for (int i=numPoints - 1; i >= 0; i--) {
    views[i]=new GraphViewData(i,getViews(cursor));
    visitors[i]=new GraphViewData(i,getVisitors(cursor));
    horLabels[i]=getDate(cursor);
    cursor.moveToNext();
  }
  viewsSeries=new GraphViewSeries(views);
  visitorsSeries=new GraphViewSeries(visitors);
  viewsSeries.getStyle().color=getResources().getColor(R.color.stats_bar_graph_views);
  viewsSeries.getStyle().padding=Utils.dpToPx(1);
  visitorsSeries.getStyle().color=getResources().getColor(R.color.stats_bar_graph_visitors);
  visitorsSeries.getStyle().padding=Utils.dpToPx(3);
  graphView=new StatsBarGraph(getActivity(),"String_Node_Str");
  graphView.addSeries(viewsSeries);
  graphView.addSeries(visitorsSeries);
  graphView.getGraphViewStyle().setNumHorizontalLabels(horLabels.length / 5);
  graphView.setHorizontalLabels(horLabels);
  mBarGraphLayout.removeAllViews();
  mBarGraphLayout.addView(graphView);
}

Fixed version (ground truth):
@Override public void onLoadFinished(Loader<Cursor> loader,Cursor cursor){
  if (getActivity() == null)   return;
  if (!cursor.moveToFirst())   return;
  int numPoints=Math.min(30,cursor.getCount());
  GraphViewData[] views=new GraphViewData[numPoints];
  GraphViewData[] visitors=new GraphViewData[numPoints];
  String[] horLabels=new String[numPoints];
  for (int i=numPoints - 1; i >= 0; i--) {
    views[i]=new GraphViewData(i,getViews(cursor));
    visitors[i]=new GraphViewData(i,getVisitors(cursor));
    horLabels[i]=getDate(cursor);
    cursor.moveToNext();
  }
  viewsSeries=new GraphViewSeries(views);
  visitorsSeries=new GraphViewSeries(visitors);
  viewsSeries.getStyle().color=getResources().getColor(R.color.stats_bar_graph_views);
  viewsSeries.getStyle().padding=Utils.dpToPx(1);
  visitorsSeries.getStyle().color=getResources().getColor(R.color.stats_bar_graph_visitors);
  visitorsSeries.getStyle().padding=Utils.dpToPx(3);
  graphView=new StatsBarGraph(getActivity(),"String_Node_Str");
  graphView.addSeries(viewsSeries);
  graphView.addSeries(visitorsSeries);
  graphView.getGraphViewStyle().setNumHorizontalLabels(horLabels.length / 5);
  graphView.setHorizontalLabels(horLabels);
  mBarGraphLayout.removeAllViews();
  mBarGraphLayout.addView(graphView);
}
Program: 15108
Project: 15108
Buggy source:
public JSONArray getJSONCategories(){
  JSONArray jArray=null;
  if (categories == null)   categories="String_Node_Str";
  try {
    jArray=new JSONArray(categories);
  }
 catch (  JSONException e) {
  }
  return jArray;
}

Fixed version (ground truth):
public JSONArray getJSONCategories(){
  JSONArray jArray=null;
  if (categories == null)   categories="String_Node_Str";
  try {
    categories=StringUtils.unescapeHTML(categories);
    jArray=new JSONArray(categories);
  }
 catch (  JSONException e) {
  }
  return jArray;
}
Program: 15110
Project: 15110
Buggy source:
public View getView(int position,View convertView,ViewGroup parent){
  RelativeLayout view=(RelativeLayout)convertView;
  if (view == null) {
    LayoutInflater inflater=getLayoutInflater();
    view=(RelativeLayout)inflater.inflate(R.layout.home_row,parent,false);
  }
  String username=accountUsers[position];
  view.setBackgroundDrawable(getResources().getDrawable(R.drawable.list_bg_selector));
  view.setId(Integer.valueOf(accountIDs[position]));
  TextView blogName=(TextView)view.findViewById(R.id.blogName);
  TextView blogUsername=(TextView)view.findViewById(R.id.blogUser);
  NetworkImageView blavatar=(NetworkImageView)view.findViewById(R.id.blavatar);
  blogName.setText(EscapeUtils.unescapeHtml(blogNames[position]));
  blogUsername.setText(EscapeUtils.unescapeHtml(username));
  blavatar.setImageUrl(blavatars[position],WordPress.imageLoader);
  return view;
}

Fixed version (ground truth):
public View getView(int position,View convertView,ViewGroup parent){
  RelativeLayout view=(RelativeLayout)convertView;
  if (view == null) {
    LayoutInflater inflater=getLayoutInflater();
    view=(RelativeLayout)inflater.inflate(R.layout.home_row,parent,false);
  }
  String username=accountUsers[position];
  view.setBackgroundDrawable(getResources().getDrawable(R.drawable.list_bg_selector));
  view.setId(Integer.valueOf(accountIDs[position]));
  TextView blogName=(TextView)view.findViewById(R.id.blogName);
  TextView blogUsername=(TextView)view.findViewById(R.id.blogUser);
  NetworkImageView blavatar=(NetworkImageView)view.findViewById(R.id.blavatar);
  blogName.setText(StringUtils.unescapeHTML(blogNames[position]));
  blogUsername.setText(StringUtils.unescapeHTML(username));
  blavatar.setImageUrl(blavatars[position],WordPress.imageLoader);
  return view;
}