nus-yam/ex-repair huggingface dataset:
Program: 15111
Project: 15111
Buggy source:
/** 
 * Get the names of all the blogs configured within the application. If a blog does not have a specific name, the blog URL is returned.
 * @return array of blog names
 */
private static String[] getBlogNames(){
  List<Map<String,Object>> accounts=WordPress.wpDB.getAccounts();
  int blogCount=accounts.size();
  blogIDs=new int[blogCount];
  String[] blogNames=new String[blogCount];
  for (int i=0; i < blogCount; i++) {
    Map<String,Object> account=accounts.get(i);
    String name;
    if (account.get("String_Node_Str") != null) {
      name=EscapeUtils.unescapeHtml(account.get("String_Node_Str").toString());
    }
 else {
      name=account.get("String_Node_Str").toString();
    }
    blogNames[i]=name;
    blogIDs[i]=Integer.valueOf(account.get("String_Node_Str").toString());
  }
  return blogNames;
}

Fixed version (ground truth):
/** 
 * Get the names of all the blogs configured within the application. If a blog does not have a specific name, the blog URL is returned.
 * @return array of blog names
 */
private static String[] getBlogNames(){
  List<Map<String,Object>> accounts=WordPress.wpDB.getAccounts();
  int blogCount=accounts.size();
  blogIDs=new int[blogCount];
  String[] blogNames=new String[blogCount];
  for (int i=0; i < blogCount; i++) {
    Map<String,Object> account=accounts.get(i);
    String name;
    if (account.get("String_Node_Str") != null) {
      name=StringUtils.unescapeHTML(account.get("String_Node_Str").toString());
    }
 else {
      name=account.get("String_Node_Str").toString();
    }
    blogNames[i]=name;
    blogIDs[i]=Integer.valueOf(account.get("String_Node_Str").toString());
  }
  return blogNames;
}
Program: 15118
Project: 15118
Buggy source:
private boolean loadDrafts(){
  List<Map<String,Object>> loadedPosts;
  if (isPage) {
    loadedPosts=WordPress.wpDB.loadDrafts(WordPress.currentBlog.getId(),true);
  }
 else {
    loadedPosts=WordPress.wpDB.loadDrafts(WordPress.currentBlog.getId(),false);
  }
  if (loadedPosts != null) {
    mDraftIDs=new String[loadedPosts.size()];
    mDraftTitles=new String[loadedPosts.size()];
    mDraftDateCreated=new String[loadedPosts.size()];
    mUploaded=new int[loadedPosts.size()];
    totalDrafts=loadedPosts.size();
    mDraftStatuses=new String[loadedPosts.size()];
    for (int i=0; i < loadedPosts.size(); i++) {
      Map<String,Object> contentHash=loadedPosts.get(i);
      mDraftIDs[i]=contentHash.get("String_Node_Str").toString();
      mDraftTitles[i]=EscapeUtils.unescapeHtml(contentHash.get("String_Node_Str").toString());
      mDraftDateCreated[i]="String_Node_Str";
      mUploaded[i]=(Integer)contentHash.get("String_Node_Str");
      mDraftStatuses[i]=getString(R.string.local_draft);
    }
    return true;
  }
 else {
    totalDrafts=0;
    return false;
  }
}

Fixed version (ground truth):
private boolean loadDrafts(){
  List<Map<String,Object>> loadedPosts;
  if (isPage) {
    loadedPosts=WordPress.wpDB.loadDrafts(WordPress.currentBlog.getId(),true);
  }
 else {
    loadedPosts=WordPress.wpDB.loadDrafts(WordPress.currentBlog.getId(),false);
  }
  if (loadedPosts != null) {
    mDraftIDs=new String[loadedPosts.size()];
    mDraftTitles=new String[loadedPosts.size()];
    mDraftDateCreated=new String[loadedPosts.size()];
    mUploaded=new int[loadedPosts.size()];
    totalDrafts=loadedPosts.size();
    mDraftStatuses=new String[loadedPosts.size()];
    for (int i=0; i < loadedPosts.size(); i++) {
      Map<String,Object> contentHash=loadedPosts.get(i);
      mDraftIDs[i]=contentHash.get("String_Node_Str").toString();
      mDraftTitles[i]=StringUtils.unescapeHTML(contentHash.get("String_Node_Str").toString());
      mDraftDateCreated[i]="String_Node_Str";
      mUploaded[i]=(Integer)contentHash.get("String_Node_Str");
      mDraftStatuses[i]=getString(R.string.local_draft);
    }
    return true;
  }
 else {
    totalDrafts=0;
    return false;
  }
}
Program: 15120
Project: 15120
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  boolean isPage=getIntent().getBooleanExtra("String_Node_Str",false);
  if (isPage) {
    this.setTitle(EscapeUtils.unescapeHtml(WordPress.currentBlog.getBlogName()) + "String_Node_Str" + getResources().getText(R.string.preview_page));
  }
 else {
    this.setTitle(EscapeUtils.unescapeHtml(WordPress.currentBlog.getBlogName()) + "String_Node_Str" + getResources().getText(R.string.preview_post));
  }
  mWebView.setWebChromeClient(new WordPressWebChromeClient(this));
  mWebView.getSettings().setJavaScriptEnabled(true);
  if (WordPress.currentPost != null)   loadPostPreview(WordPress.currentPost);
 else {
    Toast.makeText(this,R.string.post_not_found,Toast.LENGTH_SHORT).show();
  }
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  boolean isPage=getIntent().getBooleanExtra("String_Node_Str",false);
  if (isPage) {
    this.setTitle(StringUtils.unescapeHTML(WordPress.currentBlog.getBlogName()) + "String_Node_Str" + getResources().getText(R.string.preview_page));
  }
 else {
    this.setTitle(StringUtils.unescapeHTML(WordPress.currentBlog.getBlogName()) + "String_Node_Str" + getResources().getText(R.string.preview_post));
  }
  mWebView.setWebChromeClient(new WordPressWebChromeClient(this));
  mWebView.getSettings().setJavaScriptEnabled(true);
  if (WordPress.currentPost != null)   loadPostPreview(WordPress.currentPost);
 else {
    Toast.makeText(this,R.string.post_not_found,Toast.LENGTH_SHORT).show();
  }
}
Program: 15122
Project: 15122
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.blog_preferences);
  Integer id=getIntent().getIntExtra("String_Node_Str",-1);
  blog=WordPress.getBlog(id);
  if (blog == null) {
    Toast.makeText(this,getString(R.string.blog_not_found),Toast.LENGTH_SHORT).show();
    finish();
    return;
  }
  ActionBar actionBar=getSupportActionBar();
  actionBar.setTitle(EscapeUtils.unescapeHtml(blog.getBlogName()));
  actionBar.setDisplayHomeAsUpEnabled(true);
  mUsernameET=(EditText)findViewById(R.id.username);
  mPasswordET=(EditText)findViewById(R.id.password);
  mHttpUsernameET=(EditText)findViewById(R.id.httpuser);
  mHttpPasswordET=(EditText)findViewById(R.id.httppassword);
  mScaledImageWidthET=(EditText)findViewById(R.id.scaledImageWidth);
  mFullSizeCB=(CheckBox)findViewById(R.id.fullSizeImage);
  mScaledCB=(CheckBox)findViewById(R.id.scaledImage);
  mLocationCB=(CheckBox)findViewById(R.id.location);
  mImageWidthSpinner=(Spinner)findViewById(R.id.maxImageWidth);
  if (blog.isDotcomFlag()) {
    RelativeLayout credentialsRL=(RelativeLayout)findViewById(R.id.sectionContent);
    credentialsRL.setVisibility(View.GONE);
  }
  loadSettingsForBlog();
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.blog_preferences);
  Integer id=getIntent().getIntExtra("String_Node_Str",-1);
  blog=WordPress.getBlog(id);
  if (blog == null) {
    Toast.makeText(this,getString(R.string.blog_not_found),Toast.LENGTH_SHORT).show();
    finish();
    return;
  }
  ActionBar actionBar=getSupportActionBar();
  actionBar.setTitle(StringUtils.unescapeHTML(blog.getBlogName()));
  actionBar.setDisplayHomeAsUpEnabled(true);
  mUsernameET=(EditText)findViewById(R.id.username);
  mPasswordET=(EditText)findViewById(R.id.password);
  mHttpUsernameET=(EditText)findViewById(R.id.httpuser);
  mHttpPasswordET=(EditText)findViewById(R.id.httppassword);
  mScaledImageWidthET=(EditText)findViewById(R.id.scaledImageWidth);
  mFullSizeCB=(CheckBox)findViewById(R.id.fullSizeImage);
  mScaledCB=(CheckBox)findViewById(R.id.scaledImage);
  mLocationCB=(CheckBox)findViewById(R.id.location);
  mImageWidthSpinner=(Spinner)findViewById(R.id.maxImageWidth);
  if (blog.isDotcomFlag()) {
    RelativeLayout credentialsRL=(RelativeLayout)findViewById(R.id.sectionContent);
    credentialsRL.setVisibility(View.GONE);
  }
  loadSettingsForBlog();
}
Program: 15124
Project: 15124
Buggy source:
/** 
 * Update the "blogs" preference category to contain a preference for each blog to configure blog-specific settings. This also adds an "add blog" preference for setting up new blogs.
 */
protected void updateBlogsPreferenceCategory(){
  PreferenceCategory blogsCategory=(PreferenceCategory)findPreference("String_Node_Str");
  blogsCategory.removeAll();
  List<Map<String,Object>> accounts=WordPress.wpDB.getAccounts();
  int order=0;
  for (  Map<String,Object> account : accounts) {
    String blogName=EscapeUtils.unescapeHtml(account.get("String_Node_Str").toString());
    int accountId=(Integer)account.get("String_Node_Str");
    Preference blogSettingsPreference=new Preference(this);
    blogSettingsPreference.setTitle(blogName);
    try {
      URL blogUrl=new URL(account.get("String_Node_Str").toString());
      if (!blogName.equals(blogUrl.getHost())) {
        blogSettingsPreference.setSummary(blogUrl.getHost());
      }
    }
 catch (    MalformedURLException e) {
    }
    Intent intent=new Intent(this,BlogPreferencesActivity.class);
    intent.putExtra("String_Node_Str",accountId);
    blogSettingsPreference.setIntent(intent);
    blogSettingsPreference.setOrder(order++);
    blogsCategory.addPreference(blogSettingsPreference);
  }
  Preference addBlogPreference=new Preference(this);
  addBlogPreference.setTitle(R.string.add_account);
  Intent intent=new Intent(this,NewAccountActivity.class);
  addBlogPreference.setIntent(intent);
  addBlogPreference.setOrder(order++);
  blogsCategory.addPreference(addBlogPreference);
}

Fixed version (ground truth):
/** 
 * Update the "blogs" preference category to contain a preference for each blog to configure blog-specific settings. This also adds an "add blog" preference for setting up new blogs.
 */
protected void updateBlogsPreferenceCategory(){
  PreferenceCategory blogsCategory=(PreferenceCategory)findPreference("String_Node_Str");
  blogsCategory.removeAll();
  List<Map<String,Object>> accounts=WordPress.wpDB.getAccounts();
  int order=0;
  for (  Map<String,Object> account : accounts) {
    String blogName=StringUtils.unescapeHTML(account.get("String_Node_Str").toString());
    int accountId=(Integer)account.get("String_Node_Str");
    Preference blogSettingsPreference=new Preference(this);
    blogSettingsPreference.setTitle(blogName);
    try {
      URL blogUrl=new URL(account.get("String_Node_Str").toString());
      if (!blogName.equals(blogUrl.getHost())) {
        blogSettingsPreference.setSummary(blogUrl.getHost());
      }
    }
 catch (    MalformedURLException e) {
    }
    Intent intent=new Intent(this,BlogPreferencesActivity.class);
    intent.putExtra("String_Node_Str",accountId);
    blogSettingsPreference.setIntent(intent);
    blogSettingsPreference.setOrder(order++);
    blogsCategory.addPreference(blogSettingsPreference);
  }
  Preference addBlogPreference=new Preference(this);
  addBlogPreference.setTitle(R.string.add_account);
  Intent intent=new Intent(this,NewAccountActivity.class);
  addBlogPreference.setIntent(intent);
  addBlogPreference.setOrder(order++);
  blogsCategory.addPreference(addBlogPreference);
}
Program: 15125
Project: 15125
Buggy source:
public void onThemeActivated(boolean activated){
  mActivateThemeButton.setEnabled(true);
  mActivateThemeButton.setText(R.string.theme_activate_button);
  showViewSite();
}

Fixed version (ground truth):
public void onThemeActivated(boolean activated){
  mActivateThemeButton.setEnabled(true);
  mActivateThemeButton.setText(R.string.theme_activate_button);
  if (activated)   showViewSite();
}
Program: 15126
Project: 15126
Buggy source:
@Override public void onSaveInstanceState(Bundle outState){
  super.onSaveInstanceState(outState);
  if (!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("String_Node_Str",mMediaCapturePath);
}
Program: 15127
Project: 15127
Buggy source:
@Override public void onBlogChanged(){
  super.onBlogChanged();
  fetchThemes();
}

Fixed version (ground truth):
@Override public void onBlogChanged(){
  super.onBlogChanged();
  if (areThemesAccessible()) {
    fetchThemes();
  }
}
Program: 15129
Project: 15129
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  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) {
    if (savedInstanceState.getString("String_Node_Str") != null)     mMediaCapturePath=savedInstanceState.getString("String_Node_Str");
  }
  return inflater.inflate(R.layout.actionbar_add_media_cell,container,false);
}
Program: 15130
Project: 15130
Buggy source:
@Override protected void onPause(){
  super.onPause();
  mIsRunning=false;
}

Fixed version (ground truth):
@Override protected void onPause(){
  removeViewPagerFragments();
  super.onPause();
  mIsRunning=false;
}
Program: 15131
Project: 15131
Buggy source:
public void refresh(){
  Cursor cursor=fetchThemes(getThemeSortType());
  mAdapter.swapCursor(cursor);
}

Fixed version (ground truth):
public void refresh(){
  Cursor cursor=fetchThemes(getThemeSortType());
  if (mAdapter == null) {
    mAdapter=new ThemeTabAdapter(getActivity(),cursor,false);
  }
  mAdapter.swapCursor(cursor);
}
Program: 15133
Project: 15133
Buggy source:
public boolean saveMediaFile(MediaFile mf){
  boolean returnValue=false;
  ContentValues values=new ContentValues();
  values.put("String_Node_Str",mf.getPostID());
  values.put("String_Node_Str",mf.getFilePath());
  values.put("String_Node_Str",mf.getFileName());
  values.put("String_Node_Str",mf.getTitle());
  values.put("String_Node_Str",mf.getDescription());
  values.put("String_Node_Str",mf.getCaption());
  values.put("String_Node_Str",mf.getHorizontalAlignment());
  values.put("String_Node_Str",mf.getWidth());
  values.put("String_Node_Str",mf.getHeight());
  values.put("String_Node_Str",mf.getMIMEType());
  values.put("String_Node_Str",mf.isFeatured());
  values.put("String_Node_Str",mf.isVideo());
  values.put("String_Node_Str",mf.isFeaturedInPost());
  values.put("String_Node_Str",mf.getFileURL());
  values.put("String_Node_Str",mf.getThumbnailURL());
  values.put("String_Node_Str",mf.getMediaId());
  values.put("String_Node_Str",mf.getBlogId());
  values.put("String_Node_Str",mf.getDateCreatedGMT());
  values.put("String_Node_Str",mf.getUploadState());
synchronized (this) {
    int result=db.update(MEDIA_TABLE,values,"String_Node_Str",new String[]{mf.getBlogId(),String.valueOf(mf.getMediaId())});
    if (result == 0)     returnValue=db.insert(MEDIA_TABLE,null,values) > 0;
  }
  return (returnValue);
}

Fixed version (ground truth):
public boolean saveMediaFile(MediaFile mf){
  boolean returnValue=false;
  ContentValues values=new ContentValues();
  values.put("String_Node_Str",mf.getPostID());
  values.put("String_Node_Str",mf.getFilePath());
  values.put("String_Node_Str",mf.getFileName());
  values.put("String_Node_Str",mf.getTitle());
  values.put("String_Node_Str",mf.getDescription());
  values.put("String_Node_Str",mf.getCaption());
  values.put("String_Node_Str",mf.getHorizontalAlignment());
  values.put("String_Node_Str",mf.getWidth());
  values.put("String_Node_Str",mf.getHeight());
  values.put("String_Node_Str",mf.getMIMEType());
  values.put("String_Node_Str",mf.isFeatured());
  values.put("String_Node_Str",mf.isVideo());
  values.put("String_Node_Str",mf.isFeaturedInPost());
  values.put("String_Node_Str",mf.getFileURL());
  values.put("String_Node_Str",mf.getThumbnailURL());
  values.put("String_Node_Str",mf.getMediaId());
  values.put("String_Node_Str",mf.getBlogId());
  values.put("String_Node_Str",mf.getDateCreatedGMT());
  values.put("String_Node_Str",mf.getUploadState());
synchronized (this) {
    int result=0;
    if (mf.getMediaId() != null) {
      result=db.update(MEDIA_TABLE,values,"String_Node_Str",new String[]{mf.getBlogId(),String.valueOf(mf.getMediaId())});
    }
    if (result == 0)     returnValue=db.insert(MEDIA_TABLE,null,values) > 0;
  }
  return (returnValue);
}
Program: 15134
Project: 15134
Buggy source:
@Override public void onResume(){
  super.onResume();
  Cursor cursor=fetchThemes(getThemeSortType());
  mAdapter=new ThemeTabAdapter(getActivity(),cursor,false);
  mGridView.setAdapter(mAdapter);
  mGridView.setOnItemClickListener(this);
  mGridView.setSelection(mSavedScrollPosition);
}

Fixed version (ground truth):
@Override public void onResume(){
  super.onResume();
  if (getActivity() == null || WordPress.getCurrentBlog() == null)   return;
  Cursor cursor=fetchThemes(getThemeSortType());
  mAdapter=new ThemeTabAdapter(getActivity(),cursor,false);
  mGridView.setAdapter(mAdapter);
  mGridView.setOnItemClickListener(this);
  mGridView.setSelection(mSavedScrollPosition);
}
Program: 15135
Project: 15135
Buggy source:
@Override public void onResume(){
  super.onResume();
  refreshMediaFromDB();
  if (mLastRefreshTime == 0l)   refreshMediaFromServer(0);
}

Fixed version (ground truth):
@Override public void onResume(){
  super.onResume();
  setupSpinnerAdapter();
  refreshMediaFromDB();
  if (mLastRefreshTime == 0l)   refreshMediaFromServer(0);
}
Program: 15136
Project: 15136
Buggy source:
public void refreshMediaFromDB(){
  setFilter(mFilter);
  if (mCursor != null) {
    mGridAdapter=new MediaGridAdapter(getActivity(),mCursor,0,mCheckedItems);
    mGridAdapter.setCallback(this);
    mGridView.setAdapter(mGridAdapter);
    mGridView.setSelection(mSavedFirstVisiblePosition);
  }
}

Fixed version (ground truth):
public void refreshMediaFromDB(){
  setFilter(mFilter);
  if (mCursor != null) {
    if (mCursor.getCount() == 0) {
      refreshMediaFromServer(0,true);
    }
    mGridAdapter=new MediaGridAdapter(getActivity(),mCursor,0,mCheckedItems);
    mGridAdapter.setCallback(this);
    mGridView.setAdapter(mGridAdapter);
    mGridView.setSelection(mSavedFirstVisiblePosition);
  }
}
Program: 15137
Project: 15137
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());
  if (mCursor != null && mCursor.getCount() > 0 && mGridAdapter != null) {
    mGridAdapter.swapCursor(mCursor);
    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);
  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));
  }
}
Program: 15139
Project: 15139
Buggy source:
@Override public void onCommentSelected(Comment comment){
  FragmentManager fm=getSupportFragmentManager();
  CommentFragment f=(CommentFragment)fm.findFragmentById(R.id.commentDetail);
  if (comment != null) {
    if (f == null || !f.isInLayout()) {
      WordPress.currentComment=comment;
      FragmentTransaction ft=fm.beginTransaction();
      ft.hide(commentList);
      f=new CommentFragment();
      ft.add(R.id.commentDetailFragmentContainer,f);
      ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
      ft.addToBackStack(null);
      ft.commit();
      mMenuDrawer.setDrawerIndicatorEnabled(false);
    }
 else {
      f.loadComment(comment);
    }
  }
}

Fixed version (ground truth):
@Override public void onCommentSelected(Comment comment){
  FragmentManager fm=getSupportFragmentManager();
  fm.executePendingTransactions();
  CommentFragment f=(CommentFragment)fm.findFragmentById(R.id.commentDetail);
  if (comment != null && fm.getBackStackEntryCount() == 0) {
    if (f == null || !f.isInLayout()) {
      WordPress.currentComment=comment;
      FragmentTransaction ft=fm.beginTransaction();
      ft.hide(commentList);
      f=new CommentFragment();
      ft.add(R.id.commentDetailFragmentContainer,f);
      ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
      ft.addToBackStack(null);
      ft.commit();
      mMenuDrawer.setDrawerIndicatorEnabled(false);
    }
 else {
      f.loadComment(comment);
    }
  }
}
Program: 15140
Project: 15140
Buggy source:
@Override public void onMediaItemSelected(String mediaId){
  if (mSearchView != null)   mSearchView.clearFocus();
  if (mSearchMenuItem != null)   mSearchMenuItem.collapseActionView();
  FragmentManager fm=getSupportFragmentManager();
  if (mMediaEditFragment == null || !mMediaEditFragment.isInLayout()) {
    FragmentTransaction ft=fm.beginTransaction();
    ft.hide(mMediaGridFragment);
    setupBaseLayout();
    mMediaItemFragment=MediaItemFragment.newInstance(mediaId);
    ft.add(R.id.media_browser_container,mMediaItemFragment,MediaItemFragment.TAG);
    ft.addToBackStack(null);
    ft.commit();
    mMenuDrawer.setDrawerIndicatorEnabled(false);
  }
 else {
    mMediaEditFragment.loadMedia(mediaId);
  }
}

Fixed version (ground truth):
@Override public void onMediaItemSelected(String mediaId){
  if (mSearchView != null)   mSearchView.clearFocus();
  if (mSearchMenuItem != null)   mSearchMenuItem.collapseActionView();
  FragmentManager fm=getSupportFragmentManager();
  if (mMediaEditFragment == null || !mMediaEditFragment.isInLayout()) {
    if (fm.getBackStackEntryCount() == 0) {
      FragmentTransaction ft=fm.beginTransaction();
      ft.hide(mMediaGridFragment);
      setupBaseLayout();
      mMediaItemFragment=MediaItemFragment.newInstance(mediaId);
      ft.add(R.id.media_browser_container,mMediaItemFragment,MediaItemFragment.TAG);
      ft.addToBackStack(null);
      ft.commit();
      mMenuDrawer.setDrawerIndicatorEnabled(false);
    }
  }
 else {
    mMediaEditFragment.loadMedia(mediaId);
  }
}
Program: 15141
Project: 15141
Buggy source:
@Override protected int sizeOf(String key,Bitmap value){
  return super.sizeOf(key,value);
}

Fixed version (ground truth):
@Override protected int sizeOf(String key,Bitmap value){
  int bytes=(value.getRowBytes() * value.getHeight());
  return (bytes / 1024);
}
Program: 15142
Project: 15142
Buggy source:
@Override public void onCreate(){
  versionName=getVersionName();
  wpDB=new WordPressDB(this);
  requestQueue=Volley.newRequestQueue(this);
  int maxMemory=(int)(Runtime.getRuntime().maxMemory() / 1024);
  int cacheSize=maxMemory / 16;
  imageLoader=new ImageLoader(requestQueue,new BitmapLruCache(cacheSize));
  Log.d("String_Node_Str","String_Node_Str" + cacheSize + "String_Node_Str"+ maxMemory);
  localImageCache=new BitmapLruCache(cacheSize / 2);
  SharedPreferences settings=PreferenceManager.getDefaultSharedPreferences(this);
  if (settings.getInt("String_Node_Str",-1) >= 0)   shouldRestoreSelectedActivity=true;
  restClient=new WPRestClient(requestQueue,new OauthAuthenticator(),settings.getString(ACCESS_TOKEN_PREFERENCE,null));
  registerForCloudMessaging(this);
  loadNotifications(this);
  super.onCreate();
}

Fixed version (ground truth):
@Override public void onCreate(){
  versionName=getVersionName();
  wpDB=new WordPressDB(this);
  requestQueue=Volley.newRequestQueue(this);
  int maxMemory=(int)(Runtime.getRuntime().maxMemory() / 1024);
  int cacheSize=maxMemory / 32;
  imageLoader=new ImageLoader(requestQueue,new BitmapLruCache(cacheSize));
  localImageCache=new BitmapLruCache(cacheSize / 2);
  SharedPreferences settings=PreferenceManager.getDefaultSharedPreferences(this);
  if (settings.getInt("String_Node_Str",-1) >= 0)   shouldRestoreSelectedActivity=true;
  restClient=new WPRestClient(requestQueue,new OauthAuthenticator(),settings.getString(ACCESS_TOKEN_PREFERENCE,null));
  registerForCloudMessaging(this);
  loadNotifications(this);
  super.onCreate();
}
Program: 15143
Project: 15143
Buggy source:
@Override protected int sizeOf(String key,Bitmap value){
  if (android.os.Build.VERSION.SDK_INT < 12)   return value.getRowBytes() * value.getHeight();
 else   return value.getByteCount() / 1024;
}

Fixed version (ground truth):
@Override protected int sizeOf(String key,Bitmap value){
  return value.getRowBytes() * value.getHeight() / 1024;
}
Program: 15144
Project: 15144
Buggy source:
public void onEditCompleted(boolean result){
  if (mMediaEditFragment != null && mMediaEditFragment.isVisible() && result) {
    getSupportFragmentManager().popBackStack();
    if (mMediaItemFragment != null)     mMediaItemFragment.loadMedia(mMediaItemFragment.getMediaId());
    mMediaGridFragment.refreshMediaFromDB();
  }
}

Fixed version (ground truth):
public void onEditCompleted(String mediaId,boolean result){
  if (mMediaEditFragment != null && mMediaEditFragment.isVisible() && result) {
    getSupportFragmentManager().popBackStack();
    if (mMediaItemFragment != null)     mMediaItemFragment.loadMedia(mMediaItemFragment.getMediaId());
    mMediaEditFragment.loadMedia(mediaId);
    mMediaGridFragment.refreshMediaFromDB();
  }
}
Program: 15145
Project: 15145
Buggy source:
public void hideKeyboard(){
  InputMethodManager inputManager=(InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
  inputManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),InputMethodManager.HIDE_NOT_ALWAYS);
}

Fixed version (ground truth):
public void hideKeyboard(){
  if (getActivity() != null) {
    InputMethodManager inputManager=(InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    inputManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),InputMethodManager.HIDE_NOT_ALWAYS);
  }
}
Program: 15146
Project: 15146
Buggy source:
private void refreshViews(Cursor cursor){
  if (!cursor.moveToFirst())   return;
  mTitleView.setText(cursor.getString(cursor.getColumnIndex("String_Node_Str")));
  mCaptionView.setText(cursor.getString(cursor.getColumnIndex("String_Node_Str")));
  mDescriptionView.setText(cursor.getString(cursor.getColumnIndex("String_Node_Str")));
  String imageUrl=cursor.getString(cursor.getColumnIndex("String_Node_Str"));
  if (MediaUtils.isValidImage(imageUrl)) {
    int width=cursor.getInt(cursor.getColumnIndex("String_Node_Str"));
    int height=cursor.getInt(cursor.getColumnIndex("String_Node_Str"));
    float screenWidth=getActivity().getResources().getDisplayMetrics().widthPixels;
    View parentView=(View)mImageView.getParent();
    if (this.isInLayout()) {
      screenWidth=parentView.getMeasuredWidth();
    }
 else {
      screenWidth=getActivity().getResources().getDisplayMetrics().widthPixels;
    }
    float screenHeight=getActivity().getResources().getDisplayMetrics().heightPixels;
    mImageView.setImageUrl(imageUrl + "String_Node_Str" + screenWidth,WordPress.imageLoader);
    mImageView.setVisibility(View.VISIBLE);
    if (width > screenWidth) {
      height=(int)(height / (width / screenWidth));
    }
 else     if (height > screenHeight) {
      width=(int)(width / (height / screenHeight));
    }
    mImageView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,height));
  }
 else {
    mImageView.setVisibility(View.GONE);
  }
}

Fixed version (ground truth):
private void refreshViews(Cursor cursor){
  if (!cursor.moveToFirst())   return;
  mMediaId=cursor.getString(cursor.getColumnIndex("String_Node_Str"));
  mTitleView.setText(cursor.getString(cursor.getColumnIndex("String_Node_Str")));
  mCaptionView.setText(cursor.getString(cursor.getColumnIndex("String_Node_Str")));
  mDescriptionView.setText(cursor.getString(cursor.getColumnIndex("String_Node_Str")));
  String imageUrl=cursor.getString(cursor.getColumnIndex("String_Node_Str"));
  if (MediaUtils.isValidImage(imageUrl)) {
    int width=cursor.getInt(cursor.getColumnIndex("String_Node_Str"));
    int height=cursor.getInt(cursor.getColumnIndex("String_Node_Str"));
    float screenWidth=getActivity().getResources().getDisplayMetrics().widthPixels;
    View parentView=(View)mImageView.getParent();
    if (this.isInLayout()) {
      screenWidth=parentView.getMeasuredWidth();
    }
 else {
      screenWidth=getActivity().getResources().getDisplayMetrics().widthPixels;
    }
    float screenHeight=getActivity().getResources().getDisplayMetrics().heightPixels;
    mImageView.setImageUrl(imageUrl + "String_Node_Str" + screenWidth,WordPress.imageLoader);
    mImageView.setVisibility(View.VISIBLE);
    if (width > screenWidth) {
      height=(int)(height / (width / screenWidth));
    }
 else     if (height > screenHeight) {
      width=(int)(width / (height / screenHeight));
    }
    mImageView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,height));
  }
 else {
    mImageView.setVisibility(View.GONE);
  }
}
Program: 15147
Project: 15147
Buggy source:
@Override public void onFailure(){
  Toast.makeText(getActivity(),R.string.media_edit_failure,Toast.LENGTH_LONG).show();
  setMediaUpdating(false);
  mCallback.onEditCompleted(false);
}

Fixed version (ground truth):
@Override public void onFailure(){
  if (getActivity() != null)   Toast.makeText(getActivity(),R.string.media_edit_failure,Toast.LENGTH_LONG).show();
  setMediaUpdating(false);
  mCallback.onEditCompleted(mediaId,false);
}
Program: 15148
Project: 15148
Buggy source:
public void onEditCompleted(boolean result);

Fixed version (ground truth):
public void onEditCompleted(String mediaId,boolean result);
Program: 15149
Project: 15149
Buggy source:
public void editMedia(){
  hideKeyboard();
  final String mediaId=this.getMediaId();
  final String title=mTitleView.getText().toString();
  final String description=mDescriptionView.getText().toString();
  final Blog currentBlog=WordPress.getCurrentBlog();
  ApiHelper.EditMediaItemTask task=new ApiHelper.EditMediaItemTask(mediaId,title,description,new ApiHelper.EditMediaItemTask.Callback(){
    @Override public void onSuccess(){
      String blogId=String.valueOf(currentBlog.getBlogId());
      WordPress.wpDB.updateMediaFile(blogId,mediaId,title,description);
      Toast.makeText(getActivity(),R.string.media_edit_success,Toast.LENGTH_LONG).show();
      setMediaUpdating(false);
      mCallback.onEditCompleted(true);
    }
    @Override public void onFailure(){
      Toast.makeText(getActivity(),R.string.media_edit_failure,Toast.LENGTH_LONG).show();
      setMediaUpdating(false);
      mCallback.onEditCompleted(false);
    }
  }
);
  List<Object> apiArgs=new ArrayList<Object>();
  apiArgs.add(currentBlog);
  if (!isMediaUpdating()) {
    setMediaUpdating(true);
    task.execute(apiArgs);
  }
}

Fixed version (ground truth):
public void editMedia(){
  hideKeyboard();
  final String mediaId=this.getMediaId();
  final String title=mTitleView.getText().toString();
  final String description=mDescriptionView.getText().toString();
  final Blog currentBlog=WordPress.getCurrentBlog();
  ApiHelper.EditMediaItemTask task=new ApiHelper.EditMediaItemTask(mediaId,title,description,new ApiHelper.EditMediaItemTask.Callback(){
    @Override public void onSuccess(){
      String blogId=String.valueOf(currentBlog.getBlogId());
      WordPress.wpDB.updateMediaFile(blogId,mediaId,title,description);
      if (getActivity() != null)       Toast.makeText(getActivity(),R.string.media_edit_success,Toast.LENGTH_LONG).show();
      setMediaUpdating(false);
      mCallback.onEditCompleted(mediaId,true);
    }
    @Override public void onFailure(){
      if (getActivity() != null)       Toast.makeText(getActivity(),R.string.media_edit_failure,Toast.LENGTH_LONG).show();
      setMediaUpdating(false);
      mCallback.onEditCompleted(mediaId,false);
    }
  }
);
  List<Object> apiArgs=new ArrayList<Object>();
  apiArgs.add(currentBlog);
  if (!isMediaUpdating()) {
    setMediaUpdating(true);
    task.execute(apiArgs);
  }
}
Program: 15150
Project: 15150
Buggy source:
@Override public void onSuccess(){
  String blogId=String.valueOf(currentBlog.getBlogId());
  WordPress.wpDB.updateMediaFile(blogId,mediaId,title,description);
  Toast.makeText(getActivity(),R.string.media_edit_success,Toast.LENGTH_LONG).show();
  setMediaUpdating(false);
  mCallback.onEditCompleted(true);
}

Fixed version (ground truth):
@Override public void onSuccess(){
  String blogId=String.valueOf(currentBlog.getBlogId());
  WordPress.wpDB.updateMediaFile(blogId,mediaId,title,description);
  if (getActivity() != null)   Toast.makeText(getActivity(),R.string.media_edit_success,Toast.LENGTH_LONG).show();
  setMediaUpdating(false);
  mCallback.onEditCompleted(mediaId,true);
}
Program: 15151
Project: 15151
Buggy source:
@Override public void onEditCompleted(boolean result){
  if (mMediaEditFragment != null && mMediaEditFragment.isVisible() && result) {
    getSupportFragmentManager().popBackStack();
  }
}

Fixed version (ground truth):
@Override public void onEditCompleted(String mediaId,boolean result){
  if (mMediaEditFragment != null && mMediaEditFragment.isVisible() && result) {
    getSupportFragmentManager().popBackStack();
  }
}
Program: 15152
Project: 15152
Buggy source:
private void updateFilterText(){
  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);
  mFilters[0]=getResources().getString(R.string.all) + "String_Node_Str" + countAll+ "String_Node_Str";
  mFilters[1]=getResources().getString(R.string.images) + "String_Node_Str" + countImages+ "String_Node_Str";
  mFilters[2]=getResources().getString(R.string.unattached) + "String_Node_Str" + countUnattached+ "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);
  mFilters[0]=getResources().getString(R.string.all) + "String_Node_Str" + countAll+ "String_Node_Str";
  mFilters[1]=getResources().getString(R.string.images) + "String_Node_Str" + countImages+ "String_Node_Str";
  mFilters[2]=getResources().getString(R.string.unattached) + "String_Node_Str" + countUnattached+ "String_Node_Str";
}
Program: 15153
Project: 15153
Buggy source:
@Override protected void onPostExecute(ArrayList<Theme> result){
  if (result == null) {
    Toast.makeText(ThemeBrowserActivity.this,"String_Node_Str",Toast.LENGTH_SHORT).show();
    refreshFragments();
  }
}

Fixed version (ground truth):
@Override protected void onPostExecute(ArrayList<Theme> result){
  if (result == null) {
    Toast.makeText(ThemeBrowserActivity.this,"String_Node_Str",Toast.LENGTH_SHORT).show();
  }
  refreshFragments();
}
Program: 15154
Project: 15154
Buggy source:
@Override public void onResponse(ImageContainer response,boolean isImmediate){
  if (response != null && response.getBitmap() != null)   imageView.setImageBitmap(response.getBitmap());
 else   imageView.setImageBitmap(null);
}

Fixed version (ground truth):
@Override public void onResponse(ImageContainer response,boolean isImmediate){
  ViewHolder holder=(ViewHolder)imageView.getTag();
  if (holder != null) {
    String url=holder.requestURL;
    if (response != null && response.getBitmap() != null && response.getRequestUrl().equals(url)) {
      imageView.setImageBitmap(response.getBitmap());
    }
  }
}
Program: 15155
Project: 15155
Buggy source:
@Override public void bindView(View view,Context context,Cursor cursor){
  String screenshotURL=cursor.getString(cursor.getColumnIndex("String_Node_Str"));
  final ImageView imageView=(ImageView)view.findViewById(R.id.theme_grid_item_image);
  imageView.setImageBitmap(null);
  WordPress.imageLoader.get(screenshotURL,new ImageListener(){
    @Override public void onErrorResponse(    VolleyError error){
    }
    @Override public void onResponse(    ImageContainer response,    boolean isImmediate){
      if (response != null && response.getBitmap() != null)       imageView.setImageBitmap(response.getBitmap());
 else       imageView.setImageBitmap(null);
    }
  }
,getGridWidth(context),getGridHeight(context));
  updateGridWidth(mContext,view);
}

Fixed version (ground truth):
@Override public void bindView(View view,Context context,Cursor cursor){
  final String screenshotURL=cursor.getString(cursor.getColumnIndex("String_Node_Str"));
  final ImageView imageView=(ImageView)view.findViewById(R.id.theme_grid_item_image);
  ViewHolder holder=(ViewHolder)imageView.getTag();
  if (holder == null) {
    holder=new ViewHolder();
    holder.requestURL=screenshotURL;
    imageView.setTag(holder);
  }
  if (!holder.requestURL.equals(screenshotURL)) {
    imageView.setImageBitmap(null);
    holder.requestURL=screenshotURL;
  }
  WordPress.imageLoader.get(holder.requestURL,new ImageListener(){
    @Override public void onErrorResponse(    VolleyError error){
    }
    @Override public void onResponse(    ImageContainer response,    boolean isImmediate){
      ViewHolder holder=(ViewHolder)imageView.getTag();
      if (holder != null) {
        String url=holder.requestURL;
        if (response != null && response.getBitmap() != null && response.getRequestUrl().equals(url)) {
          imageView.setImageBitmap(response.getBitmap());
        }
      }
    }
  }
,getGridWidth(context),getGridHeight(context));
  updateGridWidth(mContext,view);
}
Program: 15156
Project: 15156
Buggy source:
/** 
 * Login to the WordPress blog and load the specified URL.
 * @param url URL to be loaded in the webview.
 */
protected void loadAuthenticatedUrl(String url){
  String postData=String.format("String_Node_Str",mBlog.getUsername(),mBlog.getPassword(),url);
  mWebView.postUrl(getLoginUrl(),postData.getBytes());
}

Fixed version (ground truth):
/** 
 * Login to the WordPress blog and load the specified URL.
 * @param url URL to be loaded in the webview.
 */
protected void loadAuthenticatedUrl(String url){
  try {
    String postData=String.format("String_Node_Str",mBlog.getUsername(),mBlog.getPassword(),URLEncoder.encode(url,"String_Node_Str"));
    mWebView.postUrl(getLoginUrl(),postData.getBytes());
  }
 catch (  UnsupportedEncodingException e) {
    e.printStackTrace();
  }
}
Program: 15161
Project: 15161
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  Log.d("String_Node_Str","String_Node_Str");
  if (WordPress.wpDB == null) {
    Toast.makeText(this,R.string.fatal_db_error,Toast.LENGTH_LONG).show();
    Log.d("String_Node_Str","String_Node_Str");
    finish();
    return;
  }
  createMenuDrawer(R.layout.media_browser_activity);
  ActionBar actionBar=getSupportActionBar();
  actionBar.setDisplayShowTitleEnabled(true);
  FragmentManager fm=getSupportFragmentManager();
  fm.addOnBackStackChangedListener(mOnBackStackChangedListener);
  mMediaItemListFragment=(MediaItemListFragment)fm.findFragmentById(R.id.mediaItemListFragment);
  mMediaItemListFragment.setListShown(true);
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  Log.d("String_Node_Str","String_Node_Str");
  if (WordPress.wpDB == null) {
    Toast.makeText(this,R.string.fatal_db_error,Toast.LENGTH_LONG).show();
    Log.d("String_Node_Str","String_Node_Str");
    finish();
    return;
  }
  createMenuDrawer(R.layout.media_browser_activity);
  ActionBar actionBar=getSupportActionBar();
  actionBar.setDisplayShowTitleEnabled(true);
  FragmentManager fm=getSupportFragmentManager();
  fm.addOnBackStackChangedListener(mOnBackStackChangedListener);
  mMediaItemListFragment=(MediaItemListFragment)fm.findFragmentById(R.id.mediaItemListFragment);
  mMediaItemListFragment.setListShown(true);
  mMediaItemFragment=(MediaItemFragment)fm.findFragmentById(R.id.mediaItemFragment);
}
Program: 15162
Project: 15162
Buggy source:
@Override public void onMediaItemSelected(String mediaId){
  FragmentManager fm=getSupportFragmentManager();
  mMediaItemFragment=(MediaItemFragment)fm.findFragmentById(R.id.mediaItemFragment);
  if (mMediaItemFragment == null || !mMediaItemFragment.isInLayout()) {
    FragmentTransaction ft=fm.beginTransaction();
    ft.hide(mMediaItemListFragment);
    mMediaItemFragment=MediaItemFragment.newInstance(mediaId);
    ft.add(R.id.media_browser_container,mMediaItemFragment);
    ft.addToBackStack(null);
    ft.commit();
    mMenuDrawer.setDrawerIndicatorEnabled(false);
  }
 else {
    mMediaItemFragment.loadMedia(mediaId);
  }
}

Fixed version (ground truth):
@Override public void onMediaItemSelected(String mediaId){
  FragmentManager fm=getSupportFragmentManager();
  if (mMediaItemFragment == null || !mMediaItemFragment.isInLayout()) {
    FragmentTransaction ft=fm.beginTransaction();
    ft.hide(mMediaItemListFragment);
    mMediaItemFragment=MediaItemFragment.newInstance(mediaId);
    ft.add(R.id.media_browser_container,mMediaItemFragment);
    ft.addToBackStack(null);
    ft.commit();
    mMenuDrawer.setDrawerIndicatorEnabled(false);
  }
 else {
    mMediaItemFragment.loadMedia(mediaId);
  }
}
Program: 15163
Project: 15163
Buggy source:
public void loadMedia(String mediaId){
  if (mediaId == null)   return;
  Blog blog=WordPress.getCurrentBlog();
  if (blog != null) {
    String blogId=String.valueOf(blog.getBlogId());
    Cursor cursor=WordPress.wpDB.getMediaFile(blogId,mediaId);
    refreshViews(cursor);
  }
}

Fixed version (ground truth):
public void loadMedia(String mediaId){
  String id=mediaId;
  Blog blog=WordPress.getCurrentBlog();
  if (blog != null) {
    String blogId=String.valueOf(blog.getBlogId());
    Cursor cursor;
    if (id == null) {
      cursor=WordPress.wpDB.getFirstMediaFileForBlog(blogId);
    }
 else {
      cursor=WordPress.wpDB.getMediaFile(blogId,id);
    }
    refreshViews(cursor);
  }
}
Program: 15164
Project: 15164
Buggy source:
@Override public void onAttach(Activity activity){
  super.onAttach(activity);
  try {
    mListener=(OnMediaItemSelectedListener)activity;
  }
 catch (  ClassCastException e) {
    throw new ClassCastException(activity.toString() + "String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public void onAttach(Activity activity){
  super.onAttach(activity);
  try {
    mListener=(MediaItemListListener)activity;
  }
 catch (  ClassCastException e) {
    throw new ClassCastException(activity.toString() + "String_Node_Str");
  }
}
Program: 15165
Project: 15165
Buggy source:
private void loadCursor(){
  Blog blog=WordPress.getCurrentBlog();
  if (blog != null) {
    String blogId=String.valueOf(blog.getBlogId());
    mCursor=WordPress.wpDB.getMediaFilesForBlog(blogId);
    if (mCursor.moveToFirst()) {
      String mediaId=mCursor.getString(mCursor.getColumnIndex("String_Node_Str"));
      mListener.onMediaItemSelected(mediaId);
    }
  }
}

Fixed version (ground truth):
private void loadCursor(){
  Blog blog=WordPress.getCurrentBlog();
  if (blog != null) {
    String blogId=String.valueOf(blog.getBlogId());
    mCursor=WordPress.wpDB.getMediaFilesForBlog(blogId);
  }
}
Program: 15166
Project: 15166
Buggy source:
@Override public void onSuccess(){
  loadCursor();
  mAdapter.changeCursor(mCursor);
}

Fixed version (ground truth):
@Override public void onSuccess(){
  loadCursor();
  mListener.onMediaItemListDownloaded();
  mAdapter.changeCursor(mCursor);
}
Program: 15167
Project: 15167
Buggy source:
public void addAll(List<Note> notes){
  if (notes.size() == 0) {
    mAllNotesLoaded=true;
    if (mPressFooterView != null)     mProgressFooterView.setVisibility(View.GONE);
  }
 else {
    Iterator<Note> noteIterator=notes.iterator();
    while (noteIterator.hasNext()) {
      add(noteIterator.next());
    }
  }
}

Fixed version (ground truth):
public void addAll(List<Note> notes){
  if (notes.size() == 0) {
    mAllNotesLoaded=true;
    if (mProgressFooterView != null)     mProgressFooterView.setVisibility(View.GONE);
  }
 else {
    Iterator<Note> noteIterator=notes.iterator();
    while (noteIterator.hasNext()) {
      add(noteIterator.next());
    }
  }
}
Program: 15168
Project: 15168
Buggy source:
public void refreshNotes(){
  mFirstLoadComplete=false;
  shouldAnimateRefreshButton=true;
  startAnimatingRefreshButton(mRefreshMenuItem);
  NotesResponseHandler handler=new NotesResponseHandler(){
    @Override public void onNotes(    List<Note> notes){
      mFirstLoadComplete=true;
      final NotificationsListFragment.NotesAdapter adapter=mNotesList.getNotesAdapter();
      adapter.clear();
      adapter.addAll(notes);
      adapter.notifyDataSetChanged();
      if (!notes.isEmpty()) {
        updateLastSeen(notes.get(0).getTimestamp());
      }
      stopAnimatingRefreshButton(mRefreshMenuItem);
    }
    @Override public void onErrorResponse(    VolleyError error){
      mFirstLoadComplete=true;
      final NotificationsListFragment.NotesAdapter adapter=mNotesList.getNotesAdapter();
      adapter.clear();
      adapter.addAll(new ArrayList<Note>());
      adapter.notifyDataSetChanged();
      Toast.makeText(NotificationsActivity.this,getString(R.string.error_refresh),Toast.LENGTH_LONG).show();
      stopAnimatingRefreshButton(mRefreshMenuItem);
    }
  }
;
  restClient.getNotifications(handler,handler);
}

Fixed version (ground truth):
public void refreshNotes(){
  mFirstLoadComplete=false;
  shouldAnimateRefreshButton=true;
  startAnimatingRefreshButton(mRefreshMenuItem);
  NotesResponseHandler handler=new NotesResponseHandler(){
    @Override public void onNotes(    List<Note> notes){
      mFirstLoadComplete=true;
      final NotificationsListFragment.NotesAdapter adapter=mNotesList.getNotesAdapter();
      adapter.clear();
      adapter.addAll(notes);
      adapter.notifyDataSetChanged();
      if (!notes.isEmpty()) {
        updateLastSeen(notes.get(0).getTimestamp());
      }
      stopAnimatingRefreshButton(mRefreshMenuItem);
    }
    @Override public void onErrorResponse(    VolleyError error){
      mFirstLoadComplete=true;
      final NotificationsListFragment.NotesAdapter adapter=mNotesList.getNotesAdapter();
      adapter.clear();
      adapter.addAll(new ArrayList<Note>());
      adapter.notifyDataSetChanged();
      Toast.makeText(NotificationsActivity.this,String.format(getResources().getString(R.string.error_refresh),getResources().getText(R.string.notifications).toString().toLowerCase()),Toast.LENGTH_LONG).show();
      stopAnimatingRefreshButton(mRefreshMenuItem);
    }
  }
;
  restClient.getNotifications(handler,handler);
}