nus-yam/ex-repair huggingface dataset:
Program: 92641
Project: 92641
Buggy source:
@Override @Before public void setUp(){
  super.setUp();
  fixtures.purgeHabits(habitList);
  habit=fixtures.createLongHabit();
  view=new ScoreChart(targetContext);
  view.setScores(habit.getScores().getAll());
  view.setColor(ColorUtils.getColor(targetContext,habit.getColor()));
  view.setBucketSize(7);
  measureView(view,dpToPixels(300),dpToPixels(200));
}

Fixed version (ground truth):
@Override @Before public void setUp(){
  super.setUp();
  fixtures.purgeHabits(habitList);
  habit=fixtures.createLongHabit();
  view=new ScoreChart(targetContext);
  view.setScores(habit.getScores().toList());
  view.setColor(ColorUtils.getColor(targetContext,habit.getColor()));
  view.setBucketSize(7);
  measureView(view,dpToPixels(300),dpToPixels(200));
}
Program: 92642
Project: 92642
Buggy source:
@Test public void testGetAll(){
  List<Score> list=scores.getAll();
  assertThat(list.size(),equalTo(121));
  assertThat(list.get(0).getTimestamp(),equalTo(today));
  assertThat(list.get(10).getTimestamp(),equalTo(today - 10 * day));
}

Fixed version (ground truth):
@Test public void testGetAll(){
  List<Score> list=scores.toList();
  assertThat(list.size(),equalTo(121));
  assertThat(list.get(0).getTimestamp(),equalTo(today));
  assertThat(list.get(10).getTimestamp(),equalTo(today - 10 * day));
}
Program: 92643
Project: 92643
Buggy source:
@Override public void doInBackground(){
  List<Score> scores;
  ScoreList scoreList=getHabit().getScores();
  if (bucketSize == 1)   scores=scoreList.getAll();
 else   scores=scoreList.groupBy(getTruncateField(bucketSize));
  chart.setScores(scores);
  chart.setBucketSize(bucketSize);
}

Fixed version (ground truth):
@Override public void doInBackground(){
  List<Score> scores;
  ScoreList scoreList=getHabit().getScores();
  if (bucketSize == 1)   scores=scoreList.toList();
 else   scores=scoreList.groupBy(getTruncateField(bucketSize));
  chart.setScores(scores);
  chart.setBucketSize(bucketSize);
}
Program: 92644
Project: 92644
Buggy source:
/** 
 * Computes and stores one checkmark for each day that falls inside the specified interval of time. Days that already have a corresponding checkmark are skipped.
 * @param from timestamp for the beginning of the interval
 * @param to   timestamp for the end of the interval
 */
protected final synchronized void compute(long from,final long to){
  final long day=DateUtils.millisecondsInOneDay;
  Checkmark newestCheckmark=getNewestComputed();
  if (newestCheckmark != null)   from=newestCheckmark.getTimestamp() + day;
  if (from > to)   return;
  Frequency freq=habit.getFrequency();
  long fromExtended=from - (long)(freq.getDenominator()) * day;
  List<Repetition> reps=habit.getRepetitions().getByInterval(fromExtended,to);
  final int nDays=(int)((to - from) / day) + 1;
  int nDaysExtended=(int)((to - fromExtended) / day) + 1;
  final int checks[]=new int[nDaysExtended];
  for (  Repetition rep : reps) {
    int offset=(int)((rep.getTimestamp() - fromExtended) / day);
    checks[nDaysExtended - offset - 1]=Checkmark.CHECKED_EXPLICITLY;
  }
  for (int i=0; i < nDays; i++) {
    int counter=0;
    for (int j=0; j < freq.getDenominator(); j++)     if (checks[i + j] == 2)     counter++;
    if (counter >= freq.getNumerator())     if (checks[i] != Checkmark.CHECKED_EXPLICITLY)     checks[i]=Checkmark.CHECKED_IMPLICITLY;
  }
  List<Checkmark> checkmarks=new LinkedList<>();
  for (int i=0; i < nDays; i++) {
    int value=checks[i];
    long timestamp=to - i * day;
    checkmarks.add(new Checkmark(timestamp,value));
  }
  add(checkmarks);
}

Fixed version (ground truth):
/** 
 * Computes and stores one checkmark for each day that falls inside the specified interval of time. Days that already have a corresponding checkmark are skipped. This method assumes the list of computed checkmarks has no holes. That is, if there is a checkmark computed at time t1 and another at time t2, then every checkmark between t1 and t2 is also computed.
 * @param from timestamp for the beginning of the interval
 * @param to   timestamp for the end of the interval
 */
protected final synchronized void compute(long from,long to){
  final long day=DateUtils.millisecondsInOneDay;
  Checkmark newest=getNewestComputed();
  Checkmark oldest=getOldestComputed();
  if (newest == null) {
    forceRecompute(from,to);
  }
 else {
    forceRecompute(from,oldest.getTimestamp() - day);
    forceRecompute(newest.getTimestamp() + day,to);
  }
}
Program: 92645
Project: 92645
Buggy source:
/** 
 * Returns newest checkmark that has already been computed. <p> Ignores any checkmark that has timestamp in the future.
 * @return newest checkmark already computed
 */
protected abstract Checkmark getNewestComputed();

Fixed version (ground truth):
/** 
 * Returns newest checkmark that has already been computed.
 * @return newest checkmark already computed
 */
protected abstract Checkmark getNewestComputed();
Program: 92646
Project: 92646
Buggy source:
/** 
 * Computes and stores one checkmark for each day, since the first repetition until today. Days that already have a corresponding checkmark are skipped.
 */
protected final void computeAll(){
  Repetition oldest=habit.getRepetitions().getOldest();
  if (oldest == null)   return;
  Long today=DateUtils.getStartOfToday();
  compute(oldest.getTimestamp(),today);
}

Fixed version (ground truth):
/** 
 * Computes and stores one checkmark for each day, since the first repetition of the habit until today. Days that already have a corresponding checkmark are skipped.
 */
protected final void computeAll(){
  Repetition oldest=habit.getRepetitions().getOldest();
  if (oldest == null)   return;
  Long today=DateUtils.getStartOfToday();
  compute(oldest.getTimestamp(),today);
}
Program: 92647
Project: 92647
Buggy source:
/** 
 * Returns the most recent score that has already been computed. <p> If no score has been computed yet, returns null.
 * @return the newest score computed, or null if none exist
 */
@Nullable protected abstract Score getNewestComputed();

Fixed version (ground truth):
/** 
 * Returns the most recent score that has already been computed. If no score has been computed yet, returns null.
 */
@Nullable protected abstract Score getNewestComputed();
Program: 92648
Project: 92648
Buggy source:
public List<Score> groupBy(DateUtils.TruncateField field){
  HashMap<Long,ArrayList<Long>> groups=getGroupedValues(field);
  List<Score> scores=groupsToAvgScores(groups);
  Collections.sort(scores,(s1,s2) -> s2.compareNewer(s1));
  return scores;
}

Fixed version (ground truth):
public List<Score> groupBy(DateUtils.TruncateField field){
  computeAll();
  HashMap<Long,ArrayList<Long>> groups=getGroupedValues(field);
  List<Score> scores=groupsToAvgScores(groups);
  Collections.sort(scores,(s1,s2) -> s2.compareNewer(s1));
  return scores;
}
Program: 92649
Project: 92649
Buggy source:
/** 
 * Computes and saves the scores that are missing since the first repetition of the habit.
 */
protected void computeAll(){
  Repetition oldestRep=habit.getRepetitions().getOldest();
  if (oldestRep == null)   return;
  long toTimestamp=DateUtils.getStartOfToday();
  compute(oldestRep.getTimestamp(),toTimestamp);
}

Fixed version (ground truth):
/** 
 * Computes and saves the scores that are missing since the first repetition of the habit.
 */
protected void computeAll(){
  Repetition oldestRep=habit.getRepetitions().getOldest();
  if (oldestRep == null)   return;
  long today=DateUtils.getStartOfToday();
  compute(oldestRep.getTimestamp(),today);
}
Program: 92650
Project: 92650
Buggy source:
/** 
 * Computes and saves the scores that are missing inside a given time interval. <p> Scores that have already been computed are skipped, therefore there is no harm in calling this function more times, or with larger intervals, than strictly needed. The endpoints of the interval are included. <p> This function assumes that there are no gaps on the scores. That is, if the newest score has timestamp t, then every score with timestamp lower than t has already been computed.
 * @param from timestamp of the beginning of the interval
 * @param to   timestamp of the end of the time interval
 */
protected synchronized void compute(long from,long to){
  final long day=DateUtils.millisecondsInOneDay;
  final double freq=habit.getFrequency().toDouble();
  int newestValue=0;
  long newestTimestamp=0;
  Score newest=getNewestComputed();
  if (newest != null) {
    newestValue=newest.getValue();
    newestTimestamp=newest.getTimestamp();
  }
  if (newestTimestamp > 0)   from=newestTimestamp + day;
  final int checkmarkValues[]=habit.getCheckmarks().getValues(from,to);
  final long beginning=from;
  int lastScore=newestValue;
  List<Score> scores=new LinkedList<>();
  for (int i=0; i < checkmarkValues.length; i++) {
    int value=checkmarkValues[checkmarkValues.length - i - 1];
    lastScore=Score.compute(freq,lastScore,value);
    scores.add(new Score(beginning + day * i,lastScore));
  }
  add(scores);
}

Fixed version (ground truth):
/** 
 * Computes and stores one score for each day inside the given interval. <p> Scores that have already been computed are skipped, therefore there is no harm in calling this function more times, or with larger intervals, than strictly needed. The endpoints of the interval are included. <p> This method assumes the list of computed scores has no holes. That is, if there is a score computed at time t1 and another at time t2, then every score between t1 and t2 is also computed.
 * @param from timestamp of the beginning of the interval
 * @param to   timestamp of the end of the time interval
 */
protected synchronized void compute(long from,long to){
  final long day=DateUtils.millisecondsInOneDay;
  Score newest=getNewestComputed();
  Score oldest=getOldestComputed();
  if (newest == null) {
    Repetition oldestRep=habit.getRepetitions().getOldest();
    if (oldestRep != null)     from=Math.min(from,oldestRep.getTimestamp());
    forceRecompute(from,to,0);
  }
 else {
    if (oldest == null)     throw new IllegalStateException();
    forceRecompute(from,oldest.getTimestamp() - day,0);
    forceRecompute(newest.getTimestamp() + day,to,newest.getValue());
  }
}
Program: 92651
Project: 92651
Buggy source:
/** 
 * Returns the value of the score for a given day. <p> If there is no score at the given timestamp (for example, if the timestamp given happens before the first repetition of the habit) then returns zero.
 * @param timestamp the timestamp of a day
 * @return score value for that day
 */
public final int getValue(long timestamp){
  Score s=getByTimestamp(timestamp);
  if (s != null)   return s.getValue();
  return 0;
}

Fixed version (ground truth):
/** 
 * Returns the value of the score for a given day. <p> If the timestamp given happens before the first repetition of the habit then returns zero.
 * @param timestamp the timestamp of a day
 * @return score value for that day
 */
public final int getValue(long timestamp){
  compute(timestamp,timestamp);
  Score s=getComputedByTimestamp(timestamp);
  if (s == null)   throw new IllegalStateException();
  return s.getValue();
}
Program: 92652
Project: 92652
Buggy source:
@Override public Iterator<Score> iterator(){
  return getAll().iterator();
}

Fixed version (ground truth):
@Override public Iterator<Score> iterator(){
  return toList().iterator();
}
Program: 92653
Project: 92653
Buggy source:
@Override protected Checkmark getNewestComputed(){
  long newestTimestamp=0;
  Checkmark newestCheck=null;
  for (  Checkmark c : list) {
    if (c.getTimestamp() > newestTimestamp) {
      newestCheck=c;
      newestTimestamp=c.getTimestamp();
    }
  }
  return newestCheck;
}

Fixed version (ground truth):
@Override protected Checkmark getNewestComputed(){
  if (list.isEmpty())   return null;
  return list.getFirst();
}
Program: 92654
Project: 92654
Buggy source:
@Override protected void onActivityResult(int request,int result,Intent data){
  if (screen == null)   return;
  screen.onResult(request,result,data);
}

Fixed version (ground truth):
@Override protected void onActivityResult(int request,int result,Intent data){
  if (screen == null)   super.onActivityResult(request,result,data);
 else   screen.onResult(request,result,data);
}
Program: 92655
Project: 92655
Buggy source:
public static void parseRingtoneData(Context context,@Nullable Intent data){
  if (data == null)   return;
  Uri ringtoneUri=data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
  if (ringtoneUri != null) {
    SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(context);
    prefs.edit().putString("String_Node_Str",ringtoneUri.toString()).apply();
  }
 else {
    String off=context.getResources().getString(R.string.none);
    SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(context);
    prefs.edit().putString("String_Node_Str","String_Node_Str").apply();
  }
}

Fixed version (ground truth):
public static void parseRingtoneData(Context context,@Nullable Intent data){
  if (data == null)   return;
  Uri ringtoneUri=data.getParcelableExtra(EXTRA_RINGTONE_PICKED_URI);
  if (ringtoneUri != null) {
    SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(context);
    prefs.edit().putString("String_Node_Str",ringtoneUri.toString()).apply();
  }
 else {
    String off=context.getResources().getString(R.string.none);
    SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(context);
    prefs.edit().putString("String_Node_Str","String_Node_Str").apply();
  }
}
Program: 92656
Project: 92656
Buggy source:
public static void startRingtonePickerActivity(Fragment fragment,int requestCode){
  Uri existingRingtoneUri=getRingtoneUri(fragment.getContext());
  Uri defaultRingtoneUri=Settings.System.DEFAULT_NOTIFICATION_URI;
  Intent intent=new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
  intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE,RingtoneManager.TYPE_NOTIFICATION);
  intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT,true);
  intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT,true);
  intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI,defaultRingtoneUri);
  intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI,existingRingtoneUri);
  fragment.startActivityForResult(intent,requestCode);
}

Fixed version (ground truth):
public static void startRingtonePickerActivity(Fragment fragment,int requestCode){
  Uri existingRingtoneUri=getRingtoneUri(fragment.getContext());
  Uri defaultRingtoneUri=Settings.System.DEFAULT_NOTIFICATION_URI;
  Intent intent=new Intent(ACTION_RINGTONE_PICKER);
  intent.putExtra(EXTRA_RINGTONE_TYPE,TYPE_NOTIFICATION);
  intent.putExtra(EXTRA_RINGTONE_SHOW_DEFAULT,true);
  intent.putExtra(EXTRA_RINGTONE_SHOW_SILENT,true);
  intent.putExtra(EXTRA_RINGTONE_DEFAULT_URI,defaultRingtoneUri);
  intent.putExtra(EXTRA_RINGTONE_EXISTING_URI,existingRingtoneUri);
  fragment.startActivityForResult(intent,requestCode);
}
Program: 92657
Project: 92657
Buggy source:
@Nullable public static String getRingtoneName(Context context){
  try {
    Uri ringtoneUri=getRingtoneUri(context);
    String ringtoneName=context.getResources().getString(R.string.none);
    if (ringtoneUri != null) {
      Ringtone ringtone=RingtoneManager.getRingtone(context,ringtoneUri);
      if (ringtone != null) {
        ringtoneName=ringtone.getTitle(context);
        ringtone.stop();
      }
    }
    return ringtoneName;
  }
 catch (  RuntimeException e) {
    e.printStackTrace();
    return null;
  }
}

Fixed version (ground truth):
@Nullable public static String getRingtoneName(Context context){
  try {
    Uri ringtoneUri=getRingtoneUri(context);
    String ringtoneName=context.getResources().getString(R.string.none);
    if (ringtoneUri != null) {
      Ringtone ringtone=getRingtone(context,ringtoneUri);
      if (ringtone != null) {
        ringtoneName=ringtone.getTitle(context);
        ringtone.stop();
      }
    }
    return ringtoneName;
  }
 catch (  RuntimeException e) {
    e.printStackTrace();
    return null;
  }
}
Program: 92658
Project: 92658
Buggy source:
private void setStatusBarColor(int baseColor){
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)   return;
  int darkerColor=ColorUtils.mixColors(baseColor,Color.BLACK,0.75f);
  activity.getWindow().setStatusBarColor(darkerColor);
}

Fixed version (ground truth):
private void setStatusBarColor(int baseColor){
  if (SDK_INT < LOLLIPOP)   return;
  int darkerColor=ColorUtils.mixColors(baseColor,Color.BLACK,0.75f);
  activity.getWindow().setStatusBarColor(darkerColor);
}
Program: 92659
Project: 92659
Buggy source:
private void setupToolbarElevation(Toolbar toolbar){
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)   return;
  toolbar.setElevation(InterfaceUtils.dpToPixels(activity,2));
  View view=activity.findViewById(R.id.toolbarShadow);
  if (view != null)   view.setVisibility(View.GONE);
}

Fixed version (ground truth):
private void setupToolbarElevation(Toolbar toolbar){
  if (SDK_INT < LOLLIPOP)   return;
  toolbar.setElevation(InterfaceUtils.dpToPixels(activity,2));
  View view=activity.findViewById(R.id.toolbarShadow);
  if (view != null)   view.setVisibility(View.GONE);
}
Program: 92660
Project: 92660
Buggy source:
@Deprecated public static void setupActionBarColor(@NonNull AppCompatActivity activity,int color){
  Toolbar toolbar=(Toolbar)activity.findViewById(R.id.toolbar);
  if (toolbar == null)   return;
  activity.setSupportActionBar(toolbar);
  ActionBar actionBar=activity.getSupportActionBar();
  if (actionBar == null)   return;
  actionBar.setDisplayHomeAsUpEnabled(true);
  ColorDrawable drawable=new ColorDrawable(color);
  actionBar.setBackgroundDrawable(drawable);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    int darkerColor=ColorUtils.mixColors(color,Color.BLACK,0.75f);
    activity.getWindow().setStatusBarColor(darkerColor);
    toolbar.setElevation(InterfaceUtils.dpToPixels(activity,2));
    View view=activity.findViewById(R.id.toolbarShadow);
    if (view != null)     view.setVisibility(View.GONE);
  }
}

Fixed version (ground truth):
@Deprecated public static void setupActionBarColor(@NonNull AppCompatActivity activity,int color){
  Toolbar toolbar=(Toolbar)activity.findViewById(R.id.toolbar);
  if (toolbar == null)   return;
  activity.setSupportActionBar(toolbar);
  ActionBar actionBar=activity.getSupportActionBar();
  if (actionBar == null)   return;
  actionBar.setDisplayHomeAsUpEnabled(true);
  ColorDrawable drawable=new ColorDrawable(color);
  actionBar.setBackgroundDrawable(drawable);
  if (SDK_INT >= LOLLIPOP) {
    int darkerColor=ColorUtils.mixColors(color,Color.BLACK,0.75f);
    activity.getWindow().setStatusBarColor(darkerColor);
    toolbar.setElevation(InterfaceUtils.dpToPixels(activity,2));
    View view=activity.findViewById(R.id.toolbarShadow);
    if (view != null)     view.setVisibility(View.GONE);
    view=activity.findViewById(R.id.headerShadow);
    if (view != null)     view.setVisibility(View.GONE);
  }
}
Program: 92661
Project: 92661
Buggy source:
@NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState){
  Context context=getActivity();
  historyChart=new HistoryChart(context);
  historyChart.setController(controller);
  if (savedInstanceState != null) {
    long id=savedInstanceState.getLong("String_Node_Str",-1);
    if (id > 0)     this.habit=habitList.getById(id);
  }
  int padding=(int)getResources().getDimension(R.dimen.history_editor_padding);
  historyChart.setPadding(padding,0,padding,0);
  historyChart.setIsEditable(true);
  AlertDialog.Builder builder=new AlertDialog.Builder(context);
  builder.setTitle(R.string.history).setView(historyChart).setPositiveButton(android.R.string.ok,this);
  return builder.create();
}

Fixed version (ground truth):
@NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState){
  Context context=getActivity();
  HabitsApplication app=(HabitsApplication)getActivity().getApplicationContext();
  habitList=app.getComponent().getHabitList();
  taskRunner=app.getComponent().getTaskRunner();
  historyChart=new HistoryChart(context);
  historyChart.setController(controller);
  if (savedInstanceState != null) {
    long id=savedInstanceState.getLong("String_Node_Str",-1);
    if (id > 0)     this.habit=habitList.getById(id);
  }
  int padding=(int)getResources().getDimension(R.dimen.history_editor_padding);
  historyChart.setPadding(padding,0,padding,0);
  historyChart.setIsEditable(true);
  AlertDialog.Builder builder=new AlertDialog.Builder(context);
  builder.setTitle(R.string.history).setView(historyChart).setPositiveButton(android.R.string.ok,this);
  return builder.create();
}
Program: 92662
Project: 92662
Buggy source:
public HistoryEditorDialog(){
  this.controller=new Controller(){
  }
;
  HabitsApplication app=(HabitsApplication)getContext().getApplicationContext();
  habitList=app.getComponent().getHabitList();
  taskRunner=app.getComponent().getTaskRunner();
}

Fixed version (ground truth):
public HistoryEditorDialog(){
  this.controller=new Controller(){
  }
;
}
Program: 92663
Project: 92663
Buggy source:
@Override public boolean onSingleTapUp(MotionEvent e){
  if (!isEditable)   return false;
  performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
  int pointerId=e.getPointerId(0);
  float x=e.getX(pointerId);
  float y=e.getY(pointerId);
  final Long timestamp=positionToTimestamp(x,y);
  if (timestamp == null)   return false;
  int offset=timestampToOffset(timestamp);
  boolean isChecked=checkmarks[offset] == CHECKED_EXPLICITLY;
  checkmarks[offset]=(isChecked ? UNCHECKED : CHECKED_EXPLICITLY);
  controller.onToggleCheckmark(timestamp);
  postInvalidate();
  return true;
}

Fixed version (ground truth):
@Override public boolean onSingleTapUp(MotionEvent e){
  if (!isEditable)   return false;
  performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
  int pointerId=e.getPointerId(0);
  float x=e.getX(pointerId);
  float y=e.getY(pointerId);
  final Long timestamp=positionToTimestamp(x,y);
  if (timestamp == null)   return false;
  int offset=timestampToOffset(timestamp);
  if (offset < checkmarks.length) {
    boolean isChecked=checkmarks[offset] == CHECKED_EXPLICITLY;
    checkmarks[offset]=(isChecked ? UNCHECKED : CHECKED_EXPLICITLY);
  }
  controller.onToggleCheckmark(timestamp);
  postInvalidate();
  return true;
}
Program: 92664
Project: 92664
Buggy source:
public void setHabit(Habit habit){
  int color=getActiveColor(habit);
  label.setText(habit.getName());
  label.setTextColor(color);
  scoreRing.setColor(color);
  checkmarkPanel.setColor(color);
  checkmarkPanel.setHabit(habit);
  postInvalidate();
}

Fixed version (ground truth):
public void setHabit(@NonNull Habit habit){
  if (this.habit != null)   detachFromHabit();
  this.habit=habit;
  checkmarkPanel.setHabit(habit);
  attachToHabit();
  postInvalidate();
}
Program: 92665
Project: 92665
Buggy source:
private void init(){
  setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT));
  res=new StyledResources(getContext());
  inflate(context,R.layout.list_habits_card,this);
  ButterKnife.bind(this);
  innerFrame.setOnTouchListener((v,event) -> {
    if (SDK_INT >= LOLLIPOP)     v.getBackground().setHotspot(event.getX(),event.getY());
    return false;
  }
);
  if (isInEditMode())   initEditMode();
}

Fixed version (ground truth):
private void init(){
  setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));
  res=new StyledResources(getContext());
  inflate(context,R.layout.list_habits_card,this);
  ButterKnife.bind(this);
  setWillNotDraw(false);
  innerFrame.setOnTouchListener((v,event) -> {
    if (SDK_INT >= LOLLIPOP)     v.getBackground().setHotspot(event.getX(),event.getY());
    return false;
  }
);
  if (isInEditMode())   initEditMode();
}
Program: 92666
Project: 92666
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  HabitsApplication app=(HabitsApplication)getApplicationContext();
  habits=app.getComponent().getHabitList();
  Habit habit=getHabitFromIntent();
  ShowHabitComponent component=DaggerShowHabitComponent.builder().appComponent(app.getComponent()).showHabitModule(new ShowHabitModule(this,habit)).build();
  ShowHabitRootView rootView=component.getRootView();
  ShowHabitScreen screen=component.getScreen();
  setScreen(screen);
  screen.setMenu(component.getMenu());
  rootView.setController(component.getController());
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  HabitsApplication app=(HabitsApplication)getApplicationContext();
  habits=app.getComponent().getHabitList();
  Habit habit=getHabitFromIntent();
  ShowHabitComponent component=DaggerShowHabitComponent.builder().appComponent(app.getComponent()).showHabitModule(new ShowHabitModule(this,habit)).build();
  ShowHabitRootView rootView=component.getRootView();
  ShowHabitScreen screen=component.getScreen();
  setScreen(screen);
  screen.setMenu(component.getMenu());
  screen.setController(component.getController());
  rootView.setController(component.getController());
  screen.reattachDialogs();
}
Program: 92667
Project: 92667
Buggy source:
@Override public void onEditHistoryButtonClick(){
  screen.showEditHistoryDialog(this);
}

Fixed version (ground truth):
@Override public void onEditHistoryButtonClick(){
  screen.showEditHistoryDialog();
}
Program: 92668
Project: 92668
Buggy source:
public void showEditHistoryDialog(@NonNull HistoryEditorDialog.Controller controller){
  HistoryEditorDialog dialog=new HistoryEditorDialog();
  dialog.setHabit(habit);
  dialog.setController(controller);
  dialog.show(activity.getSupportFragmentManager(),"String_Node_Str");
}

Fixed version (ground truth):
public void showEditHistoryDialog(){
  if (controller == null)   throw new IllegalStateException();
  HistoryEditorDialog dialog=new HistoryEditorDialog();
  dialog.setHabit(habit);
  dialog.setController(controller);
  dialog.show(activity.getSupportFragmentManager(),"String_Node_Str");
}
Program: 92669
Project: 92669
Buggy source:
/** 
 * Hides the progress bar.
 */
void hide();

Fixed version (ground truth):
/** 
 * Hides the progress bar.
 */
default void hide(){
}
Program: 92670
Project: 92670
Buggy source:
/** 
 * Shows the progress bar.
 */
void show();

Fixed version (ground truth):
/** 
 * Shows the progress bar.
 */
default void show(){
}
Program: 92671
Project: 92671
Buggy source:
@Override public void show(){
  progressBar.setIndeterminate(true);
  progressBar.setVisibility(View.VISIBLE);
}

Fixed version (ground truth):
@Override public void show(){
  progressBar.setVisibility(View.VISIBLE);
}
Program: 92672
Project: 92672
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  HabitsApplication.getComponent().inject(this);
  int checkmarkCount=ListHabitsRootView.MAX_CHECKMARK_COUNT;
  system=new BaseSystem(this);
  adapter=new HabitCardListAdapter(habits,checkmarkCount);
  rootView=new ListHabitsRootView(this,adapter);
  screen=new ListHabitsScreen(this,rootView);
  menu=new ListHabitsMenu(this,screen,adapter);
  selectionMenu=new ListHabitsSelectionMenu(habits,screen,adapter);
  controller=new ListHabitsController(habits,screen,system);
  screen.setMenu(menu);
  screen.setController(controller);
  screen.setSelectionMenu(selectionMenu);
  rootView.setController(controller,selectionMenu);
  setScreen(screen);
  controller.onStartup();
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  HabitsApplication.getComponent().inject(this);
  int checkmarkCount=ListHabitsRootView.MAX_CHECKMARK_COUNT;
  system=new BaseSystem(this);
  adapter=new HabitCardListAdapter(habits,checkmarkCount);
  rootView=new ListHabitsRootView(this,adapter);
  screen=new ListHabitsScreen(this,rootView);
  menu=new ListHabitsMenu(this,screen,adapter);
  selectionMenu=new ListHabitsSelectionMenu(habits,screen,adapter);
  controller=new ListHabitsController(habits,screen,system);
  adapter.setProgressBar(new AndroidProgressBar(rootView.getProgressBar()));
  screen.setMenu(menu);
  screen.setController(controller);
  screen.setSelectionMenu(selectionMenu);
  rootView.setController(controller,selectionMenu);
  setScreen(screen);
  controller.onStartup();
}
Program: 92673
Project: 92673
Buggy source:
public void refresh(){
  cache.refreshAllHabits(true);
}

Fixed version (ground truth):
public void refresh(){
  cache.refreshAllHabits();
}
Program: 92674
Project: 92674
Buggy source:
@Override public void onBindViewHolder(@Nullable HabitCardViewHolder holder,int position){
  if (holder == null)   return;
  if (listView == null)   return;
  Habit habit=cache.getHabitByPosition(position);
  int score=cache.getScore(habit.getId());
  int checkmarks[]=cache.getCheckmarks(habit.getId());
  boolean selected=this.selected.contains(habit);
  Log.d("String_Node_Str",String.format("String_Node_Str",position,holder.getItemId(),habit.getId(),habit.getName()));
  HabitCardView cardView=(HabitCardView)holder.itemView;
  listView.bindCardView(cardView,habit,score,checkmarks,selected,position);
}

Fixed version (ground truth):
@Override public void onBindViewHolder(@Nullable HabitCardViewHolder holder,int position){
  if (holder == null)   return;
  if (listView == null)   return;
  Habit habit=cache.getHabitByPosition(position);
  int score=cache.getScore(habit.getId());
  int checkmarks[]=cache.getCheckmarks(habit.getId());
  boolean selected=this.selected.contains(habit);
  HabitCardView cardView=(HabitCardView)holder.itemView;
  listView.bindCardView(cardView,habit,score,checkmarks,selected,position);
}
Program: 92675
Project: 92675
Buggy source:
public static PendingIntent buildCheckIntent(Context context,Habit habit,Long timestamp){
  Uri data=habit.getUri();
  Intent checkIntent=new Intent(context,HabitBroadcastReceiver.class);
  checkIntent.setData(data);
  checkIntent.setAction(ACTION_CHECK);
  if (timestamp != null)   checkIntent.putExtra("String_Node_Str",timestamp);
  return PendingIntent.getBroadcast(context,0,checkIntent,PendingIntent.FLAG_ONE_SHOT);
}

Fixed version (ground truth):
public static PendingIntent buildCheckIntent(Context context,Habit habit,Long timestamp){
  Uri data=habit.getUri();
  Intent checkIntent=new Intent(context,HabitBroadcastReceiver.class);
  checkIntent.setData(data);
  checkIntent.setAction(ACTION_CHECK);
  if (timestamp != null)   checkIntent.putExtra("String_Node_Str",timestamp);
  return PendingIntent.getBroadcast(context,0,checkIntent,PendingIntent.FLAG_CANCEL_CURRENT);
}
Program: 92677
Project: 92677
Buggy source:
public static PendingIntent buildDismissIntent(Context context){
  Intent deleteIntent=new Intent(context,HabitBroadcastReceiver.class);
  deleteIntent.setAction(ACTION_DISMISS);
  return PendingIntent.getBroadcast(context,0,deleteIntent,0);
}

Fixed version (ground truth):
public static PendingIntent buildDismissIntent(Context context){
  Intent deleteIntent=new Intent(context,HabitBroadcastReceiver.class);
  deleteIntent.setAction(ACTION_DISMISS);
  return PendingIntent.getBroadcast(context,0,deleteIntent,PendingIntent.FLAG_CANCEL_CURRENT);
}
Program: 92679
Project: 92679
Buggy source:
public static PendingIntent buildSnoozeIntent(Context context,Habit habit){
  Uri data=habit.getUri();
  Intent snoozeIntent=new Intent(context,HabitBroadcastReceiver.class);
  snoozeIntent.setData(data);
  snoozeIntent.setAction(ACTION_SNOOZE);
  return PendingIntent.getBroadcast(context,0,snoozeIntent,0);
}

Fixed version (ground truth):
public static PendingIntent buildSnoozeIntent(Context context,Habit habit){
  Uri data=habit.getUri();
  Intent snoozeIntent=new Intent(context,HabitBroadcastReceiver.class);
  snoozeIntent.setData(data);
  snoozeIntent.setAction(ACTION_SNOOZE);
  return PendingIntent.getBroadcast(context,0,snoozeIntent,PendingIntent.FLAG_CANCEL_CURRENT);
}
Program: 92680
Project: 92680
Buggy source:
/** 
 * Computes and stores one checkmark for each day that falls inside the specified interval of time. Days that already have a corresponding checkmark are skipped.
 * @param from timestamp for the beginning of the interval
 * @param to timestamp for the end of the interval
 */
protected void compute(long from,final long to){
  InterfaceUtils.throwIfMainThread();
  final long day=DateUtils.millisecondsInOneDay;
  Checkmark newestCheckmark=findNewest();
  if (newestCheckmark != null)   from=Math.max(from,newestCheckmark.timestamp + day);
  if (from > to)   return;
  long fromExtended=from - (long)(habit.freqDen) * day;
  List<Repetition> reps=habit.repetitions.selectFromTo(fromExtended,to).execute();
  final int nDays=(int)((to - from) / day) + 1;
  int nDaysExtended=(int)((to - fromExtended) / day) + 1;
  final int checks[]=new int[nDaysExtended];
  for (  Repetition rep : reps) {
    int offset=(int)((rep.timestamp - fromExtended) / day);
    checks[nDaysExtended - offset - 1]=Checkmark.CHECKED_EXPLICITLY;
  }
  for (int i=0; i < nDays; i++) {
    int counter=0;
    for (int j=0; j < habit.freqDen; j++)     if (checks[i + j] == 2)     counter++;
    if (counter >= habit.freqNum)     if (checks[i] != Checkmark.CHECKED_EXPLICITLY)     checks[i]=Checkmark.CHECKED_IMPLICITLY;
  }
  long timestamps[]=new long[nDays];
  for (int i=0; i < nDays; i++)   timestamps[i]=to - i * day;
  insert(timestamps,checks);
}

Fixed version (ground truth):
/** 
 * Computes and stores one checkmark for each day that falls inside the specified interval of time. Days that already have a corresponding checkmark are skipped.
 * @param from timestamp for the beginning of the interval
 * @param to timestamp for the end of the interval
 */
protected void compute(long from,final long to){
  InterfaceUtils.throwIfMainThread();
  final long day=DateUtils.millisecondsInOneDay;
  Checkmark newestCheckmark=findNewest();
  if (newestCheckmark != null)   from=newestCheckmark.timestamp + day;
  if (from > to)   return;
  long fromExtended=from - (long)(habit.freqDen) * day;
  List<Repetition> reps=habit.repetitions.selectFromTo(fromExtended,to).execute();
  final int nDays=(int)((to - from) / day) + 1;
  int nDaysExtended=(int)((to - fromExtended) / day) + 1;
  final int checks[]=new int[nDaysExtended];
  for (  Repetition rep : reps) {
    int offset=(int)((rep.timestamp - fromExtended) / day);
    checks[nDaysExtended - offset - 1]=Checkmark.CHECKED_EXPLICITLY;
  }
  for (int i=0; i < nDays; i++) {
    int counter=0;
    for (int j=0; j < habit.freqDen; j++)     if (checks[i + j] == 2)     counter++;
    if (counter >= habit.freqNum)     if (checks[i] != Checkmark.CHECKED_EXPLICITLY)     checks[i]=Checkmark.CHECKED_IMPLICITLY;
  }
  long timestamps[]=new long[nDays];
  for (int i=0; i < nDays; i++)   timestamps[i]=to - i * day;
  insert(timestamps,checks);
}
Program: 92681
Project: 92681
Buggy source:
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  float thickness=size * 0.15f;
  pRing.setColor(color);
  rect.set(0,0,size,size);
  canvas.drawArc(rect,-90,360 * percentage,true,pRing);
  pRing.setColor(Color.rgb(230,230,230));
  canvas.drawArc(rect,360 * percentage - 90 + 2,360 * (1 - percentage) - 4,true,pRing);
  pRing.setColor(Color.WHITE);
  rect.inset(thickness,thickness);
  canvas.drawArc(rect,-90,360,true,pRing);
  float lineHeight=pRing.getFontSpacing();
  pRing.setColor(Color.GRAY);
  pRing.setTextSize(size * 0.2f);
  canvas.drawText(String.format("String_Node_Str",percentage * 100),rect.centerX(),rect.centerY() + lineHeight / 3,pRing);
  pRing.setTextSize(size * 0.15f);
  canvas.translate(size / 2,size + labelMarginTop);
  labelLayout.draw(canvas);
}

Fixed version (ground truth):
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  float thickness=size * 0.15f;
  pRing.setColor(color);
  rect.set(0,0,size,size);
  canvas.drawArc(rect,-90,360 * percentage,true,pRing);
  pRing.setColor(Color.rgb(230,230,230));
  canvas.drawArc(rect,360 * percentage - 90 + 2,360 * (1 - percentage) - 4,true,pRing);
  pRing.setColor(Color.WHITE);
  rect.inset(thickness,thickness);
  canvas.drawArc(rect,-90,360,true,pRing);
  pRing.setColor(Color.GRAY);
  pRing.setTextSize(size * 0.2f);
  float lineHeight=pRing.getFontSpacing();
  canvas.drawText(String.format("String_Node_Str",percentage * 100),rect.centerX(),rect.centerY() + lineHeight / 3,pRing);
  pRing.setTextSize(size * 0.15f);
  canvas.translate(size / 2,size + labelMarginTop);
  labelLayout.draw(canvas);
}
Program: 92682
Project: 92682
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View view=inflater.inflate(R.layout.show_habit,container,false);
  activity=(ShowHabitActivity)getActivity();
  habit=activity.habit;
  habit.checkmarks.rebuild();
  Button btEditHistory=(Button)view.findViewById(R.id.btEditHistory);
  streakView=(HabitStreakView)view.findViewById(R.id.streakView);
  scoreView=(HabitScoreView)view.findViewById(R.id.scoreView);
  historyView=(HabitHistoryView)view.findViewById(R.id.historyView);
  punchcardView=(WeekdayFrequencyView)view.findViewById(R.id.punchcardView);
  updateHeaders(view);
  updateScoreRing(view);
  streakView.setHabit(habit);
  scoreView.setHabit(habit);
  historyView.setHabit(habit);
  punchcardView.setHabit(habit);
  btEditHistory.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      HistoryEditorDialog frag=new HistoryEditorDialog();
      frag.setHabit(habit);
      frag.setListener(ShowHabitFragment.this);
      frag.show(getFragmentManager(),"String_Node_Str");
    }
  }
);
  if (savedInstanceState != null) {
    EditHabitFragment fragEdit=(EditHabitFragment)getFragmentManager().findFragmentByTag("String_Node_Str");
    HistoryEditorDialog fragEditor=(HistoryEditorDialog)getFragmentManager().findFragmentByTag("String_Node_Str");
    if (fragEdit != null)     fragEdit.setOnSavedListener(this);
    if (fragEditor != null)     fragEditor.setListener(this);
  }
  setHasOptionsMenu(true);
  return view;
}

Fixed version (ground truth):
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View view=inflater.inflate(R.layout.show_habit,container,false);
  activity=(ShowHabitActivity)getActivity();
  habit=activity.habit;
  habit.checkmarks.rebuild();
  Button btEditHistory=(Button)view.findViewById(R.id.btEditHistory);
  streakView=(HabitStreakView)view.findViewById(R.id.streakView);
  scoreView=(HabitScoreView)view.findViewById(R.id.scoreView);
  historyView=(HabitHistoryView)view.findViewById(R.id.historyView);
  punchcardView=(HabitFrequencyView)view.findViewById(R.id.punchcardView);
  updateHeaders(view);
  updateScoreRing(view);
  streakView.setHabit(habit);
  scoreView.setHabit(habit);
  historyView.setHabit(habit);
  punchcardView.setHabit(habit);
  btEditHistory.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      HistoryEditorDialog frag=new HistoryEditorDialog();
      frag.setHabit(habit);
      frag.setListener(ShowHabitFragment.this);
      frag.show(getFragmentManager(),"String_Node_Str");
    }
  }
);
  if (savedInstanceState != null) {
    EditHabitFragment fragEdit=(EditHabitFragment)getFragmentManager().findFragmentByTag("String_Node_Str");
    HistoryEditorDialog fragEditor=(HistoryEditorDialog)getFragmentManager().findFragmentByTag("String_Node_Str");
    if (fragEdit != null)     fragEdit.setOnSavedListener(this);
    if (fragEditor != null)     fragEditor.setListener(this);
  }
  setHasOptionsMenu(true);
  return view;
}
Program: 92683
Project: 92683
Buggy source:
public HashMap<Long,Integer[]> getWeekdayFrequency(){
  Repetition oldestRep=getOldest();
  if (oldestRep == null)   return new HashMap<>();
  String query="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  String[] params={habit.getId().toString()};
  SQLiteDatabase db=Cache.openDatabase();
  Cursor cursor=db.rawQuery(query,params);
  if (!cursor.moveToFirst())   return new HashMap<>();
  HashMap<Long,Integer[]> map=new HashMap<>();
  do {
    int year=Integer.parseInt(cursor.getString(0));
    int month=Integer.parseInt(cursor.getString(1));
    int weekday=(Integer.parseInt(cursor.getString(2)) + 1) % 7;
    int count=cursor.getInt(3);
    Log.d("String_Node_Str",String.format("String_Node_Str",year,month,weekday));
    GregorianCalendar date=DateHelper.getStartOfTodayCalendar();
    date.set(Calendar.YEAR,year);
    date.set(Calendar.MONTH,month);
    date.set(Calendar.DAY_OF_MONTH,1);
    long timestamp=date.getTimeInMillis();
    Integer[] list=map.get(timestamp);
    if (list == null) {
      list=new Integer[7];
      Arrays.fill(list,0);
      map.put(timestamp,list);
    }
    list[weekday]=count;
  }
 while (cursor.moveToNext());
  cursor.close();
  return map;
}

Fixed version (ground truth):
public HashMap<Long,Integer[]> getWeekdayFrequency(){
  Repetition oldestRep=getOldest();
  if (oldestRep == null)   return new HashMap<>();
  String query="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  String[] params={habit.getId().toString()};
  SQLiteDatabase db=Cache.openDatabase();
  Cursor cursor=db.rawQuery(query,params);
  if (!cursor.moveToFirst())   return new HashMap<>();
  HashMap<Long,Integer[]> map=new HashMap<>();
  GregorianCalendar date=DateHelper.getStartOfTodayCalendar();
  do {
    int year=Integer.parseInt(cursor.getString(0));
    int month=Integer.parseInt(cursor.getString(1));
    int weekday=(Integer.parseInt(cursor.getString(2)) + 1) % 7;
    int count=cursor.getInt(3);
    date.set(year,month - 1,1);
    long timestamp=date.getTimeInMillis();
    Integer[] list=map.get(timestamp);
    if (list == null) {
      list=new Integer[7];
      Arrays.fill(list,0);
      map.put(timestamp,list);
    }
    list[weekday]=count;
  }
 while (cursor.moveToNext());
  cursor.close();
  return map;
}
Program: 92684
Project: 92684
Buggy source:
private void updateDate(){
  baseDate=new GregorianCalendar();
  baseDate.add(Calendar.DAY_OF_YEAR,-(getDataOffset() - 1) * 7);
  nDays=(nColumns - 1) * 7;
  todayWeekday=new GregorianCalendar().get(Calendar.DAY_OF_WEEK) % 7;
  baseDate.add(Calendar.DAY_OF_YEAR,-nDays);
  baseDate.add(Calendar.DAY_OF_YEAR,-todayWeekday);
}

Fixed version (ground truth):
private void updateDate(){
  baseDate=new GregorianCalendar();
  baseDate.setTimeInMillis(DateHelper.getLocalTime());
  baseDate.add(Calendar.DAY_OF_YEAR,-(getDataOffset() - 1) * 7);
  nDays=(nColumns - 1) * 7;
  todayWeekday=new GregorianCalendar().get(Calendar.DAY_OF_WEEK) % 7;
  baseDate.add(Calendar.DAY_OF_YEAR,-nDays);
  baseDate.add(Calendar.DAY_OF_YEAR,-todayWeekday);
}
Program: 92686
Project: 92686
Buggy source:
private void init(){
  createPaints();
  createColors();
  updateDimensions();
  wdays=DateHelper.getShortDayNames();
  dfMonth=new SimpleDateFormat("String_Node_Str",Locale.getDefault());
  dfYear=new SimpleDateFormat("String_Node_Str",Locale.getDefault());
  baseLocation=new Rect();
}

Fixed version (ground truth):
private void init(){
  createPaints();
  createColors();
  wdays=DateHelper.getShortDayNames();
  dfMonth=new SimpleDateFormat("String_Node_Str",Locale.getDefault());
  dfYear=new SimpleDateFormat("String_Node_Str",Locale.getDefault());
  baseLocation=new Rect();
}
Program: 92687
Project: 92687
Buggy source:
private void updateDate(){
  baseDate=new GregorianCalendar();
  baseDate.add(Calendar.DAY_OF_YEAR,-(dataOffset - 1) * 7);
  nDays=(nColumns - 1) * 7;
  todayWeekday=new GregorianCalendar().get(Calendar.DAY_OF_WEEK) % 7;
  baseDate.add(Calendar.DAY_OF_YEAR,-nDays);
  baseDate.add(Calendar.DAY_OF_YEAR,-todayWeekday);
}

Fixed version (ground truth):
private void updateDate(){
  baseDate=new GregorianCalendar();
  baseDate.add(Calendar.DAY_OF_YEAR,-(getDataOffset() - 1) * 7);
  nDays=(nColumns - 1) * 7;
  todayWeekday=new GregorianCalendar().get(Calendar.DAY_OF_WEEK) % 7;
  baseDate.add(Calendar.DAY_OF_YEAR,-nDays);
  baseDate.add(Calendar.DAY_OF_YEAR,-todayWeekday);
}
Program: 92688
Project: 92688
Buggy source:
@Override protected void onSizeChanged(int w,int h,int oldw,int oldh){
  super.onSizeChanged(w,h,oldw,oldh);
  updateDate();
}

Fixed version (ground truth):
@Override protected void onSizeChanged(int width,int height,int oldWidth,int oldHeight){
  baseSize=height / 8;
  setScrollerBucketSize(baseSize);
  columnWidth=baseSize;
  columnHeight=8 * baseSize;
  nColumns=width / baseSize;
  squareSpacing=baseSize / 10;
  pSquareFg.setTextSize(baseSize * 0.5f);
  pTextHeader.setTextSize(baseSize * 0.5f);
  squareTextOffset=pSquareFg.getFontSpacing() * 0.4f;
  headerTextOffset=pTextHeader.getFontSpacing() * 0.3f;
  updateDate();
}
Program: 92689
Project: 92689
Buggy source:
private void drawColumn(Canvas canvas,Rect location,GregorianCalendar date,int column){
  drawColumnHeader(canvas,location,date);
  location.offset(0,columnWidth);
  for (int j=0; j < 7; j++) {
    if (!(column == nColumns - 2 && dataOffset == 0 && j > todayWeekday)) {
      int checkmarkOffset=dataOffset * 7 + nDays - 7 * (column + 1) + todayWeekday - j;
      drawSquare(canvas,location,date,checkmarkOffset);
    }
    date.add(Calendar.DAY_OF_MONTH,1);
    location.offset(0,columnWidth);
  }
}

Fixed version (ground truth):
private void drawColumn(Canvas canvas,Rect location,GregorianCalendar date,int column){
  drawColumnHeader(canvas,location,date);
  location.offset(0,columnWidth);
  for (int j=0; j < 7; j++) {
    if (!(column == nColumns - 2 && getDataOffset() == 0 && j > todayWeekday)) {
      int checkmarkOffset=getDataOffset() * 7 + nDays - 7 * (column + 1) + todayWeekday - j;
      drawSquare(canvas,location,date,checkmarkOffset);
    }
    date.add(Calendar.DAY_OF_MONTH,1);
    location.offset(0,columnWidth);
  }
}
Program: 92690
Project: 92690
Buggy source:
private void init(){
  createPaints();
  createColors();
  updateDimensions();
  dfMonth=new SimpleDateFormat("String_Node_Str",Locale.getDefault());
  dfDay=new SimpleDateFormat("String_Node_Str",Locale.getDefault());
  rect=new RectF();
  prevRect=new RectF();
}

Fixed version (ground truth):
private void init(){
  createPaints();
  createColors();
  dfMonth=new SimpleDateFormat("String_Node_Str",Locale.getDefault());
  dfDay=new SimpleDateFormat("String_Node_Str",Locale.getDefault());
  rect=new RectF();
  prevRect=new RectF();
}
Program: 92691
Project: 92691
Buggy source:
public HabitScoreView(Context context,AttributeSet attrs){
  super(context,attrs);
  this.baseSize=(int)context.getResources().getDimension(R.dimen.small_square_size);
  this.primaryColor=ColorHelper.palette[7];
  init();
}

Fixed version (ground truth):
public HabitScoreView(Context context,AttributeSet attrs){
  super(context,attrs);
  this.primaryColor=ColorHelper.palette[7];
  init();
}