nus-yam/ex-repair huggingface dataset:
Program: 15013
Project: 15013
Buggy source:
/** 
 * @param canvas
 */
@Override protected void onDraw(Canvas canvas){
  paint.setStrokeWidth(0);
  if (labelTextHeight == null || verLabelTextWidth == null) {
    paint.setTextSize(getGraphViewStyle().getTextSize());
    double testY=((getMaxY() - getMinY()) * 0.783) + getMinY();
    String testLabel=formatLabel(testY,false);
    paint.getTextBounds(testLabel,0,testLabel.length(),textBounds);
    labelTextHeight=(textBounds.height());
    verLabelTextWidth=(textBounds.width());
  }
  if (getGraphViewStyle().getVerticalLabelsWidth() == 0 && getLayoutParams().width != verLabelTextWidth + GraphViewConfig.BORDER) {
    setLayoutParams(new LayoutParams((int)(verLabelTextWidth + GraphViewConfig.BORDER),LayoutParams.FILL_PARENT));
  }
 else   if (getGraphViewStyle().getVerticalLabelsWidth() != 0 && getGraphViewStyle().getVerticalLabelsWidth() != getLayoutParams().width) {
    setLayoutParams(new LayoutParams(getGraphViewStyle().getVerticalLabelsWidth(),LayoutParams.FILL_PARENT));
  }
  float border=GraphViewConfig.BORDER;
  border+=labelTextHeight;
  float height=getHeight();
  float graphheight=height - (2 * border);
  if (verlabels == null) {
    verlabels=generateVerlabels(graphheight);
  }
  paint.setTextAlign(Align.LEFT);
  int vers=verlabels.length - 1;
  for (int i=0; i < verlabels.length; i++) {
    float y=((graphheight / vers) * i) + border;
    paint.setColor(graphViewStyle.getVerticalLabelsColor());
    canvas.drawText(verlabels[i],0,y,paint);
  }
}

Fixed version (ground truth):
/** 
 * @param canvas
 */
@Override protected void onDraw(Canvas canvas){
  paint.setStrokeWidth(0);
  int padding=(int)dpToPx(8);
  if (labelTextHeight == null || verLabelTextWidth == null) {
    paint.setTextSize(getGraphViewStyle().getTextSize());
    double testY=((getMaxY() - getMinY()) * 0.783) + getMinY();
    String testLabel=formatLabel(testY,false);
    paint.getTextBounds(testLabel,0,testLabel.length(),textBounds);
    labelTextHeight=(textBounds.height());
    verLabelTextWidth=(textBounds.width()) + padding;
  }
  if (getGraphViewStyle().getVerticalLabelsWidth() == 0 && getLayoutParams().width != verLabelTextWidth + GraphViewConfig.BORDER) {
    setLayoutParams(new LayoutParams((int)(verLabelTextWidth + GraphViewConfig.BORDER),LayoutParams.FILL_PARENT));
  }
 else   if (getGraphViewStyle().getVerticalLabelsWidth() != 0 && getGraphViewStyle().getVerticalLabelsWidth() != getLayoutParams().width) {
    setLayoutParams(new LayoutParams(getGraphViewStyle().getVerticalLabelsWidth(),LayoutParams.FILL_PARENT));
  }
  float border=GraphViewConfig.BORDER;
  border+=labelTextHeight;
  float height=getHeight();
  float graphheight=height - (2 * border);
  if (verlabels == null) {
    verlabels=generateVerlabels(graphheight);
  }
  paint.setTextAlign(Align.RIGHT);
  int vers=verlabels.length - 1;
  for (int i=0; i < verlabels.length; i++) {
    float y=((graphheight / vers) * i) + border;
    paint.setColor(graphViewStyle.getVerticalLabelsColor());
    canvas.drawText(verlabels[i],0,y,paint);
  }
}
Program: 15014
Project: 15014
Buggy source:
public GraphViewSeriesStyle(int color,int thickness){
  super();
  this.color=color;
  this.thickness=thickness;
}

Fixed version (ground truth):
public GraphViewSeriesStyle(int color,int thickness,float padding){
  super();
  this.color=color;
  this.thickness=thickness;
  this.padding=padding;
}
Program: 15015
Project: 15015
Buggy source:
public GraphViewStyle(int vLabelsColor,int hLabelsColor,int gridColor){
  this.verticalLabelsColor=vLabelsColor;
  this.horizontalLabelsColor=hLabelsColor;
  this.gridColor=gridColor;
}

Fixed version (ground truth):
public GraphViewStyle(int vLabelsColor,int hLabelsColor,int gridXColor,int gridYColor){
  this.verticalLabelsColor=vLabelsColor;
  this.horizontalLabelsColor=hLabelsColor;
  this.gridXColor=gridXColor;
  this.gridYColor=gridYColor;
}
Program: 15017
Project: 15017
Buggy source:
private synchronized void loadLocalImage(Cursor cursor,final ImageView imageView){
  final String filePath=cursor.getString(cursor.getColumnIndex("String_Node_Str"));
  if (MediaUtils.isValidImage(filePath)) {
    imageView.setTag(filePath);
    Bitmap bitmap=WordPress.localImageCache.get(filePath);
    if (bitmap != null) {
      imageView.setImageBitmap(bitmap);
    }
 else {
      imageView.setImageBitmap(null);
      boolean shouldFetch=false;
      List<BitmapReadyCallback> list;
      if (mFilePathToCallbackMap.containsKey(filePath)) {
        list=mFilePathToCallbackMap.get(filePath);
      }
 else {
        list=new ArrayList<MediaGridAdapter.BitmapReadyCallback>();
        shouldFetch=true;
        mFilePathToCallbackMap.put(filePath,list);
      }
      list.add(new BitmapReadyCallback(){
        @Override public void onBitmapReady(        Bitmap bitmap){
          if (imageView.getTag().equals(filePath))           imageView.setImageBitmap(bitmap);
        }
      }
);
      if (shouldFetch) {
        fetchBitmap(filePath);
      }
    }
  }
}

Fixed version (ground truth):
private synchronized void loadLocalImage(Cursor cursor,final ImageView imageView){
  final String filePath=cursor.getString(cursor.getColumnIndex("String_Node_Str"));
  if (MediaUtils.isValidImage(filePath)) {
    imageView.setTag(filePath);
    Bitmap bitmap=WordPress.localImageCache.get(filePath);
    if (bitmap != null) {
      imageView.setImageBitmap(bitmap);
    }
 else {
      imageView.setImageBitmap(null);
      boolean shouldFetch=false;
      List<BitmapReadyCallback> list;
      if (mFilePathToCallbackMap.containsKey(filePath)) {
        list=mFilePathToCallbackMap.get(filePath);
      }
 else {
        list=new ArrayList<MediaGridAdapter.BitmapReadyCallback>();
        shouldFetch=true;
        mFilePathToCallbackMap.put(filePath,list);
      }
      list.add(new BitmapReadyCallback(){
        @Override public void onBitmapReady(        Bitmap bitmap){
          if (imageView.getTag().equals(filePath))           imageView.setImageBitmap(bitmap);
        }
      }
);
      if (shouldFetch) {
        fetchBitmap(filePath);
      }
    }
  }
 else {
    imageView.setImageBitmap(null);
  }
}
Program: 15018
Project: 15018
Buggy source:
public MediaGridAdapter(Context context,Cursor c,int flags,ArrayList<String> checkedItems){
  super(context,c,flags);
  mCheckedItems=checkedItems;
  mFilePathToCallbackMap=new HashMap<String,List<BitmapReadyCallback>>();
}

Fixed version (ground truth):
public MediaGridAdapter(Context context,Cursor c,int flags,ArrayList<String> checkedItems){
  super(context,c,flags);
  mCheckedItems=checkedItems;
  mFilePathToCallbackMap=new HashMap<String,List<BitmapReadyCallback>>();
  mHandler=new Handler();
}
Program: 15019
Project: 15019
Buggy source:
private void fetchBitmap(final String filePath){
  int width=mContext.getResources().getDimensionPixelSize(R.dimen.media_grid_local_image_width);
  BitmapWorkerTask task=new BitmapWorkerTask(null,width,width,new BitmapWorkerCallback(){
    @Override public void onBitmapReady(    String path,    ImageView imageView,    Bitmap bitmap){
      List<BitmapReadyCallback> callbacks=mFilePathToCallbackMap.get(path);
      for (      BitmapReadyCallback callback : callbacks) {
        callback.onBitmapReady(bitmap);
      }
      WordPress.localImageCache.put(path,bitmap);
      callbacks.clear();
      mFilePathToCallbackMap.remove(path);
    }
  }
);
  task.execute(filePath);
}

Fixed version (ground truth):
private void fetchBitmap(final String filePath){
  int width=mContext.getResources().getDimensionPixelSize(R.dimen.media_grid_local_image_width);
  BitmapWorkerTask task=new BitmapWorkerTask(null,width,width,new BitmapWorkerCallback(){
    @Override public void onBitmapReady(    final String path,    ImageView imageView,    final Bitmap bitmap){
      mHandler.post(new Runnable(){
        @Override public void run(){
          List<BitmapReadyCallback> callbacks=mFilePathToCallbackMap.get(path);
          for (          BitmapReadyCallback callback : callbacks) {
            callback.onBitmapReady(bitmap);
          }
          WordPress.localImageCache.put(path,bitmap);
          callbacks.clear();
          mFilePathToCallbackMap.remove(path);
        }
      }
);
    }
  }
);
  task.execute(filePath);
}
Program: 15020
Project: 15020
Buggy source:
@Override public void onBitmapReady(String path,ImageView imageView,Bitmap bitmap){
  List<BitmapReadyCallback> callbacks=mFilePathToCallbackMap.get(path);
  for (  BitmapReadyCallback callback : callbacks) {
    callback.onBitmapReady(bitmap);
  }
  WordPress.localImageCache.put(path,bitmap);
  callbacks.clear();
  mFilePathToCallbackMap.remove(path);
}

Fixed version (ground truth):
@Override public void onBitmapReady(final String path,ImageView imageView,final Bitmap bitmap){
  mHandler.post(new Runnable(){
    @Override public void run(){
      List<BitmapReadyCallback> callbacks=mFilePathToCallbackMap.get(path);
      for (      BitmapReadyCallback callback : callbacks) {
        callback.onBitmapReady(bitmap);
      }
      WordPress.localImageCache.put(path,bitmap);
      callbacks.clear();
      mFilePathToCallbackMap.remove(path);
    }
  }
);
}
Program: 15021
Project: 15021
Buggy source:
private void refreshStats(){
  if (WordPress.getCurrentBlog() == null)   return;
  final String blogId=String.valueOf(WordPress.getCurrentBlog().getBlogId());
  new AsyncTask<String,Void,StatsSummary>(){
    @Override protected StatsSummary doInBackground(    String... params){
      final String blogId=params[0];
      StatsSummary stats=StatUtils.getSummary(blogId);
      return stats;
    }
    protected void onPostExecute(    StatsSummary result){
      refreshViews(result);
    }
  }
.execute(blogId);
}

Fixed version (ground truth):
private void refreshStats(){
  if (WordPress.getCurrentBlog() == null)   return;
  final String blogId=String.valueOf(WordPress.getCurrentBlog().getBlogId());
  new AsyncTask<String,Void,StatsSummary>(){
    @Override protected StatsSummary doInBackground(    String... params){
      final String blogId=params[0];
      StatsSummary stats=StatUtils.getSummary(blogId);
      return stats;
    }
    protected void onPostExecute(    final StatsSummary result){
      runOnUiThread(new Runnable(){
        @Override public void run(){
          refreshViews(result);
        }
      }
);
    }
  }
.execute(blogId);
}
Program: 15022
Project: 15022
Buggy source:
protected void onPostExecute(StatsSummary result){
  refreshViews(result);
}

Fixed version (ground truth):
protected void onPostExecute(final StatsSummary result){
  runOnUiThread(new Runnable(){
    @Override public void run(){
      refreshViews(result);
    }
  }
);
}
Program: 15023
Project: 15023
Buggy source:
private void refreshSummary(){
  if (WordPress.getCurrentBlog() == null)   return;
  final String blogId=String.valueOf(WordPress.getCurrentBlog().getBlogId());
  new AsyncTask<String,Void,StatsVisitorsAndViewsSummary>(){
    @Override protected StatsVisitorsAndViewsSummary doInBackground(    String... params){
      final String blogId=params[0];
      StatsVisitorsAndViewsSummary stats=StatUtils.getVisitorsAndViewsSummary(blogId);
      return stats;
    }
    protected void onPostExecute(    StatsVisitorsAndViewsSummary result){
      refreshViews(result);
    }
  }
.execute(blogId);
}

Fixed version (ground truth):
private void refreshSummary(){
  if (WordPress.getCurrentBlog() == null)   return;
  final String blogId=String.valueOf(WordPress.getCurrentBlog().getBlogId());
  new AsyncTask<String,Void,StatsVisitorsAndViewsSummary>(){
    @Override protected StatsVisitorsAndViewsSummary doInBackground(    String... params){
      final String blogId=params[0];
      StatsVisitorsAndViewsSummary stats=StatUtils.getVisitorsAndViewsSummary(blogId);
      return stats;
    }
    protected void onPostExecute(    final StatsVisitorsAndViewsSummary result){
      getActivity().runOnUiThread(new Runnable(){
        @Override public void run(){
          refreshViews(result);
        }
      }
);
    }
  }
.execute(blogId);
}
Program: 15024
Project: 15024
Buggy source:
protected void onPostExecute(StatsVisitorsAndViewsSummary result){
  refreshViews(result);
}

Fixed version (ground truth):
protected void onPostExecute(final StatsVisitorsAndViewsSummary result){
  getActivity().runOnUiThread(new Runnable(){
    @Override public void run(){
      refreshViews(result);
    }
  }
);
}
Program: 15025
Project: 15025
Buggy source:
public void setDateFilter(){
  Blog blog=WordPress.getCurrentBlog();
  if (blog == null)   return;
  String blogId=String.valueOf(blog.getBlogId());
  GregorianCalendar startDate=new GregorianCalendar(mStartYear,mStartMonth,mStartDay);
  GregorianCalendar endDate=new GregorianCalendar(mEndYear,mEndMonth,mEndDay);
  long one_day=24 * 60 * 60* 1000;
  Cursor cursor=WordPress.wpDB.getMediaFilesForBlog(blogId,startDate.getTimeInMillis(),endDate.getTimeInMillis() + one_day);
  mGridAdapter.changeCursor(cursor);
  if (cursor != null && cursor.moveToFirst()) {
    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(mStartYear,mStartMonth,mStartDay);
  GregorianCalendar endDate=new GregorianCalendar(mEndYear,mEndMonth,mEndDay);
  long one_day=24 * 60 * 60* 1000;
  Cursor cursor=WordPress.wpDB.getMediaFilesForBlog(blogId,startDate.getTimeInMillis(),endDate.getTimeInMillis() + one_day);
  mGridAdapter.swapCursor(cursor);
  if (cursor != null && cursor.moveToFirst()) {
    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: 15026
Project: 15026
Buggy source:
public void setFilter(Filter filter){
  mFilter=filter;
  Cursor cursor=filterItems(mFilter);
  if (cursor != null) {
    mGridAdapter.changeCursor(cursor);
    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: 15027
Project: 15027
Buggy source:
@Override public void onActivityResult(int requestCode,int resultCode,Intent data){
  super.onActivityResult(requestCode,resultCode,data);
  if (data != null || requestCode == RequestCode.ACTIVITY_REQUEST_CODE_TAKE_PHOTO || requestCode == RequestCode.ACTIVITY_REQUEST_CODE_TAKE_VIDEO) {
    String path=null;
switch (requestCode) {
case RequestCode.ACTIVITY_REQUEST_CODE_PICTURE_LIBRARY:
case RequestCode.ACTIVITY_REQUEST_CODE_PICTURE_VIDEO_LIBRARY:
      Uri imageUri=data.getData();
    path=getRealPathFromURI(imageUri);
  queueFileForUpload(path);
break;
case RequestCode.ACTIVITY_REQUEST_CODE_TAKE_PHOTO:
if (resultCode == Activity.RESULT_OK) {
path=mMediaCapturePath;
mMediaCapturePath=null;
queueFileForUpload(path);
}
break;
case RequestCode.ACTIVITY_REQUEST_CODE_TAKE_VIDEO:
if (resultCode == Activity.RESULT_OK) {
Uri videoUri=data.getData();
path=getRealPathFromURI(videoUri);
queueFileForUpload(path);
}
break;
}
}
}

Fixed version (ground truth):
@Override public void onActivityResult(int requestCode,int resultCode,Intent data){
  super.onActivityResult(requestCode,resultCode,data);
  if (data != null || requestCode == RequestCode.ACTIVITY_REQUEST_CODE_TAKE_PHOTO || requestCode == RequestCode.ACTIVITY_REQUEST_CODE_TAKE_VIDEO) {
    String path=null;
switch (requestCode) {
case RequestCode.ACTIVITY_REQUEST_CODE_PICTURE_LIBRARY:
case RequestCode.ACTIVITY_REQUEST_CODE_PICTURE_VIDEO_LIBRARY:
      Uri imageUri=data.getData();
    path=getRealPathFromURI(imageUri);
  queueFileForUpload(path);
break;
case RequestCode.ACTIVITY_REQUEST_CODE_TAKE_PHOTO:
case RequestCode.ACTIVITY_REQUEST_CODE_TAKE_VIDEO:
if (resultCode == Activity.RESULT_OK) {
path=mMediaCapturePath;
mMediaCapturePath=null;
queueFileForUpload(path);
}
break;
}
}
}
Program: 15028
Project: 15028
Buggy source:
public void launchVideoCamera(){
  MediaUtils.launchVideoCamera(this);
}

Fixed version (ground truth):
public void launchVideoCamera(){
  MediaUtils.launchVideoCamera(this,this);
}
Program: 15029
Project: 15029
Buggy source:
public static void launchCamera(Activity activity,LaunchCameraCallback callback){
  String state=android.os.Environment.getExternalStorageState();
  if (!state.equals(android.os.Environment.MEDIA_MOUNTED)) {
    showSDCardRequiredDialog(activity);
  }
 else {
    Intent takePictureFromCameraIntent=prepareLaunchCameraIntent(callback);
    activity.startActivityForResult(takePictureFromCameraIntent,RequestCode.ACTIVITY_REQUEST_CODE_TAKE_PHOTO);
  }
}

Fixed version (ground truth):
public static void launchCamera(Activity activity,LaunchCameraCallback callback){
  String state=android.os.Environment.getExternalStorageState();
  if (!state.equals(android.os.Environment.MEDIA_MOUNTED)) {
    showSDCardRequiredDialog(activity);
  }
 else {
    Intent intent=prepareLaunchCameraIntent(callback,false);
    activity.startActivityForResult(intent,RequestCode.ACTIVITY_REQUEST_CODE_TAKE_PHOTO);
  }
}
Program: 15030
Project: 15030
Buggy source:
public static void launchVideoCamera(Fragment fragment){
  fragment.startActivityForResult(new Intent(MediaStore.ACTION_VIDEO_CAPTURE),RequestCode.ACTIVITY_REQUEST_CODE_TAKE_VIDEO);
}

Fixed version (ground truth):
public static void launchVideoCamera(Fragment fragment,LaunchCameraCallback callback){
  String state=android.os.Environment.getExternalStorageState();
  if (!state.equals(android.os.Environment.MEDIA_MOUNTED)) {
    showSDCardRequiredDialog(fragment.getActivity());
  }
 else {
    Intent intent=prepareLaunchCameraIntent(callback,true);
    fragment.startActivityForResult(intent,RequestCode.ACTIVITY_REQUEST_CODE_TAKE_VIDEO);
  }
}
Program: 15031
Project: 15031
Buggy source:
private static Intent prepareLaunchCameraIntent(LaunchCameraCallback callback){
  String dcimFolderName=Environment.DIRECTORY_DCIM;
  if (dcimFolderName == null)   dcimFolderName="String_Node_Str";
  String mediaCapturePath=Environment.getExternalStorageDirectory() + File.separator + dcimFolderName+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str"+ System.currentTimeMillis()+ "String_Node_Str";
  Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
  intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT,Uri.fromFile(new File(mediaCapturePath)));
  if (callback != null) {
    callback.onMediaCapturePathReady(mediaCapturePath);
  }
  File directory=new File(mediaCapturePath).getParentFile();
  if (!directory.exists() && !directory.mkdirs()) {
    try {
      throw new IOException("String_Node_Str");
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
  return intent;
}

Fixed version (ground truth):
private static Intent prepareLaunchCameraIntent(LaunchCameraCallback callback,boolean isVideo){
  String ext="String_Node_Str";
  String action=MediaStore.ACTION_IMAGE_CAPTURE;
  if (isVideo) {
    ext="String_Node_Str";
    action=MediaStore.ACTION_VIDEO_CAPTURE;
  }
  String dcimFolderName=Environment.DIRECTORY_DCIM;
  if (dcimFolderName == null)   dcimFolderName="String_Node_Str";
  String mediaCapturePath=Environment.getExternalStorageDirectory() + File.separator + dcimFolderName+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str"+ System.currentTimeMillis()+ ext;
  Intent intent=new Intent(action);
  intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT,Uri.fromFile(new File(mediaCapturePath)));
  if (callback != null) {
    callback.onMediaCapturePathReady(mediaCapturePath);
  }
  File directory=new File(mediaCapturePath).getParentFile();
  if (!directory.exists() && !directory.mkdirs()) {
    try {
      throw new IOException("String_Node_Str");
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
  return intent;
}
Program: 15033
Project: 15033
Buggy source:
@Override public void onMediaCapturePathReady(String mediaCapturePath){
  mMediaCapturePath=mediaCapturePath;
  mCurrentActivityRequest=RequestCode.ACTIVITY_REQUEST_CODE_TAKE_PHOTO;
}

Fixed version (ground truth):
@Override public void onMediaCapturePathReady(String mediaCapturePath){
  mMediaCapturePath=mediaCapturePath;
  mCurrentActivityRequest=RequestCode.ACTIVITY_REQUEST_CODE_TAKE_VIDEO;
}
Program: 15034
Project: 15034
Buggy source:
private void launchVideoCamera(){
  mCurrentActivityRequest=RequestCode.ACTIVITY_REQUEST_CODE_TAKE_VIDEO;
  MediaUtils.launchVideoCamera(this);
}

Fixed version (ground truth):
private void launchVideoCamera(){
  mCurrentActivityRequest=RequestCode.ACTIVITY_REQUEST_CODE_TAKE_VIDEO;
  MediaUtils.launchVideoCamera(this,new LaunchCameraCallback(){
    @Override public void onMediaCapturePathReady(    String mediaCapturePath){
      mMediaCapturePath=mediaCapturePath;
      mCurrentActivityRequest=RequestCode.ACTIVITY_REQUEST_CODE_TAKE_VIDEO;
    }
  }
);
}
Program: 15035
Project: 15035
Buggy source:
@Override public void onActivityResult(int requestCode,int resultCode,Intent data){
  super.onActivityResult(requestCode,resultCode,data);
  if (data != null || requestCode == RequestCode.ACTIVITY_REQUEST_CODE_TAKE_PHOTO || requestCode == RequestCode.ACTIVITY_REQUEST_CODE_TAKE_VIDEO) {
    String path=null;
switch (requestCode) {
case RequestCode.ACTIVITY_REQUEST_CODE_PICTURE_LIBRARY:
case RequestCode.ACTIVITY_REQUEST_CODE_PICTURE_VIDEO_LIBRARY:
      Uri imageUri=data.getData();
    path=getRealPathFromURI(imageUri);
  queueFileForUpload(path);
break;
case RequestCode.ACTIVITY_REQUEST_CODE_TAKE_PHOTO:
case RequestCode.ACTIVITY_REQUEST_CODE_TAKE_VIDEO:
if (resultCode == Activity.RESULT_OK) {
path=mMediaCapturePath;
mMediaCapturePath=null;
queueFileForUpload(path);
}
break;
}
}
}

Fixed version (ground truth):
@Override public void onActivityResult(int requestCode,int resultCode,Intent data){
  super.onActivityResult(requestCode,resultCode,data);
  if (data != null || requestCode == RequestCode.ACTIVITY_REQUEST_CODE_TAKE_PHOTO || requestCode == RequestCode.ACTIVITY_REQUEST_CODE_TAKE_VIDEO) {
    String path=null;
switch (requestCode) {
case RequestCode.ACTIVITY_REQUEST_CODE_PICTURE_LIBRARY:
case RequestCode.ACTIVITY_REQUEST_CODE_PICTURE_VIDEO_LIBRARY:
      Uri imageUri=data.getData();
    path=getRealPathFromURI(imageUri);
  queueFileForUpload(path);
break;
case RequestCode.ACTIVITY_REQUEST_CODE_TAKE_PHOTO:
if (resultCode == Activity.RESULT_OK) {
path=mMediaCapturePath;
mMediaCapturePath=null;
queueFileForUpload(path);
}
break;
case RequestCode.ACTIVITY_REQUEST_CODE_TAKE_VIDEO:
if (resultCode == Activity.RESULT_OK) {
path=getRealPathFromURI(MediaUtils.getLastRecordedVideoUri(getActivity()));
queueFileForUpload(path);
}
break;
}
}
}
Program: 15036
Project: 15036
Buggy source:
public void launchVideoCamera(){
  MediaUtils.launchVideoCamera(this,this);
}

Fixed version (ground truth):
public void launchVideoCamera(){
  MediaUtils.launchVideoCamera(this);
}
Program: 15037
Project: 15037
Buggy source:
public static void launchCamera(Activity activity,LaunchCameraCallback callback){
  String state=android.os.Environment.getExternalStorageState();
  if (!state.equals(android.os.Environment.MEDIA_MOUNTED)) {
    showSDCardRequiredDialog(activity);
  }
 else {
    Intent intent=prepareLaunchCameraIntent(callback,false);
    activity.startActivityForResult(intent,RequestCode.ACTIVITY_REQUEST_CODE_TAKE_PHOTO);
  }
}

Fixed version (ground truth):
public static void launchCamera(Activity activity,LaunchCameraCallback callback){
  String state=android.os.Environment.getExternalStorageState();
  if (!state.equals(android.os.Environment.MEDIA_MOUNTED)) {
    showSDCardRequiredDialog(activity);
  }
 else {
    Intent intent=prepareLaunchCameraIntent(callback);
    activity.startActivityForResult(intent,RequestCode.ACTIVITY_REQUEST_CODE_TAKE_PHOTO);
  }
}
Program: 15038
Project: 15038
Buggy source:
public static void launchVideoCamera(Fragment fragment,LaunchCameraCallback callback){
  String state=android.os.Environment.getExternalStorageState();
  if (!state.equals(android.os.Environment.MEDIA_MOUNTED)) {
    showSDCardRequiredDialog(fragment.getActivity());
  }
 else {
    Intent intent=prepareLaunchCameraIntent(callback,true);
    fragment.startActivityForResult(intent,RequestCode.ACTIVITY_REQUEST_CODE_TAKE_VIDEO);
  }
}

Fixed version (ground truth):
public static void launchVideoCamera(Fragment fragment){
  Intent intent=new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
  fragment.startActivityForResult(intent,RequestCode.ACTIVITY_REQUEST_CODE_TAKE_VIDEO);
}
Program: 15039
Project: 15039
Buggy source:
private static Intent prepareLaunchCameraIntent(LaunchCameraCallback callback,boolean isVideo){
  String ext="String_Node_Str";
  String action=MediaStore.ACTION_IMAGE_CAPTURE;
  if (isVideo) {
    ext="String_Node_Str";
    action=MediaStore.ACTION_VIDEO_CAPTURE;
  }
  String dcimFolderName=Environment.DIRECTORY_DCIM;
  if (dcimFolderName == null)   dcimFolderName="String_Node_Str";
  String mediaCapturePath=Environment.getExternalStorageDirectory() + File.separator + dcimFolderName+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str"+ System.currentTimeMillis()+ ext;
  Intent intent=new Intent(action);
  intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT,Uri.fromFile(new File(mediaCapturePath)));
  if (callback != null) {
    callback.onMediaCapturePathReady(mediaCapturePath);
  }
  File directory=new File(mediaCapturePath).getParentFile();
  if (!directory.exists() && !directory.mkdirs()) {
    try {
      throw new IOException("String_Node_Str");
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
  return intent;
}

Fixed version (ground truth):
private static Intent prepareLaunchCameraIntent(LaunchCameraCallback callback){
  File path=Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
  String mediaCapturePath=path + File.separator + "String_Node_Str"+ File.separator+ "String_Node_Str"+ System.currentTimeMillis()+ "String_Node_Str";
  Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
  intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT,Uri.fromFile(new File(mediaCapturePath)));
  if (callback != null) {
    callback.onMediaCapturePathReady(mediaCapturePath);
  }
  File directory=new File(mediaCapturePath).getParentFile();
  if (!directory.exists() && !directory.mkdirs()) {
    try {
      throw new IOException("String_Node_Str");
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
  return intent;
}
Program: 15041
Project: 15041
Buggy source:
@Override public void onMediaCapturePathReady(String mediaCapturePath){
  mMediaCapturePath=mediaCapturePath;
  mCurrentActivityRequest=RequestCode.ACTIVITY_REQUEST_CODE_TAKE_VIDEO;
}

Fixed version (ground truth):
@Override public void onMediaCapturePathReady(String mediaCapturePath){
  mMediaCapturePath=mediaCapturePath;
  mCurrentActivityRequest=RequestCode.ACTIVITY_REQUEST_CODE_TAKE_PHOTO;
}
Program: 15042
Project: 15042
Buggy source:
private void launchVideoCamera(){
  mCurrentActivityRequest=RequestCode.ACTIVITY_REQUEST_CODE_TAKE_VIDEO;
  MediaUtils.launchVideoCamera(this,new LaunchCameraCallback(){
    @Override public void onMediaCapturePathReady(    String mediaCapturePath){
      mMediaCapturePath=mediaCapturePath;
      mCurrentActivityRequest=RequestCode.ACTIVITY_REQUEST_CODE_TAKE_VIDEO;
    }
  }
);
}

Fixed version (ground truth):
private void launchVideoCamera(){
  mCurrentActivityRequest=RequestCode.ACTIVITY_REQUEST_CODE_TAKE_VIDEO;
  MediaUtils.launchVideoCamera(this);
}
Program: 15043
Project: 15043
Buggy source:
public void refreshMediaFromDB(){
  setFilter(mFilter);
  if (mGridAdapter.getCount() == 0 && !mHasRetrievedAllMedia) {
    refreshMediaFromServer(0,true);
  }
}

Fixed version (ground truth):
public void refreshMediaFromDB(){
  setFilter(mFilter);
  if (mGridAdapter.getDataCount() == 0 && !mHasRetrievedAllMedia) {
    refreshMediaFromServer(0,true);
  }
}
Program: 15044
Project: 15044
Buggy source:
@Override public void onMediaAdded(String mediaId){
  mMediaGridFragment.refreshMediaFromDB();
}

Fixed version (ground truth):
@Override public void onMediaAdded(String mediaId){
  mMediaGridFragment.checkSelection(mediaId);
  mMediaGridFragment.refreshMediaFromDB();
}
Program: 15045
Project: 15045
Buggy source:
private void uploadMediaFile(Cursor cursor){
  if (!cursor.moveToFirst())   return;
  mUploadInProgress=true;
  final String blogIdStr=cursor.getString((cursor.getColumnIndex("String_Node_Str")));
  final String mediaId=cursor.getString(cursor.getColumnIndex("String_Node_Str"));
  String fileName=cursor.getString(cursor.getColumnIndex("String_Node_Str"));
  String filePath=cursor.getString(cursor.getColumnIndex("String_Node_Str"));
  String mimeType=cursor.getString(cursor.getColumnIndex("String_Node_Str"));
  MediaFile mediaFile=new MediaFile();
  mediaFile.setBlogId(blogIdStr);
  mediaFile.setFileName(fileName);
  mediaFile.setFilePath(filePath);
  mediaFile.setMIMEType(mimeType);
  ApiHelper.UploadMediaTask task=new ApiHelper.UploadMediaTask(mContext,mediaFile,new Callback(){
    @Override public void onSuccess(    String id){
      WordPress.wpDB.deleteMediaFile(blogIdStr,mediaId);
      fetchMediaFile(id);
    }
    @Override public void onFailure(){
      WordPress.wpDB.updateMediaUploadState(blogIdStr,mediaId,"String_Node_Str");
      mUploadInProgress=false;
      sendUpdateBroadcast(mediaId);
      mHandler.post(mFetchQueueTask);
    }
  }
);
  WordPress.wpDB.updateMediaUploadState(blogIdStr,mediaId,"String_Node_Str");
  sendUpdateBroadcast(mediaId);
  List<Object> apiArgs=new ArrayList<Object>();
  apiArgs.add(WordPress.getCurrentBlog());
  task.execute(apiArgs);
  mHandler.post(mFetchQueueTask);
}

Fixed version (ground truth):
private void uploadMediaFile(Cursor cursor){
  if (!cursor.moveToFirst())   return;
  mUploadInProgress=true;
  final String blogIdStr=cursor.getString((cursor.getColumnIndex("String_Node_Str")));
  final String mediaId=cursor.getString(cursor.getColumnIndex("String_Node_Str"));
  String fileName=cursor.getString(cursor.getColumnIndex("String_Node_Str"));
  String filePath=cursor.getString(cursor.getColumnIndex("String_Node_Str"));
  String mimeType=cursor.getString(cursor.getColumnIndex("String_Node_Str"));
  MediaFile mediaFile=new MediaFile();
  mediaFile.setBlogId(blogIdStr);
  mediaFile.setFileName(fileName);
  mediaFile.setFilePath(filePath);
  mediaFile.setMIMEType(mimeType);
  ApiHelper.UploadMediaTask task=new ApiHelper.UploadMediaTask(mContext,mediaFile,new Callback(){
    @Override public void onSuccess(    String id){
      WordPress.wpDB.deleteMediaFile(blogIdStr,mediaId);
      sendUpdateBroadcast(mediaId);
      fetchMediaFile(id);
    }
    @Override public void onFailure(){
      WordPress.wpDB.updateMediaUploadState(blogIdStr,mediaId,"String_Node_Str");
      mUploadInProgress=false;
      sendUpdateBroadcast(mediaId);
      mHandler.post(mFetchQueueTask);
    }
  }
);
  WordPress.wpDB.updateMediaUploadState(blogIdStr,mediaId,"String_Node_Str");
  sendUpdateBroadcast(mediaId);
  List<Object> apiArgs=new ArrayList<Object>();
  apiArgs.add(WordPress.getCurrentBlog());
  task.execute(apiArgs);
  mHandler.post(mFetchQueueTask);
}
Program: 15046
Project: 15046
Buggy source:
@Override public void onCreate(){
  super.onCreate();
  post=WordPress.currentPost;
  context=this.getApplicationContext();
}

Fixed version (ground truth):
@Override public void onCreate(){
  super.onCreate();
  context=this.getApplicationContext();
}
Program: 15047
Project: 15047
Buggy source:
@Override public void onStart(Intent intent,int startId){
  if (post == null || context == null) {
    this.stopSelf();
    return;
  }
 else {
    new uploadPostTask().execute(post);
  }
}

Fixed version (ground truth):
@Override public void onStart(Intent intent,int startId){
  if (WordPress.currentPost == null || context == null) {
    this.stopSelf();
    return;
  }
 else {
    new uploadPostTask().execute(WordPress.currentPost);
  }
}
Program: 15048
Project: 15048
Buggy source:
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.addAll(savedInstanceState.getStringArrayList(BUNDLE_CHECKED_STATES));
    if (isInMultiSelectMode) {
      mListener.onMultiSelectChange(mCheckedItems.size());
      onMultiSelectChange(mCheckedItems.size());
    }
    mGridView.setMultiSelectModeEnabled(isInMultiSelectMode);
  }
  mGridView.setSelection(savedInstanceState.getInt(BUNDLE_SCROLL_POSITION,0));
  mHasRetrievedAllMedia=savedInstanceState.getBoolean(BUNDLE_HAS_RETREIEVED_ALL_MEDIA,false);
  mFilter=Filter.getFilter(savedInstanceState.getInt(BUNDLE_FILTER));
  mIsDateFilterSet=savedInstanceState.getBoolean(BUNDLE_DATE_FILTER_SET,false);
  mStartDay=savedInstanceState.getInt(BUNDLE_DATE_FILTER_START_DAY);
  mStartMonth=savedInstanceState.getInt(BUNDLE_DATE_FILTER_START_MONTH);
  mStartYear=savedInstanceState.getInt(BUNDLE_DATE_FILTER_START_YEAR);
  mEndDay=savedInstanceState.getInt(BUNDLE_DATE_FILTER_END_DAY);
  mEndMonth=savedInstanceState.getInt(BUNDLE_DATE_FILTER_END_MONTH);
  mEndYear=savedInstanceState.getInt(BUNDLE_DATE_FILTER_END_YEAR);
}

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.addAll(savedInstanceState.getStringArrayList(BUNDLE_CHECKED_STATES));
    if (isInMultiSelectMode) {
      mListener.onMultiSelectChange(mCheckedItems.size());
      onMultiSelectChange(mCheckedItems.size());
    }
    mGridView.setMultiSelectModeEnabled(isInMultiSelectMode);
  }
  mGridView.setSelection(savedInstanceState.getInt(BUNDLE_SCROLL_POSITION,0));
  mHasRetrievedAllMedia=savedInstanceState.getBoolean(BUNDLE_HAS_RETREIEVED_ALL_MEDIA,false);
  mFilter=Filter.getFilter(savedInstanceState.getInt(BUNDLE_FILTER));
  mIsDateFilterSet=savedInstanceState.getBoolean(BUNDLE_DATE_FILTER_SET,false);
  mStartDay=savedInstanceState.getInt(BUNDLE_DATE_FILTER_START_DAY);
  mStartMonth=savedInstanceState.getInt(BUNDLE_DATE_FILTER_START_MONTH);
  mStartYear=savedInstanceState.getInt(BUNDLE_DATE_FILTER_START_YEAR);
  mEndDay=savedInstanceState.getInt(BUNDLE_DATE_FILTER_END_DAY);
  mEndMonth=savedInstanceState.getInt(BUNDLE_DATE_FILTER_END_MONTH);
  mEndYear=savedInstanceState.getInt(BUNDLE_DATE_FILTER_END_YEAR);
  boolean datePickerShowing=savedInstanceState.getBoolean(BUNDLE_DATE_FILTER_VISIBLE);
  if (datePickerShowing)   showDatePicker();
}
Program: 15049
Project: 15049
Buggy source:
private void saveState(Bundle outState){
  outState.putStringArrayList(BUNDLE_CHECKED_STATES,mCheckedItems);
  outState.putInt(BUNDLE_SCROLL_POSITION,mGridView.getFirstVisiblePosition());
  outState.putBoolean(BUNDLE_HAS_RETREIEVED_ALL_MEDIA,mHasRetrievedAllMedia);
  outState.putBoolean(BUNDLE_IN_MULTI_SELECT_MODE,isInMultiSelect());
  outState.putInt(BUNDLE_FILTER,mFilter.ordinal());
  outState.putBoolean(BUNDLE_DATE_FILTER_SET,mIsDateFilterSet);
  outState.putInt(BUNDLE_DATE_FILTER_START_DAY,mStartDay);
  outState.putInt(BUNDLE_DATE_FILTER_START_MONTH,mStartMonth);
  outState.putInt(BUNDLE_DATE_FILTER_START_YEAR,mStartYear);
  outState.putInt(BUNDLE_DATE_FILTER_END_DAY,mEndDay);
  outState.putInt(BUNDLE_DATE_FILTER_END_MONTH,mEndMonth);
  outState.putInt(BUNDLE_DATE_FILTER_END_YEAR,mEndYear);
}

Fixed version (ground truth):
private void saveState(Bundle outState){
  outState.putStringArrayList(BUNDLE_CHECKED_STATES,mCheckedItems);
  outState.putInt(BUNDLE_SCROLL_POSITION,mGridView.getFirstVisiblePosition());
  outState.putBoolean(BUNDLE_HAS_RETREIEVED_ALL_MEDIA,mHasRetrievedAllMedia);
  outState.putBoolean(BUNDLE_IN_MULTI_SELECT_MODE,isInMultiSelect());
  outState.putInt(BUNDLE_FILTER,mFilter.ordinal());
  outState.putBoolean(BUNDLE_DATE_FILTER_SET,mIsDateFilterSet);
  outState.putBoolean(BUNDLE_DATE_FILTER_VISIBLE,(mDatePickerDialog != null && mDatePickerDialog.isShowing()));
  outState.putInt(BUNDLE_DATE_FILTER_START_DAY,mStartDay);
  outState.putInt(BUNDLE_DATE_FILTER_START_MONTH,mStartMonth);
  outState.putInt(BUNDLE_DATE_FILTER_START_YEAR,mStartYear);
  outState.putInt(BUNDLE_DATE_FILTER_END_DAY,mEndDay);
  outState.putInt(BUNDLE_DATE_FILTER_END_MONTH,mEndMonth);
  outState.putInt(BUNDLE_DATE_FILTER_END_YEAR,mEndYear);
}
Program: 15050
Project: 15050
Buggy source:
private Cursor filterItems(Filter filter){
  Blog blog=WordPress.getCurrentBlog();
  if (blog == null)   return null;
  String blogId=String.valueOf(blog.getBlogId());
switch (filter) {
case ALL:
    return WordPress.wpDB.getMediaFilesForBlog(blogId);
case IMAGES:
  return WordPress.wpDB.getMediaImagesForBlog(blogId);
case UNATTACHED:
return WordPress.wpDB.getMediaUnattachedForBlog(blogId);
case CUSTOM_DATE:
hideDatePicker();
if (mIsDateFilterSet) {
mIsDateFilterSet=false;
showDatePicker();
}
 else {
setDateFilter();
}
break;
}
return null;
}

Fixed version (ground truth):
private Cursor filterItems(Filter filter){
  Blog blog=WordPress.getCurrentBlog();
  if (blog == null)   return null;
  String blogId=String.valueOf(blog.getBlogId());
switch (filter) {
case ALL:
    return WordPress.wpDB.getMediaFilesForBlog(blogId);
case IMAGES:
  return WordPress.wpDB.getMediaImagesForBlog(blogId);
case UNATTACHED:
return WordPress.wpDB.getMediaUnattachedForBlog(blogId);
case CUSTOM_DATE:
if (mIsDateFilterSet) {
mIsDateFilterSet=false;
showDatePicker();
}
 else {
setDateFilter();
}
break;
}
return null;
}
Program: 15051
Project: 15051
Buggy source:
@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;
}

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()) {
        mSpinnerHasLaunched=true;
        mSpinner.performClick();
      }
    }
  }
);
  restoreState(savedInstanceState);
  setupSpinnerAdapter();
  return view;
}
Program: 15053
Project: 15053
Buggy source:
private void stopAnimatingRefreshButton(){
  if (mRefreshMenuItem != null)   stopAnimatingRefreshButton(mRefreshMenuItem);
  if (mAddMediaPopup != null)   mAddMediaPopup.dismiss();
}

Fixed version (ground truth):
private void stopAnimatingRefreshButton(){
  if (mRefreshMenuItem != null)   stopAnimatingRefreshButton(mRefreshMenuItem);
}
Program: 15054
Project: 15054
Buggy source:
@Override public void onMediaAdded(String mediaId){
  mMediaGridFragment.checkSelection(mediaId);
  mMediaGridFragment.refreshMediaFromDB();
}

Fixed version (ground truth):
@Override public void onMediaAdded(String mediaId){
  if (WordPress.getCurrentBlog() == null || mediaId == null)   return;
  String blogId=String.valueOf(WordPress.getCurrentBlog().getBlogId());
  Cursor cursor=WordPress.wpDB.getMediaFile(blogId,mediaId);
  if (cursor == null || !cursor.moveToFirst()) {
    mMediaGridFragment.removeFromMultiSelect(mediaId);
    mMediaGridFragment.refreshMediaFromDB();
    if (mMediaEditFragment != null && mMediaEditFragment.isVisible() && mediaId.equals(mMediaEditFragment.getMediaId())) {
      if (mMediaEditFragment.isInLayout()) {
        mMediaEditFragment.loadMedia(null);
      }
 else {
        getSupportFragmentManager().popBackStack();
      }
    }
    if (cursor != null)     cursor.close();
  }
 else {
    mMediaGridFragment.refreshMediaFromDB();
    cursor.close();
  }
}
Program: 15055
Project: 15055
Buggy source:
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);
}

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.addAll(savedInstanceState.getStringArrayList(BUNDLE_CHECKED_STATES));
    if (isInMultiSelectMode) {
      mListener.onMultiSelectChange(mCheckedItems.size());
      onMultiSelectChange(mCheckedItems.size());
    }
    mGridView.setMultiSelectModeEnabled(isInMultiSelectMode);
  }
  mGridView.setSelection(savedInstanceState.getInt(BUNDLE_SCROLL_POSITION,0));
  mHasRetrievedAllMedia=savedInstanceState.getBoolean(BUNDLE_HAS_RETREIEVED_ALL_MEDIA,false);
  mFilter=Filter.getFilter(savedInstanceState.getInt(BUNDLE_FILTER));
}
Program: 15056
Project: 15056
Buggy source:
private void setupSpinnerAdapter(){
  if (getActivity() == null || WordPress.getCurrentBlog() == null)   return;
  updateFilterText();
  Context context=((WPActionBarActivity)getActivity()).getSupportActionBar().getThemedContext();
  ArrayAdapter<String> adapter=new ArrayAdapter<String>(context,R.layout.sherlock_spinner_dropdown_item,mFiltersText);
  mSpinner.setAdapter(adapter);
}

Fixed version (ground truth):
private void setupSpinnerAdapter(){
  if (getActivity() == null || WordPress.getCurrentBlog() == null)   return;
  updateFilterText();
  Context context=((WPActionBarActivity)getActivity()).getSupportActionBar().getThemedContext();
  ArrayAdapter<String> adapter=new ArrayAdapter<String>(context,R.layout.sherlock_spinner_dropdown_item,mFiltersText);
  mSpinner.setAdapter(adapter);
  mSpinner.setSelection(mFilter.ordinal());
}
Program: 15057
Project: 15057
Buggy source:
private void saveState(Bundle outState){
  outState.putStringArrayList(BUNDLE_CHECKED_STATES,mCheckedItems);
  outState.putInt(BUNDLE_SCROLL_POSITION,mGridView.getFirstVisiblePosition());
  outState.putBoolean(BUNDLE_HAS_RETREIEVED_ALL_MEDIA,mHasRetrievedAllMedia);
  outState.putBoolean(BUNDLE_IN_MULTI_SELECT_MODE,isInMultiSelect());
}

Fixed version (ground truth):
private void saveState(Bundle outState){
  outState.putStringArrayList(BUNDLE_CHECKED_STATES,mCheckedItems);
  outState.putInt(BUNDLE_SCROLL_POSITION,mGridView.getFirstVisiblePosition());
  outState.putBoolean(BUNDLE_HAS_RETREIEVED_ALL_MEDIA,mHasRetrievedAllMedia);
  outState.putBoolean(BUNDLE_IN_MULTI_SELECT_MODE,isInMultiSelect());
  outState.putInt(BUNDLE_FILTER,mFilter.ordinal());
}
Program: 15058
Project: 15058
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);
  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));
  }
}

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;
  Cursor cursor=WordPress.wpDB.getMediaFilesForBlog(blogId,startDate.getTimeInMillis(),endDate.getTimeInMillis() + one_day);
  mGridAdapter.swapCursor(cursor);
  if (cursor != null && cursor.moveToFirst()) {
    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));
  }
}