nus-yam/ex-repair huggingface dataset:
Program: 8621
Project: 8621
Buggy source:
private void bringTodayYearMonth(){
  Intent intent=new Intent(Constants.BROADCAST_INTENT_TO_MONTH_FRAGMENT);
  intent.putExtra(Constants.BROADCAST_FIELD_TO_MONTH_FRAGMENT,Constants.BROADCAST_TO_MONTH_FRAGMENT_RESET_DAY);
  intent.putExtra(Constants.BROADCAST_FIELD_SELECT_DAY,-1);
  LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
  CalendarAdapter.gotoOffset(monthViewPager,0);
  selectDay(Utils.getTodayJdn());
}

Fixed version (ground truth):
private void bringTodayYearMonth(){
  LocalBroadcastManager.getInstance(getContext()).sendBroadcast(new Intent(Constants.BROADCAST_INTENT_TO_MONTH_FRAGMENT).putExtra(Constants.BROADCAST_FIELD_TO_MONTH_FRAGMENT,Constants.BROADCAST_TO_MONTH_FRAGMENT_RESET_DAY).putExtra(Constants.BROADCAST_FIELD_SELECT_DAY_JDN,-1));
  CalendarAdapter.gotoOffset(monthViewPager,0);
  selectDay(Utils.getTodayJdn());
}
Program: 8622
Project: 8622
Buggy source:
void selectDay(long jdn){
  lastSelectedJdn=jdn;
  PersianDate persianDate=DateConverter.jdnToPersian(jdn);
  weekDayName.setText(Utils.getWeekDayName(persianDate));
  CivilDate civilDate=DateConverter.persianToCivil(persianDate);
  IslamicDate hijriDate=DateConverter.civilToIslamic(civilDate,Utils.getIslamicOffset());
  shamsiDateLinear.setText(Utils.toLinearDate(persianDate));
  shamsiDateDay.setText(Utils.formatNumber(persianDate.getDayOfMonth()));
  shamsiDate.setText(Utils.getMonthName(persianDate) + "String_Node_Str" + Utils.formatNumber(persianDate.getYear()));
  gregorianDateLinear.setText(Utils.toLinearDate(civilDate));
  gregorianDateDay.setText(Utils.formatNumber(civilDate.getDayOfMonth()));
  gregorianDate.setText(Utils.getMonthName(civilDate) + "String_Node_Str" + Utils.formatNumber(civilDate.getYear()));
  islamicDateLinear.setText(Utils.toLinearDate(hijriDate));
  islamicDateDay.setText(Utils.formatNumber(hijriDate.getDayOfMonth()));
  islamicDate.setText(Utils.getMonthName(hijriDate) + "String_Node_Str" + Utils.formatNumber(hijriDate.getYear()));
  boolean isToday=Utils.getTodayJdn() == jdn;
  if (isToday) {
    today.setVisibility(View.GONE);
    todayIcon.setVisibility(View.GONE);
    if (Utils.isIranTime())     weekDayName.setText(weekDayName.getText() + "String_Node_Str" + getString(R.string.iran_time)+ "String_Node_Str");
  }
 else {
    today.setVisibility(View.VISIBLE);
    todayIcon.setVisibility(View.VISIBLE);
  }
  setOwghat(civilDate,isToday);
  showEvent(jdn);
}

Fixed version (ground truth):
void selectDay(long jdn){
  lastSelectedJdn=jdn;
  PersianDate persianDate=DateConverter.jdnToPersian(jdn);
  weekDayName.setText(Utils.getWeekDayName(persianDate));
  CivilDate civilDate=DateConverter.persianToCivil(persianDate);
  IslamicDate hijriDate=DateConverter.civilToIslamic(civilDate,Utils.getIslamicOffset());
  shamsiDateLinear.setText(Utils.toLinearDate(persianDate));
  shamsiDateDay.setText(Utils.formatNumber(persianDate.getDayOfMonth()));
  shamsiDate.setText(Utils.getMonthName(persianDate) + "String_Node_Str" + Utils.formatNumber(persianDate.getYear()));
  gregorianDateLinear.setText(Utils.toLinearDate(civilDate));
  gregorianDateDay.setText(Utils.formatNumber(civilDate.getDayOfMonth()));
  gregorianDate.setText(Utils.getMonthName(civilDate) + "String_Node_Str" + Utils.formatNumber(civilDate.getYear()));
  islamicDateLinear.setText(Utils.toLinearDate(hijriDate));
  islamicDateDay.setText(Utils.formatNumber(hijriDate.getDayOfMonth()));
  islamicDate.setText(Utils.getMonthName(hijriDate) + "String_Node_Str" + Utils.formatNumber(hijriDate.getYear()));
  boolean isToday=Utils.getTodayJdn() == jdn;
  if (isToday) {
    today.setVisibility(View.GONE);
    todayIcon.setVisibility(View.GONE);
    if (Utils.isIranTime()) {
      weekDayName.setText(weekDayName.getText() + "String_Node_Str" + getString(R.string.iran_time)+ "String_Node_Str");
    }
    lastSelectedJdn=-1;
  }
 else {
    today.setVisibility(View.VISIBLE);
    todayIcon.setVisibility(View.VISIBLE);
  }
  setOwghat(civilDate,isToday);
  showEvent(jdn);
}
Program: 8624
Project: 8624
Buggy source:
private void fillTheFields(){
  CalendarType mainCalendar=Utils.getMainCalendar();
  List<DayEntity> days=new ArrayList<>();
  typedDate=Utils.getTodayOfCalendar(mainCalendar);
  int month=typedDate.getMonth() - offset;
  month-=1;
  int year=typedDate.getYear();
  year=year + (month / 12);
  month=month % 12;
  if (month < 0) {
    year-=1;
    month+=12;
  }
  month+=1;
  typedDate=Utils.getDateOfCalendar(mainCalendar,year,month,1);
  long baseJdn=Utils.getJdnDate(typedDate);
  int monthLength=(int)(Utils.getJdnOfCalendar(mainCalendar,month == 12 ? year + 1 : year,month == 12 ? 1 : month + 1,1) - baseJdn);
  int dayOfWeek=Utils.getDayOfWeekFromJdn(baseJdn);
  long todayJdn=Utils.getTodayJdn();
  for (int i=0; i < monthLength; i++) {
    DayEntity dayEntity=new DayEntity();
    dayEntity.setJdn(baseJdn + i);
    if (baseJdn + i == todayJdn) {
      dayEntity.setToday(true);
    }
    dayEntity.setDayOfWeek(dayOfWeek);
    days.add(dayEntity);
    dayOfWeek++;
    if (dayOfWeek == 7) {
      dayOfWeek=0;
    }
  }
  this.days=days;
  long startOfYearJdn=Utils.getJdnOfCalendar(mainCalendar,year,1,1);
  weekOfYearStart=calculateWeekOfYear(baseJdn,startOfYearJdn);
  weeksCount=1 + calculateWeekOfYear(baseJdn + monthLength - 1,startOfYearJdn) - weekOfYearStart;
  startingDayOfWeek=Utils.getDayOfWeekFromJdn(baseJdn);
}

Fixed version (ground truth):
private void fillTheFields(){
  CalendarType mainCalendar=Utils.getMainCalendar();
  List<DayEntity> days=new ArrayList<>();
  typedDate=Utils.getTodayOfCalendar(mainCalendar);
  int month=typedDate.getMonth() - offset;
  month-=1;
  int year=typedDate.getYear();
  year=year + (month / 12);
  month=month % 12;
  if (month < 0) {
    year-=1;
    month+=12;
  }
  month+=1;
  typedDate=Utils.getDateOfCalendar(mainCalendar,year,month,1);
  baseJdn=Utils.getJdnDate(typedDate);
  monthLength=(int)(Utils.getJdnOfCalendar(mainCalendar,month == 12 ? year + 1 : year,month == 12 ? 1 : month + 1,1) - baseJdn);
  int dayOfWeek=Utils.getDayOfWeekFromJdn(baseJdn);
  long todayJdn=Utils.getTodayJdn();
  for (int i=0; i < monthLength; i++) {
    DayEntity dayEntity=new DayEntity();
    dayEntity.setJdn(baseJdn + i);
    if (baseJdn + i == todayJdn) {
      dayEntity.setToday(true);
    }
    dayEntity.setDayOfWeek(dayOfWeek);
    days.add(dayEntity);
    dayOfWeek++;
    if (dayOfWeek == 7) {
      dayOfWeek=0;
    }
  }
  this.days=days;
  long startOfYearJdn=Utils.getJdnOfCalendar(mainCalendar,year,1,1);
  weekOfYearStart=calculateWeekOfYear(baseJdn,startOfYearJdn);
  weeksCount=1 + calculateWeekOfYear(baseJdn + monthLength - 1,startOfYearJdn) - weekOfYearStart;
  startingDayOfWeek=Utils.getDayOfWeekFromJdn(baseJdn);
}
Program: 8625
Project: 8625
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View view=inflater.inflate(R.layout.fragment_month,container,false);
  offset=getArguments().getInt(Constants.OFFSET_ARGUMENT);
  AppCompatImageView prev=view.findViewById(R.id.prev);
  AppCompatImageView next=view.findViewById(R.id.next);
  prev.setOnClickListener(this);
  next.setOnClickListener(this);
  RecyclerView recyclerView=view.findViewById(R.id.RecyclerView);
  recyclerView.setHasFixedSize(true);
  RecyclerView.LayoutManager layoutManager=new GridLayoutManager(getContext(),Utils.isWeekOfYearEnabled() ? 8 : 7);
  recyclerView.setLayoutManager(layoutManager);
  fillTheFields();
  adapter=new MonthAdapter(getContext(),this,days,startingDayOfWeek,weekOfYearStart,weeksCount);
  recyclerView.setAdapter(adapter);
  recyclerView.setItemAnimator(null);
  calendarFragment=(CalendarFragment)getActivity().getSupportFragmentManager().findFragmentByTag(CalendarFragment.class.getName());
  if (offset == 0 && calendarFragment.getViewPagerPosition() == offset) {
    calendarFragment.selectDay(Utils.getTodayJdn());
    updateTitle();
  }
  LocalBroadcastManager.getInstance(getContext()).registerReceiver(setCurrentMonthReceiver,new IntentFilter(Constants.BROADCAST_INTENT_TO_MONTH_FRAGMENT));
  return view;
}

Fixed version (ground truth):
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View view=inflater.inflate(R.layout.fragment_month,container,false);
  offset=getArguments().getInt(Constants.OFFSET_ARGUMENT);
  AppCompatImageView prev=view.findViewById(R.id.prev);
  AppCompatImageView next=view.findViewById(R.id.next);
  prev.setOnClickListener(this);
  next.setOnClickListener(this);
  RecyclerView recyclerView=view.findViewById(R.id.RecyclerView);
  recyclerView.setHasFixedSize(true);
  RecyclerView.LayoutManager layoutManager=new GridLayoutManager(getContext(),Utils.isWeekOfYearEnabled() ? 8 : 7);
  recyclerView.setLayoutManager(layoutManager);
  fillTheFields();
  adapter=new MonthAdapter(getContext(),this,days,startingDayOfWeek,weekOfYearStart,weeksCount);
  recyclerView.setAdapter(adapter);
  recyclerView.setItemAnimator(null);
  calendarFragment=(CalendarFragment)getActivity().getSupportFragmentManager().findFragmentByTag(CalendarFragment.class.getName());
  if (calendarFragment.firstTime && offset == 0 && calendarFragment.getViewPagerPosition() == offset) {
    calendarFragment.firstTime=false;
    calendarFragment.selectDay(Utils.getTodayJdn());
    updateTitle();
  }
  LocalBroadcastManager.getInstance(getContext()).registerReceiver(setCurrentMonthReceiver,new IntentFilter(Constants.BROADCAST_INTENT_TO_MONTH_FRAGMENT));
  return view;
}
Program: 8626
Project: 8626
Buggy source:
@Override public void onReceive(Context context,Intent intent){
  int value=intent.getExtras().getInt(Constants.BROADCAST_FIELD_TO_MONTH_FRAGMENT);
  if (value == offset) {
    updateTitle();
    int day=intent.getExtras().getInt(Constants.BROADCAST_FIELD_SELECT_DAY);
    if (day != -1) {
      adapter.selectDay(day);
    }
  }
 else   if (value == Constants.BROADCAST_TO_MONTH_FRAGMENT_RESET_DAY) {
    adapter.clearSelectedDay();
  }
}

Fixed version (ground truth):
@Override public void onReceive(Context context,Intent intent){
  int value=intent.getExtras().getInt(Constants.BROADCAST_FIELD_TO_MONTH_FRAGMENT);
  if (value == offset) {
    updateTitle();
    long jdn=intent.getExtras().getLong(Constants.BROADCAST_FIELD_SELECT_DAY_JDN);
    long selectedDay=1 + jdn - baseJdn;
    if (jdn != -1 && jdn >= baseJdn && selectedDay <= monthLength) {
      adapter.selectDay((int)(1 + jdn - baseJdn));
    }
  }
 else {
    adapter.selectDay(-1);
  }
}
Program: 8627
Project: 8627
Buggy source:
@Override public void onClick(){
  try {
    startActivityAndCollapse(new Intent(this,MainActivity.class));
  }
 catch (  Exception e) {
    Log.e("String_Node_Str","String_Node_Str",e);
  }
}

Fixed version (ground truth):
@Override public void onClick(){
  try {
    startActivityAndCollapse(new Intent(this,MainActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
  }
 catch (  Exception e) {
    Log.e("String_Node_Str","String_Node_Str",e);
  }
}
Program: 8628
Project: 8628
Buggy source:
@Override public void onClick(View v){
  int position=getAdapterPosition();
  if (Utils.isWeekOfYearEnabled()) {
    if (position % 8 == 0) {
      return;
    }
    position=fixForWeekOfYearNumber(position);
  }
  if (totalDays < position - 6 - startingDayOfWeek) {
    return;
  }
  if (position - 7 - startingDayOfWeek >= 0) {
    monthFragment.onClickItem(days.get(position - 7 - startingDayOfWeek).getJdn());
    MonthAdapter.this.selectDay(1 + position - 7 - startingDayOfWeek);
  }
}

Fixed version (ground truth):
@Override public void onClick(View v){
  int position=getAdapterPosition();
  if (Utils.isWeekOfYearEnabled()) {
    if (position % 8 == 0) {
      return;
    }
    position=fixForWeekOfYearNumber(position);
  }
  if (totalDays < position - 6 - startingDayOfWeek || position - 7 - startingDayOfWeek < 0) {
    return;
  }
  monthFragment.onClickItem(days.get(position - 7 - startingDayOfWeek).getJdn());
  MonthAdapter.this.selectDay(1 + position - 7 - startingDayOfWeek);
}
Program: 8629
Project: 8629
Buggy source:
@Override public boolean onLongClick(View v){
  int position=getAdapterPosition();
  if (Utils.isWeekOfYearEnabled()) {
    if (position % 8 == 0) {
      return false;
    }
    position=fixForWeekOfYearNumber(position);
  }
  if (totalDays < position - 6 - startingDayOfWeek) {
    return false;
  }
  monthFragment.onLongClickItem(days.get(position - 7 - startingDayOfWeek).getJdn());
  onClick(v);
  return false;
}

Fixed version (ground truth):
@Override public boolean onLongClick(View v){
  int position=getAdapterPosition();
  if (Utils.isWeekOfYearEnabled()) {
    if (position % 8 == 0) {
      return false;
    }
    position=fixForWeekOfYearNumber(position);
  }
  if (totalDays < position - 6 - startingDayOfWeek || position - 7 - startingDayOfWeek < 0) {
    return false;
  }
  monthFragment.onLongClickItem(days.get(position - 7 - startingDayOfWeek).getJdn());
  onClick(v);
  return false;
}
Program: 8632
Project: 8632
Buggy source:
@Override public void onClick(View v){
  int position=fixRtlPosition(getAdapterPosition());
  if (Utils.isWeekOfYearEnabled()) {
    position=fixForWeekOfYearNumber(position);
  }
  if (totalDays < position - 6 - firstDayDayOfWeek) {
    return;
  }
  if (position - 7 - firstDayDayOfWeek >= 0) {
    monthFragment.onClickItem(days.get(position - 7 - firstDayDayOfWeek).getJdn());
    selectedDay=position;
    notifyItemChanged(prevDay);
    notifyItemChanged(getAdapterPosition());
    prevDay=getAdapterPosition();
  }
}

Fixed version (ground truth):
@Override public void onClick(View v){
  int position=fixRtlPosition(getAdapterPosition());
  if (Utils.isWeekOfYearEnabled()) {
    position=fixForWeekOfYearNumber(position);
    if (position % 8 == 0) {
      return;
    }
  }
  if (totalDays < position - 6 - firstDayDayOfWeek) {
    return;
  }
  if (position - 7 - firstDayDayOfWeek >= 0) {
    monthFragment.onClickItem(days.get(position - 7 - firstDayDayOfWeek).getJdn());
    selectedDay=position;
    notifyItemChanged(prevDay);
    notifyItemChanged(getAdapterPosition());
    prevDay=getAdapterPosition();
  }
}
Program: 8633
Project: 8633
Buggy source:
@Override public boolean onLongClick(View v){
  int position=fixRtlPosition(getAdapterPosition());
  if (Utils.isWeekOfYearEnabled()) {
    position=fixForWeekOfYearNumber(position);
  }
  if (totalDays < position - 6 - firstDayDayOfWeek) {
    return false;
  }
  try {
    monthFragment.onLongClickItem(days.get(position - 7 - firstDayDayOfWeek).getJdn());
  }
 catch (  Exception e) {
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean onLongClick(View v){
  int position=fixRtlPosition(getAdapterPosition());
  if (Utils.isWeekOfYearEnabled()) {
    position=fixForWeekOfYearNumber(position);
    if (position % 8 == 0) {
      return false;
    }
  }
  if (totalDays < position - 6 - firstDayDayOfWeek) {
    return false;
  }
  try {
    monthFragment.onLongClickItem(days.get(position - 7 - firstDayDayOfWeek).getJdn());
  }
 catch (  Exception e) {
  }
  return false;
}
Program: 8634
Project: 8634
Buggy source:
public void drawTrueNorthArrow(Canvas canvas,float drawnAngle){
  trueNorthArrowPaint.reset();
  trueNorthArrowPaint.setColor(Color.RED);
  trueNorthArrowPaint.setStyle(Paint.Style.FILL);
  trueNorthArrowPaint.setAlpha(100);
  int r=Radius / 12;
  mPath.reset();
  mPath.moveTo(px,py - px);
  mPath.lineTo(px - r,py);
  mPath.lineTo(px,py + r);
  mPath.lineTo(px + r,py);
  mPath.addCircle(px,py,r,Path.Direction.CCW);
  mPath.close();
  canvas.drawPath(mPath,trueNorthArrowPaint);
  dashedPaint.setColor(Color.RED);
  canvas.drawLine(px,py - px,px,py + Radius,dashedPaint);
  canvas.drawCircle(px,py,5,dashedPaint);
  canvas.restore();
}

Fixed version (ground truth):
public void drawTrueNorthArrow(Canvas canvas,float drawnAngle){
  trueNorthArrowPaint.reset();
  trueNorthArrowPaint.setColor(Color.RED);
  trueNorthArrowPaint.setStyle(Paint.Style.FILL);
  trueNorthArrowPaint.setAlpha(100);
  int r=Radius / 12;
  mPath.reset();
  mPath.moveTo(px,py - Radius);
  mPath.lineTo(px - r,py);
  mPath.lineTo(px,py + r);
  mPath.lineTo(px + r,py);
  mPath.addCircle(px,py,r,Path.Direction.CCW);
  mPath.close();
  canvas.drawPath(mPath,trueNorthArrowPaint);
  dashedPaint.setColor(Color.RED);
  canvas.drawLine(px,py - px,px,py + Radius,dashedPaint);
  canvas.drawCircle(px,py,5,dashedPaint);
  canvas.restore();
}
Program: 8635
Project: 8635
Buggy source:
public void drawDial(Canvas canvas){
  circlePaint.reset();
  circlePaint.setColor(ContextCompat.getColor(getContext(),R.color.qibla_color));
  circlePaint.setStrokeWidth(1);
  circlePaint.setStyle(Paint.Style.STROKE);
  int textHeight=(int)textPaint.measureText("String_Node_Str");
  markerPaint.reset();
  markerPaint.setColor(ContextCompat.getColor(getContext(),R.color.qibla_color));
  canvas.drawCircle(px,py,Radius,circlePaint);
  canvas.drawCircle(px,py,Radius - 20,circlePaint);
  int textWidth=(int)textPaint.measureText("String_Node_Str");
  int cardinalX=px - textWidth / 2;
  int cardinalY=py - Radius + textHeight;
  for (int i=0; i < 24; i++) {
    canvas.drawLine(px,py - Radius,px,py - Radius + 10,markerPaint);
    canvas.save();
    canvas.translate(0,textHeight);
    if (i % 6 == 0) {
      String dirString="String_Node_Str";
switch (i) {
case (0):
{
          dirString=northString;
          break;
        }
case (6):
      dirString=eastString;
    break;
case (12):
  dirString=southString;
break;
case (18):
dirString=westString;
break;
}
canvas.drawText(dirString,cardinalX,cardinalY,textPaint);
}
 else if (i % 3 == 0) {
String angle=String.valueOf(i * 15);
float angleTextWidth=textPaint.measureText(angle);
int angleTextX=(int)(px - angleTextWidth / 2);
int angleTextY=py - Radius + textHeight;
canvas.drawText(angle,angleTextX,angleTextY,textPaint);
}
canvas.restore();
canvas.rotate(15,px,py);
}
}

Fixed version (ground truth):
public void drawDial(Canvas canvas){
  circlePaint.reset();
  circlePaint.setColor(ContextCompat.getColor(getContext(),R.color.qibla_color));
  circlePaint.setStrokeWidth(1);
  circlePaint.setStyle(Paint.Style.STROKE);
  int textHeight=(int)textPaint.measureText("String_Node_Str");
  markerPaint.reset();
  markerPaint.setColor(ContextCompat.getColor(getContext(),R.color.qibla_color));
  canvas.drawCircle(px,py,Radius,circlePaint);
  canvas.drawCircle(px,py,Radius - 20,circlePaint);
  int textWidth=(int)textPaint.measureText("String_Node_Str");
  int cardinalX=px - textWidth / 2;
  int cardinalY=py - Radius + textHeight;
  for (int i=0; i < 24; i++) {
    canvas.drawLine(px,py - Radius,px,py - Radius + 10,markerPaint);
    canvas.save();
    canvas.translate(0,textHeight);
    if (i % 6 == 0) {
      String dirString="String_Node_Str";
switch (i) {
case 0:
        dirString=northString;
      break;
case 6:
    dirString=eastString;
  break;
case 12:
dirString=southString;
break;
case 18:
dirString=westString;
break;
}
canvas.drawText(dirString,cardinalX,cardinalY,textPaint);
}
 else if (i % 3 == 0) {
String angle=String.valueOf(i * 15);
float angleTextWidth=textPaint.measureText(angle);
int angleTextX=(int)(px - angleTextWidth / 2);
int angleTextY=py - Radius + textHeight;
canvas.drawText(angle,angleTextX,angleTextY,textPaint);
}
canvas.restore();
canvas.rotate(15,px,py);
}
}
Program: 8639
Project: 8639
Buggy source:
static public int fillYearMonthDaySpinners(Context context,Spinner calendarTypeSpinner,Spinner yearSpinner,Spinner monthSpinner,Spinner daySpinner){
  AbstractDate date;
  PersianDate newDatePersian=getToday();
  CivilDate newDateCivil=DateConverter.persianToCivil(newDatePersian);
  IslamicDate newDateIslamic=DateConverter.persianToIslamic(newDatePersian);
  date=newDateCivil;
switch (calendarTypeFromPosition(calendarTypeSpinner.getSelectedItemPosition())) {
case GREGORIAN:
    date=newDateCivil;
  break;
case ISLAMIC:
date=newDateIslamic;
break;
case SHAMSI:
date=newDatePersian;
break;
}
String[] years=new String[200];
int startingYearOnYearSpinner=date.getYear() - years.length / 2;
for (int i=0; i < years.length; ++i) {
years[i]=formatNumber(i + startingYearOnYearSpinner);
}
yearSpinner.setAdapter(new ShapedArrayAdapter<>(context,DROPDOWN_LAYOUT,years));
yearSpinner.setSelection(years.length / 2);
String[] months=monthsNamesOfCalendar(context,date);
for (int i=0; i < months.length; ++i) {
months[i]=months[i] + "String_Node_Str" + formatNumber(i + 1);
}
monthSpinner.setAdapter(new ShapedArrayAdapter<>(context,DROPDOWN_LAYOUT,months));
monthSpinner.setSelection(date.getMonth() - 1);
String[] days=new String[31];
for (int i=0; i < days.length; ++i) {
days[i]=formatNumber(i + 1);
}
daySpinner.setAdapter(new ShapedArrayAdapter<>(context,DROPDOWN_LAYOUT,days));
daySpinner.setSelection(date.getDayOfMonth() - 1);
return startingYearOnYearSpinner;
}

Fixed version (ground truth):
static public int fillYearMonthDaySpinners(Context context,Spinner calendarTypeSpinner,Spinner yearSpinner,Spinner monthSpinner,Spinner daySpinner){
  AbstractDate date;
  PersianDate newDatePersian=getToday();
  CivilDate newDateCivil=DateConverter.persianToCivil(newDatePersian);
  IslamicDate newDateIslamic=DateConverter.persianToIslamic(newDatePersian);
  date=newDateCivil;
switch (calendarTypeFromPosition(calendarTypeSpinner.getSelectedItemPosition())) {
case GREGORIAN:
    date=newDateCivil;
  break;
case ISLAMIC:
date=newDateIslamic;
break;
case SHAMSI:
date=newDatePersian;
break;
}
String[] years=new String[200];
int startingYearOnYearSpinner=date.getYear() - years.length / 2;
for (int i=0; i < years.length; ++i) {
years[i]=formatNumber(i + startingYearOnYearSpinner);
}
yearSpinner.setAdapter(new ShapedArrayAdapter<>(context,DROPDOWN_LAYOUT,years));
yearSpinner.setSelection(years.length / 2);
String[] months=monthsNamesOfCalendar(context,date).clone();
for (int i=0; i < months.length; ++i) {
months[i]=months[i] + "String_Node_Str" + formatNumber(i + 1);
}
monthSpinner.setAdapter(new ShapedArrayAdapter<>(context,DROPDOWN_LAYOUT,months));
monthSpinner.setSelection(date.getMonth() - 1);
String[] days=new String[31];
for (int i=0; i < days.length; ++i) {
days[i]=formatNumber(i + 1);
}
daySpinner.setAdapter(new ShapedArrayAdapter<>(context,DROPDOWN_LAYOUT,days));
daySpinner.setSelection(date.getDayOfMonth() - 1);
return startingYearOnYearSpinner;
}
Program: 8641
Project: 8641
Buggy source:
@Override public void onConfigurationChanged(Configuration newConfig){
  super.onConfigurationChanged(newConfig);
  Utils.changeAppLanguage(this);
  View v=findViewById(R.id.drawer);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
    v.setLayoutDirection(isRTL() ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR);
  }
}

Fixed version (ground truth):
@Override public void onConfigurationChanged(Configuration newConfig){
  super.onConfigurationChanged(newConfig);
  Utils.updateStoredPreference(this);
  Utils.changeAppLanguage(this);
  UpdateUtils.update(getApplicationContext(),true);
  View v=findViewById(R.id.drawer);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
    v.setLayoutDirection(isRTL() ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR);
  }
}
Program: 8643
Project: 8643
Buggy source:
static private void changeAppLanguage(Context context){
  String localeCode=language.replaceAll("String_Node_Str","String_Node_Str");
  Locale locale=new Locale(localeCode);
  Locale.setDefault(locale);
  Resources resources=context.getResources();
  Configuration config=resources.getConfiguration();
  config.locale=locale;
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
    config.setLayoutDirection(config.locale);
  }
  resources.updateConfiguration(config,resources.getDisplayMetrics());
}

Fixed version (ground truth):
static public void changeAppLanguage(Context context){
  String localeCode=language.replaceAll("String_Node_Str","String_Node_Str");
  Locale locale=new Locale(localeCode);
  Locale.setDefault(locale);
  Resources resources=context.getResources();
  Configuration config=resources.getConfiguration();
  config.locale=locale;
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
    config.setLayoutDirection(config.locale);
  }
  resources.updateConfiguration(config,resources.getDisplayMetrics());
}
Program: 8645
Project: 8645
Buggy source:
private void beforeMenuChange(int position){
  if (menuPosition != PREFERENCE)   return;
  Utils.initUtils(this);
  UpdateUtils.update(getApplicationContext(),true);
  boolean needsActivityRestart=false;
  String locale=Utils.getAppLanguage();
  if (!locale.equals(lastLocale)) {
    lastLocale=locale;
    Utils.initUtils(this);
    needsActivityRestart=true;
  }
  if (!lastTheme.equals(Utils.getTheme(this))) {
    needsActivityRestart=true;
    lastTheme=Utils.getTheme(this);
  }
  if (needsActivityRestart)   restartActivity();
}

Fixed version (ground truth):
private void beforeMenuChange(int position){
  if (menuPosition != PREFERENCE)   return;
  Utils.initUtils(this);
  UpdateUtils.update(getApplicationContext(),true);
  boolean needsActivityRestart=false;
  String locale=Utils.getAppLanguage();
  if (!locale.equals(lastLocale)) {
    lastLocale=locale;
    needsActivityRestart=true;
  }
  if (!lastTheme.equals(Utils.getTheme(this))) {
    needsActivityRestart=true;
    lastTheme=Utils.getTheme(this);
  }
  if (needsActivityRestart)   restartActivity();
}
Program: 8647
Project: 8647
Buggy source:
public Set<String> commaSeparatedToSet(String commaSeparated){
  Set<String> result=new HashSet<>();
  result.addAll(Arrays.asList(TextUtils.split(commaSeparated,"String_Node_Str")));
  return result;
}

Fixed version (ground truth):
public Set<String> commaSeparatedToSet(String commaSeparated){
  return new HashSet<>(Arrays.asList(TextUtils.split(commaSeparated,"String_Node_Str")));
}
Program: 8649
Project: 8649
Buggy source:
private void stop(){
  if (mediaPlayer != null && mediaPlayer.isPlaying()) {
    mediaPlayer.stop();
    mediaPlayer.release();
  }
}

Fixed version (ground truth):
private void stop(){
  try {
    if (mediaPlayer != null && mediaPlayer.isPlaying()) {
      mediaPlayer.stop();
      mediaPlayer.release();
    }
  }
 catch (  IllegalStateException ignored) {
  }
}
Program: 8650
Project: 8650
Buggy source:
public String getWeekDayName(AbstractDate date){
  if (date instanceof IslamicDate)   date=DateConverter.islamicToCivil((IslamicDate)date);
  if (weekDays == null)   loadLanguageResource();
  return weekDays[date.getDayOfWeek() - 1];
}

Fixed version (ground truth):
public String getWeekDayName(AbstractDate date){
  if (date instanceof IslamicDate)   date=DateConverter.islamicToCivil((IslamicDate)date);
 else   if (date instanceof PersianDate)   date=DateConverter.persianToCivil((PersianDate)date);
  if (weekDays == null)   loadLanguageResource();
  return weekDays[date.getDayOfWeek() % 7];
}
Program: 8651
Project: 8651
Buggy source:
@Override protected void onPrepareDialogBuilder(AlertDialog.Builder builder){
  super.onPrepareDialogBuilder(builder);
  final ShapedListPreference listPref=(ShapedListPreference)getPreference();
  final CharSequence[] entriesValues=listPref.getEntryValues();
  ShapedArrayAdapter entriesAdapter=new ShapedArrayAdapter(getContext(),R.layout.select_dialog_singlechoice_material,Arrays.asList(listPref.getEntries()));
  int index=Arrays.asList(entriesValues).indexOf(listPref.getSelected());
  builder.setSingleChoiceItems(entriesAdapter,index,new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      listPref.setSelected(entriesValues[which].toString());
      getDialog().dismiss();
    }
  }
);
  builder.setPositiveButton("String_Node_Str",null);
}

Fixed version (ground truth):
@Override protected void onPrepareDialogBuilder(AlertDialog.Builder builder){
  super.onPrepareDialogBuilder(builder);
  final ShapedListPreference listPref=(ShapedListPreference)getPreference();
  final CharSequence[] entriesValues=listPref.getEntryValues();
  int selectDialogLayout=R.layout.select_dialog_singlechoice_material;
  if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN_MR1)   selectDialogLayout=android.R.layout.select_dialog_singlechoice;
  ShapedArrayAdapter entriesAdapter=new ShapedArrayAdapter(getContext(),selectDialogLayout,Arrays.asList(listPref.getEntries()));
  int index=Arrays.asList(entriesValues).indexOf(listPref.getSelected());
  builder.setSingleChoiceItems(entriesAdapter,index,new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      listPref.setSelected(entriesValues[which].toString());
      getDialog().dismiss();
    }
  }
);
  builder.setPositiveButton("String_Node_Str",null);
}
Program: 8652
Project: 8652
Buggy source:
private void fillYearMonthDaySpinners(){
  AbstractDate date=null;
  PersianDate newDatePersian=utils.getToday();
  CivilDate newDateCivil=DateConverter.persianToCivil(newDatePersian);
  IslamicDate newDateIslamic=DateConverter.persianToIslamic(newDatePersian);
  date=newDateCivil;
  CalendarTypeEnum selectedCalendarType=calendarTypeFromPosition(calendarTypeSpinner.getSelectedItemPosition());
switch (selectedCalendarType) {
case GREGORIAN:
    date=newDateCivil;
  break;
case ISLAMIC:
date=newDateIslamic;
break;
case SHAMSI:
date=newDatePersian;
break;
}
int dropdownLayout=R.layout.select_dialog_item_material;
List<String> yearsList=new ArrayList<>();
int yearDiffRange=200;
startingYearOnYearSpinner=date.getYear() - yearDiffRange / 2;
for (int i=startingYearOnYearSpinner; i < startingYearOnYearSpinner + yearDiffRange; ++i) {
yearsList.add(utils.formatNumber(i));
}
yearSpinner.setAdapter(new ShapedArrayAdapter(getContext(),dropdownLayout,yearsList));
yearSpinner.setSelection(yearDiffRange / 2);
List<String> monthsList=utils.getMonthsNamesListWithOrdinal(date);
monthSpinner.setAdapter(new ShapedArrayAdapter(getContext(),dropdownLayout,monthsList));
monthSpinner.setSelection(date.getMonth() - 1);
List<String> daysList=new ArrayList<>();
for (int i=1; i <= 31; ++i) {
daysList.add(utils.formatNumber(i));
}
daySpinner.setAdapter(new ShapedArrayAdapter(getContext(),dropdownLayout,daysList));
daySpinner.setSelection(date.getDayOfMonth() - 1);
}

Fixed version (ground truth):
private void fillYearMonthDaySpinners(){
  AbstractDate date=null;
  PersianDate newDatePersian=utils.getToday();
  CivilDate newDateCivil=DateConverter.persianToCivil(newDatePersian);
  IslamicDate newDateIslamic=DateConverter.persianToIslamic(newDatePersian);
  date=newDateCivil;
  CalendarTypeEnum selectedCalendarType=calendarTypeFromPosition(calendarTypeSpinner.getSelectedItemPosition());
switch (selectedCalendarType) {
case GREGORIAN:
    date=newDateCivil;
  break;
case ISLAMIC:
date=newDateIslamic;
break;
case SHAMSI:
date=newDatePersian;
break;
}
List<String> yearsList=new ArrayList<>();
int yearDiffRange=200;
startingYearOnYearSpinner=date.getYear() - yearDiffRange / 2;
for (int i=startingYearOnYearSpinner; i < startingYearOnYearSpinner + yearDiffRange; ++i) {
yearsList.add(utils.formatNumber(i));
}
yearSpinner.setAdapter(new ShapedArrayAdapter(getContext(),DROPDOWN_LAYOUT,yearsList));
yearSpinner.setSelection(yearDiffRange / 2);
List<String> monthsList=utils.getMonthsNamesListWithOrdinal(date);
monthSpinner.setAdapter(new ShapedArrayAdapter(getContext(),DROPDOWN_LAYOUT,monthsList));
monthSpinner.setSelection(date.getMonth() - 1);
List<String> daysList=new ArrayList<>();
for (int i=1; i <= 31; ++i) {
daysList.add(utils.formatNumber(i));
}
daySpinner.setAdapter(new ShapedArrayAdapter(getContext(),DROPDOWN_LAYOUT,daysList));
daySpinner.setSelection(date.getDayOfMonth() - 1);
}
Program: 8654
Project: 8654
Buggy source:
public CalendarTypesSpinnerAdapter(Context context,int resource){
  super(context,resource);
  utils=Utils.getInstance(context);
  utils.loadLanguageFromSettings();
  spinnerResource=resource;
  calendarTypes.put(CalendarTypeEnum.SHAMSI,utils.getString(Constants.HIJRI_SHAMSI));
  calendarTypes.put(CalendarTypeEnum.ISLAMIC,utils.getString(Constants.HIJRI_QAMARI));
  calendarTypes.put(CalendarTypeEnum.GEORGIAN,utils.getString(Constants.GEORGIAN));
}

Fixed version (ground truth):
public CalendarTypesSpinnerAdapter(Context context,int resource){
  super(context,resource);
  utils=Utils.getInstance(context);
  spinnerResource=resource;
  calendarTypes.put(CalendarTypeEnum.SHAMSI,utils.getString(Constants.HIJRI_SHAMSI));
  calendarTypes.put(CalendarTypeEnum.ISLAMIC,utils.getString(Constants.HIJRI_QAMARI));
  calendarTypes.put(CalendarTypeEnum.GEORGIAN,utils.getString(Constants.GEORGIAN));
}
Program: 8656
Project: 8656
Buggy source:
public void changeAppLanguage(String localeCode){
  Locale locale=TextUtils.isEmpty(localeCode) ? Locale.getDefault() : new Locale(localeCode);
  Locale.setDefault(locale);
  Configuration config=new Configuration();
  config.locale=locale;
  Resources resources=context.getResources();
  resources.updateConfiguration(config,resources.getDisplayMetrics());
}

Fixed version (ground truth):
public void changeAppLanguage(Context context){
  String localeCode=getAppLanguage().replaceAll("String_Node_Str","String_Node_Str");
  Locale locale=TextUtils.isEmpty(localeCode) ? Locale.getDefault() : new Locale(localeCode);
  Locale.setDefault(locale);
  Configuration config=new Configuration();
  config.locale=locale;
  Resources resources=context.getResources();
  resources.updateConfiguration(config,resources.getDisplayMetrics());
}
Program: 8657
Project: 8657
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  String prayerKey=getIntent().getStringExtra(Constants.KEY_EXTRA_PRAYER_KEY);
  Utils utils=Utils.getInstance(getApplicationContext());
  setContentView(R.layout.activity_athan);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
  }
  getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  textAlarmName=(TextView)findViewById(R.id.athan_name);
  TextView textCityName=(TextView)findViewById(R.id.place);
  athanIconView=(AppCompatImageView)findViewById(R.id.background_image);
  athanIconView.setOnClickListener(this);
  setPrayerView(prayerKey);
  CityEntity cityEntity=utils.getCityFromPreference();
  if (cityEntity != null) {
    String cityName=utils.getAppLanguage().equals("String_Node_Str") ? cityEntity.getEn() : cityEntity.getFa();
    textCityName.setText(getString(R.string.in_city_time) + "String_Node_Str" + cityName);
  }
 else {
    Coordinate coordinate=utils.getCoordinate();
    textCityName.setText(getString(R.string.in_city_time) + "String_Node_Str" + coordinate.getLatitude()+ "String_Node_Str"+ coordinate.getLongitude());
  }
  new Handler().postDelayed(new Runnable(){
    @Override public void run(){
      finish();
    }
  }
,TimeUnit.SECONDS.toMillis(45));
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  String prayerKey=getIntent().getStringExtra(Constants.KEY_EXTRA_PRAYER_KEY);
  Utils utils=Utils.getInstance(getApplicationContext());
  utils.changeAppLanguage(this);
  utils.loadLanguageResource();
  setContentView(R.layout.activity_athan);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
  }
  getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  textAlarmName=(TextView)findViewById(R.id.athan_name);
  TextView textCityName=(TextView)findViewById(R.id.place);
  athanIconView=(AppCompatImageView)findViewById(R.id.background_image);
  athanIconView.setOnClickListener(this);
  setPrayerView(prayerKey);
  CityEntity cityEntity=utils.getCityFromPreference();
  if (cityEntity != null) {
    String cityName=utils.getAppLanguage().equals("String_Node_Str") ? cityEntity.getEn() : cityEntity.getFa();
    textCityName.setText(getString(R.string.in_city_time) + "String_Node_Str" + cityName);
  }
 else {
    Coordinate coordinate=utils.getCoordinate();
    textCityName.setText(getString(R.string.in_city_time) + "String_Node_Str" + coordinate.getLatitude()+ "String_Node_Str"+ coordinate.getLongitude());
  }
  new Handler().postDelayed(new Runnable(){
    @Override public void run(){
      finish();
    }
  }
,TimeUnit.SECONDS.toMillis(45));
}
Program: 8659
Project: 8659
Buggy source:
private void menuChange(){
  if (menuPosition != PREFERENCE)   return;
  utils.updateStoredPreference();
  updateUtils.update(true);
  boolean needsActivityRestart=false;
  String locale=utils.getAppLanguage();
  if (!locale.equals(prevLocale)) {
    prevLocale=locale;
    utils.loadLanguageFromSettings();
    needsActivityRestart=true;
  }
  if (!prevTheme.equals(utils.getTheme())) {
    needsActivityRestart=true;
  }
  if (needsActivityRestart) {
    Intent intent=getIntent();
    finish();
    startActivity(intent);
  }
}

Fixed version (ground truth):
private void menuChange(){
  if (menuPosition != PREFERENCE)   return;
  utils.updateStoredPreference();
  updateUtils.update(true);
  boolean needsActivityRestart=false;
  String locale=utils.getAppLanguage();
  if (!locale.equals(lastLocale)) {
    lastLocale=locale;
    utils.changeAppLanguage(this);
    utils.loadLanguageResource();
    needsActivityRestart=true;
  }
  if (!lastTheme.equals(utils.getTheme())) {
    needsActivityRestart=true;
  }
  if (needsActivityRestart) {
    Intent intent=getIntent();
    finish();
    startActivity(intent);
  }
}
Program: 8660
Project: 8660
Buggy source:
public CivilDate(int year,int month,int day){
  this();
  setYear(year);
  setMonth(month);
  setDayOfMonth(day);
}

Fixed version (ground truth):
public CivilDate(int year,int month,int day){
  this();
  setYear(year);
  this.day=1;
  setMonth(month);
  setDayOfMonth(day);
}
Program: 8661
Project: 8661
Buggy source:
@Override public void onClick(View v){
  if (getAdapterPosition() - 7 - days.get(0).getDayOfWeek() >= 0) {
    monthFragment.onClickItem(days.get(getAdapterPosition() - 7 - days.get(0).getDayOfWeek()).getPersianDate());
    select_Day=getAdapterPosition();
    notifyDataSetChanged();
  }
}

Fixed version (ground truth):
@Override public void onClick(View v){
  int position=getAdapterPosition();
  position+=6 - (position % 7) * 2;
  if (days.size() < position - 6 - firstDayDayOfWeek) {
    return;
  }
  if (position - 7 - firstDayDayOfWeek >= 0) {
    monthFragment.onClickItem(days.get(position - 7 - firstDayDayOfWeek).getPersianDate());
    select_Day=position;
    notifyDataSetChanged();
  }
}
Program: 8662
Project: 8662
Buggy source:
@Override public boolean onLongClick(View v){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    try {
      monthFragment.onLongClickItem(days.get(getAdapterPosition() - 7 - days.get(0).getDayOfWeek()).getPersianDate());
    }
 catch (    Exception e) {
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean onLongClick(View v){
  int position=getAdapterPosition();
  position+=6 - (position % 7) * 2;
  if (days.size() < position - 6 - firstDayDayOfWeek) {
    return false;
  }
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    try {
      monthFragment.onLongClickItem(days.get(position - 7 - firstDayDayOfWeek).getPersianDate());
    }
 catch (    Exception e) {
    }
  }
  return false;
}
Program: 8663
Project: 8663
Buggy source:
public MonthAdapter(Context context,MonthFragment monthFragment,List<DayEntity> days){
  this.monthFragment=monthFragment;
  this.context=context;
  this.days=days;
  utils=Utils.getInstance(context);
  persianDigit=utils.isPersianDigitSelected();
  context.getTheme().resolveAttribute(R.attr.colorHoliday,colorHoliday,true);
  context.getTheme().resolveAttribute(R.attr.colorTextHoliday,colorTextHoliday,true);
  context.getTheme().resolveAttribute(R.attr.colorPrimary,colorPrimary,true);
  context.getTheme().resolveAttribute(R.attr.colorTextDayName,colorDayName,true);
}

Fixed version (ground truth):
public MonthAdapter(Context context,MonthFragment monthFragment,List<DayEntity> days){
  firstDayDayOfWeek=days.get(0).getDayOfWeek();
  this.monthFragment=monthFragment;
  this.context=context;
  this.days=days;
  utils=Utils.getInstance(context);
  persianDigit=utils.isPersianDigitSelected();
  context.getTheme().resolveAttribute(R.attr.colorHoliday,colorHoliday,true);
  context.getTheme().resolveAttribute(R.attr.colorTextHoliday,colorTextHoliday,true);
  context.getTheme().resolveAttribute(R.attr.colorPrimary,colorPrimary,true);
  context.getTheme().resolveAttribute(R.attr.colorTextDayName,colorDayName,true);
}
Program: 8664
Project: 8664
Buggy source:
@Override public int getItemCount(){
  return days.size() + days.get(0).getDayOfWeek() + 7;
}

Fixed version (ground truth):
@Override public int getItemCount(){
  return 7 * 6;
}
Program: 8666
Project: 8666
Buggy source:
public int getIslamicOffset(){
  return Integer.parseInt(prefs.getString(Constants.PREF_ISLAMIC_OFFSET,Constants.DEFAULT_ISLAMIC_OFFSET));
}

Fixed version (ground truth):
public int getIslamicOffset(){
  return Integer.parseInt(prefs.getString(Constants.PREF_ISLAMIC_OFFSET,Constants.DEFAULT_ISLAMIC_OFFSET).replace("String_Node_Str","String_Node_Str"));
}
Program: 8667
Project: 8667
Buggy source:
@Override protected View onCreateDialogView(Context context){
  View view=super.onCreateDialogView(context);
  final AthanVolumePreference athanPref=(AthanVolumePreference)getPreference();
  audioManager=(AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
  mediaPlayer=new MediaPlayer();
  try {
    mediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM);
    mediaPlayer.setDataSource(getContext(),Utils.getInstance(getContext()).getAthanUri());
    audioManager.setStreamVolume(AudioManager.STREAM_ALARM,athanPref.getVolume(),0);
  }
 catch (  IOException e) {
    Log.e("String_Node_Str","String_Node_Str",e);
  }
  SeekBar seekBar=(SeekBar)view.findViewById(R.id.sbVolumeSlider);
  seekBar.setProgress(athanPref.getVolume());
  seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener(){
    @Override public void onProgressChanged(    SeekBar seekBar,    int progress,    boolean fromUser){
      volume=progress;
      audioManager.setStreamVolume(AudioManager.STREAM_ALARM,progress,0);
    }
    @Override public void onStartTrackingTouch(    SeekBar seekBar){
    }
    @Override public void onStopTrackingTouch(    SeekBar seekBar){
      try {
        if (!mediaPlayer.isPlaying()) {
          mediaPlayer.prepare();
          mediaPlayer.start();
        }
      }
 catch (      IOException ignored) {
      }
    }
  }
);
  return view;
}

Fixed version (ground truth):
@Override protected View onCreateDialogView(Context context){
  View view=super.onCreateDialogView(context);
  final AthanVolumePreference athanPref=(AthanVolumePreference)getPreference();
  audioManager=(AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
  mediaPlayer=new MediaPlayer();
  try {
    mediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM);
    mediaPlayer.setDataSource(getContext(),Utils.getInstance(getContext()).getAthanUri());
    audioManager.setStreamVolume(AudioManager.STREAM_ALARM,athanPref.getVolume(),0);
  }
 catch (  IOException e) {
    Log.e("String_Node_Str","String_Node_Str",e);
  }
  SeekBar seekBar=(SeekBar)view.findViewById(R.id.sbVolumeSlider);
  volume=athanPref.getVolume();
  seekBar.setProgress(volume);
  seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener(){
    @Override public void onProgressChanged(    SeekBar seekBar,    int progress,    boolean fromUser){
      volume=progress;
      audioManager.setStreamVolume(AudioManager.STREAM_ALARM,progress,0);
    }
    @Override public void onStartTrackingTouch(    SeekBar seekBar){
    }
    @Override public void onStopTrackingTouch(    SeekBar seekBar){
      try {
        if (!mediaPlayer.isPlaying()) {
          mediaPlayer.prepare();
          mediaPlayer.start();
        }
      }
 catch (      IOException ignored) {
      }
    }
  }
);
  return view;
}
Program: 8668
Project: 8668
Buggy source:
public AthanVolumePreference(Context context,AttributeSet attrs){
  super(context,attrs);
  this.context=context;
  utils=Utils.getInstance(context);
  setDialogLayoutResource(R.layout.preference_volume);
  setDialogIcon(null);
}

Fixed version (ground truth):
public AthanVolumePreference(Context context,AttributeSet attrs){
  super(context,attrs);
  utils=Utils.getInstance(context);
  setDialogLayoutResource(R.layout.preference_volume);
  setDialogIcon(null);
}
Program: 8669
Project: 8669
Buggy source:
public void setAlarm(PrayTime prayTime,long timeInMillis,int id){
  String valAthanGap=prefs.getString("String_Node_Str","String_Node_Str");
  long athanGap=TextUtils.isEmpty(valAthanGap) ? 0 : Long.parseLong(valAthanGap);
  Calendar triggerTime=Calendar.getInstance();
  triggerTime.setTimeInMillis(timeInMillis - TimeUnit.SECONDS.toMillis(athanGap));
  AlarmManager alarmManager=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
  if (!triggerTime.before(Calendar.getInstance())) {
    Log.d(TAG,"String_Node_Str" + triggerTime.getTime());
    Intent intent=new Intent(context,BroadcastReceivers.class);
    intent.setAction(Constants.BROADCAST_ALARM);
    intent.putExtra(Constants.KEY_EXTRA_PRAYER_KEY,prayTime.name());
    PendingIntent pendingIntent=PendingIntent.getBroadcast(context,id,intent,0);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      alarmManager.setExact(AlarmManager.RTC_WAKEUP,triggerTime.getTimeInMillis(),pendingIntent);
    }
 else {
      alarmManager.set(AlarmManager.RTC_WAKEUP,triggerTime.getTimeInMillis(),pendingIntent);
    }
  }
}

Fixed version (ground truth):
public void setAlarm(PrayTime prayTime,long timeInMillis,int id){
  String valAthanGap=prefs.getString("String_Node_Str","String_Node_Str");
  long athanGap;
  try {
    athanGap=(long)(Double.parseDouble(valAthanGap) * 60);
  }
 catch (  NumberFormatException e) {
    athanGap=0;
  }
  Calendar triggerTime=Calendar.getInstance();
  triggerTime.setTimeInMillis(timeInMillis - TimeUnit.SECONDS.toMillis(athanGap));
  AlarmManager alarmManager=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
  if (!triggerTime.before(Calendar.getInstance())) {
    Log.d(TAG,"String_Node_Str" + triggerTime.getTime());
    Intent intent=new Intent(context,BroadcastReceivers.class);
    intent.setAction(Constants.BROADCAST_ALARM);
    intent.putExtra(Constants.KEY_EXTRA_PRAYER_KEY,prayTime.name());
    PendingIntent pendingIntent=PendingIntent.getBroadcast(context,id,intent,0);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      alarmManager.setExact(AlarmManager.RTC_WAKEUP,triggerTime.getTimeInMillis(),pendingIntent);
    }
 else {
      alarmManager.set(AlarmManager.RTC_WAKEUP,triggerTime.getTimeInMillis(),pendingIntent);
    }
  }
}
Program: 8670
Project: 8670
Buggy source:
public void loadApp(){
  AlarmManager alarmManager=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
  Calendar startTime=Calendar.getInstance();
  startTime.set(Calendar.HOUR_OF_DAY,0);
  startTime.set(Calendar.MINUTE,1);
  Intent intent=new Intent(context,BroadcastReceivers.class);
  intent.setAction(Constants.BROADCAST_ALARM);
  PendingIntent pendingIntent=PendingIntent.getBroadcast(context,0,intent,PendingIntent.FLAG_UPDATE_CURRENT);
  alarmManager.set(AlarmManager.RTC,startTime.getTimeInMillis(),pendingIntent);
}

Fixed version (ground truth):
public void loadApp(){
  AlarmManager alarmManager=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
  Calendar startTime=Calendar.getInstance();
  startTime.set(Calendar.HOUR_OF_DAY,0);
  startTime.set(Calendar.MINUTE,1);
  Intent intent=new Intent(context,BroadcastReceivers.class);
  intent.setAction(Constants.BROADCAST_RESTART_APP);
  PendingIntent pendingIntent=PendingIntent.getBroadcast(context,0,intent,PendingIntent.FLAG_UPDATE_CURRENT);
  alarmManager.set(AlarmManager.RTC,startTime.getTimeInMillis(),pendingIntent);
}