nus-yam/ex-repair huggingface dataset:
Program: 19148
Project: 19148
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case android.R.id.home:
    getActivity().finish();
  return true;
case R.id.selectAll:
if (PARAM_SCREEN__CACHE_TYPE.equals(mSubScreenKey)) {
  for (int i=0; i < CacheType.values().length; i++)   findPreference(FILTER_CACHE_TYPE_PREFIX + i,CheckBoxPreference.class).setChecked(true);
}
 else if (PARAM_SCREEN__CONTAINER_TYPE.equals(mSubScreenKey)) {
  for (int i=0; i < ContainerType.values().length; i++)   findPreference(FILTER_CONTAINER_TYPE_PREFIX + i,CheckBoxPreference.class).setChecked(true);
}
return true;
case R.id.deselectAll:
if (PARAM_SCREEN__CACHE_TYPE.equals(mSubScreenKey)) {
for (int i=0; i < CacheType.values().length; i++) findPreference(FILTER_CACHE_TYPE_PREFIX + i,CheckBoxPreference.class).setChecked(false);
}
 else if (PARAM_SCREEN__CONTAINER_TYPE.equals(mSubScreenKey)) {
for (int i=0; i < ContainerType.values().length; i++) findPreference(FILTER_CONTAINER_TYPE_PREFIX + i,CheckBoxPreference.class).setChecked(false);
}
return true;
default :
return super.onOptionsItemSelected(item);
}
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case android.R.id.home:
    getActivity().finish();
  return true;
case R.id.selectAll:
if (PARAM_SCREEN__CACHE_TYPE.equals(mSubScreenKey)) {
  for (int i=0; i < GeocacheType.values().length; i++)   findPreference(FILTER_CACHE_TYPE_PREFIX + i,CheckBoxPreference.class).setChecked(true);
}
 else if (PARAM_SCREEN__CONTAINER_TYPE.equals(mSubScreenKey)) {
  for (int i=0; i < ContainerType.values().length; i++)   findPreference(FILTER_CONTAINER_TYPE_PREFIX + i,CheckBoxPreference.class).setChecked(true);
}
return true;
case R.id.deselectAll:
if (PARAM_SCREEN__CACHE_TYPE.equals(mSubScreenKey)) {
for (int i=0; i < GeocacheType.values().length; i++) findPreference(FILTER_CACHE_TYPE_PREFIX + i,CheckBoxPreference.class).setChecked(false);
}
 else if (PARAM_SCREEN__CONTAINER_TYPE.equals(mSubScreenKey)) {
for (int i=0; i < ContainerType.values().length; i++) findPreference(FILTER_CONTAINER_TYPE_PREFIX + i,CheckBoxPreference.class).setChecked(false);
}
return true;
default :
return super.onOptionsItemSelected(item);
}
}
Program: 19149
Project: 19149
Buggy source:
private CharSequence prepareCacheTypeSummary(){
  StringBuilder sb=new StringBuilder();
  boolean allChecked=true;
  boolean noneChecked=true;
  for (int i=0; i < CacheType.values().length; i++) {
    if (mPrefs.getBoolean(PrefConstants.FILTER_CACHE_TYPE_PREFIX + i,true)) {
      noneChecked=false;
    }
 else {
      allChecked=false;
    }
  }
  if (allChecked || noneChecked) {
    sb.append(getString(R.string.pref_cache_type_all));
  }
 else {
    for (int i=0; i < CacheType.values().length; i++) {
      if (mPrefs.getBoolean(PrefConstants.FILTER_CACHE_TYPE_PREFIX + i,true)) {
        if (sb.length() != 0)         sb.append("String_Node_Str");
        sb.append(shortCacheTypeName[i]);
      }
    }
  }
  return preparePreferenceSummary(sb.toString(),0);
}

Fixed version (ground truth):
private CharSequence prepareCacheTypeSummary(){
  StringBuilder sb=new StringBuilder();
  boolean allChecked=true;
  boolean noneChecked=true;
  for (int i=0; i < GeocacheType.values().length; i++) {
    if (mPrefs.getBoolean(PrefConstants.FILTER_CACHE_TYPE_PREFIX + i,true)) {
      noneChecked=false;
    }
 else {
      allChecked=false;
    }
  }
  if (allChecked || noneChecked) {
    sb.append(getString(R.string.pref_cache_type_all));
  }
 else {
    for (int i=0; i < GeocacheType.values().length; i++) {
      if (mPrefs.getBoolean(PrefConstants.FILTER_CACHE_TYPE_PREFIX + i,true)) {
        if (sb.length() != 0)         sb.append("String_Node_Str");
        sb.append(shortCacheTypeName[i]);
      }
    }
  }
  return preparePreferenceSummary(sb.toString(),0);
}
Program: 19150
Project: 19150
Buggy source:
private CacheType[] getCacheTypeFilterResult(SharedPreferences prefs){
  List<CacheType> filter=new Vector<>();
  for (int i=0; i < CacheType.values().length; i++) {
    if (prefs.getBoolean(PrefConstants.FILTER_CACHE_TYPE_PREFIX + i,true)) {
      filter.add(CacheType.values()[i]);
    }
  }
  return filter.toArray(new CacheType[filter.size()]);
}

Fixed version (ground truth):
private GeocacheType[] getCacheTypeFilterResult(SharedPreferences prefs){
  List<GeocacheType> filter=new Vector<>();
  for (int i=0; i < GeocacheType.values().length; i++) {
    if (prefs.getBoolean(PrefConstants.FILTER_CACHE_TYPE_PREFIX + i,true)) {
      filter.add(GeocacheType.values()[i]);
    }
  }
  return filter.toArray(new GeocacheType[filter.size()]);
}
Program: 19151
Project: 19151
Buggy source:
private CacheType[] getCacheTypeFilterResult(@NonNull SharedPreferences prefs){
  Vector<CacheType> filter=new Vector<>();
  for (int i=0; i < CacheType.values().length; i++) {
    if (prefs.getBoolean(PrefConstants.FILTER_CACHE_TYPE_PREFIX + i,true)) {
      filter.add(CacheType.values()[i]);
    }
  }
  return filter.toArray(new CacheType[filter.size()]);
}

Fixed version (ground truth):
private GeocacheType[] getCacheTypeFilterResult(@NonNull SharedPreferences prefs){
  Vector<GeocacheType> filter=new Vector<>();
  for (int i=0; i < GeocacheType.values().length; i++) {
    if (prefs.getBoolean(PrefConstants.FILTER_CACHE_TYPE_PREFIX + i,true)) {
      filter.add(GeocacheType.values()[i]);
    }
  }
  return filter.toArray(new GeocacheType[filter.size()]);
}
Program: 19157
Project: 19157
Buggy source:
public GeocachingLiveApiConfiguration(Context context){
  preferences=context.getSharedPreferences(GeocachingLiveApiProvider.PROVIDER_ID);
  restrictions=new AccountRestrictions(preferences);
}

Fixed version (ground truth):
public GeocachingLiveApiConfiguration(Context context){
  preferences=context.getSharedPreferences(GeocachingLiveApiProvider.PROVIDER_ID,Context.MODE_PRIVATE);
  restrictions=new AccountRestrictions(preferences);
}
Program: 19158
Project: 19158
Buggy source:
@Override public void onStart(){
  super.onStart();
  if (errorMessage != null) {
    editText.setError(errorMessage);
    errorMessage=null;
  }
}

Fixed version (ground truth):
@Override public void onStart(){
  super.onStart();
  getDialog().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
  if (errorMessage != null) {
    editText.setError(errorMessage);
    errorMessage=null;
  }
}
Program: 19159
Project: 19159
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  if (savedInstanceState == null)   savedInstanceState=lastInstanceState;
  getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
  View view=inflater.inflate(R.layout.dialog_login,container);
  progressHolder=view.findViewById(R.id.progressHolder);
  progressHolder.setVisibility(View.VISIBLE);
  if (savedInstanceState != null) {
    progressHolder.setVisibility(savedInstanceState.getInt(STATE_PROGRESS_VISIBLE,View.VISIBLE));
  }
  webView=createWebView(savedInstanceState);
  ViewManager webViewHolder=(ViewManager)view.findViewById(R.id.webViewPlaceholder);
  webViewHolder.addView(webView,new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));
  return view;
}

Fixed version (ground truth):
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  if (savedInstanceState == null)   savedInstanceState=lastInstanceState;
  getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
  View view=inflater.inflate(R.layout.dialog_login,container);
  progressHolder=view.findViewById(R.id.progressHolder);
  progressHolder.setVisibility(View.VISIBLE);
  if (savedInstanceState != null) {
    progressHolder.setVisibility(savedInstanceState.getInt(STATE_PROGRESS_VISIBLE,View.VISIBLE));
  }
  webView=createWebView(savedInstanceState);
  FrameLayout webViewHolder=(FrameLayout)view.findViewById(R.id.webViewPlaceholder);
  webViewHolder.addView(webView,new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));
  return view;
}
Program: 19160
Project: 19160
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (!LocusTesting.isLocusInstalled(this)) {
    LocusTesting.showLocusMissingError(this);
    return;
  }
  ImportDialogFragment fragment=(ImportDialogFragment)getSupportFragmentManager().findFragmentByTag(ImportDialogFragment.TAG);
  if (fragment != null) {
    fragment.show(getSupportFragmentManager(),ImportDialogFragment.TAG);
    return;
  }
  if (!Geocaching4LocusApplication.getAuthenticatorHelper().hasAccount()) {
    if (savedInstanceState != null)     authenticatorActivityVisible=savedInstanceState.getBoolean(AppConstants.STATE_AUTHENTICATOR_ACTIVITY_VISIBLE,false);
    if (!authenticatorActivityVisible) {
      startActivityForResult(AuthenticatorActivity.createIntent(this,true),REQUEST_LOGIN);
      authenticatorActivityVisible=true;
    }
    return;
  }
  if (showBasicMemeberWarningDialog())   return;
  showGCNumberInputDialog=true;
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (!LocusTesting.isLocusInstalled(this)) {
    LocusTesting.showLocusMissingError(this);
    return;
  }
  if (getSupportFragmentManager().findFragmentByTag(ImportDialogFragment.TAG) != null) {
    showGCNumberInputDialog=false;
    return;
  }
  if (!Geocaching4LocusApplication.getAuthenticatorHelper().hasAccount()) {
    if (savedInstanceState != null)     authenticatorActivityVisible=savedInstanceState.getBoolean(AppConstants.STATE_AUTHENTICATOR_ACTIVITY_VISIBLE,false);
    if (!authenticatorActivityVisible) {
      startActivityForResult(AuthenticatorActivity.createIntent(this,true),REQUEST_LOGIN);
      authenticatorActivityVisible=true;
    }
    return;
  }
  if (showBasicMemeberWarningDialog())   return;
  showGCNumberInputDialog=true;
}
Program: 19161
Project: 19161
Buggy source:
protected void sendError(Throwable exception){
  Intent intent=new ExceptionHandler(this).handle(exception);
  final int resErrorId=intent.getIntExtra(ErrorActivity.PARAM_RESOURCE_TEXT,0);
  notificationManager.notify(resErrorId,createErrorNotification(intent));
  LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}

Fixed version (ground truth):
protected void sendError(Throwable exception){
  if (!canceled) {
    notificationManager.cancel(notificationId);
  }
  Intent intent=new ExceptionHandler(this).handle(exception);
  final int resErrorId=intent.getIntExtra(ErrorActivity.PARAM_RESOURCE_TEXT,0);
  notificationManager.notify(resErrorId,createErrorNotification(intent));
  LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
Program: 19162
Project: 19162
Buggy source:
@Override public void onCancel(AbstractDialogFragment dialogFragment){
  SearchNearestActivity activity=activityRef.get();
  if (activity == null)   return;
  pd=null;
  activity.stopService(new Intent(activity,SearchGeocacheService.class));
}

Fixed version (ground truth):
@Override public void onCancel(AbstractDialogFragment dialogFragment){
  SearchNearestActivity activity=activityRef.get();
  if (activity == null)   return;
  if (pd != null && pd.isShowing())   pd.dismiss();
  pd=null;
  activity.stopService(new Intent(activity,SearchGeocacheService.class));
}
Program: 19163
Project: 19163
Buggy source:
@Override public synchronized void onReceive(Context context,final Intent intent){
  SearchNearestActivity activity=activityRef.get();
  if (activity == null || !registered)   return;
  if (pd == null)   pd=(DownloadProgressDialogFragment)activity.getSupportFragmentManager().findFragmentByTag(DownloadProgressDialogFragment.TAG);
  if (SearchGeocacheService.ACTION_PROGRESS_UPDATE.equals(intent.getAction())) {
    if (pd == null) {
      pd=DownloadProgressDialogFragment.newInstance(R.string.downloading,intent.getIntExtra(SearchGeocacheService.PARAM_COUNT,1),intent.getIntExtra(SearchGeocacheService.PARAM_CURRENT,0));
      pd.setOnCancelListener(this);
      pd.show(activity.getSupportFragmentManager(),DownloadProgressDialogFragment.TAG);
    }
    pd.setProgress(intent.getIntExtra(SearchGeocacheService.PARAM_CURRENT,0));
  }
 else   if (SearchGeocacheService.ACTION_PROGRESS_COMPLETE.equals(intent.getAction())) {
    if (pd != null && pd.isShowing())     pd.dismiss();
    if (intent.getIntExtra(SearchGeocacheService.PARAM_COUNT,0) != 0 && !activity.isFinishing()) {
      activity.finish();
    }
  }
 else   if (ErrorActivity.ACTION_ERROR.equals(intent.getAction())) {
    if (pd != null && pd.isShowing())     pd.dismiss();
    Intent errorIntent=new Intent(intent);
    errorIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    activity.startActivity(errorIntent);
  }
}

Fixed version (ground truth):
@Override public synchronized void onReceive(Context context,final Intent intent){
  SearchNearestActivity activity=activityRef.get();
  if (activity == null || !registered)   return;
  if (pd == null)   pd=(DownloadProgressDialogFragment)activity.getSupportFragmentManager().findFragmentByTag(DownloadProgressDialogFragment.TAG);
  if (SearchGeocacheService.ACTION_PROGRESS_UPDATE.equals(intent.getAction())) {
    if (pd == null || !pd.isShowing()) {
      pd=DownloadProgressDialogFragment.newInstance(R.string.downloading,intent.getIntExtra(SearchGeocacheService.PARAM_COUNT,1),intent.getIntExtra(SearchGeocacheService.PARAM_CURRENT,0));
      pd.setOnCancelListener(this);
      pd.show(activity.getSupportFragmentManager(),DownloadProgressDialogFragment.TAG);
      activity.getSupportFragmentManager().executePendingTransactions();
    }
    pd.setProgress(intent.getIntExtra(SearchGeocacheService.PARAM_CURRENT,0));
  }
 else   if (SearchGeocacheService.ACTION_PROGRESS_COMPLETE.equals(intent.getAction())) {
    if (pd != null && pd.isShowing())     pd.dismiss();
    if (intent.getIntExtra(SearchGeocacheService.PARAM_COUNT,0) != 0 && !activity.isFinishing()) {
      activity.finish();
    }
  }
 else   if (ErrorActivity.ACTION_ERROR.equals(intent.getAction())) {
    if (pd != null && pd.isShowing())     pd.dismiss();
    Intent errorIntent=new Intent(intent);
    errorIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    activity.startActivity(errorIntent);
  }
}
Program: 19164
Project: 19164
Buggy source:
protected void sendError(Throwable exception){
  if (!canceled) {
    notificationManager.cancel(notificationId);
  }
  Intent intent=new ExceptionHandler(this).handle(exception);
  final int resErrorId=intent.getIntExtra(ErrorActivity.PARAM_RESOURCE_TEXT,0);
  notificationManager.notify(resErrorId,createErrorNotification(intent));
  LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}

Fixed version (ground truth):
protected void sendError(Throwable exception){
  notificationManager.cancel(notificationId);
  Intent intent=new ExceptionHandler(this).handle(exception);
  final int resErrorId=intent.getIntExtra(ErrorActivity.PARAM_RESOURCE_TEXT,0);
  notificationManager.notify(resErrorId,createErrorNotification(intent));
  LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
Program: 19165
Project: 19165
Buggy source:
protected void sendProgressComplete(int count){
  if (!canceled) {
    notificationManager.cancel(notificationId);
  }
  Intent broadcastIntent=new Intent();
  broadcastIntent.setAction(ACTION_PROGRESS_COMPLETE);
  broadcastIntent.putExtra(PARAM_COUNT,count);
  broadcastIntent.putExtra(PARAM_CURRENT,count);
  LocalBroadcastManager.getInstance(this).sendBroadcast(broadcastIntent);
}

Fixed version (ground truth):
protected void sendProgressComplete(int count){
  notificationManager.cancel(notificationId);
  Intent broadcastIntent=new Intent();
  broadcastIntent.setAction(ACTION_PROGRESS_COMPLETE);
  broadcastIntent.putExtra(PARAM_COUNT,count);
  broadcastIntent.putExtra(PARAM_CURRENT,count);
  LocalBroadcastManager.getInstance(this).sendBroadcast(broadcastIntent);
}
Program: 19166
Project: 19166
Buggy source:
protected void requestProgressUpdate(){
  if (SearchGeocacheService.getInstance() != null)   SearchGeocacheService.getInstance().sendProgressUpdate();
}

Fixed version (ground truth):
protected void requestProgressUpdate(){
  if (SearchGeocacheService.getInstance() != null && !SearchGeocacheService.getInstance().isCanceled()) {
    SearchGeocacheService.getInstance().sendProgressUpdate();
  }
}
Program: 19167
Project: 19167
Buggy source:
@Override public void onCancel(AbstractDialogFragment dialogFragment){
  SearchNearestActivity activity=activityRef.get();
  if (activity == null)   return;
  activity.stopService(new Intent(activity,SearchGeocacheService.class));
}

Fixed version (ground truth):
@Override public void onCancel(AbstractDialogFragment dialogFragment){
  SearchNearestActivity activity=activityRef.get();
  if (activity == null)   return;
  pd=null;
  activity.stopService(new Intent(activity,SearchGeocacheService.class));
}
Program: 19168
Project: 19168
Buggy source:
@Override public synchronized void onReceive(Context context,final Intent intent){
  SearchNearestActivity activity=activityRef.get();
  if (activity == null || !registered)   return;
  if (pd == null)   pd=(DownloadProgressDialogFragment)activity.getSupportFragmentManager().findFragmentByTag(DownloadProgressDialogFragment.TAG);
  if (SearchGeocacheService.ACTION_PROGRESS_UPDATE.equals(intent.getAction())) {
    if (pd == null) {
      pd=DownloadProgressDialogFragment.newInstance(R.string.downloading,intent.getIntExtra(SearchGeocacheService.PARAM_COUNT,1),intent.getIntExtra(SearchGeocacheService.PARAM_CURRENT,0));
      pd.setOnCancelListener(this);
      pd.show(activity.getSupportFragmentManager(),DownloadProgressDialogFragment.TAG);
    }
 else {
      pd.setProgress(intent.getIntExtra(SearchGeocacheService.PARAM_CURRENT,0));
    }
  }
 else   if (SearchGeocacheService.ACTION_PROGRESS_COMPLETE.equals(intent.getAction())) {
    if (pd != null && pd.isShowing())     pd.dismiss();
    if (intent.getIntExtra(SearchGeocacheService.PARAM_COUNT,0) != 0 && !activity.isFinishing()) {
      activity.finish();
    }
  }
 else   if (ErrorActivity.ACTION_ERROR.equals(intent.getAction())) {
    if (pd != null && pd.isShowing())     pd.dismiss();
    Intent errorIntent=new Intent(intent);
    errorIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    activity.startActivity(errorIntent);
  }
}

Fixed version (ground truth):
@Override public synchronized void onReceive(Context context,final Intent intent){
  SearchNearestActivity activity=activityRef.get();
  if (activity == null || !registered)   return;
  if (pd == null)   pd=(DownloadProgressDialogFragment)activity.getSupportFragmentManager().findFragmentByTag(DownloadProgressDialogFragment.TAG);
  if (SearchGeocacheService.ACTION_PROGRESS_UPDATE.equals(intent.getAction())) {
    if (pd == null) {
      pd=DownloadProgressDialogFragment.newInstance(R.string.downloading,intent.getIntExtra(SearchGeocacheService.PARAM_COUNT,1),intent.getIntExtra(SearchGeocacheService.PARAM_CURRENT,0));
      pd.setOnCancelListener(this);
      pd.show(activity.getSupportFragmentManager(),DownloadProgressDialogFragment.TAG);
    }
    pd.setProgress(intent.getIntExtra(SearchGeocacheService.PARAM_CURRENT,0));
  }
 else   if (SearchGeocacheService.ACTION_PROGRESS_COMPLETE.equals(intent.getAction())) {
    if (pd != null && pd.isShowing())     pd.dismiss();
    if (intent.getIntExtra(SearchGeocacheService.PARAM_COUNT,0) != 0 && !activity.isFinishing()) {
      activity.finish();
    }
  }
 else   if (ErrorActivity.ACTION_ERROR.equals(intent.getAction())) {
    if (pd != null && pd.isShowing())     pd.dismiss();
    Intent errorIntent=new Intent(intent);
    errorIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    activity.startActivity(errorIntent);
  }
}
Program: 19169
Project: 19169
Buggy source:
@Override public Dialog onCreateDialog(Bundle savedInstanceState){
  Context context=new ContextThemeWrapper(getActivity(),R.style.G4LTheme_Dialog);
  View view=LayoutInflater.from(context).inflate(R.layout.gc_number_input_dialog,null);
  editText=(EditText)view.findViewById(R.id.gc_number_input_edit_text);
  editText.setText("String_Node_Str");
  editText.addTextChangedListener(new TextWatcher(){
    @Override public void afterTextChanged(    Editable s){
    }
    @Override public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    @Override public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
      if (s != null && s.length() > 0 && editText.getError() != null) {
        editText.setError(null);
      }
    }
  }
);
  if (savedInstanceState != null && savedInstanceState.containsKey(PARAM_INPUT)) {
    editText.setText(savedInstanceState.getCharSequence(PARAM_INPUT));
    editText.setError(savedInstanceState.getCharSequence(PARAM_ERROR_MESSAGE));
  }
  editText.setSelection(editText.getText().length());
  return new AlertDialog.Builder(context).setTitle(R.string.dialog_gc_number_input_title).setView(view).setPositiveButton(R.string.ok_button,new EmptyDialogOnClickListener()).setNegativeButton(R.string.cancel_button,new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      fireOnInputFinished(null);
    }
  }
).create();
}

Fixed version (ground truth):
@Override public Dialog onCreateDialog(Bundle savedInstanceState){
  Context context=new ContextThemeWrapper(getActivity(),R.style.G4LTheme_Dialog);
  View view=LayoutInflater.from(context).inflate(R.layout.gc_number_input_dialog,null);
  editText=(EditText)view.findViewById(R.id.gc_number_input_edit_text);
  editText.setText("String_Node_Str");
  editText.addTextChangedListener(new TextWatcher(){
    @Override public void afterTextChanged(    Editable s){
    }
    @Override public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    @Override public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
      if (s != null && s.length() > 0 && editText.getError() != null) {
        editText.setError(null);
      }
    }
  }
);
  if (savedInstanceState != null && savedInstanceState.containsKey(PARAM_INPUT)) {
    editText.setText(savedInstanceState.getCharSequence(PARAM_INPUT));
    errorMessage=savedInstanceState.getCharSequence(PARAM_ERROR_MESSAGE);
  }
  editText.setSelection(editText.getText().length());
  return new AlertDialog.Builder(context).setTitle(R.string.dialog_gc_number_input_title).setView(view).setPositiveButton(R.string.ok_button,new EmptyDialogOnClickListener()).setNegativeButton(R.string.cancel_button,new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      fireOnInputFinished(null);
    }
  }
).create();
}
Program: 19170
Project: 19170
Buggy source:
@Override public void onReceivedError(WebView view,int errorCode,String description,String failingUrl){
  super.onReceivedError(view,errorCode,description,failingUrl);
  onTaskError(ErrorActivity.createErrorIntent(getActivity(),0,description,false,null));
}

Fixed version (ground truth):
@Override public void onReceivedError(WebView view,int errorCode,String description,String failingUrl){
  super.onReceivedError(view,errorCode,description,failingUrl);
  if (getActivity() != null)   onTaskError(ErrorActivity.createErrorIntent(getActivity(),0,description,false,null));
}
Program: 19172
Project: 19172
Buggy source:
public void updateMemberType(MemberType memberType){
switch (memberType) {
case Charter:
case Premium:
    premiumMember=true;
default :
  premiumMember=false;
break;
}
Editor editor=mPrefs.edit();
editor.putBoolean(PrefConstants.RESTRICTION__PREMIUM_MEMBER,premiumMember);
editor.commit();
}

Fixed version (ground truth):
public void updateMemberType(MemberType memberType){
switch (memberType) {
case Charter:
case Premium:
    premiumMember=true;
  break;
default :
premiumMember=false;
break;
}
Editor editor=mPrefs.edit();
editor.putBoolean(PrefConstants.RESTRICTION__PREMIUM_MEMBER,premiumMember);
editor.commit();
}
Program: 19173
Project: 19173
Buggy source:
@Override public void onCreate(){
  context=getApplicationContext();
  if (AppConstants.USE_PRODUCTION_CONFIGURATION) {
    geocachingApiConfiguration=GeocachingApiConfigurationResolver.resolve(OAuthGeocachingApiConfiguration.class,AppConstants.PRODUCTION_CONFIGURATION);
  }
 else {
    geocachingApiConfiguration=GeocachingApiConfigurationResolver.resolve(OAuthGeocachingApiConfiguration.class,AppConstants.STAGGING_CONFIGURATION);
  }
  ACRA.init(this);
  authenticatorHelper=new PreferenceAuthenticatorHelper(this);
  authenticatorHelper.convertFromOldStorage();
  if (authenticatorHelper.hasAccount()) {
    ErrorReporter.getInstance().putCustomData("String_Node_Str",authenticatorHelper.getAccount().name);
  }
  PackageInfo pi=LocusUtils.getLocusPackageInfo(this);
  if (pi != null) {
    ErrorReporter.getInstance().putCustomData("String_Node_Str",pi.versionName);
    ErrorReporter.getInstance().putCustomData("String_Node_Str",pi.packageName);
  }
  System.setProperty("String_Node_Str","String_Node_Str");
  super.onCreate();
}

Fixed version (ground truth):
@Override public void onCreate(){
  context=getApplicationContext();
  disableConnectionReuseIfNecessary();
  if (AppConstants.USE_PRODUCTION_CONFIGURATION) {
    geocachingApiConfiguration=GeocachingApiConfigurationResolver.resolve(OAuthGeocachingApiConfiguration.class,AppConstants.PRODUCTION_CONFIGURATION);
  }
 else {
    geocachingApiConfiguration=GeocachingApiConfigurationResolver.resolve(OAuthGeocachingApiConfiguration.class,AppConstants.STAGGING_CONFIGURATION);
  }
  ACRA.init(this);
  authenticatorHelper=new PreferenceAuthenticatorHelper(this);
  authenticatorHelper.convertFromOldStorage();
  if (authenticatorHelper.hasAccount()) {
    ErrorReporter.getInstance().putCustomData("String_Node_Str",authenticatorHelper.getAccount().name);
  }
  PackageInfo pi=LocusUtils.getLocusPackageInfo(this);
  if (pi != null) {
    ErrorReporter.getInstance().putCustomData("String_Node_Str",pi.versionName);
    ErrorReporter.getInstance().putCustomData("String_Node_Str",pi.packageName);
  }
  System.setProperty("String_Node_Str","String_Node_Str");
  super.onCreate();
}
Program: 19175
Project: 19175
Buggy source:
@Override public void dismiss(){
  try {
    super.dismiss();
    if (getDialog() != null)     getDialog().dismiss();
  }
 catch (  IllegalStateException e) {
    dismissAllowingStateLoss();
  }
}

Fixed version (ground truth):
@Override public void dismiss(){
  try {
    super.dismiss();
  }
 catch (  IllegalStateException e) {
    dismissAllowingStateLoss();
  }
  getFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
  getFragmentManager().executePendingTransactions();
}
Program: 19176
Project: 19176
Buggy source:
@Override public void show(FragmentManager manager,String tag){
  FragmentTransaction ft=manager.beginTransaction();
  Fragment prev=manager.findFragmentByTag(tag);
  if (prev != null) {
    ft.remove(prev);
  }
  ft.addToBackStack(null);
  super.show(manager,tag);
}

Fixed version (ground truth):
@Override public void show(FragmentManager manager,String tag){
  Fragment prev=manager.findFragmentByTag(tag);
  if (prev != null) {
    return;
  }
  super.show(manager,tag);
}
Program: 19177
Project: 19177
Buggy source:
@Override public void onResume(){
  super.onResume();
  final AlertDialog alertDialog=(AlertDialog)getDialog();
  Button button=alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
  button.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      if (validateInput(editText)) {
        fireOnInputFinished(editText.getText().toString());
        alertDialog.dismiss();
      }
    }
  }
);
}

Fixed version (ground truth):
@Override public void onResume(){
  super.onResume();
  final AlertDialog alertDialog=(AlertDialog)getDialog();
  if (alertDialog == null)   return;
  Button button=alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
  button.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      if (validateInput(editText)) {
        fireOnInputFinished(editText.getText().toString());
        alertDialog.dismiss();
      }
    }
  }
);
}
Program: 19178
Project: 19178
Buggy source:
@Override public Dialog onCreateDialog(Bundle savedInstanceState){
  Context context=new ContextThemeWrapper(getActivity(),R.style.G4LTheme_Dialog);
  editText=new EditText(context);
  editText.setFilters(new InputFilter[]{new InputFilter.AllCaps()});
  editText.addTextChangedListener(new TextWatcher(){
    @Override public void afterTextChanged(    Editable s){
    }
    @Override public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    @Override public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
      if (s != null && s.length() > 0 && editText.getError() != null) {
        editText.setError(null);
      }
    }
  }
);
  if (savedInstanceState != null && savedInstanceState.containsKey(PARAM_INPUT)) {
    editText.setText(savedInstanceState.getCharSequence(PARAM_INPUT));
  }
  return new AlertDialog.Builder(context).setTitle(R.string.gc_number_input_title).setView(editText).setPositiveButton(R.string.ok_button,null).setNegativeButton(R.string.cancel_button,new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      fireOnInputFinished(null);
    }
  }
).create();
}

Fixed version (ground truth):
@Override public Dialog onCreateDialog(Bundle savedInstanceState){
  Context context=new ContextThemeWrapper(getActivity(),R.style.G4LTheme_Dialog);
  editText=new EditText(context);
  editText.setFilters(new InputFilter[]{new InputFilter.AllCaps()});
  editText.addTextChangedListener(new TextWatcher(){
    @Override public void afterTextChanged(    Editable s){
    }
    @Override public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    @Override public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
      if (s != null && s.length() > 0 && editText.getError() != null) {
        editText.setError(null);
      }
    }
  }
);
  if (savedInstanceState != null && savedInstanceState.containsKey(PARAM_INPUT)) {
    editText.setText(savedInstanceState.getCharSequence(PARAM_INPUT));
    editText.setError(savedInstanceState.getCharSequence(PARAM_ERROR_MESSAGE));
  }
  return new AlertDialog.Builder(context).setTitle(R.string.gc_number_input_title).setView(editText).setPositiveButton(R.string.ok_button,new EmptyDialogOnClickListener()).setNegativeButton(R.string.cancel_button,new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      fireOnInputFinished(null);
    }
  }
).create();
}
Program: 19179
Project: 19179
Buggy source:
@Override public void onSaveInstanceState(Bundle outState){
  super.onSaveInstanceState(outState);
  if (editText != null && isShowing()) {
    outState.putCharSequence(PARAM_INPUT,editText.getText());
  }
}

Fixed version (ground truth):
@Override public void onSaveInstanceState(Bundle outState){
  super.onSaveInstanceState(outState);
  if (editText != null && isShowing()) {
    outState.putCharSequence(PARAM_INPUT,editText.getText());
    outState.putCharSequence(PARAM_ERROR_MESSAGE,editText.getError());
  }
}
Program: 19181
Project: 19181
Buggy source:
@Override protected void onPostExecute(Waypoint result){
  super.onPostExecute(result);
  if (result != null) {
    PackWaypoints pack=new PackWaypoints("String_Node_Str");
    pack.addWaypoint(result);
    try {
      ActionDisplayPoints.sendPack(Geocaching4LocusApplication.getAppContext(),pack,true);
    }
 catch (    RequiredVersionMissingException e) {
      Log.e(TAG,e.getMessage(),e);
    }
  }
  OnTaskFinishedListener listener=onTaskFinishedListenerRef.get();
  if (listener != null) {
    listener.onTaskFinished(result != null);
  }
}

Fixed version (ground truth):
@Override protected void onPostExecute(Waypoint result){
  super.onPostExecute(result);
  if (result != null) {
    PackWaypoints pack=new PackWaypoints("String_Node_Str");
    pack.addWaypoint(result);
    try {
      ActionDisplayPointsExtended.sendPack(Geocaching4LocusApplication.getAppContext(),pack,true,Intent.FLAG_ACTIVITY_NEW_TASK);
    }
 catch (    RequiredVersionMissingException e) {
      Log.e(TAG,e.getMessage(),e);
    }
  }
  OnTaskFinishedListener listener=onTaskFinishedListenerRef.get();
  if (listener != null) {
    listener.onTaskFinished(result != null);
  }
}
Program: 19183
Project: 19183
Buggy source:
@Override protected void onPreExecute(){
  super.onPreExecute();
  activity.showDialog(DIALOG_PROGRESS_ID);
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(activity);
  logCount=prefs.getInt(PrefConstants.DOWNLOADING_COUNT_OF_LOGS,5);
}

Fixed version (ground truth):
@Override protected void onPreExecute(){
  super.onPreExecute();
  if (activity.isFinishing()) {
    cancel(true);
    return;
  }
  activity.showDialog(DIALOG_PROGRESS_ID);
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(activity);
  logCount=prefs.getInt(PrefConstants.DOWNLOADING_COUNT_OF_LOGS,5);
}
Program: 19184
Project: 19184
Buggy source:
@Override protected void onPreExecute(){
  super.onPreExecute();
  activity.showDialog(DIALOG_PROGRESS_ID);
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(activity);
  logCount=prefs.getInt(PrefConstants.DOWNLOADING_COUNT_OF_LOGS,5);
  replaceCache=PrefConstants.DOWNLOADING_FULL_CACHE_DATE_ON_SHOW__UPDATE_ONCE.equals(prefs.getString(PrefConstants.DOWNLOADING_FULL_CACHE_DATE_ON_SHOW,PrefConstants.DOWNLOADING_FULL_CACHE_DATE_ON_SHOW__UPDATE_ONCE));
}

Fixed version (ground truth):
@Override protected void onPreExecute(){
  super.onPreExecute();
  if (activity.isFinishing()) {
    cancel(true);
    return;
  }
  activity.showDialog(DIALOG_PROGRESS_ID);
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(activity);
  logCount=prefs.getInt(PrefConstants.DOWNLOADING_COUNT_OF_LOGS,5);
  replaceCache=PrefConstants.DOWNLOADING_FULL_CACHE_DATE_ON_SHOW__UPDATE_ONCE.equals(prefs.getString(PrefConstants.DOWNLOADING_FULL_CACHE_DATE_ON_SHOW,PrefConstants.DOWNLOADING_FULL_CACHE_DATE_ON_SHOW__UPDATE_ONCE));
}
Program: 19185
Project: 19185
Buggy source:
@Override protected void onPreExecute(){
  super.onPreExecute();
  activity.showDialog(DIALOG_PROGRESS_ID);
}

Fixed version (ground truth):
@Override protected void onPreExecute(){
  super.onPreExecute();
  if (activity.isFinishing()) {
    cancel(true);
    return;
  }
  activity.showDialog(DIALOG_PROGRESS_ID);
}
Program: 19187
Project: 19187
Buggy source:
public static String round(double source,int decimals){
  if (decimals < 0)   throw new IllegalArgumentException("String_Node_Str");
  if (decimals == 0) {
    return Long.toString((long)source);
  }
  int decimalLimiter=1;
  for (byte i=0; i < decimals; i++)   decimalLimiter*=10;
  double rounded=((double)Math.round(source * decimalLimiter)) / decimalLimiter;
  String val=Double.toString(rounded);
  int dot=val.indexOf('.');
  if (dot == -1) {
    StringBuffer sb=new StringBuffer(val);
    sb.append('.');
    for (int i=0; i < decimals; i++)     sb.append('0');
    return sb.toString();
  }
 else {
    if (val.length() - (dot + decimals) > 0) {
      return val.substring(0,dot + decimals + 1);
    }
    StringBuffer sb=new StringBuffer(val);
    for (int i=val.length(); i <= dot + decimals; i++)     sb.append('0');
    return sb.toString();
  }
}

Fixed version (ground truth):
public static String round(double source,int decimals){
  if (decimals < 0)   throw new IllegalArgumentException("String_Node_Str");
  if (decimals == 0) {
    return Long.toString((long)source);
  }
  double rounded=roundDouble(source,decimals);
  String val=Double.toString(rounded);
  int dot=val.indexOf('.');
  if (dot == -1) {
    StringBuffer sb=new StringBuffer(val);
    sb.append('.');
    for (int i=0; i < decimals; i++)     sb.append('0');
    return sb.toString();
  }
 else {
    if (val.length() - (dot + decimals) > 0) {
      return val.substring(0,dot + decimals + 1);
    }
    StringBuffer sb=new StringBuffer(val);
    for (int i=val.length(); i <= dot + decimals; i++)     sb.append('0');
    return sb.toString();
  }
}
Program: 19188
Project: 19188
Buggy source:
public static String convertDoubleToDeg(double source,boolean isLon,int precision){
  StringBuffer sb=new StringBuffer();
  if (source < 0) {
    sb.append((!isLon) ? 'S' : 'W');
    source=-source;
  }
 else {
    sb.append((!isLon) ? 'N' : 'E');
  }
  sb.append(' ');
  int deg=(int)source;
  sb.append(deg);
  sb.append("String_Node_Str");
  double min=(source - deg) * 60D;
  sb.append(round(min,precision));
  return sb.toString();
}

Fixed version (ground truth):
public static String convertDoubleToDeg(double source,boolean isLon,int precision){
  StringBuffer sb=new StringBuffer();
  if (source < 0) {
    sb.append((!isLon) ? 'S' : 'W');
    source=-source;
  }
 else {
    sb.append((!isLon) ? 'N' : 'E');
  }
  sb.append(' ');
  int deg=(int)source;
  double min=roundDouble(((source - deg) * 60D),precision);
  if (min == 60D) {
    deg++;
    min=0D;
  }
  sb.append(deg);
  sb.append("String_Node_Str");
  sb.append(round(min,precision));
  return sb.toString();
}
Program: 19189
Project: 19189
Buggy source:
@Override public boolean isValid(){
  return min != 1 && max != 5;
}

Fixed version (ground truth):
@Override public boolean isValid(){
  return min != 1 || max != 5;
}
Program: 19190
Project: 19190
Buggy source:
@Override public boolean isValid(){
  return min != 1 && max != 5;
}

Fixed version (ground truth):
@Override public boolean isValid(){
  return min != 1 || max != 5;
}
Program: 19191
Project: 19191
Buggy source:
public static boolean isAndroidMarketInstalled(Context context){
  Intent market=new Intent(Intent.ACTION_VIEW,Uri.parse("String_Node_Str"));
  PackageManager manager=context.getPackageManager();
  List<ResolveInfo> list=manager.queryIntentActivities(market,0);
  if (list != null && list.size() > 0) {
    for (int i=0; i < list.size(); i++) {
      if (list.get(i).activityInfo.packageName.startsWith("String_Node_Str") == true) {
        return true;
      }
    }
  }
  return false;
}

Fixed version (ground truth):
protected static boolean isAndroidMarketInstalled(Context context){
  Intent market=new Intent(Intent.ACTION_VIEW,Uri.parse("String_Node_Str"));
  PackageManager manager=context.getPackageManager();
  List<ResolveInfo> list=manager.queryIntentActivities(market,0);
  if (list != null && list.size() > 0) {
    for (int i=0; i < list.size(); i++) {
      if (list.get(i).activityInfo.packageName.startsWith("String_Node_Str") == true) {
        return true;
      }
    }
  }
  return false;
}
Program: 19192
Project: 19192
Buggy source:
protected void checkError(JsonReader r) throws GeocachingApiException, IOException {
  if ("String_Node_Str".equals(r.nextName())) {
    StatusJsonParser.Status status=StatusJsonParser.parse(r);
switch (status.getStatusCode()) {
case OK:
      return;
case UserAccountProblem:
case UserDidNotAuthorize:
case UserTokenNotValid:
    throw new InvalidSessionException(status.getStatusMessage());
case AccountNotFound:
  throw new InvalidCredentialsException(status.getStatusMessage());
default :
throw new GeocachingApiException(status.getStatusMessage());
}
}
}

Fixed version (ground truth):
protected void checkError(JsonReader r) throws GeocachingApiException, IOException {
  if ("String_Node_Str".equals(r.nextName())) {
    StatusJsonParser.Status status=StatusJsonParser.parse(r);
switch (status.getStatusCode()) {
case OK:
      return;
case NotAuthorized:
case UserAccountProblem:
case UserDidNotAuthorize:
case UserTokenNotValid:
    throw new InvalidSessionException(status.getStatusMessage());
case AccountNotFound:
  throw new InvalidCredentialsException(status.getStatusMessage());
default :
throw new GeocachingApiException(status.getStatusMessage());
}
}
}
Program: 19193
Project: 19193
Buggy source:
/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  res=getResources();
  prefs=PreferenceManager.getDefaultSharedPreferences(this);
  Version locusVersion=Version.parseVersion(LocusUtils.getLocusVersion(this));
  Log.i(TAG,"String_Node_Str" + locusVersion);
  if (locusVersion.compareTo(LOCUS_MIN_VERSION) < 0) {
    locusInstalled=false;
    showError(locusVersion == Version.emptyVersion ? R.string.error_locus_not_found : R.string.error_locus_old,LOCUS_MIN_VERSION.toString(),new DialogInterface.OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int which){
        Uri localUri=Uri.parse("String_Node_Str" + LocusUtils.getLocusDefaultPackageName(MainActivity.this));
        Intent localIntent=new Intent("String_Node_Str",localUri);
        startActivity(localIntent);
        finish();
      }
    }
);
    return;
  }
  setContentView(R.layout.main_activity);
  if (getIntent().getAction() != null && getIntent().getAction().equals("String_Node_Str")) {
    latitude=getIntent().getDoubleExtra("String_Node_Str",0.0);
    longitude=getIntent().getDoubleExtra("String_Node_Str",0.0);
    Log.i(TAG,"String_Node_Str" + latitude + "String_Node_Str"+ longitude);
    hasCoordinates=true;
  }
}

Fixed version (ground truth):
/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  res=getResources();
  prefs=PreferenceManager.getDefaultSharedPreferences(this);
  Version locusVersion=Version.parseVersion(LocusUtils.getLocusVersion(this));
  Log.i(TAG,"String_Node_Str" + locusVersion);
  if (locusVersion.compareTo(LOCUS_MIN_VERSION) < 0) {
    locusInstalled=false;
    showError(locusVersion == Version.emptyVersion ? R.string.error_locus_not_found : R.string.error_locus_old,LOCUS_MIN_VERSION.toString(),new DialogInterface.OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int which){
        Uri localUri=Uri.parse("String_Node_Str" + LocusUtils.getLocusDefaultPackageName(MainActivity.this));
        Intent localIntent=new Intent("String_Node_Str",localUri);
        startActivity(localIntent);
        finish();
      }
    }
);
    return;
  }
  setContentView(R.layout.main_activity);
  if (LocusIntents.isIntentOnPointAction(getIntent())) {
    Point p=LocusIntents.handleIntentOnPointAction(getIntent());
    if (p == null) {
      Toast.makeText(this,"String_Node_Str",Toast.LENGTH_SHORT).show();
    }
 else {
      latitude=p.getLocation().getLatitude();
      longitude=p.getLocation().getLongitude();
      Log.i(TAG,"String_Node_Str" + latitude + "String_Node_Str"+ longitude);
      hasCoordinates=true;
    }
  }
}
Program: 19194
Project: 19194
Buggy source:
@Override public void onFocusChange(View v,boolean hasFocus){
  if (!hasFocus) {
    double deg=Coordinates.convertDegToDouble(longitudeEditText.getText().toString());
    if (Double.isNaN(deg)) {
      longitudeEditText.setText("String_Node_Str");
    }
 else {
      longitudeEditText.setText(Coordinates.convertDoubleToDeg(deg,true));
    }
  }
}

Fixed version (ground truth):
@Override public void onFocusChange(View v,boolean hasFocus){
  if (!hasFocus) {
    double deg=Coordinates.convertDegToDouble(longitudeEditText.getText().toString());
    if (Double.isNaN(deg)) {
      ((EditText)v).setText("String_Node_Str");
    }
 else {
      ((EditText)v).setText(Coordinates.convertDoubleToDeg(deg,true));
    }
  }
}
Program: 19195
Project: 19195
Buggy source:
protected void cancelAcquiring(){
  if (pd != null && pd.isShowing())   pd.dismiss();
  locationManager.removeUpdates(MainActivity.this);
  Location location=locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
  if (location == null)   location=locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
  if (location == null) {
    latitude=prefs.getFloat("String_Node_Str",0F);
    longitude=prefs.getFloat("String_Node_Str",0F);
  }
 else {
    latitude=location.getLatitude();
    longitude=location.getLongitude();
  }
  hasCoordinates=true;
  latitudeEditText.setText(Coordinates.convertDoubleToDeg(latitude,false));
  longitudeEditText.setText(Coordinates.convertDoubleToDeg(longitude,true));
}

Fixed version (ground truth):
protected void cancelAcquiring(){
  if (pd != null && pd.isShowing())   pd.dismiss();
  locationManager.removeUpdates(MainActivity.this);
  Location location=locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
  if (location == null)   location=locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
  if (location == null) {
    latitude=prefs.getFloat("String_Node_Str",0F);
    longitude=prefs.getFloat("String_Node_Str",0F);
  }
 else {
    latitude=location.getLatitude();
    longitude=location.getLongitude();
  }
  hasCoordinates=true;
  updateCoordinateTextView();
}
Program: 19197
Project: 19197
Buggy source:
@Override public void onLocationChanged(Location location){
  locationManager.removeUpdates(this);
  if (location == null) {
    handler.post(new Runnable(){
      @Override public void run(){
        pd.dismiss();
        Log.e(TAG,"String_Node_Str");
        showError(R.string.error_location,null);
      }
    }
);
    return;
  }
  if (!pd.isShowing())   return;
  latitude=location.getLatitude();
  longitude=location.getLongitude();
  latitudeEditText.setText(Coordinates.convertDoubleToDeg(latitude,false));
  longitudeEditText.setText(Coordinates.convertDoubleToDeg(longitude,true));
  hasCoordinates=true;
  Editor editor=prefs.edit();
  editor.putFloat("String_Node_Str",(float)latitude);
  editor.putFloat("String_Node_Str",(float)longitude);
  editor.commit();
  handler.post(new Runnable(){
    @Override public void run(){
      pd.dismiss();
    }
  }
);
}

Fixed version (ground truth):
@Override public void onLocationChanged(Location location){
  locationManager.removeUpdates(this);
  if (location == null) {
    handler.post(new Runnable(){
      @Override public void run(){
        pd.dismiss();
        Log.e(TAG,"String_Node_Str");
        showError(R.string.error_location,null);
      }
    }
);
    return;
  }
  if (!pd.isShowing())   return;
  latitude=location.getLatitude();
  longitude=location.getLongitude();
  hasCoordinates=true;
  updateCoordinateTextView();
  Editor editor=prefs.edit();
  editor.putFloat("String_Node_Str",(float)latitude);
  editor.putFloat("String_Node_Str",(float)longitude);
  editor.commit();
  handler.post(new Runnable(){
    @Override public void run(){
      pd.dismiss();
    }
  }
);
}
Program: 19198
Project: 19198
Buggy source:
public Point toPoint(){
  Location loc=new Location(getClass().getName());
  loc.setLatitude(latitude);
  loc.setLongitude(longitude);
  Point p=new Point(name,loc);
  PointGeocachingData d=new PointGeocachingData();
  d.cacheID=geoCode;
  d.name=name;
  d.type=cacheType.getId();
  d.difficulty=difficultyRating;
  d.terrain=terrainRating;
  d.owner=authorName;
  d.placedBy=contactName;
  d.available=available;
  d.archived=archived;
  d.premiumOnly=premiumListing;
  d.country=countryName;
  d.state=stateName;
  d.hidden=GPX_TIME_FMT.format(created);
  d.exported=GPX_TIME_FMT.format(new Date());
  d.container=containerType.getId();
  p.setGeocachingData(d);
  return p;
}

Fixed version (ground truth):
public Point toPoint(){
  Location loc=new Location(getClass().getName());
  loc.setLatitude(latitude);
  loc.setLongitude(longitude);
  Point p=new Point(name,loc);
  PointGeocachingData d=new PointGeocachingData();
  d.cacheID=geoCode;
  d.name=name;
  d.type=cacheType.getId();
  d.difficulty=difficultyRating;
  d.terrain=terrainRating;
  d.owner=authorName;
  d.placedBy=contactName;
  d.available=available;
  d.archived=archived;
  d.premiumOnly=premiumListing;
  d.country=countryName;
  d.state=stateName;
  d.hidden=GPX_TIME_FMT.format(created);
  d.exported=GPX_TIME_FMT.format(new Date());
  d.container=containerType.getId();
  d.found=found;
  p.setGeocachingData(d);
  return p;
}