nus-yam/ex-repair huggingface dataset:
Program: 13731
Project: 13731
Buggy source:
@SuppressWarnings("String_Node_Str") public void onEventMainThread(UploadService.UploadMediaSuccessEvent event){
  if (event.mediaModelList != null && !event.mediaModelList.isEmpty()) {
    UploadUtils.onMediaUploadedSnackbarHandler(getActivity(),getActivity().findViewById(R.id.coordinator),true,event.mediaModelList,event.successMessage);
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public void onEventMainThread(UploadService.UploadMediaSuccessEvent event){
  if (event.mediaModelList != null && !event.mediaModelList.isEmpty()) {
    UploadUtils.onMediaUploadedSnackbarHandler(getActivity(),getActivity().findViewById(R.id.coordinator),false,event.mediaModelList,event.successMessage);
  }
}
Program: 13732
Project: 13732
Buggy source:
private void updatePostUploadProgressBar(ProgressBar view,PostModel post){
  if (UploadService.isPostUploadingOrQueued(post) || UploadService.hasInProgressMediaUploadsForPost(post)) {
    view.setVisibility(View.VISIBLE);
    int overallProgress=Math.round(UploadService.getMediaUploadProgressForPost(post) * 100);
    view.setProgress(Math.min(MAX_DISPLAYED_UPLOAD_PROGRESS,overallProgress));
  }
 else {
    view.setVisibility(View.GONE);
  }
}

Fixed version (ground truth):
private void updatePostUploadProgressBar(ProgressBar view,PostModel post){
  if (!mUploadStore.isFailedPost(post) && (UploadService.isPostUploadingOrQueued(post) || UploadService.hasInProgressMediaUploadsForPost(post))) {
    view.setVisibility(View.VISIBLE);
    int overallProgress=Math.round(UploadService.getMediaUploadProgressForPost(post) * 100);
    view.setProgress(Math.min(MAX_DISPLAYED_UPLOAD_PROGRESS,overallProgress));
  }
 else {
    view.setVisibility(View.GONE);
  }
}
Program: 13735
Project: 13735
Buggy source:
private void resetNotificationCounters(){
  sNotificationData.currentPostItem=0;
  sNotificationData.currentMediaItem=0;
  sNotificationData.totalMediaItems=0;
  sNotificationData.totalPostItems=0;
  sNotificationData.totalPageItemsIncludedInPostCount=0;
  sNotificationData.mediaItemToProgressMap.clear();
}

Fixed version (ground truth):
private void resetNotificationCounters(){
  sNotificationData.currentPostItem=0;
  sNotificationData.currentMediaItem=0;
  sNotificationData.totalMediaItems=0;
  sNotificationData.totalPostItems=0;
  sNotificationData.totalPageItemsIncludedInPostCount=0;
  sNotificationData.mediaItemToProgressMap.clear();
  sNotificationData.mUploadedPostsCounted.clear();
}
Program: 13736
Project: 13736
Buggy source:
void incrementUploadedPostCountFromForegroundNotificationOrFinish(@NonNull PostModel post){
  sNotificationData.currentPostItem++;
  if (post.isPage()) {
    sNotificationData.totalPageItemsIncludedInPostCount--;
  }
  if (!removeNotificationAndStopForegroundServiceIfNoItemsInQueue()) {
    updateForegroundNotification(post);
  }
}

Fixed version (ground truth):
void incrementUploadedPostCountFromForegroundNotificationOrFinish(@NonNull PostModel post){
  if (isPostAlreadyInPostCount(post)) {
    return;
  }
 else {
    addPostToPostCount(post);
  }
  sNotificationData.currentPostItem++;
  if (post.isPage()) {
    sNotificationData.totalPageItemsIncludedInPostCount--;
  }
  if (!removeNotificationAndStopForegroundServiceIfNoItemsInQueue()) {
    updateForegroundNotification(post);
  }
}
Program: 13737
Project: 13737
Buggy source:
private void cancelPostUploadMatchingMedia(@NonNull MediaModel media,String errorMessage){
  PostModel postToCancel=mPostStore.getPostByLocalPostId(media.getLocalPostId());
  if (postToCancel == null)   return;
  SiteModel site=mSiteStore.getSiteByLocalId(postToCancel.getLocalSiteId());
  mPostUploadNotifier.cancelNotification(postToCancel);
  if (mUploadStore.isPendingPost(postToCancel) || mUploadStore.isCancelledPost(postToCancel)) {
    String message=UploadUtils.getErrorMessage(this,postToCancel,errorMessage,true);
    mPostUploadNotifier.updateNotificationError(postToCancel,site,message);
  }
  mPostUploadHandler.unregisterPostForAnalyticsTracking(postToCancel);
  EventBus.getDefault().post(new PostEvents.PostUploadCanceled(postToCancel.getLocalSiteId()));
}

Fixed version (ground truth):
private void cancelPostUploadMatchingMedia(@NonNull MediaModel media,String errorMessage){
  PostModel postToCancel=mPostStore.getPostByLocalPostId(media.getLocalPostId());
  if (postToCancel == null)   return;
  SiteModel site=mSiteStore.getSiteByLocalId(postToCancel.getLocalSiteId());
  mPostUploadNotifier.cancelNotification(postToCancel);
  if (!mUploadStore.isPendingPost(postToCancel) && !mUploadStore.isCancelledPost(postToCancel)) {
    String message=UploadUtils.getErrorMessage(this,postToCancel,errorMessage,true);
    mPostUploadNotifier.updateNotificationError(postToCancel,site,message);
  }
  mPostUploadHandler.unregisterPostForAnalyticsTracking(postToCancel);
  EventBus.getDefault().post(new PostEvents.PostUploadCanceled(postToCancel.getLocalSiteId()));
}
Program: 13738
Project: 13738
Buggy source:
private static void openWPCOMURL(Activity activity,String url,Theme currentTheme,SiteModel site,Boolean isCurrentTheme){
  if (activity == null) {
    AppLog.e(AppLog.T.UTILS,"String_Node_Str");
    return;
  }
  if (TextUtils.isEmpty(url)) {
    AppLog.e(AppLog.T.UTILS,"String_Node_Str");
    ToastUtils.showToast(activity,R.string.invalid_site_url_message,ToastUtils.Duration.SHORT);
    return;
  }
  String authURL=ThemeWebActivity.getSiteLoginUrl(site);
  Intent intent=new Intent(activity,ThemeWebActivity.class);
  intent.putExtra(WPWebViewActivity.URL_TO_LOAD,url);
  intent.putExtra(WPWebViewActivity.AUTHENTICATION_URL,authURL);
  intent.putExtra(WPWebViewActivity.LOCAL_BLOG_ID,site.getId());
  intent.putExtra(WPWebViewActivity.USE_GLOBAL_WPCOM_USER,true);
  intent.putExtra(IS_PREMIUM_THEME,currentTheme.isPremium());
  intent.putExtra(IS_CURRENT_THEME,isCurrentTheme);
  intent.putExtra(THEME_NAME,currentTheme.getName());
  intent.putExtra(ThemeBrowserActivity.THEME_ID,currentTheme.getId());
  activity.startActivityForResult(intent,ThemeBrowserActivity.ACTIVATE_THEME);
}

Fixed version (ground truth):
private static void openWPCOMURL(Activity activity,String url,ThemeModel currentTheme,SiteModel site,Boolean isCurrentTheme){
  if (activity == null) {
    AppLog.e(AppLog.T.UTILS,"String_Node_Str");
    return;
  }
  if (TextUtils.isEmpty(url)) {
    AppLog.e(AppLog.T.UTILS,"String_Node_Str");
    ToastUtils.showToast(activity,R.string.invalid_site_url_message,ToastUtils.Duration.SHORT);
    return;
  }
  String authURL=ThemeWebActivity.getSiteLoginUrl(site);
  Intent intent=new Intent(activity,ThemeWebActivity.class);
  intent.putExtra(WPWebViewActivity.URL_TO_LOAD,url);
  intent.putExtra(WPWebViewActivity.AUTHENTICATION_URL,authURL);
  intent.putExtra(WPWebViewActivity.LOCAL_BLOG_ID,site.getId());
  intent.putExtra(WPWebViewActivity.USE_GLOBAL_WPCOM_USER,true);
  intent.putExtra(IS_CURRENT_THEME,isCurrentTheme);
  intent.putExtra(THEME_NAME,currentTheme.getName());
  intent.putExtra(ThemeBrowserActivity.THEME_ID,currentTheme.getId());
  activity.startActivityForResult(intent,ThemeBrowserActivity.ACTIVATE_THEME);
}
Program: 13739
Project: 13739
Buggy source:
private static void requestAndOpenCurrentTheme(final Activity activity,final SiteModel site){
  WordPress.getRestClientUtilsV1_1().getCurrentTheme(site.getSiteId(),new RestRequest.Listener(){
    @Override public void onResponse(    JSONObject response){
      try {
        Theme currentTheme=Theme.fromJSONV1_1(response,site);
        if (currentTheme != null) {
          currentTheme.setIsCurrent(true);
          ThemeTable.saveTheme(WordPress.wpDB.getDatabase(),currentTheme);
          ThemeTable.setCurrentTheme(WordPress.wpDB.getDatabase(),String.valueOf(site.getSiteId()),currentTheme.getId());
          openTheme(activity,site,currentTheme.getId(),ThemeWebActivityType.PREVIEW,true);
        }
      }
 catch (      JSONException e) {
        ToastUtils.showToast(activity,R.string.could_not_load_theme);
        AppLog.e(AppLog.T.THEMES,e);
      }
    }
  }
,new RestRequest.ErrorListener(){
    @Override public void onErrorResponse(    VolleyError error){
      AppLog.e(AppLog.T.THEMES,error);
    }
  }
);
}

Fixed version (ground truth):
private static void requestAndOpenCurrentTheme(final Activity activity,final SiteModel site){
  openTheme(activity,site,null,ThemeWebActivityType.PREVIEW,true);
}
Program: 13740
Project: 13740
Buggy source:
public static String getUrl(SiteModel site,Theme theme,ThemeWebActivityType type,boolean isPremium){
  String url="String_Node_Str";
  String homeURL=site.getUrl();
  String domain=isPremium ? THEME_DOMAIN_PREMIUM : THEME_DOMAIN_PUBLIC;
switch (type) {
case PREVIEW:
    url=String.format(THEME_URL_PREVIEW,homeURL,domain,theme.getId());
  break;
case DEMO:
url=theme.getDemoURI();
if (url.contains("String_Node_Str")) {
url=url + "String_Node_Str" + THEME_URL_DEMO_PARAMETER;
}
 else {
url=url + "String_Node_Str" + THEME_URL_DEMO_PARAMETER;
}
break;
case DETAILS:
String currentURL=homeURL.replaceFirst(THEME_HTTPS_PREFIX,"String_Node_Str");
url=String.format(THEME_URL_DETAILS,currentURL,theme.getId());
break;
case SUPPORT:
url=String.format(THEME_URL_SUPPORT,theme.getId());
break;
default :
break;
}
return url;
}

Fixed version (ground truth):
public static String getUrl(SiteModel site,ThemeModel theme,ThemeWebActivityType type,boolean isPremium){
  String url="String_Node_Str";
  String homeURL=site.getUrl();
  String domain=isPremium ? THEME_DOMAIN_PREMIUM : THEME_DOMAIN_PUBLIC;
switch (type) {
case PREVIEW:
    url=String.format(THEME_URL_PREVIEW,homeURL,domain,theme.getId());
  break;
case DEMO:
url=theme.getDemoUrl();
if (url.contains("String_Node_Str")) {
url=url + "String_Node_Str" + THEME_URL_DEMO_PARAMETER;
}
 else {
url=url + "String_Node_Str" + THEME_URL_DEMO_PARAMETER;
}
break;
case DETAILS:
String currentURL=homeURL.replaceFirst(THEME_HTTPS_PREFIX,"String_Node_Str");
url=String.format(THEME_URL_DETAILS,currentURL,theme.getId());
break;
case SUPPORT:
url=String.format(THEME_URL_SUPPORT,theme.getId());
break;
default :
break;
}
return url;
}
Program: 13741
Project: 13741
Buggy source:
public static void openTheme(Activity activity,SiteModel site,String themeId,ThemeWebActivityType type,boolean isCurrentTheme){
  Theme currentTheme=ThemeTable.getTheme(WordPress.wpDB.getDatabase(),String.valueOf(site.getSiteId()),themeId);
  if (currentTheme == null) {
    ToastUtils.showToast(activity,R.string.could_not_load_theme);
    return;
  }
  String url=getUrl(site,currentTheme,type,currentTheme.isPremium());
  if (type == ThemeWebActivityType.PREVIEW) {
    ActivityLauncher.openUrlExternal(activity,url);
  }
 else {
    openWPCOMURL(activity,url,currentTheme,site,isCurrentTheme);
  }
}

Fixed version (ground truth):
public static void openTheme(Activity activity,SiteModel site,String themeId,ThemeWebActivityType type,boolean isCurrentTheme){
  ThemeModel currentTheme=null;
  if (currentTheme == null) {
    ToastUtils.showToast(activity,R.string.could_not_load_theme);
    return;
  }
  String url=getUrl(site,currentTheme,type,false);
  if (type == ThemeWebActivityType.PREVIEW) {
    ActivityLauncher.openUrlExternal(activity,url);
  }
 else {
    openWPCOMURL(activity,url,currentTheme,site,isCurrentTheme);
  }
}
Program: 13742
Project: 13742
Buggy source:
public static void openCurrentTheme(Activity activity,SiteModel site,ThemeWebActivityType type){
  String themeId=ThemeTable.getCurrentThemeId(WordPress.wpDB.getDatabase(),String.valueOf(site.getSiteId()));
  if (themeId.isEmpty()) {
    requestAndOpenCurrentTheme(activity,site);
  }
 else {
    openTheme(activity,site,themeId,type,true);
  }
}

Fixed version (ground truth):
public static void openCurrentTheme(Activity activity,SiteModel site,ThemeWebActivityType type){
  String themeId="String_Node_Str";
  if (themeId.isEmpty()) {
    requestAndOpenCurrentTheme(activity,site);
  }
 else {
    openTheme(activity,site,themeId,type,true);
  }
}
Program: 13743
Project: 13743
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
  if (item.getItemId() == R.id.action_activate) {
    Intent returnIntent=new Intent();
    setResult(RESULT_OK,returnIntent);
    returnIntent.putExtra(ThemeBrowserActivity.THEME_ID,getIntent().getStringExtra(ThemeBrowserActivity.THEME_ID));
    finish();
    return true;
  }
 else {
    return super.onOptionsItemSelected(item);
  }
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
  if (item.getItemId() == R.id.action_activate) {
    Intent returnIntent=new Intent();
    setResult(RESULT_OK,returnIntent);
    returnIntent.putExtra(ThemeBrowserActivity.THEME_ID,getIntent().getStringExtra(ThemeBrowserActivity.THEME_ID));
    finish();
    return true;
  }
  return super.onOptionsItemSelected(item);
}
Program: 13744
Project: 13744
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  ((WordPress)getApplication()).component().inject(this);
  final SiteModel site;
  if (savedInstanceState == null) {
    site=(SiteModel)getIntent().getSerializableExtra(WordPress.SITE);
  }
 else {
    site=(SiteModel)savedInstanceState.getSerializable(WordPress.SITE);
  }
  if (site == null) {
    ToastUtils.showToast(this,R.string.blog_not_found,ToastUtils.Duration.SHORT);
    finish();
    return;
  }
  ActionBar actionBar=getSupportActionBar();
  if (actionBar != null) {
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle(StringUtils.unescapeHTML(SiteUtils.getSiteNameOrHomeURL(site)));
  }
  FragmentManager fragmentManager=getFragmentManager();
  Fragment siteSettingsFragment=fragmentManager.findFragmentByTag(KEY_SETTINGS_FRAGMENT);
  if (siteSettingsFragment == null) {
    siteSettingsFragment=new SiteSettingsFragment();
    siteSettingsFragment.setArguments(getIntent().getExtras());
    fragmentManager.beginTransaction().replace(android.R.id.content,siteSettingsFragment,KEY_SETTINGS_FRAGMENT).commit();
  }
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  ((WordPress)getApplication()).component().inject(this);
  if (savedInstanceState == null) {
    mSite=(SiteModel)getIntent().getSerializableExtra(WordPress.SITE);
  }
 else {
    mSite=(SiteModel)savedInstanceState.getSerializable(WordPress.SITE);
  }
  if (mSite == null) {
    ToastUtils.showToast(this,R.string.blog_not_found,ToastUtils.Duration.SHORT);
    finish();
    return;
  }
  ActionBar actionBar=getSupportActionBar();
  if (actionBar != null) {
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle(StringUtils.unescapeHTML(SiteUtils.getSiteNameOrHomeURL(mSite)));
  }
  FragmentManager fragmentManager=getFragmentManager();
  Fragment siteSettingsFragment=fragmentManager.findFragmentByTag(KEY_SETTINGS_FRAGMENT);
  if (siteSettingsFragment == null) {
    siteSettingsFragment=new SiteSettingsFragment();
    siteSettingsFragment.setArguments(getIntent().getExtras());
    fragmentManager.beginTransaction().replace(android.R.id.content,siteSettingsFragment,KEY_SETTINGS_FRAGMENT).commit();
  }
}
Program: 13745
Project: 13745
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  ((WordPress)getApplication()).component().inject(this);
  mDispatcher.register(this);
  if (savedInstanceState == null) {
    mSite=(SiteModel)getIntent().getSerializableExtra(WordPress.SITE);
  }
 else {
    mSite=(SiteModel)savedInstanceState.getSerializable(WordPress.SITE);
  }
  if (mSite == null) {
    ToastUtils.showToast(this,R.string.blog_not_found,ToastUtils.Duration.SHORT);
    finish();
    return;
  }
  setContentView(R.layout.theme_browser_activity);
  if (savedInstanceState == null) {
    AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat.THEMES_ACCESSED_THEMES_BROWSER,mSite);
    mThemeBrowserFragment=ThemeBrowserFragment.newInstance(mSite);
    mThemeSearchFragment=ThemeSearchFragment.newInstance(mSite);
    addBrowserFragment();
  }
  setCurrentThemeFromDB();
  showToolbar();
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  ((WordPress)getApplication()).component().inject(this);
  mDispatcher.register(this);
  if (savedInstanceState == null) {
    mSite=(SiteModel)getIntent().getSerializableExtra(WordPress.SITE);
  }
 else {
    mSite=(SiteModel)savedInstanceState.getSerializable(WordPress.SITE);
  }
  if (mSite == null) {
    ToastUtils.showToast(this,R.string.blog_not_found,ToastUtils.Duration.SHORT);
    finish();
    return;
  }
  setContentView(R.layout.theme_browser_activity);
  if (savedInstanceState == null) {
    AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat.THEMES_ACCESSED_THEMES_BROWSER,mSite);
    mThemeBrowserFragment=ThemeBrowserFragment.newInstance(mSite);
    mThemeSearchFragment=ThemeSearchFragment.newInstance(mSite);
    addBrowserFragment();
  }
  showToolbar();
}
Program: 13746
Project: 13746
Buggy source:
@Override protected void onResume(){
  super.onResume();
  showCorrectToolbar();
  mIsRunning=true;
  ActivityId.trackLastActivity(ActivityId.THEMES);
  fetchThemesIfNoneAvailable();
  fetchPurchasedThemes();
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  showCorrectToolbar();
  mIsRunning=true;
  ActivityId.trackLastActivity(ActivityId.THEMES);
  fetchThemesIfNoneAvailable();
}
Program: 13747
Project: 13747
Buggy source:
@Override public void onRestoreInstanceState(Parcelable state){
  if (state instanceof Bundle) {
    Bundle bundle=(Bundle)state;
    PrefListItems items=(PrefListItems)bundle.getSerializable(KEY_LIST_ITEMS);
    setListItems(items);
    state=bundle.getParcelable(KEY_SUPER_STATE);
  }
  super.onRestoreInstanceState(state);
}

Fixed version (ground truth):
@Override public void onRestoreInstanceState(Parcelable state){
  if (state instanceof Bundle) {
    Bundle bundle=(Bundle)state;
    PrefListItemsWrapper listWrapper=(PrefListItemsWrapper)bundle.getSerializable(KEY_LIST_ITEMS);
    if (listWrapper != null) {
      PrefListItems items=listWrapper.getList();
      setListItems(items);
    }
    state=bundle.getParcelable(KEY_SUPER_STATE);
  }
  super.onRestoreInstanceState(state);
}
Program: 13748
Project: 13748
Buggy source:
@Override public Parcelable onSaveInstanceState(){
  Bundle bundle=new Bundle();
  bundle.putSerializable(KEY_LIST_ITEMS,mListItems);
  bundle.putParcelable(KEY_SUPER_STATE,super.onSaveInstanceState());
  return bundle;
}

Fixed version (ground truth):
@Override public Parcelable onSaveInstanceState(){
  Bundle bundle=new Bundle();
  bundle.putSerializable(KEY_LIST_ITEMS,new PrefListItemsWrapper(mListItems));
  bundle.putParcelable(KEY_SUPER_STATE,super.onSaveInstanceState());
  return bundle;
}
Program: 13750
Project: 13750
Buggy source:
@Override public void onProgressChanged(SeekBar seekBar,int progress,boolean fromUser){
  if (progress == 0) {
    progress=1;
  }
  widthText.setText(progress * 10 + "String_Node_Str");
}

Fixed version (ground truth):
@Override public void onProgressChanged(SeekBar seekBar,int progress,boolean fromUser){
  if (progress == 0) {
    progress=1;
  }
  widthText.setText(String.format(Locale.US,getString(R.string.pixel_suffix),progress * 10));
}
Program: 13751
Project: 13751
Buggy source:
@Override public boolean onEditorAction(TextView v,int actionId,KeyEvent event){
  int width=getEditTextIntegerClamped(widthText,10,mMaxImageWidth);
  widthSeekBar.setProgress(width / 10);
  widthText.setSelection((String.valueOf(width).length()));
  InputMethodManager imm=(InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
  imm.hideSoftInputFromWindow(widthText.getWindowToken(),InputMethodManager.RESULT_UNCHANGED_SHOWN);
  return true;
}

Fixed version (ground truth):
@Override public boolean onEditorAction(TextView v,int actionId,KeyEvent event){
  int width=getEditTextIntegerClamped(widthText,10,mMaxImageWidth);
  int progress=width / 10;
  if (widthSeekBar.getProgress() == progress) {
    widthText.setText(String.format(Locale.US,getString(R.string.pixel_suffix),progress * 10));
  }
 else {
    widthSeekBar.setProgress(progress);
  }
  widthText.setSelection((String.valueOf(width).length()));
  InputMethodManager imm=(InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
  imm.hideSoftInputFromWindow(widthText.getWindowToken(),InputMethodManager.RESULT_UNCHANGED_SHOWN);
  return true;
}
Program: 13754
Project: 13754
Buggy source:
@Override public void onProgressChanged(SeekBar seekBar,int progress,boolean fromUser){
  if (progress == 0) {
    progress=1;
  }
  widthText.setText(progress * 10 + "String_Node_Str");
}

Fixed version (ground truth):
@Override public void onProgressChanged(SeekBar seekBar,int progress,boolean fromUser){
  if (progress == 0) {
    progress=1;
  }
  widthText.setText(String.format(Locale.US,getString(R.string.pixel_suffix),progress * 10));
}
Program: 13755
Project: 13755
Buggy source:
@Override public boolean onEditorAction(TextView v,int actionId,KeyEvent event){
  int width=getEditTextIntegerClamped(widthText,10,mMaxImageWidth);
  widthSeekBar.setProgress(width / 10);
  widthText.setSelection((String.valueOf(width).length()));
  InputMethodManager imm=(InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
  imm.hideSoftInputFromWindow(widthText.getWindowToken(),InputMethodManager.RESULT_UNCHANGED_SHOWN);
  return true;
}

Fixed version (ground truth):
@Override public boolean onEditorAction(TextView v,int actionId,KeyEvent event){
  int width=getEditTextIntegerClamped(widthText,10,mMaxImageWidth);
  int progress=width / 10;
  if (widthSeekBar.getProgress() == progress) {
    widthText.setText(String.format(Locale.US,getString(R.string.pixel_suffix),progress * 10));
  }
 else {
    widthSeekBar.setProgress(progress);
  }
  widthText.setSelection((String.valueOf(width).length()));
  InputMethodManager imm=(InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
  imm.hideSoftInputFromWindow(widthText.getWindowToken(),InputMethodManager.RESULT_UNCHANGED_SHOWN);
  return true;
}
Program: 13757
Project: 13757
Buggy source:
@Override protected void onSaveInstanceState(Bundle outState){
  super.onSaveInstanceState(outState);
  outState.putString(ARG_MEDIA_CONTENT_URI,mContentUri);
  outState.putBoolean(ARG_IS_VIDEO,mIsVideo);
  if (mSite != null) {
    outState.putSerializable(WordPress.SITE,mSite);
  }
}

Fixed version (ground truth):
@Override protected void onSaveInstanceState(Bundle outState){
  super.onSaveInstanceState(outState);
  outState.putString(ARG_MEDIA_CONTENT_URI,mContentUri);
  outState.putBoolean(ARG_IS_VIDEO,mIsVideo);
  outState.putBoolean(ARG_IS_AUDIO,mIsAudio);
  if (mSite != null) {
    outState.putSerializable(WordPress.SITE,mSite);
  }
}
Program: 13760
Project: 13760
Buggy source:
public static void publishPost(Activity activity,final PostModel post,SiteModel site,Dispatcher dispatcher){
  if (!NetworkUtils.isNetworkAvailable(activity)) {
    ToastUtils.showToast(activity,R.string.error_publish_no_network,ToastUtils.Duration.SHORT);
    return;
  }
  if (!PostUtils.isPublishable(post)) {
    String message=activity.getString(post.isPage() ? R.string.error_publish_empty_page_param : R.string.error_publish_empty_post_param);
    ToastUtils.showToast(activity,message,ToastUtils.Duration.SHORT);
    return;
  }
  PostUtils.updatePublishDateIfShouldBePublishedImmediately(post);
  boolean isFirstTimePublish=PostStatus.fromPost(post) == PostStatus.DRAFT || (PostStatus.fromPost(post) == PostStatus.PUBLISHED && post.isLocalDraft());
  post.setStatus(PostStatus.PUBLISHED.toString());
  dispatcher.dispatch(PostActionBuilder.newUpdatePostAction(post));
  if (isFirstTimePublish) {
    UploadService.uploadPostAndTrackAnalytics(activity,post);
  }
 else {
    UploadService.uploadPost(activity,post);
  }
  PostUtils.trackSavePostAnalytics(post,site);
}

Fixed version (ground truth):
public static void publishPost(Activity activity,final PostModel post,SiteModel site,Dispatcher dispatcher){
  if (!NetworkUtils.isNetworkAvailable(activity)) {
    ToastUtils.showToast(activity,R.string.error_publish_no_network,ToastUtils.Duration.SHORT);
    return;
  }
  if (!PostUtils.isPublishable(post)) {
    String message=activity.getString(post.isPage() ? R.string.error_publish_empty_page : R.string.error_publish_empty_post);
    ToastUtils.showToast(activity,message,ToastUtils.Duration.SHORT);
    return;
  }
  PostUtils.updatePublishDateIfShouldBePublishedImmediately(post);
  boolean isFirstTimePublish=PostStatus.fromPost(post) == PostStatus.DRAFT || (PostStatus.fromPost(post) == PostStatus.PUBLISHED && post.isLocalDraft());
  post.setStatus(PostStatus.PUBLISHED.toString());
  dispatcher.dispatch(PostActionBuilder.newUpdatePostAction(post));
  if (isFirstTimePublish) {
    UploadService.uploadPostAndTrackAnalytics(activity,post);
  }
 else {
    UploadService.uploadPost(activity,post);
  }
  PostUtils.trackSavePostAnalytics(post,site);
}
Program: 13761
Project: 13761
Buggy source:
/** 
 * Returns an error message string for a failed post upload.
 */
public static @NonNull String getErrorMessageFromPostError(Context context,PostModel post,PostError error){
switch (error.type) {
case UNKNOWN_POST:
    return post.isPage() ? context.getString(R.string.error_unknown_page_param) : context.getString(R.string.error_unknown_post_param);
case UNKNOWN_POST_TYPE:
  return context.getString(R.string.error_unknown_post_type);
case UNAUTHORIZED:
return post.isPage() ? context.getString(R.string.error_refresh_unauthorized_pages) : context.getString(R.string.error_refresh_unauthorized_posts);
}
return TextUtils.isEmpty(error.message) ? error.type.toString() : error.message;
}

Fixed version (ground truth):
/** 
 * Returns an error message string for a failed post upload.
 */
public static @NonNull String getErrorMessageFromPostError(Context context,PostModel post,PostError error){
switch (error.type) {
case UNKNOWN_POST:
    return post.isPage() ? context.getString(R.string.error_unknown_page) : context.getString(R.string.error_unknown_post);
case UNKNOWN_POST_TYPE:
  return context.getString(R.string.error_unknown_post_type);
case UNAUTHORIZED:
return post.isPage() ? context.getString(R.string.error_refresh_unauthorized_pages) : context.getString(R.string.error_refresh_unauthorized_posts);
}
return TextUtils.isEmpty(error.message) ? error.type.toString() : error.message;
}
Program: 13762
Project: 13762
Buggy source:
/** 
 * Returns a post-type specific error message string.
 */
static @NonNull String getErrorMessage(Context context,PostModel post,String errorMessage,boolean isMediaError){
  String baseErrorString;
  if (post.isPage()) {
    if (isMediaError) {
      baseErrorString=context.getString(R.string.error_upload_page_media_params);
    }
 else {
      baseErrorString=context.getString(R.string.error_upload_page_params);
    }
  }
 else {
    if (isMediaError) {
      baseErrorString=context.getString(R.string.error_upload_post_media_params);
    }
 else {
      baseErrorString=context.getString(R.string.error_upload_post_params);
    }
  }
  return String.format(baseErrorString,errorMessage);
}

Fixed version (ground truth):
/** 
 * Returns a post-type specific error message string.
 */
static @NonNull String getErrorMessage(Context context,PostModel post,String errorMessage,boolean isMediaError){
  String baseErrorString;
  if (post.isPage()) {
    if (isMediaError) {
      baseErrorString=context.getString(R.string.error_upload_page_media_param);
    }
 else {
      baseErrorString=context.getString(R.string.error_upload_page_param);
    }
  }
 else {
    if (isMediaError) {
      baseErrorString=context.getString(R.string.error_upload_post_media_param);
    }
 else {
      baseErrorString=context.getString(R.string.error_upload_post_param);
    }
  }
  return String.format(baseErrorString,errorMessage);
}
Program: 13764
Project: 13764
Buggy source:
public static void publishPost(Activity activity,final PostModel post,SiteModel site,Dispatcher dispatcher){
  if (!NetworkUtils.isNetworkAvailable(activity)) {
    ToastUtils.showToast(activity,R.string.error_publish_no_network,ToastUtils.Duration.SHORT);
    return;
  }
  if (!PostUtils.isPublishable(post)) {
    String postType=activity.getString(post.isPage() ? R.string.page : R.string.post).toLowerCase();
    String message=activity.getString(R.string.error_publish_empty_post_param,postType);
    ToastUtils.showToast(activity,message,ToastUtils.Duration.SHORT);
    return;
  }
  PostUtils.updatePublishDateIfShouldBePublishedImmediately(post);
  boolean isFirstTimePublish=PostStatus.fromPost(post) == PostStatus.DRAFT || (PostStatus.fromPost(post) == PostStatus.PUBLISHED && post.isLocalDraft());
  post.setStatus(PostStatus.PUBLISHED.toString());
  dispatcher.dispatch(PostActionBuilder.newUpdatePostAction(post));
  if (isFirstTimePublish) {
    UploadService.uploadPostAndTrackAnalytics(activity,post);
  }
 else {
    UploadService.uploadPost(activity,post);
  }
  PostUtils.trackSavePostAnalytics(post,site);
}

Fixed version (ground truth):
public static void publishPost(Activity activity,final PostModel post,SiteModel site,Dispatcher dispatcher){
  if (!NetworkUtils.isNetworkAvailable(activity)) {
    ToastUtils.showToast(activity,R.string.error_publish_no_network,ToastUtils.Duration.SHORT);
    return;
  }
  if (!PostUtils.isPublishable(post)) {
    String message=activity.getString(post.isPage() ? R.string.error_publish_empty_page_param : R.string.error_publish_empty_post_param);
    ToastUtils.showToast(activity,message,ToastUtils.Duration.SHORT);
    return;
  }
  PostUtils.updatePublishDateIfShouldBePublishedImmediately(post);
  boolean isFirstTimePublish=PostStatus.fromPost(post) == PostStatus.DRAFT || (PostStatus.fromPost(post) == PostStatus.PUBLISHED && post.isLocalDraft());
  post.setStatus(PostStatus.PUBLISHED.toString());
  dispatcher.dispatch(PostActionBuilder.newUpdatePostAction(post));
  if (isFirstTimePublish) {
    UploadService.uploadPostAndTrackAnalytics(activity,post);
  }
 else {
    UploadService.uploadPost(activity,post);
  }
  PostUtils.trackSavePostAnalytics(post,site);
}
Program: 13765
Project: 13765
Buggy source:
/** 
 * Returns an error message string for a failed post upload.
 */
public static @NonNull String getErrorMessageFromPostError(Context context,PostModel post,PostError error){
switch (error.type) {
case UNKNOWN_POST:
    String postType=context.getString(post.isPage() ? R.string.page : R.string.post).toLowerCase();
  return context.getString(R.string.error_unknown_post_param,postType);
case UNKNOWN_POST_TYPE:
return context.getString(R.string.error_unknown_post_type);
case UNAUTHORIZED:
return post.isPage() ? context.getString(R.string.error_refresh_unauthorized_pages) : context.getString(R.string.error_refresh_unauthorized_posts);
}
return TextUtils.isEmpty(error.message) ? error.type.toString() : error.message;
}

Fixed version (ground truth):
/** 
 * Returns an error message string for a failed post upload.
 */
public static @NonNull String getErrorMessageFromPostError(Context context,PostModel post,PostError error){
switch (error.type) {
case UNKNOWN_POST:
    return post.isPage() ? context.getString(R.string.error_unknown_page_param) : context.getString(R.string.error_unknown_post_param);
case UNKNOWN_POST_TYPE:
  return context.getString(R.string.error_unknown_post_type);
case UNAUTHORIZED:
return post.isPage() ? context.getString(R.string.error_refresh_unauthorized_pages) : context.getString(R.string.error_refresh_unauthorized_posts);
}
return TextUtils.isEmpty(error.message) ? error.type.toString() : error.message;
}
Program: 13766
Project: 13766
Buggy source:
/** 
 * Returns a post-type specific error message string.
 */
static @NonNull String getErrorMessage(Context context,PostModel post,String errorMessage,boolean isMediaError){
  String baseErrorString=context.getString(isMediaError ? R.string.error_upload_post_media_params : R.string.error_upload_post_params);
  String postType=context.getString(post.isPage() ? R.string.page : R.string.post).toLowerCase();
  return String.format(baseErrorString,postType,errorMessage);
}

Fixed version (ground truth):
/** 
 * Returns a post-type specific error message string.
 */
static @NonNull String getErrorMessage(Context context,PostModel post,String errorMessage,boolean isMediaError){
  String baseErrorString;
  if (post.isPage()) {
    if (isMediaError) {
      baseErrorString=context.getString(R.string.error_upload_page_media_params);
    }
 else {
      baseErrorString=context.getString(R.string.error_upload_page_params);
    }
  }
 else {
    if (isMediaError) {
      baseErrorString=context.getString(R.string.error_upload_post_media_params);
    }
 else {
      baseErrorString=context.getString(R.string.error_upload_post_params);
    }
  }
  return String.format(baseErrorString,errorMessage);
}
Program: 13767
Project: 13767
Buggy source:
@Override public void onMediaItemSelected(View sourceView,int localMediaId){
  MediaModel media=mMediaStore.getMediaWithLocalId(localMediaId);
  if (media == null) {
    AppLog.w(AppLog.T.MEDIA,"String_Node_Str" + localMediaId);
    ToastUtils.showToast(this,R.string.error_media_load);
    return;
  }
  if (mBrowserType.isPicker()) {
    Intent intent=new Intent();
    ArrayList<Long> remoteMediaIds=new ArrayList<>();
    remoteMediaIds.add(media.getMediaId());
    intent.putExtra(RESULT_IDS,ListUtils.toLongArray(remoteMediaIds));
    setResult(RESULT_OK,intent);
    finish();
  }
 else {
    String mimeType=StringUtils.notNullStr(media.getMimeType()).toLowerCase();
    if (mimeType.startsWith("String_Node_Str") || mimeType.startsWith("String_Node_Str")) {
      MediaPreviewActivity.showPreview(this,sourceView,mSite,localMediaId);
    }
  }
}

Fixed version (ground truth):
@Override public void onMediaItemSelected(View sourceView,int localMediaId){
  MediaModel media=mMediaStore.getMediaWithLocalId(localMediaId);
  if (media == null) {
    AppLog.w(AppLog.T.MEDIA,"String_Node_Str" + localMediaId);
    ToastUtils.showToast(this,R.string.error_media_load);
    return;
  }
  if (mBrowserType.isPicker()) {
    Intent intent=new Intent();
    ArrayList<Long> remoteMediaIds=new ArrayList<>();
    remoteMediaIds.add(media.getMediaId());
    intent.putExtra(RESULT_IDS,ListUtils.toLongArray(remoteMediaIds));
    setResult(RESULT_OK,intent);
    finish();
  }
 else {
    String mimeType=StringUtils.notNullStr(media.getMimeType()).toLowerCase();
    if (mimeType.startsWith("String_Node_Str") || mimeType.startsWith("String_Node_Str")) {
      if (media.getUploadState() != null && MediaUtils.isLocalFile(media.getUploadState().toLowerCase())) {
        MediaPreviewActivity.showPreview(this,sourceView,media.getFilePath(),mimeType.startsWith("String_Node_Str"));
      }
 else {
        MediaPreviewActivity.showPreview(this,sourceView,mSite,localMediaId);
      }
    }
  }
}
Program: 13768
Project: 13768
Buggy source:
private void checkSmartLockPasswordAndStartLogin(){
  if (!mSmartLockCompleted && mSmartLockHelper == null) {
    mSmartLockHelper=new SmartLockHelper(this);
    mSmartLockHelper.initSmartLockForPasswords();
  }
 else {
    startLogin();
  }
}

Fixed version (ground truth):
private void checkSmartLockPasswordAndStartLogin(){
  boolean smartLockStarted=false;
  if (!mSmartLockCompleted && mSmartLockHelper == null) {
    mSmartLockHelper=new SmartLockHelper(this);
    smartLockStarted=mSmartLockHelper.initSmartLockForPasswords();
  }
  if (!smartLockStarted) {
    startLogin();
  }
}
Program: 13769
Project: 13769
Buggy source:
public void initSmartLockForPasswords(){
  FragmentActivity activity=getActivityAndCheckAvailability();
  if (activity == null) {
    return;
  }
  mCredentialsClient=new GoogleApiClient.Builder(activity).addConnectionCallbacks((ConnectionCallbacks)activity).enableAutoManage(activity,(OnConnectionFailedListener)activity).addApi(Auth.CREDENTIALS_API).build();
}

Fixed version (ground truth):
public boolean initSmartLockForPasswords(){
  FragmentActivity activity=getActivityAndCheckAvailability();
  if (activity == null) {
    return false;
  }
  mCredentialsClient=new GoogleApiClient.Builder(activity).addConnectionCallbacks((ConnectionCallbacks)activity).enableAutoManage(activity,(OnConnectionFailedListener)activity).addApi(Auth.CREDENTIALS_API).build();
  return true;
}
Program: 13770
Project: 13770
Buggy source:
@Override public void onResponse(ImageLoader.ImageContainer response,boolean isImmediate){
  Bitmap bitmap=response.getBitmap();
  if (bitmap == null) {
    callbacks.onImageLoading(null);
  }
 else {
    BitmapDrawable bitmapDrawable=new BitmapDrawable(context.getResources(),bitmap);
    callbacks.onImageLoaded(bitmapDrawable);
  }
}

Fixed version (ground truth):
@Override public void onResponse(ImageLoader.ImageContainer response,boolean isImmediate){
  Bitmap bitmap=response.getBitmap();
  if (bitmap == null && !isImmediate) {
    callbacks.onImageFailed();
  }
 else {
    BitmapDrawable bitmapDrawable=new BitmapDrawable(context.getResources(),bitmap);
    callbacks.onImageLoaded(bitmapDrawable);
  }
}
Program: 13771
Project: 13771
Buggy source:
@Override public void loadImage(String url,final Callbacks callbacks,int maxWidth){
  if (new File(url).exists()) {
    int orientation=ImageUtils.getImageOrientation(this.context,url);
    byte[] bytes=ImageUtils.createThumbnailFromUri(context,Uri.parse(url),maxWidth,null,orientation);
    if (bytes != null) {
      Bitmap bitmap=BitmapFactory.decodeByteArray(bytes,0,bytes.length);
      BitmapDrawable bitmapDrawable=new BitmapDrawable(context.getResources(),bitmap);
      callbacks.onImageLoaded(bitmapDrawable);
    }
 else {
      callbacks.onImageFailed();
    }
    return;
  }
  WordPress.sImageLoader.get(url,new ImageLoader.ImageListener(){
    @Override public void onResponse(    ImageLoader.ImageContainer response,    boolean isImmediate){
      Bitmap bitmap=response.getBitmap();
      if (bitmap == null) {
        callbacks.onImageLoading(null);
      }
 else {
        BitmapDrawable bitmapDrawable=new BitmapDrawable(context.getResources(),bitmap);
        callbacks.onImageLoaded(bitmapDrawable);
      }
    }
    @Override public void onErrorResponse(    VolleyError error){
      callbacks.onImageFailed();
    }
  }
,maxWidth,0);
}

Fixed version (ground truth):
@Override public void loadImage(String url,final Callbacks callbacks,int maxWidth){
  final int maxWidthForEditor=ImageUtils.getMaximumThumbnailWidthForEditor(context);
  if (new File(url).exists()) {
    int orientation=ImageUtils.getImageOrientation(this.context,url);
    byte[] bytes=ImageUtils.createThumbnailFromUri(context,Uri.parse(url),maxWidthForEditor,null,orientation);
    if (bytes != null) {
      Bitmap bitmap=BitmapFactory.decodeByteArray(bytes,0,bytes.length);
      BitmapDrawable bitmapDrawable=new BitmapDrawable(context.getResources(),bitmap);
      callbacks.onImageLoaded(bitmapDrawable);
    }
 else {
      callbacks.onImageFailed();
    }
    return;
  }
  Drawable drawable=context.getResources().getDrawable(R.drawable.ic_gridicons_image);
  drawable.setBounds(0,0,AztecEditorFragment.DEFAULT_MEDIA_PLACEHOLDER_DIMENSION_DP,AztecEditorFragment.DEFAULT_MEDIA_PLACEHOLDER_DIMENSION_DP);
  callbacks.onImageLoading(drawable);
  WordPress.sImageLoader.get(url,new ImageLoader.ImageListener(){
    @Override public void onResponse(    ImageLoader.ImageContainer response,    boolean isImmediate){
      Bitmap bitmap=response.getBitmap();
      if (bitmap == null && !isImmediate) {
        callbacks.onImageFailed();
      }
 else {
        BitmapDrawable bitmapDrawable=new BitmapDrawable(context.getResources(),bitmap);
        callbacks.onImageLoaded(bitmapDrawable);
      }
    }
    @Override public void onErrorResponse(    VolleyError error){
      callbacks.onImageFailed();
    }
  }
,maxWidthForEditor,0);
}
Program: 13772
Project: 13772
Buggy source:
public void loadVideoThumbnail(final String url,final Html.VideoThumbnailGetter.Callbacks callbacks,final int maxWidth){
  if (TextUtils.isEmpty(url) || maxWidth <= 0) {
    callbacks.onThumbnailFailed();
    return;
  }
  new AsyncTask<Void,Void,Bitmap>(){
    protected Bitmap doInBackground(    Void... params){
      callbacks.onThumbnailLoading(null);
      if (new File(url).exists()) {
        Bitmap thumb=ThumbnailUtils.createVideoThumbnail(url,MediaStore.Images.Thumbnails.FULL_SCREEN_KIND);
        return ImageUtils.getScaledBitmapAtLongestSide(thumb,maxWidth);
      }
      return ImageUtils.getVideoFrameFromVideo(url,maxWidth);
    }
    protected void onPostExecute(    Bitmap thumb){
      if (thumb == null) {
        callbacks.onThumbnailFailed();
      }
      BitmapDrawable bitmapDrawable=new BitmapDrawable(context.getResources(),thumb);
      callbacks.onThumbnailLoaded(bitmapDrawable);
    }
  }
.execute();
}

Fixed version (ground truth):
public void loadVideoThumbnail(final String url,final Html.VideoThumbnailGetter.Callbacks callbacks,final int maxWidth){
  final int maxWidthForEditor=ImageUtils.getMaximumThumbnailWidthForEditor(context);
  if (TextUtils.isEmpty(url) || maxWidthForEditor <= 0) {
    callbacks.onThumbnailFailed();
    return;
  }
  Drawable drawable=context.getResources().getDrawable(R.drawable.ic_gridicons_video_camera);
  drawable.setBounds(0,0,AztecEditorFragment.DEFAULT_MEDIA_PLACEHOLDER_DIMENSION_DP,AztecEditorFragment.DEFAULT_MEDIA_PLACEHOLDER_DIMENSION_DP);
  callbacks.onThumbnailLoading(drawable);
  new AsyncTask<Void,Void,Bitmap>(){
    protected Bitmap doInBackground(    Void... params){
      if (new File(url).exists()) {
        Bitmap thumb=ThumbnailUtils.createVideoThumbnail(url,MediaStore.Images.Thumbnails.FULL_SCREEN_KIND);
        return ImageUtils.getScaledBitmapAtLongestSide(thumb,maxWidthForEditor);
      }
      return ImageUtils.getVideoFrameFromVideo(url,maxWidthForEditor);
    }
    protected void onPostExecute(    Bitmap thumb){
      if (thumb == null) {
        callbacks.onThumbnailFailed();
      }
      BitmapDrawable bitmapDrawable=new BitmapDrawable(context.getResources(),thumb);
      callbacks.onThumbnailLoaded(bitmapDrawable);
    }
  }
.execute();
}
Program: 13773
Project: 13773
Buggy source:
protected Bitmap doInBackground(Void... params){
  callbacks.onThumbnailLoading(null);
  if (new File(url).exists()) {
    Bitmap thumb=ThumbnailUtils.createVideoThumbnail(url,MediaStore.Images.Thumbnails.FULL_SCREEN_KIND);
    return ImageUtils.getScaledBitmapAtLongestSide(thumb,maxWidth);
  }
  return ImageUtils.getVideoFrameFromVideo(url,maxWidth);
}

Fixed version (ground truth):
protected Bitmap doInBackground(Void... params){
  if (new File(url).exists()) {
    Bitmap thumb=ThumbnailUtils.createVideoThumbnail(url,MediaStore.Images.Thumbnails.FULL_SCREEN_KIND);
    return ImageUtils.getScaledBitmapAtLongestSide(thumb,maxWidthForEditor);
  }
  return ImageUtils.getVideoFrameFromVideo(url,maxWidthForEditor);
}
Program: 13775
Project: 13775
Buggy source:
@Override public void onResponse(ImageLoader.ImageContainer container,boolean isImmediate){
  if (!isAdded()) {
    return;
  }
  Bitmap downloadedBitmap=container.getBitmap();
  if (downloadedBitmap == null) {
    if (isImmediate) {
      return;
    }
    showErrorPlaceholder();
    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);
    replaceDrawable(drawable);
    return;
  }
  Bitmap resizedBitmap=ImageUtils.getScaledBitmapAtLongestSide(downloadedBitmap,maxWidth);
  replaceDrawable(new BitmapDrawable(getResources(),resizedBitmap));
  if (mediaFile.isVideo()) {
    addVideoUploadingClassIfMissing(attributes);
    content.insertVideo(new BitmapDrawable(getResources(),resizedBitmap),attributes);
    overlayVideoIcon(0,new MediaPredicate(mediaUrl,ATTR_SRC));
  }
 else {
    content.insertImage(new BitmapDrawable(getResources(),resizedBitmap),attributes);
  }
}

Fixed version (ground truth):
@Override public void onResponse(ImageLoader.ImageContainer container,boolean isImmediate){
  if (!isAdded()) {
    return;
  }
  Bitmap downloadedBitmap=container.getBitmap();
  if (downloadedBitmap == null) {
    if (isImmediate) {
      return;
    }
    showErrorPlaceholder();
    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);
    replaceDrawable(drawable);
    return;
  }
  Bitmap resizedBitmap=ImageUtils.getScaledBitmapAtLongestSide(downloadedBitmap,maxWidth);
  replaceDrawable(new BitmapDrawable(getResources(),resizedBitmap));
}
Program: 13776
Project: 13776
Buggy source:
public static Uri getOptimizedMedia(Activity activity,String path,boolean isVideo){
  if (isVideo) {
    return null;
  }
  int resizeWidth=AppPrefs.getImageOptimizeWidth() > 0 ? AppPrefs.getImageOptimizeWidth() : Integer.MAX_VALUE;
  int quality=AppPrefs.getImageOptimizeQuality();
  if (resizeWidth == Integer.MAX_VALUE && quality == 100) {
    return null;
  }
  String optimizedPath=ImageUtils.optimizeImage(activity,path,resizeWidth,quality);
  if (optimizedPath == null) {
    AppLog.e(AppLog.T.EDITOR,"String_Node_Str");
    AnalyticsTracker.track(AnalyticsTracker.Stat.MEDIA_PHOTO_OPTIMIZE_ERROR);
  }
 else {
    AnalyticsTracker.track(AnalyticsTracker.Stat.MEDIA_PHOTO_OPTIMIZED);
    return Uri.parse(optimizedPath);
  }
  return null;
}

Fixed version (ground truth):
public static Uri getOptimizedMedia(Activity activity,String path,boolean isVideo){
  if (isVideo) {
    return null;
  }
  int resizeWidth=AppPrefs.getImageOptimizeWidth() > 1 ? AppPrefs.getImageOptimizeWidth() : Integer.MAX_VALUE;
  int quality=AppPrefs.getImageOptimizeQuality();
  if (resizeWidth == Integer.MAX_VALUE && quality == 100) {
    return null;
  }
  String optimizedPath=ImageUtils.optimizeImage(activity,path,resizeWidth,quality);
  if (optimizedPath == null) {
    AppLog.e(AppLog.T.EDITOR,"String_Node_Str");
    AnalyticsTracker.track(AnalyticsTracker.Stat.MEDIA_PHOTO_OPTIMIZE_ERROR);
  }
 else {
    AnalyticsTracker.track(AnalyticsTracker.Stat.MEDIA_PHOTO_OPTIMIZED);
    return Uri.parse(optimizedPath);
  }
  return null;
}
Program: 13777
Project: 13777
Buggy source:
@Override public void onSettingsUpdated(Exception error){
  if (error == null) {
    updatePostFormat(mSiteSettings.getDefaultPostFormat());
  }
}

Fixed version (ground truth):
@Override public void onSettingsUpdated(Exception error){
  if (error == null && mEditPostActivityHook != null) {
    updatePostFormat(mSiteSettings.getDefaultPostFormat());
  }
}