Program: 19123
Project: 19123
Buggy source:
private Intent handleLiveGeocachingApiExceptions(LiveGeocachingApiException t,Intent positiveAction,String baseMessage){
  AccountRestrictions restrictions=App.get(mContext).getAuthenticatorHelper().getRestrictions();
  ErrorActivity.IntentBuilder builder=new ErrorActivity.IntentBuilder(mContext);
switch (t.getStatusCode()) {
case CacheLimitExceeded:
    int title=restrictions.isPremiumMember() ? R.string.premium_member_warning_title : R.string.basic_member_warning_title;
  int message=restrictions.isPremiumMember() ? R.string.premium_member_full_geocaching_quota_exceeded_message : R.string.basic_member_full_geocaching_quota_exceeded;
int cachesPerPeriod=(int)restrictions.getMaxFullGeocacheLimit();
int period=(int)restrictions.getFullGeocacheLimitPeriod();
String periodString;
if (period < AppConstants.SECONDS_PER_MINUTE) {
periodString=mContext.getResources().getQuantityString(R.plurals.plurals_minute,period,period);
}
 else {
period/=AppConstants.SECONDS_PER_MINUTE;
periodString=mContext.getResources().getQuantityString(R.plurals.plurals_hour,period,period);
}
String renewTime=DateFormat.getTimeFormat(mContext).format(restrictions.getRenewFullGeocacheLimit());
String cacheString=mContext.getResources().getQuantityString(R.plurals.plurals_cache,cachesPerPeriod,cachesPerPeriod);
String errorText=ResourcesUtil.getHtmlString(mContext,message,cacheString,periodString,renewTime);
builder.setTitle(title).setMessage(baseMessage,errorText);
if (positiveAction != null) {
builder.setPositiveAction(positiveAction).setPositiveButtonText(R.string.yes_button).setNegativeButtonText(R.string.no_button);
}
return builder.build();
case NumberOfCallsExceeded:
builder.setTitle(R.string.method_quota_exceeded_title).setMessage(baseMessage,ResourcesUtil.getHtmlString(mContext,R.string.method_quota_exceeded_message));
if (positiveAction != null) {
builder.setPositiveAction(positiveAction).setPositiveButtonText(R.string.yes_button).setNegativeButtonText(R.string.no_button);
}
return builder.build();
case PremiumMembershipRequiredForBookmarksExcludeFilter:
case PremiumMembershipRequiredForDifficultyFilter:
case PremiumMembershipRequiredForFavoritePointsFilter:
case PremiumMembershipRequiredForGeocacheContainerSizeFilter:
case PremiumMembershipRequiredForGeocacheNameFilter:
case PremiumMembershipRequiredForHiddenByUserFilter:
case PremiumMembershipRequiredForNotHiddenByUserFilter:
case PremiumMembershipRequiredForTerrainFilter:
case PremiumMembershipRequiredForTrackableCountFilter:
restrictions.updateMemberType(MemberType.Basic);
return builder.setTitle(R.string.premium_member_warning_title).setMessage(R.string.premium_member_for_filter_required).build();
default :
return null;
}
}

Fixed version (ground truth):
private Intent handleLiveGeocachingApiExceptions(LiveGeocachingApiException t,Intent positiveAction,CharSequence baseMessage){
  AccountRestrictions restrictions=App.get(mContext).getAuthenticatorHelper().getRestrictions();
  ErrorActivity.IntentBuilder builder=new ErrorActivity.IntentBuilder(mContext);
switch (t.getStatusCode()) {
case CacheLimitExceeded:
    int title=restrictions.isPremiumMember() ? R.string.premium_member_warning_title : R.string.basic_member_warning_title;
  int message=restrictions.isPremiumMember() ? R.string.premium_member_full_geocaching_quota_exceeded_message : R.string.basic_member_full_geocaching_quota_exceeded;
int cachesPerPeriod=(int)restrictions.getMaxFullGeocacheLimit();
int period=(int)restrictions.getFullGeocacheLimitPeriod();
String periodString;
if (period < AppConstants.SECONDS_PER_MINUTE) {
periodString=mContext.getResources().getQuantityString(R.plurals.plurals_minute,period,period);
}
 else {
period/=AppConstants.SECONDS_PER_MINUTE;
periodString=mContext.getResources().getQuantityString(R.plurals.plurals_hour,period,period);
}
CharSequence renewTime=DateFormat.getTimeFormat(mContext).format(restrictions.getRenewFullGeocacheLimit());
CharSequence cacheString=ResourcesUtil.getQuantityText(mContext,R.plurals.plurals_cache,cachesPerPeriod,cachesPerPeriod);
CharSequence errorText=ResourcesUtil.getText(mContext,message,cacheString,periodString,renewTime);
builder.setTitle(title).setMessage(baseMessage,errorText);
if (positiveAction != null) {
builder.setPositiveAction(positiveAction).setPositiveButtonText(R.string.yes_button).setNegativeButtonText(R.string.no_button);
}
return builder.build();
case NumberOfCallsExceeded:
builder.setTitle(R.string.method_quota_exceeded_title).setMessage(baseMessage,mContext.getText(R.string.method_quota_exceeded_message));
if (positiveAction != null) {
builder.setPositiveAction(positiveAction).setPositiveButtonText(R.string.yes_button).setNegativeButtonText(R.string.no_button);
}
return builder.build();
case PremiumMembershipRequiredForBookmarksExcludeFilter:
case PremiumMembershipRequiredForDifficultyFilter:
case PremiumMembershipRequiredForFavoritePointsFilter:
case PremiumMembershipRequiredForGeocacheContainerSizeFilter:
case PremiumMembershipRequiredForGeocacheNameFilter:
case PremiumMembershipRequiredForHiddenByUserFilter:
case PremiumMembershipRequiredForNotHiddenByUserFilter:
case PremiumMembershipRequiredForTerrainFilter:
case PremiumMembershipRequiredForTrackableCountFilter:
restrictions.updateMemberType(MemberType.Basic);
return builder.setTitle(R.string.premium_member_warning_title).setMessage(R.string.premium_member_for_filter_required).build();
default :
return null;
}
}