nus-yam/ex-repair huggingface dataset:
Program: 13778
Project: 13778
Buggy source:
private void fetchSiteSettingsAndUpdateDefaultPostFormatIfNecessary(){
  if (!TextUtils.isEmpty(getPost().getPostFormat())) {
    return;
  }
  mSiteSettings=SiteSettingsInterface.getInterface(getActivity(),getSite(),new SiteSettingsListener(){
    @Override public void onSettingsUpdated(    Exception error){
      if (error == null) {
        updatePostFormat(mSiteSettings.getDefaultPostFormat());
      }
    }
    @Override public void onSettingsSaved(    Exception error){
    }
    @Override public void onCredentialsValidated(    Exception error){
    }
  }
);
  if (mSiteSettings != null) {
    mSiteSettings.init(true);
  }
}

Fixed version (ground truth):
private void fetchSiteSettingsAndUpdateDefaultPostFormatIfNecessary(){
  if (!TextUtils.isEmpty(getPost().getPostFormat())) {
    return;
  }
  mSiteSettings=SiteSettingsInterface.getInterface(getActivity(),getSite(),new SiteSettingsListener(){
    @Override public void onSettingsUpdated(    Exception error){
      if (error == null && mEditPostActivityHook != null) {
        updatePostFormat(mSiteSettings.getDefaultPostFormat());
      }
    }
    @Override public void onSettingsSaved(    Exception error){
    }
    @Override public void onCredentialsValidated(    Exception error){
    }
  }
);
  if (mSiteSettings != null) {
    mSiteSettings.init(true);
  }
}
Program: 13780
Project: 13780
Buggy source:
@Override public void run(){
  getActivity().invalidateOptionsMenu();
}

Fixed version (ground truth):
@Override public void run(){
  if (isAdded()) {
    getActivity().invalidateOptionsMenu();
  }
}
Program: 13782
Project: 13782
Buggy source:
@Override public void onResponse(ImageLoader.ImageContainer container,boolean isImmediate){
  Bitmap downloadedBitmap=container.getBitmap();
  if (downloadedBitmap == null) {
    return;
  }
  AztecAttributes attributes=new AztecAttributes();
  attributes.setValue(ATTR_SRC,mediaUrl);
  setAttributeValuesIfNotDefault(attributes,mediaFile);
  int minimumDimension=DisplayUtils.dpToPx(getActivity(),MIN_BITMAP_DIMENSION_DP);
  if (downloadedBitmap.getHeight() < minimumDimension || downloadedBitmap.getWidth() < minimumDimension) {
    ToastUtils.showToast(getActivity(),R.string.error_media_small);
    Drawable drawable=getResources().getDrawable(R.drawable.ic_image_loading_grey_a_40_48dp);
    content.insertImage(drawable,attributes);
    return;
  }
  Bitmap resizedBitmap=ImageUtils.getScaledBitmapAtLongestSide(downloadedBitmap,DisplayUtils.getDisplayPixelWidth(getActivity()));
  content.insertImage(new BitmapDrawable(getResources(),resizedBitmap),attributes);
}

Fixed version (ground truth):
@Override public void onResponse(ImageLoader.ImageContainer container,boolean isImmediate){
  Bitmap downloadedBitmap=container.getBitmap();
  if (downloadedBitmap == null || !isAdded()) {
    return;
  }
  AztecAttributes attributes=new AztecAttributes();
  attributes.setValue(ATTR_SRC,mediaUrl);
  setAttributeValuesIfNotDefault(attributes,mediaFile);
  int minimumDimension=DisplayUtils.dpToPx(getActivity(),MIN_BITMAP_DIMENSION_DP);
  if (downloadedBitmap.getHeight() < minimumDimension || downloadedBitmap.getWidth() < minimumDimension) {
    ToastUtils.showToast(getActivity(),R.string.error_media_small);
    Drawable drawable=getResources().getDrawable(R.drawable.ic_image_loading_grey_a_40_48dp);
    content.insertImage(drawable,attributes);
    return;
  }
  Bitmap resizedBitmap=ImageUtils.getScaledBitmapAtLongestSide(downloadedBitmap,DisplayUtils.getDisplayPixelWidth(getActivity()));
  content.insertImage(new BitmapDrawable(getResources(),resizedBitmap),attributes);
}
Program: 13784
Project: 13784
Buggy source:
@Override public void onErrorResponse(VolleyError error){
  ToastUtils.showToast(getActivity(),R.string.error_media_load);
  Drawable drawable=getResources().getDrawable(R.drawable.ic_image_failed_grey_a_40_48dp);
  AztecAttributes attributes=new AztecAttributes();
  attributes.setValue(ATTR_SRC,mediaUrl);
  setAttributeValuesIfNotDefault(attributes,mediaFile);
  content.insertImage(drawable,attributes);
}

Fixed version (ground truth):
@Override public void onErrorResponse(VolleyError error){
  if (!isAdded()) {
    return;
  }
  ToastUtils.showToast(getActivity(),R.string.error_media_load);
  Drawable drawable=getResources().getDrawable(R.drawable.ic_image_failed_grey_a_40_48dp);
  AztecAttributes attributes=new AztecAttributes();
  attributes.setValue(ATTR_SRC,mediaUrl);
  setAttributeValuesIfNotDefault(attributes,mediaFile);
  content.insertImage(drawable,attributes);
}
Program: 13786
Project: 13786
Buggy source:
private void handleMediaUploadCompletedLegacy(OnMediaUploaded event){
  if (sCurrentUploadingPost == null || mMediaLatchMap.get(event.media.getId()) == null) {
    AppLog.i(T.POSTS,"String_Node_Str" + event.media.getId() + "String_Node_Str");
    return;
  }
  if (event.isError()) {
    AppLog.w(T.POSTS,"String_Node_Str" + event.error.type + "String_Node_Str"+ event.error.message);
    SiteModel site=mSiteStore.getSiteByLocalId(sCurrentUploadingPost.getLocalSiteId());
    Context context=WordPress.getContext();
    String errorMessage=UploadUtils.getErrorMessageFromMediaError(context,event.error);
    String notificationMessage=UploadUtils.getErrorMessage(context,sCurrentUploadingPost,errorMessage);
    mPostUploadNotifier.updateNotificationError(sCurrentUploadingPost,site,notificationMessage,true);
    sFirstPublishPosts.remove(sCurrentUploadingPost.getId());
    finishUpload();
    return;
  }
  if (event.canceled) {
    return;
  }
  if (event.completed) {
    AppLog.i(T.POSTS,"String_Node_Str" + event.media.getId() + "String_Node_Str"+ sCurrentUploadingPost.getId());
    mMediaLatchMap.get(event.media.getId()).countDown();
    mMediaLatchMap.remove(event.media.getId());
  }
 else {
    mPostUploadNotifier.updateNotificationProgress(sCurrentUploadingPost,event.progress);
  }
}

Fixed version (ground truth):
private void handleMediaUploadCompletedLegacy(OnMediaUploaded event){
  if (sCurrentUploadingPost == null || mMediaLatchMap.get(event.media.getId()) == null) {
    AppLog.i(T.POSTS,"String_Node_Str" + event.media.getId() + "String_Node_Str");
    return;
  }
  if (event.isError()) {
    AppLog.w(T.POSTS,"String_Node_Str" + event.error.type + "String_Node_Str"+ event.error.message);
    SiteModel site=mSiteStore.getSiteByLocalId(sCurrentUploadingPost.getLocalSiteId());
    Context context=WordPress.getContext();
    String errorMessage=UploadUtils.getErrorMessageFromMediaError(context,event.error);
    String notificationMessage=UploadUtils.getErrorMessage(context,sCurrentUploadingPost,errorMessage);
    mPostUploadNotifier.cancelNotification(sCurrentUploadingPost);
    mPostUploadNotifier.updateNotificationError(sCurrentUploadingPost,site,notificationMessage,true);
    sFirstPublishPosts.remove(sCurrentUploadingPost.getId());
    finishUpload();
    return;
  }
  if (event.canceled) {
    return;
  }
  if (event.completed) {
    AppLog.i(T.POSTS,"String_Node_Str" + event.media.getId() + "String_Node_Str"+ sCurrentUploadingPost.getId());
    mMediaLatchMap.get(event.media.getId()).countDown();
    mMediaLatchMap.remove(event.media.getId());
  }
 else {
    mPostUploadNotifier.updateNotificationProgress(sCurrentUploadingPost,event.progress);
  }
}
Program: 13787
Project: 13787
Buggy source:
@Override protected void onPostExecute(Boolean pushActionWasDispatched){
  if (!pushActionWasDispatched) {
    mPostUploadNotifier.updateNotificationError(mPost,mSite,mErrorMessage,mIsMediaError);
    finishUpload();
  }
}

Fixed version (ground truth):
@Override protected void onPostExecute(Boolean pushActionWasDispatched){
  if (!pushActionWasDispatched) {
    mPostUploadNotifier.cancelNotification(mPost);
    mPostUploadNotifier.updateNotificationError(mPost,mSite,mErrorMessage,mIsMediaError);
    finishUpload();
  }
}
Program: 13788
Project: 13788
Buggy source:
@Override public void saveSettings(){
  super.saveSettings();
  final Map<String,String> params=serializeDotComParams();
  if (params == null || params.isEmpty())   return;
  WordPress.getRestClientUtils().setGeneralSiteSettings(mSite.getSiteId(),new RestRequest.Listener(){
    @Override public void onResponse(    JSONObject response){
      AppLog.d(AppLog.T.API,"String_Node_Str");
      notifySavedOnUiThread(null);
      mRemoteSettings.copyFrom(mSettings);
      if (response != null) {
        JSONObject updated=response.optJSONObject("String_Node_Str");
        if (updated == null)         return;
        HashMap<String,Object> properties=new HashMap<>();
        Iterator<String> keys=updated.keys();
        while (keys.hasNext()) {
          String currentKey=keys.next();
          Object currentValue=updated.opt(currentKey);
          if (currentValue != null) {
            properties.put(SAVED_ITEM_PREFIX + currentKey,currentValue);
          }
        }
        AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat.SITE_SETTINGS_SAVED_REMOTELY,mSite,properties);
      }
      if (mSite.isJetpackConnected()) {
        saveJetpackSettings();
      }
    }
  }
,new RestRequest.ErrorListener(){
    @Override public void onErrorResponse(    VolleyError error){
      AppLog.w(AppLog.T.API,"String_Node_Str" + error);
      notifySavedOnUiThread(error);
    }
  }
,params);
}

Fixed version (ground truth):
@Override public void saveSettings(){
  super.saveSettings();
  if (mSite.isJetpackConnected()) {
    saveJetpackSettings();
  }
  final Map<String,String> params=serializeDotComParams();
  if (params == null || params.isEmpty())   return;
  WordPress.getRestClientUtils().setGeneralSiteSettings(mSite.getSiteId(),new RestRequest.Listener(){
    @Override public void onResponse(    JSONObject response){
      AppLog.d(AppLog.T.API,"String_Node_Str");
      notifySavedOnUiThread(null);
      mRemoteSettings.copyFrom(mSettings);
      if (response != null) {
        JSONObject updated=response.optJSONObject("String_Node_Str");
        if (updated == null)         return;
        HashMap<String,Object> properties=new HashMap<>();
        Iterator<String> keys=updated.keys();
        while (keys.hasNext()) {
          String currentKey=keys.next();
          Object currentValue=updated.opt(currentKey);
          if (currentValue != null) {
            properties.put(SAVED_ITEM_PREFIX + currentKey,currentValue);
          }
        }
        AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat.SITE_SETTINGS_SAVED_REMOTELY,mSite,properties);
      }
    }
  }
,new RestRequest.ErrorListener(){
    @Override public void onErrorResponse(    VolleyError error){
      AppLog.w(AppLog.T.API,"String_Node_Str" + error);
      notifySavedOnUiThread(error);
    }
  }
,params);
}
Program: 13791
Project: 13791
Buggy source:
@Override public void onBindViewHolder(ConnectionViewHolder holder,int position){
  final PublicizeConnection connection=mConnections.get(position);
  holder.txtUser.setText(connection.getExternalDisplayName());
  holder.divider.setVisibility(position == 0 ? View.GONE : View.VISIBLE);
  if (connection.hasExternalProfilePictureUrl()) {
    holder.imgAvatar.setImageUrl(connection.getExternalProfilePictureUrl(),WPNetworkImageView.ImageType.AVATAR);
  }
 else {
    holder.imgAvatar.showDefaultGravatarImage();
  }
  holder.btnConnect.setAction(PublicizeConstants.ConnectAction.DISCONNECT);
  holder.btnConnect.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      if (mActionListener != null) {
        mActionListener.onRequestDisconnect(connection);
      }
    }
  }
);
}

Fixed version (ground truth):
@Override public void onBindViewHolder(ConnectionViewHolder holder,int position){
  final PublicizeConnection connection=mConnections.get(position);
  holder.txtUser.setText(connection.getExternalDisplayName());
  holder.divider.setVisibility(position == 0 ? View.GONE : View.VISIBLE);
  if (connection.hasExternalProfilePictureUrl()) {
    holder.imgAvatar.setImageUrl(connection.getExternalProfilePictureUrl(),WPNetworkImageView.ImageType.AVATAR);
  }
 else {
    holder.imgAvatar.showDefaultGravatarImageAndNullifyUrl();
  }
  holder.btnConnect.setAction(PublicizeConstants.ConnectAction.DISCONNECT);
  holder.btnConnect.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      if (mActionListener != null) {
        mActionListener.onRequestDisconnect(connection);
      }
    }
  }
);
}
Program: 13793
Project: 13793
Buggy source:
private void renderXPost(int position,ReaderXPostViewHolder holder){
  final ReaderPost post=getItem(position);
  if (post == null) {
    return;
  }
  if (post.hasPostAvatar()) {
    holder.imgAvatar.setImageUrl(GravatarUtils.fixGravatarUrl(post.getPostAvatar(),mAvatarSzSmall),WPNetworkImageView.ImageType.AVATAR);
  }
 else {
    holder.imgAvatar.showDefaultGravatarImage();
  }
  if (post.hasBlogImageUrl()) {
    holder.imgBlavatar.setImageUrl(GravatarUtils.fixGravatarUrl(post.getBlogImageUrl(),mAvatarSzSmall),WPNetworkImageView.ImageType.BLAVATAR);
  }
 else {
    holder.imgBlavatar.showDefaultBlavatarImage();
  }
  holder.txtTitle.setText(ReaderXPostUtils.getXPostTitle(post));
  holder.txtSubtitle.setText(ReaderXPostUtils.getXPostSubtitleHtml(post));
  checkLoadMore(position);
}

Fixed version (ground truth):
private void renderXPost(int position,ReaderXPostViewHolder holder){
  final ReaderPost post=getItem(position);
  if (post == null) {
    return;
  }
  if (post.hasPostAvatar()) {
    holder.imgAvatar.setImageUrl(GravatarUtils.fixGravatarUrl(post.getPostAvatar(),mAvatarSzSmall),WPNetworkImageView.ImageType.AVATAR);
  }
 else {
    holder.imgAvatar.showDefaultGravatarImageAndNullifyUrl();
  }
  if (post.hasBlogImageUrl()) {
    holder.imgBlavatar.setImageUrl(GravatarUtils.fixGravatarUrl(post.getBlogImageUrl(),mAvatarSzSmall),WPNetworkImageView.ImageType.BLAVATAR);
  }
 else {
    holder.imgBlavatar.showDefaultBlavatarImageAndNullifyUrl();
  }
  holder.txtTitle.setText(ReaderXPostUtils.getXPostTitle(post));
  holder.txtSubtitle.setText(ReaderXPostUtils.getXPostSubtitleHtml(post));
  checkLoadMore(position);
}
Program: 13795
Project: 13795
Buggy source:
@Override public void onBindViewHolder(UserViewHolder holder,int position){
  final ReaderUser user=mUsers.get(position);
  holder.txtName.setText(user.getDisplayName());
  if (user.hasUrl()) {
    holder.txtUrl.setVisibility(View.VISIBLE);
    holder.txtUrl.setText(user.getUrlDomain());
    holder.itemView.setOnClickListener(new View.OnClickListener(){
      @Override public void onClick(      View v){
        if (user.hasBlogId()) {
          ReaderActivityLauncher.showReaderBlogPreview(v.getContext(),user.blogId);
        }
      }
    }
);
  }
 else {
    holder.txtUrl.setVisibility(View.GONE);
    holder.itemView.setOnClickListener(null);
  }
  if (user.hasAvatarUrl()) {
    holder.imgAvatar.setImageUrl(GravatarUtils.fixGravatarUrl(user.getAvatarUrl(),mAvatarSz),WPNetworkImageView.ImageType.AVATAR);
  }
 else {
    holder.imgAvatar.showDefaultGravatarImage();
  }
}

Fixed version (ground truth):
@Override public void onBindViewHolder(UserViewHolder holder,int position){
  final ReaderUser user=mUsers.get(position);
  holder.txtName.setText(user.getDisplayName());
  if (user.hasUrl()) {
    holder.txtUrl.setVisibility(View.VISIBLE);
    holder.txtUrl.setText(user.getUrlDomain());
    holder.itemView.setOnClickListener(new View.OnClickListener(){
      @Override public void onClick(      View v){
        if (user.hasBlogId()) {
          ReaderActivityLauncher.showReaderBlogPreview(v.getContext(),user.blogId);
        }
      }
    }
);
  }
 else {
    holder.txtUrl.setVisibility(View.GONE);
    holder.itemView.setOnClickListener(null);
  }
  if (user.hasAvatarUrl()) {
    holder.imgAvatar.setImageUrl(GravatarUtils.fixGravatarUrl(user.getAvatarUrl(),mAvatarSz),WPNetworkImageView.ImageType.AVATAR);
  }
 else {
    holder.imgAvatar.showDefaultGravatarImageAndNullifyUrl();
  }
}
Program: 13796
Project: 13796
Buggy source:
public void showDefaultGravatarImage(){
  if (getContext() == null)   return;
  try {
    new ShapeBitmapTask(ShapeType.CIRCLE,null).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,BitmapFactory.decodeResource(getContext().getResources(),R.drawable.ic_placeholder_gravatar_grey_lighten_20_100dp));
  }
 catch (  RejectedExecutionException e) {
    AppLog.w(AppLog.T.UTILS,"String_Node_Str" + "String_Node_Str");
    return;
  }
}

Fixed version (ground truth):
private void showDefaultGravatarImage(){
  if (getContext() == null)   return;
  try {
    new ShapeBitmapTask(ShapeType.CIRCLE,null).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,BitmapFactory.decodeResource(getContext().getResources(),R.drawable.ic_placeholder_gravatar_grey_lighten_20_100dp));
  }
 catch (  RejectedExecutionException e) {
    AppLog.w(AppLog.T.UTILS,"String_Node_Str" + "String_Node_Str");
  }
}
Program: 13797
Project: 13797
Buggy source:
public void showDefaultBlavatarImage(){
  setImageResource(R.drawable.ic_placeholder_blavatar_grey_lighten_20_40dp);
}

Fixed version (ground truth):
private void showDefaultBlavatarImage(){
  setImageResource(R.drawable.ic_placeholder_blavatar_grey_lighten_20_40dp);
}
Program: 13798
Project: 13798
Buggy source:
ThemeViewHolder(View view){
  cardView=(CardView)view.findViewById(R.id.theme_grid_card);
  imageView=(NetworkImageView)view.findViewById(R.id.theme_grid_item_image);
  nameView=(TextView)view.findViewById(R.id.theme_grid_item_name);
  priceView=(TextView)view.findViewById(R.id.theme_grid_item_price);
  activeView=(TextView)view.findViewById(R.id.theme_grid_item_active);
  imageButton=(ImageButton)view.findViewById(R.id.theme_grid_item_image_button);
  frameLayout=(FrameLayout)view.findViewById(R.id.theme_grid_item_image_layout);
  detailsView=(RelativeLayout)view.findViewById(R.id.theme_grid_item_details);
}

Fixed version (ground truth):
ThemeViewHolder(View view){
  cardView=(CardView)view.findViewById(R.id.theme_grid_card);
  imageView=(WPNetworkImageView)view.findViewById(R.id.theme_grid_item_image);
  nameView=(TextView)view.findViewById(R.id.theme_grid_item_name);
  priceView=(TextView)view.findViewById(R.id.theme_grid_item_price);
  activeView=(TextView)view.findViewById(R.id.theme_grid_item_active);
  imageButton=(ImageButton)view.findViewById(R.id.theme_grid_item_image_button);
  frameLayout=(FrameLayout)view.findViewById(R.id.theme_grid_item_image_layout);
  detailsView=(RelativeLayout)view.findViewById(R.id.theme_grid_item_details);
}
Program: 13799
Project: 13799
Buggy source:
private void configureImageView(ThemeViewHolder themeViewHolder,String screenshotURL,final String themeId,final boolean isCurrent){
  String requestURL=(String)themeViewHolder.imageView.getTag();
  if (requestURL == null) {
    requestURL=screenshotURL;
    themeViewHolder.imageView.setDefaultImageResId(R.drawable.theme_loading);
    themeViewHolder.imageView.setTag(requestURL);
  }
  if (!requestURL.equals(screenshotURL)) {
    requestURL=screenshotURL;
  }
  themeViewHolder.imageView.setImageUrl(requestURL + THEME_IMAGE_PARAMETER + mViewWidth,WordPress.sImageLoader);
  themeViewHolder.frameLayout.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      if (isCurrent) {
        mCallback.onTryAndCustomizeSelected(themeId);
      }
 else {
        mCallback.onViewSelected(themeId);
      }
    }
  }
);
}

Fixed version (ground truth):
private void configureImageView(ThemeViewHolder themeViewHolder,String screenshotURL,final String themeId,final boolean isCurrent){
  String requestURL=(String)themeViewHolder.imageView.getTag();
  if (requestURL == null) {
    requestURL=screenshotURL;
    themeViewHolder.imageView.setDefaultImageResId(R.drawable.theme_loading);
    themeViewHolder.imageView.setTag(requestURL);
  }
  if (!requestURL.equals(screenshotURL)) {
    requestURL=screenshotURL;
  }
  themeViewHolder.imageView.setImageUrl(requestURL + THEME_IMAGE_PARAMETER + mViewWidth,WPNetworkImageView.ImageType.PHOTO);
  themeViewHolder.frameLayout.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      if (isCurrent) {
        mCallback.onTryAndCustomizeSelected(themeId);
      }
 else {
        mCallback.onViewSelected(themeId);
      }
    }
  }
);
}
Program: 13800
Project: 13800
Buggy source:
@Override public void onMovedToScrapHeap(View view){
  NetworkImageView niv=(NetworkImageView)view.findViewById(R.id.theme_grid_item_image);
  if (niv != null) {
    String requestUrl=(String)niv.getTag();
    if (requestUrl != null) {
      ImageContainer container=WordPress.sImageLoader.get(requestUrl,new ImageListener(){
        @Override public void onErrorResponse(        VolleyError error){
        }
        @Override public void onResponse(        ImageContainer response,        boolean isImmediate){
        }
      }
);
      container.cancelRequest();
    }
  }
}

Fixed version (ground truth):
@Override public void onMovedToScrapHeap(View view){
  WPNetworkImageView niv=(WPNetworkImageView)view.findViewById(R.id.theme_grid_item_image);
  if (niv != null) {
    String requestUrl=(String)niv.getTag();
    if (requestUrl != null) {
      ImageContainer container=WordPress.sImageLoader.get(requestUrl,new ImageListener(){
        @Override public void onErrorResponse(        VolleyError error){
        }
        @Override public void onResponse(        ImageContainer response,        boolean isImmediate){
        }
      }
);
      container.cancelRequest();
    }
  }
}
Program: 13801
Project: 13801
Buggy source:
@SuppressWarnings("String_Node_Str") @Subscribe(threadMode=ThreadMode.MAIN) public void onMediaUploaded(OnMediaUploaded event){
  if (event.isError()) {
    AppLog.d(AppLog.T.MEDIA,"String_Node_Str" + event.error.type + "String_Node_Str"+ event.error.message);
    String errorMessage=WPMediaUtils.getErrorMessage(this,WPMediaUtils.isImageOptimizationEnabled(this,mSite),event.media,event.error);
    if (errorMessage != null) {
      ToastUtils.showToast(this,errorMessage,ToastUtils.Duration.LONG);
    }
 else {
      showMediaToastError(R.string.media_upload_error,event.error.message);
    }
    updateViews();
  }
 else   if (event.completed) {
    String title="String_Node_Str";
    if (event.media != null) {
      title=event.media.getTitle();
    }
    AppLog.d(AppLog.T.MEDIA,"String_Node_Str" + title + "String_Node_Str");
    updateViews();
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Subscribe(threadMode=ThreadMode.MAIN) public void onMediaUploaded(OnMediaUploaded event){
  if (event.isError()) {
    AppLog.d(AppLog.T.MEDIA,"String_Node_Str" + event.error.type + "String_Node_Str"+ event.error.message);
    String errorMessage=WPMediaUtils.getErrorMessage(this,mSite,event.media,event.error);
    if (errorMessage != null) {
      ToastUtils.showToast(this,errorMessage,ToastUtils.Duration.LONG);
    }
 else {
      showMediaToastError(R.string.media_upload_error,event.error.message);
    }
    updateViews();
  }
 else   if (event.completed) {
    String title="String_Node_Str";
    if (event.media != null) {
      title=event.media.getTitle();
    }
    AppLog.d(AppLog.T.MEDIA,"String_Node_Str" + title + "String_Node_Str");
    updateViews();
  }
}
Program: 13802
Project: 13802
Buggy source:
private void onUploadError(MediaModel media,MediaStore.MediaError error){
  String localMediaId=String.valueOf(media.getId());
  Map<String,Object> properties=null;
  MediaFile mf=FluxCUtils.mediaFileFromMediaModel(media);
  if (mf != null) {
    properties=AnalyticsUtils.getMediaProperties(this,mf.isVideo(),null,mf.getFilePath());
    properties.put("String_Node_Str",error.type.name());
  }
  AnalyticsTracker.track(Stat.EDITOR_UPLOAD_MEDIA_FAILED,properties);
  String errorMessage=WPMediaUtils.getErrorMessage(this,WPMediaUtils.isImageOptimizationEnabled(this,mSite),media,error);
  if (errorMessage == null) {
    errorMessage=TextUtils.isEmpty(error.message) ? getString(R.string.tap_to_try_again) : error.message;
  }
  if (mEditorMediaUploadListener != null) {
    mEditorMediaUploadListener.onMediaUploadFailed(localMediaId,errorMessage);
  }
  removeMediaFromPendingList(media);
}

Fixed version (ground truth):
private void onUploadError(MediaModel media,MediaStore.MediaError error){
  String localMediaId=String.valueOf(media.getId());
  Map<String,Object> properties=null;
  MediaFile mf=FluxCUtils.mediaFileFromMediaModel(media);
  if (mf != null) {
    properties=AnalyticsUtils.getMediaProperties(this,mf.isVideo(),null,mf.getFilePath());
    properties.put("String_Node_Str",error.type.name());
  }
  AnalyticsTracker.track(Stat.EDITOR_UPLOAD_MEDIA_FAILED,properties);
  String errorMessage=WPMediaUtils.getErrorMessage(this,mSite,media,error);
  if (errorMessage == null) {
    errorMessage=TextUtils.isEmpty(error.message) ? getString(R.string.tap_to_try_again) : error.message;
  }
  if (mEditorMediaUploadListener != null) {
    mEditorMediaUploadListener.onMediaUploadFailed(localMediaId,errorMessage);
  }
  removeMediaFromPendingList(media);
}
Program: 13803
Project: 13803
Buggy source:
private @NonNull String getErrorMessageFromMediaError(OnMediaUploaded event){
  String errorMessage=WPMediaUtils.getErrorMessage(mContext,true,event.media,event.error);
  if (errorMessage == null) {
    errorMessage=TextUtils.isEmpty(event.error.message) ? event.error.type.toString() : event.error.message;
  }
  return errorMessage;
}

Fixed version (ground truth):
private @NonNull String getErrorMessageFromMediaError(OnMediaUploaded event){
  String errorMessage=WPMediaUtils.getErrorMessage(mContext,true,true,event.media,event.error);
  if (errorMessage == null) {
    errorMessage=TextUtils.isEmpty(event.error.message) ? event.error.type.toString() : event.error.message;
  }
  return errorMessage;
}
Program: 13807
Project: 13807
Buggy source:
@Override public void onMediaUploadSucceeded(final String localMediaId,final MediaFile mediaFile){
  if (!isAdded()) {
    return;
  }
  final MediaType mediaType=mUploadingMedia.get(localMediaId);
  if (mediaType != null) {
    String remoteUrl=Utils.escapeQuotes(mediaFile.getFileURL());
    if (mediaType.equals(MediaType.IMAGE)) {
      AztecAttributes attrs=new AztecAttributes();
      attrs.setValue(ATTR_SRC,remoteUrl);
      addDefaultSizeClassIfMissing(attrs);
      ImagePredicate predicate=ImagePredicate.getLocalMediaIdPredicate(localMediaId);
      content.clearOverlays(predicate);
      content.updateElementAttributes(predicate,attrs);
      content.refreshText();
      mUploadingMedia.remove(localMediaId);
    }
 else     if (mediaType.equals(MediaType.VIDEO)) {
    }
  }
}

Fixed version (ground truth):
@Override public void onMediaUploadSucceeded(final String localMediaId,final MediaFile mediaFile){
  if (!isAdded()) {
    return;
  }
  final MediaType mediaType=mUploadingMedia.get(localMediaId);
  if (mediaType != null) {
    String remoteUrl=Utils.escapeQuotes(mediaFile.getFileURL());
    if (mediaType.equals(MediaType.IMAGE)) {
      AztecAttributes attrs=new AztecAttributes();
      attrs.setValue(ATTR_SRC,remoteUrl);
      addDefaultSizeClassIfMissing(attrs);
      ImagePredicate predicate=ImagePredicate.getLocalMediaIdPredicate(localMediaId);
      content.resetAttributedMediaSpan(predicate);
      content.clearOverlays(predicate);
      content.updateElementAttributes(predicate,attrs);
      mUploadingMedia.remove(localMediaId);
    }
 else     if (mediaType.equals(MediaType.VIDEO)) {
    }
  }
}
Program: 13808
Project: 13808
Buggy source:
@Override public void onMediaUploadProgress(final String localMediaId,final float progress){
  if (!isAdded()) {
    return;
  }
  final MediaType mediaType=mUploadingMedia.get(localMediaId);
  if (mediaType != null) {
    AztecText.AttributePredicate localMediaIdPredicate=ImagePredicate.getLocalMediaIdPredicate(localMediaId);
    content.setOverlayLevel(localMediaIdPredicate,1,(int)(progress * 10000));
    content.refreshText();
  }
}

Fixed version (ground truth):
@Override public void onMediaUploadProgress(final String localMediaId,final float progress){
  if (!isAdded()) {
    return;
  }
  final MediaType mediaType=mUploadingMedia.get(localMediaId);
  if (mediaType != null) {
    AztecText.AttributePredicate localMediaIdPredicate=ImagePredicate.getLocalMediaIdPredicate(localMediaId);
    content.setOverlayLevel(localMediaIdPredicate,1,(int)(progress * 10000));
    content.resetAttributedMediaSpan(localMediaIdPredicate);
  }
}
Program: 13809
Project: 13809
Buggy source:
@Override public void onMediaUploadFailed(final String localMediaId,final String errorMessage){
  if (!isAdded()) {
    return;
  }
  MediaType mediaType=mUploadingMedia.get(localMediaId);
  if (mediaType != null) {
switch (mediaType) {
case IMAGE:
      AttributesWithClass attributesWithClass=new AttributesWithClass(content.getElementAttributes(ImagePredicate.getLocalMediaIdPredicate(localMediaId)));
    attributesWithClass.removeClass(ATTR_STATUS_UPLOADING);
  attributesWithClass.addClass(ATTR_STATUS_FAILED);
overlayFailedMedia(localMediaId,attributesWithClass.getAttributes());
content.refreshText();
break;
case VIDEO:
}
mFailedMediaIds.add(localMediaId);
mUploadingMedia.remove(localMediaId);
}
}

Fixed version (ground truth):
@Override public void onMediaUploadFailed(final String localMediaId,final String errorMessage){
  if (!isAdded()) {
    return;
  }
  MediaType mediaType=mUploadingMedia.get(localMediaId);
  if (mediaType != null) {
switch (mediaType) {
case IMAGE:
      ImagePredicate localMediaIdPredicate=ImagePredicate.getLocalMediaIdPredicate(localMediaId);
    AttributesWithClass attributesWithClass=new AttributesWithClass(content.getElementAttributes(localMediaIdPredicate));
  attributesWithClass.removeClass(ATTR_STATUS_UPLOADING);
attributesWithClass.addClass(ATTR_STATUS_FAILED);
overlayFailedMedia(localMediaId,attributesWithClass.getAttributes());
content.resetAttributedMediaSpan(localMediaIdPredicate);
break;
case VIDEO:
}
mFailedMediaIds.add(localMediaId);
mUploadingMedia.remove(localMediaId);
}
}
Program: 13813
Project: 13813
Buggy source:
@Override public void onMediaUploadSucceeded(final String localMediaId,final MediaFile mediaFile){
  if (!isAdded()) {
    return;
  }
  final MediaType mediaType=mUploadingMedia.get(localMediaId);
  if (mediaType != null) {
    String remoteUrl=Utils.escapeQuotes(mediaFile.getFileURL());
    if (mediaType.equals(MediaType.IMAGE)) {
      AztecAttributes attrs=new AztecAttributes();
      attrs.setValue(ATTR_SRC,remoteUrl);
      ImagePredicate predicate=ImagePredicate.getLocalMediaIdPredicate(localMediaId);
      content.clearOverlays(predicate);
      content.updateElementAttributes(predicate,attrs);
      content.refreshText();
      mUploadingMedia.remove(localMediaId);
    }
 else     if (mediaType.equals(MediaType.VIDEO)) {
    }
  }
}

Fixed version (ground truth):
@Override public void onMediaUploadSucceeded(final String localMediaId,final MediaFile mediaFile){
  if (!isAdded()) {
    return;
  }
  final MediaType mediaType=mUploadingMedia.get(localMediaId);
  if (mediaType != null) {
    String remoteUrl=Utils.escapeQuotes(mediaFile.getFileURL());
    if (mediaType.equals(MediaType.IMAGE)) {
      AztecAttributes attrs=new AztecAttributes();
      attrs.setValue(ATTR_SRC,remoteUrl);
      ImagePredicate predicate=ImagePredicate.getLocalMediaIdPredicate(localMediaId);
      content.resetAttributedMediaSpan(predicate);
      content.clearOverlays(predicate);
      content.updateElementAttributes(predicate,attrs);
      mUploadingMedia.remove(localMediaId);
    }
 else     if (mediaType.equals(MediaType.VIDEO)) {
    }
  }
}
Program: 13814
Project: 13814
Buggy source:
@Override public void onMediaUploadProgress(final String localMediaId,final float progress){
  if (!isAdded()) {
    return;
  }
  final MediaType mediaType=mUploadingMedia.get(localMediaId);
  if (mediaType != null) {
    AztecText.AttributePredicate localMediaIdPredicate=ImagePredicate.getLocalMediaIdPredicate(localMediaId);
    content.setOverlayLevel(localMediaIdPredicate,1,(int)(progress * 10000));
    content.refreshText();
  }
}

Fixed version (ground truth):
@Override public void onMediaUploadProgress(final String localMediaId,final float progress){
  if (!isAdded()) {
    return;
  }
  final MediaType mediaType=mUploadingMedia.get(localMediaId);
  if (mediaType != null) {
    AztecText.AttributePredicate localMediaIdPredicate=ImagePredicate.getLocalMediaIdPredicate(localMediaId);
    content.setOverlayLevel(localMediaIdPredicate,1,(int)(progress * 10000));
    content.resetAttributedMediaSpan(localMediaIdPredicate);
  }
}
Program: 13815
Project: 13815
Buggy source:
@Override public void onMediaUploadFailed(final String localMediaId,final String errorMessage){
  if (!isAdded()) {
    return;
  }
  MediaType mediaType=mUploadingMedia.get(localMediaId);
  if (mediaType != null) {
switch (mediaType) {
case IMAGE:
      AttributesWithClass attributesWithClass=new AttributesWithClass(content.getElementAttributes(ImagePredicate.getLocalMediaIdPredicate(localMediaId)));
    attributesWithClass.removeClass(ATTR_STATUS_UPLOADING);
  attributesWithClass.addClass(ATTR_STATUS_FAILED);
overlayFailedMedia(localMediaId,attributesWithClass.getAttributes());
content.refreshText();
break;
case VIDEO:
}
mFailedMediaIds.add(localMediaId);
mUploadingMedia.remove(localMediaId);
}
}

Fixed version (ground truth):
@Override public void onMediaUploadFailed(final String localMediaId,final String errorMessage){
  if (!isAdded()) {
    return;
  }
  MediaType mediaType=mUploadingMedia.get(localMediaId);
  if (mediaType != null) {
switch (mediaType) {
case IMAGE:
      ImagePredicate localMediaIdPredicate=ImagePredicate.getLocalMediaIdPredicate(localMediaId);
    AttributesWithClass attributesWithClass=new AttributesWithClass(content.getElementAttributes(localMediaIdPredicate));
  attributesWithClass.removeClass(ATTR_STATUS_UPLOADING);
attributesWithClass.addClass(ATTR_STATUS_FAILED);
overlayFailedMedia(localMediaId,attributesWithClass.getAttributes());
content.resetAttributedMediaSpan(localMediaIdPredicate);
break;
case VIDEO:
}
mFailedMediaIds.add(localMediaId);
mUploadingMedia.remove(localMediaId);
}
}
Program: 13816
Project: 13816
Buggy source:
private void updatePostFormatKeysAndNames(){
  if (!isAdded()) {
    return;
  }
  mPostFormatKeys=new ArrayList<>(Arrays.asList(getResources().getStringArray(R.array.post_format_keys)));
  mPostFormatNames=new ArrayList<>(Arrays.asList(getResources().getStringArray(R.array.post_format_display_names)));
  List<PostFormatModel> postFormatModels=mSiteStore.getPostFormats(mSite);
  for (  PostFormatModel postFormatModel : postFormatModels) {
    if (!mPostFormatKeys.contains(postFormatModel.getSlug())) {
      mPostFormatKeys.add(postFormatModel.getSlug());
      mPostFormatNames.add(postFormatModel.getDisplayName());
    }
  }
}

Fixed version (ground truth):
private void updatePostFormatKeysAndNames(){
  if (getActivity() == null) {
    return;
  }
  mPostFormatKeys=new ArrayList<>(Arrays.asList(getResources().getStringArray(R.array.post_format_keys)));
  mPostFormatNames=new ArrayList<>(Arrays.asList(getResources().getStringArray(R.array.post_format_display_names)));
  List<PostFormatModel> postFormatModels=mSiteStore.getPostFormats(mSite);
  for (  PostFormatModel postFormatModel : postFormatModels) {
    if (!mPostFormatKeys.contains(postFormatModel.getSlug())) {
      mPostFormatKeys.add(postFormatModel.getSlug());
      mPostFormatNames.add(postFormatModel.getDisplayName());
    }
  }
}
Program: 13817
Project: 13817
Buggy source:
private void saveMedia(){
  String[] permissionList={Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE};
  if (!PermissionUtils.checkAndRequestPermissions(this,WPPermissionUtils.MEDIA_PREVIEW_PERMISSION_REQUEST_CODE,permissionList)) {
    return;
  }
  if (!NetworkUtils.checkConnection(this)) {
    return;
  }
  MediaModel media=mMediaStore.getMediaWithLocalId(mMediaId);
  if (media == null) {
    ToastUtils.showToast(this,R.string.error_media_not_found);
    return;
  }
  ToastUtils.showToast(this,R.string.media_downloading);
  DownloadManager dm=(DownloadManager)getSystemService(DOWNLOAD_SERVICE);
  DownloadManager.Request request=new DownloadManager.Request(Uri.parse(media.getUrl()));
  request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,media.getFileName());
  request.allowScanningByMediaScanner();
  request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);
  mDownloadId=dm.enqueue(request);
  invalidateOptionsMenu();
}

Fixed version (ground truth):
private void saveMedia(){
  String[] permissionList={Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE};
  if (!PermissionUtils.checkAndRequestPermissions(this,WPPermissionUtils.MEDIA_PREVIEW_PERMISSION_REQUEST_CODE,permissionList)) {
    return;
  }
  if (!NetworkUtils.checkConnection(this)) {
    return;
  }
  MediaModel media=mMediaStore.getMediaWithLocalId(mMediaId);
  if (media == null) {
    ToastUtils.showToast(this,R.string.error_media_not_found);
    return;
  }
  DownloadManager dm=(DownloadManager)getSystemService(DOWNLOAD_SERVICE);
  DownloadManager.Request request=new DownloadManager.Request(Uri.parse(media.getUrl()));
  try {
    request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,media.getFileName());
  }
 catch (  IllegalStateException error) {
    AppLog.e(AppLog.T.MEDIA,error);
    ToastUtils.showToast(MediaPreviewActivity.this,R.string.error_media_save);
    return;
  }
  request.allowScanningByMediaScanner();
  request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);
  mDownloadId=dm.enqueue(request);
  invalidateOptionsMenu();
  ToastUtils.showToast(this,R.string.media_downloading);
}
Program: 13818
Project: 13818
Buggy source:
private String getSaveButtonText(){
  if (!mSite.getHasCapabilityPublishPosts()) {
    return getString(R.string.submit_for_review);
  }
switch (PostStatus.fromPost(mPost)) {
case SCHEDULED:
    return getString(R.string.schedule_verb);
case PUBLISHED:
case UNKNOWN:
  if (mPost.isLocalDraft()) {
    return getString(R.string.publish_post);
  }
 else {
    return getString(R.string.update_verb);
  }
default :
if (mPost.isLocalDraft()) {
  return getString(R.string.save);
}
 else {
  return getString(R.string.update_verb);
}
}
}

Fixed version (ground truth):
private String getSaveButtonText(){
  if (SiteUtils.isAccessedViaWPComRest(mSite) && !mSite.getHasCapabilityPublishPosts()) {
    return getString(R.string.submit_for_review);
  }
switch (PostStatus.fromPost(mPost)) {
case SCHEDULED:
    return getString(R.string.schedule_verb);
case PUBLISHED:
case UNKNOWN:
  if (mPost.isLocalDraft()) {
    return getString(R.string.publish_post);
  }
 else {
    return getString(R.string.update_verb);
  }
default :
if (mPost.isLocalDraft()) {
  return getString(R.string.save);
}
 else {
  return getString(R.string.update_verb);
}
}
}
Program: 13819
Project: 13819
Buggy source:
@Override public void onSettingsUpdated(Exception error){
  if (error == null && TextUtils.isEmpty(mPost.getPostFormat())) {
    mPost.setPostFormat(mSiteSettings.getDefaultPostFormat());
    if (mPostFormatKeys != null && mPostFormatNames != null && mPostFormatTextView != null) {
      int idx=mPostFormatKeys.indexOf(mPost.getPostFormat());
      if (idx != -1) {
        mPostFormatTextView.setText(getPostFormatNameFromKey(mPost.getPostFormat()));
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onSettingsUpdated(Exception error){
  if (error == null && TextUtils.isEmpty(mPost.getPostFormat())) {
    updatePostFormat(mSiteSettings.getDefaultPostFormat());
  }
}
Program: 13820
Project: 13820
Buggy source:
private void updateSiteAndFetchPostOrFinishActivity(Bundle savedInstanceState){
  int localPostId;
  if (savedInstanceState == null) {
    if (getArguments() != null) {
      mSite=(SiteModel)getArguments().getSerializable(WordPress.SITE);
      localPostId=getArguments().getInt(EXTRA_POST_LOCAL_ID);
    }
 else {
      mSite=(SiteModel)getActivity().getIntent().getSerializableExtra(WordPress.SITE);
      localPostId=getActivity().getIntent().getIntExtra(EXTRA_POST_LOCAL_ID,0);
    }
  }
 else {
    mSite=(SiteModel)savedInstanceState.getSerializable(WordPress.SITE);
    localPostId=savedInstanceState.getInt(EXTRA_POST_LOCAL_ID);
  }
  if (mSite == null) {
    ToastUtils.showToast(getActivity(),R.string.blog_not_found,ToastUtils.Duration.SHORT);
    getActivity().finish();
  }
  if (localPostId != 0) {
    mPost=mPostStore.getPostByLocalPostId(localPostId);
  }
  if (mPost == null) {
    ToastUtils.showToast(getActivity(),R.string.post_not_found,ToastUtils.Duration.SHORT);
    getActivity().finish();
  }
  fetchSiteSettingsAndUpdatePostFormat();
}

Fixed version (ground truth):
private void updateSiteAndFetchPostOrFinishActivity(Bundle savedInstanceState){
  int localPostId;
  if (savedInstanceState == null) {
    if (getArguments() != null) {
      mSite=(SiteModel)getArguments().getSerializable(WordPress.SITE);
      localPostId=getArguments().getInt(EXTRA_POST_LOCAL_ID);
    }
 else {
      mSite=(SiteModel)getActivity().getIntent().getSerializableExtra(WordPress.SITE);
      localPostId=getActivity().getIntent().getIntExtra(EXTRA_POST_LOCAL_ID,0);
    }
  }
 else {
    mSite=(SiteModel)savedInstanceState.getSerializable(WordPress.SITE);
    localPostId=savedInstanceState.getInt(EXTRA_POST_LOCAL_ID);
  }
  if (mSite == null) {
    ToastUtils.showToast(getActivity(),R.string.blog_not_found,ToastUtils.Duration.SHORT);
    getActivity().finish();
  }
  if (localPostId != 0) {
    mPost=mPostStore.getPostByLocalPostId(localPostId);
  }
  if (mPost == null) {
    ToastUtils.showToast(getActivity(),R.string.post_not_found,ToastUtils.Duration.SHORT);
    getActivity().finish();
  }
}
Program: 13821
Project: 13821
Buggy source:
private void initSettingsFields(){
  mExcerptTextView.setText(mPost.getExcerpt());
  mSlugTextView.setText(mPost.getSlug());
  mPostFormatTextView.setText(getPostFormatNameFromKey(mPost.getPostFormat()));
  mPasswordTextView.setText(mPost.getPassword());
  updateTagsTextView();
  updateStatusTextView();
  updatePublishDateTextView();
  updateCategoriesTextView();
  if (AppPrefs.isVisualEditorEnabled() || AppPrefs.isAztecEditorEnabled()) {
    updateFeaturedImage(mPost.getFeaturedImageId());
  }
}

Fixed version (ground truth):
private void initSettingsFields(){
  mExcerptTextView.setText(mPost.getExcerpt());
  mSlugTextView.setText(mPost.getSlug());
  mPasswordTextView.setText(mPost.getPassword());
  updatePostFormatTextView();
  updateTagsTextView();
  updateStatusTextView();
  updatePublishDateTextView();
  updateCategoriesTextView();
  if (AppPrefs.isVisualEditorEnabled() || AppPrefs.isAztecEditorEnabled()) {
    updateFeaturedImage(mPost.getFeaturedImageId());
  }
}
Program: 13822
Project: 13822
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  ((WordPress)getActivity().getApplicationContext()).component().inject(this);
  mDispatcher.register(this);
  if (getActivity() != null) {
    PreferenceManager.setDefaultValues(getActivity(),R.xml.account_settings,false);
  }
  updateSiteAndFetchPostOrFinishActivity(savedInstanceState);
  updatePostFormatKeysAndNames();
  mDispatcher.dispatch(SiteActionBuilder.newFetchPostFormatsAction(mSite));
  if (!mPost.isPage()) {
    mDispatcher.dispatch(TaxonomyActionBuilder.newFetchCategoriesAction(mSite));
  }
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  ((WordPress)getActivity().getApplicationContext()).component().inject(this);
  mDispatcher.register(this);
  if (getActivity() != null) {
    PreferenceManager.setDefaultValues(getActivity(),R.xml.account_settings,false);
  }
  updateSiteAndFetchPostOrFinishActivity(savedInstanceState);
  updatePostFormatKeysAndNames();
  fetchSiteSettingsAndUpdateDefaultPostFormat();
  mDispatcher.dispatch(SiteActionBuilder.newFetchPostFormatsAction(mSite));
  if (!mPost.isPage()) {
    mDispatcher.dispatch(TaxonomyActionBuilder.newFetchCategoriesAction(mSite));
  }
}
Program: 13823
Project: 13823
Buggy source:
private void showPostFormatDialog(){
  int checkedItem=0;
  if (!TextUtils.isEmpty(mPost.getPostFormat())) {
    for (int i=0; i < mPostFormatKeys.size(); i++) {
      if (mPost.getPostFormat().equals(mPostFormatKeys.get(i))) {
        checkedItem=i;
        break;
      }
    }
  }
  AlertDialog.Builder builder=new AlertDialog.Builder(getActivity(),R.style.Calypso_AlertDialog);
  builder.setTitle(R.string.post_settings_post_format);
  builder.setSingleChoiceItems(mPostFormatNames.toArray(new CharSequence[0]),checkedItem,null);
  builder.setPositiveButton(R.string.dialog_button_ok,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      ListView listView=((AlertDialog)dialog).getListView();
      String formatName=(String)listView.getAdapter().getItem(listView.getCheckedItemPosition());
      mPostFormatTextView.setText(formatName);
      mPost.setPostFormat(getPostFormatKeyFromName(formatName));
    }
  }
);
  builder.setNegativeButton(R.string.cancel,null);
  builder.show();
}

Fixed version (ground truth):
private void showPostFormatDialog(){
  int checkedItem=0;
  if (!TextUtils.isEmpty(mPost.getPostFormat())) {
    for (int i=0; i < mPostFormatKeys.size(); i++) {
      if (mPost.getPostFormat().equals(mPostFormatKeys.get(i))) {
        checkedItem=i;
        break;
      }
    }
  }
  AlertDialog.Builder builder=new AlertDialog.Builder(getActivity(),R.style.Calypso_AlertDialog);
  builder.setTitle(R.string.post_settings_post_format);
  builder.setSingleChoiceItems(mPostFormatNames.toArray(new CharSequence[0]),checkedItem,null);
  builder.setPositiveButton(R.string.dialog_button_ok,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      ListView listView=((AlertDialog)dialog).getListView();
      String formatName=(String)listView.getAdapter().getItem(listView.getCheckedItemPosition());
      updatePostFormat(getPostFormatKeyFromName(formatName));
    }
  }
);
  builder.setNegativeButton(R.string.cancel,null);
  builder.show();
}
Program: 13824
Project: 13824
Buggy source:
@Override public void onDestroy(){
  for (  MediaModel oneUpload : mInProgressUploads) {
    cancelUpload(oneUpload);
  }
  mDispatcher.unregister(this);
  EventBus.getDefault().unregister(this);
  AppLog.i(T.MEDIA,"String_Node_Str");
  super.onDestroy();
}

Fixed version (ground truth):
@Override public void onDestroy(){
  for (  MediaModel oneUpload : mInProgressUploads) {
    cancelUpload(oneUpload,false);
  }
  mDispatcher.unregister(this);
  EventBus.getDefault().unregister(this);
  AppLog.i(T.MEDIA,"String_Node_Str");
  super.onDestroy();
}
Program: 13825
Project: 13825
Buggy source:
@SuppressWarnings("String_Node_Str") public void onEventMainThread(PostEvents.PostMediaCanceled event){
  if (event.post == null) {
    return;
  }
  for (  MediaModel inProgressUpload : mInProgressUploads) {
    if (inProgressUpload.getLocalPostId() == event.post.getId()) {
      cancelUpload(inProgressUpload);
    }
  }
  for (  MediaModel pendingUpload : mPendingUploads) {
    if (pendingUpload.getLocalPostId() == event.post.getId()) {
      cancelUpload(pendingUpload);
    }
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public void onEventMainThread(PostEvents.PostMediaCanceled event){
  if (event.post == null) {
    return;
  }
  for (  MediaModel inProgressUpload : mInProgressUploads) {
    if (inProgressUpload.getLocalPostId() == event.post.getId()) {
      cancelUpload(inProgressUpload,true);
    }
  }
  for (  MediaModel pendingUpload : mPendingUploads) {
    if (pendingUpload.getLocalPostId() == event.post.getId()) {
      cancelUpload(pendingUpload,true);
    }
  }
}
Program: 13826
Project: 13826
Buggy source:
private void dispatchCancelAction(@NonNull final MediaModel media,@NonNull final SiteModel site){
  AppLog.i(T.MEDIA,"String_Node_Str" + media.getId() + "String_Node_Str"+ media.getFilePath());
  CancelMediaPayload payload=new CancelMediaPayload(site,media);
  mDispatcher.dispatch(MediaActionBuilder.newCancelMediaUploadAction(payload));
}

Fixed version (ground truth):
private void dispatchCancelAction(@NonNull final MediaModel media,@NonNull final SiteModel site,boolean delete){
  AppLog.i(T.MEDIA,"String_Node_Str" + media.getId() + "String_Node_Str"+ media.getFilePath());
  CancelMediaPayload payload=new CancelMediaPayload(site,media,delete);
  mDispatcher.dispatch(MediaActionBuilder.newCancelMediaUploadAction(payload));
}