nus-yam/ex-repair huggingface dataset:
Program: 7373
Project: 7373
Buggy source:
@Override public View newView(Context context,Cursor cursor,ViewGroup parent){
  final View view=super.newView(context,cursor,parent);
  final ContactListItemCache cache=new ContactListItemCache();
  cache.header=(TextView)view.findViewById(R.id.header);
  cache.divider=view.findViewById(R.id.list_divider);
  cache.nameView=(TextView)view.findViewById(R.id.name);
  cache.callView=view.findViewById(R.id.call_view);
  cache.callButton=(ImageView)view.findViewById(R.id.call_button);
  if (cache.callButton != null) {
    cache.callButton.setOnClickListener(ContactsListActivity.this);
  }
  cache.labelView=(TextView)view.findViewById(R.id.label);
  cache.dataView=(TextView)view.findViewById(R.id.data);
  cache.presenceView=(ImageView)view.findViewById(R.id.presence);
  cache.photoView=(FasttrackBadgeWidget)view.findViewById(R.id.photo);
  cache.photoView.setExcludeMimes(new String[]{Contacts.CONTENT_ITEM_TYPE});
  cache.nonFastTrackPhotoView=(ImageView)view.findViewById(R.id.noFastTrackphoto);
  view.setTag(cache);
  return view;
}

Fixed version (ground truth):
@Override public View newView(Context context,Cursor cursor,ViewGroup parent){
  final View view=super.newView(context,cursor,parent);
  final ContactListItemCache cache=new ContactListItemCache();
  cache.header=(TextView)view.findViewById(R.id.header);
  cache.divider=view.findViewById(R.id.list_divider);
  cache.nameView=(TextView)view.findViewById(R.id.name);
  cache.callView=view.findViewById(R.id.call_view);
  cache.callButton=(ImageView)view.findViewById(R.id.call_button);
  if (cache.callButton != null) {
    cache.callButton.setOnClickListener(ContactsListActivity.this);
  }
  cache.labelView=(TextView)view.findViewById(R.id.label);
  cache.dataView=(TextView)view.findViewById(R.id.data);
  cache.presenceView=(ImageView)view.findViewById(R.id.presence);
  cache.photoView=(FasttrackBadgeWidget)view.findViewById(R.id.photo);
  if (cache.photoView != null) {
    cache.photoView.setExcludeMimes(new String[]{Contacts.CONTENT_ITEM_TYPE});
  }
  cache.nonFastTrackPhotoView=(ImageView)view.findViewById(R.id.noFastTrackphoto);
  view.setTag(cache);
  return view;
}
Program: 7376
Project: 7376
Buggy source:
/** 
 * Detect if the given   {@link MotionEvent} is outside the boundaries of thiswindow, which usually means we should dismiss.
 */
protected void detectEventOutside(MotionEvent event){
  if (event.getAction() == MotionEvent.ACTION_DOWN) {
    mDecor.getHitRect(mRect);
    final int x=(int)event.getX();
    final int y=(int)event.getY();
    if (!mRect.contains(x,y)) {
      event.setAction(MotionEvent.ACTION_OUTSIDE);
    }
  }
}

Fixed version (ground truth):
/** 
 * Detect if the given   {@link MotionEvent} is outside the boundaries of thiswindow, which usually means we should dismiss.
 */
protected void detectEventOutside(MotionEvent event){
  if (event.getAction() == MotionEvent.ACTION_DOWN) {
    mDecor.getHitRect(mRect);
    mRect.top=mRect.top + mDecor.getPaddingTop();
    mRect.bottom=mRect.bottom - mDecor.getPaddingBottom();
    final int x=(int)event.getX();
    final int y=(int)event.getY();
    if (!mRect.contains(x,y)) {
      event.setAction(MotionEvent.ACTION_OUTSIDE);
    }
  }
}
Program: 7377
Project: 7377
Buggy source:
/** 
 * Format the given phone number using  {@link PhoneNumberUtils#formatNumber(android.text.Editable,int)}. This helper method uses   {@link #sEditable} and {@link #sFormattingType} toprevent allocations between multiple calls. <p> Because of the shared  {@link #sEditable} builder, <b>this method is notthread safe</b>, and should only be called from the GUI thread. <p> If the given String object is null or empty, return an empty String.
 */
private String formatPhoneNumber(String number){
  if (!TextUtils.isEmpty(number)) {
    return "String_Node_Str";
  }
  if (sFormattingType == FORMATTING_TYPE_INVALID) {
    sFormattingType=PhoneNumberUtils.getFormatTypeForLocale(Locale.getDefault());
  }
  sEditable.clear();
  sEditable.append(number);
  PhoneNumberUtils.formatNumber(sEditable,sFormattingType);
  return sEditable.toString();
}

Fixed version (ground truth):
/** 
 * Format the given phone number using  {@link PhoneNumberUtils#formatNumber(android.text.Editable,int)}. This helper method uses   {@link #sEditable} and {@link #sFormattingType} toprevent allocations between multiple calls. <p> Because of the shared  {@link #sEditable} builder, <b>this method is notthread safe</b>, and should only be called from the GUI thread. <p> If the given String object is null or empty, return an empty String.
 */
private String formatPhoneNumber(String number){
  if (TextUtils.isEmpty(number)) {
    return "String_Node_Str";
  }
  if (sFormattingType == FORMATTING_TYPE_INVALID) {
    sFormattingType=PhoneNumberUtils.getFormatTypeForLocale(Locale.getDefault());
  }
  sEditable.clear();
  sEditable.append(number);
  PhoneNumberUtils.formatNumber(sEditable,sFormattingType);
  return sEditable.toString();
}
Program: 7378
Project: 7378
Buggy source:
/** 
 * Parse a specific entry from the given   {@link Bundle} and insert into thegiven  {@link EntityDelta}. Silently skips the insert when missing value or no valid   {@link EditType} found.
 * @param typeExtra {@link Bundle} key that holds the incoming{@link EditType#rawValue} value.
 * @param valueExtra {@link Bundle} key that holds the incoming value.
 * @param valueColumn Column to write value into {@link ValuesDelta}.
 */
public static void parseExtras(EntityDelta state,DataKind kind,Bundle extras,String typeExtra,String valueExtra,String valueColumn){
  final CharSequence value=extras.getCharSequence(valueExtra);
  if (kind == null)   return;
  final boolean canInsert=EntityModifier.canInsert(state,kind);
  final boolean validValue=(value != null && TextUtils.isGraphic(value));
  if (!validValue || !canInsert)   return;
  final int typeValue=extras.getInt(typeExtra,BaseTypes.TYPE_CUSTOM);
  final EditType editType=EntityModifier.getBestValidType(state,kind,true,typeValue);
  final ValuesDelta child=EntityModifier.insertChild(state,kind,editType);
  child.put(valueColumn,value.toString());
  if (editType != null && editType.customColumn != null) {
    final CharSequence customType=extras.getCharSequence(typeExtra);
    child.put(editType.customColumn,customType.toString());
  }
}

Fixed version (ground truth):
/** 
 * Parse a specific entry from the given   {@link Bundle} and insert into thegiven  {@link EntityDelta}. Silently skips the insert when missing value or no valid   {@link EditType} found.
 * @param typeExtra {@link Bundle} key that holds the incoming{@link EditType#rawValue} value.
 * @param valueExtra {@link Bundle} key that holds the incoming value.
 * @param valueColumn Column to write value into {@link ValuesDelta}.
 */
public static void parseExtras(EntityDelta state,DataKind kind,Bundle extras,String typeExtra,String valueExtra,String valueColumn){
  final CharSequence value=extras.getCharSequence(valueExtra);
  if (kind == null)   return;
  final boolean canInsert=EntityModifier.canInsert(state,kind);
  final boolean validValue=(value != null && TextUtils.isGraphic(value));
  if (!validValue || !canInsert)   return;
  final int typeValue=extras.getInt(typeExtra,BaseTypes.TYPE_CUSTOM);
  final EditType editType=EntityModifier.getBestValidType(state,kind,true,typeValue);
  final ValuesDelta child=EntityModifier.insertChild(state,kind,editType);
  child.put(valueColumn,value.toString());
  if (editType != null && editType.customColumn != null) {
    final String customType=extras.getString(typeExtra);
    child.put(editType.customColumn,customType);
  }
}
Program: 7379
Project: 7379
Buggy source:
/** 
 * Find the best   {@link EditType} for a potential insert. The "best" is thefirst primary type that doesn't already exist. When all valid types exist, we pick the last valid option.
 */
public static EditType getBestValidType(EntityDelta state,DataKind kind,boolean includeSecondary,int exactValue){
  if (kind.typeColumn == null)   return null;
  final SparseIntArray typeCount=getTypeFrequencies(state,kind);
  final ArrayList<EditType> validTypes=getValidTypes(state,kind,null,includeSecondary,typeCount);
  if (validTypes.size() == 0)   return null;
  final EditType lastType=validTypes.get(validTypes.size() - 1);
  Iterator<EditType> iterator=validTypes.iterator();
  while (iterator.hasNext()) {
    final EditType type=iterator.next();
    final int count=typeCount.get(type.rawValue);
    if (count == exactValue) {
      return type;
    }
    if (count > 0) {
      iterator.remove();
    }
  }
  if (validTypes.size() > 0) {
    return validTypes.get(0);
  }
 else {
    return lastType;
  }
}

Fixed version (ground truth):
/** 
 * Find the best   {@link EditType} for a potential insert. The "best" is thefirst primary type that doesn't already exist. When all valid types exist, we pick the last valid option.
 */
public static EditType getBestValidType(EntityDelta state,DataKind kind,boolean includeSecondary,int exactValue){
  if (kind.typeColumn == null)   return null;
  final SparseIntArray typeCount=getTypeFrequencies(state,kind);
  final ArrayList<EditType> validTypes=getValidTypes(state,kind,null,includeSecondary,typeCount);
  if (validTypes.size() == 0)   return null;
  final EditType lastType=validTypes.get(validTypes.size() - 1);
  Iterator<EditType> iterator=validTypes.iterator();
  while (iterator.hasNext()) {
    final EditType type=iterator.next();
    final int count=typeCount.get(type.rawValue);
    if (exactValue == type.rawValue) {
      return type;
    }
    if (count > 0) {
      iterator.remove();
    }
  }
  if (validTypes.size() > 0) {
    return validTypes.get(0);
  }
 else {
    return lastType;
  }
}
Program: 7380
Project: 7380
Buggy source:
/** 
 * Find   {@link RawContacts#_ID} of the requested {@link EntityDelta}.
 */
public long getRawContactId(int index){
  if (index >= 0 && index < this.size()) {
    final EntityDelta delta=this.get(index);
    return delta.getValues().getAsLong(RawContacts._ID);
  }
 else {
    return 0;
  }
}

Fixed version (ground truth):
/** 
 * Find   {@link RawContacts#_ID} of the requested {@link EntityDelta}.
 */
public long getRawContactId(int index){
  if (index >= 0 && index < this.size()) {
    final EntityDelta delta=this.get(index);
    final ValuesDelta values=delta.getValues();
    if (values.isVisible()) {
      return values.getAsLong(RawContacts._ID);
    }
  }
  return 0;
}
Program: 7381
Project: 7381
Buggy source:
/** 
 * Find index of given   {@link RawContacts#_ID} when present.
 */
public int indexOfRawContactId(long rawContactId){
  final int size=this.size();
  for (int i=0; i < size; i++) {
    final long currentId=getRawContactId(i);
    if (currentId == rawContactId) {
      return i;
    }
  }
  return -1;
}

Fixed version (ground truth):
/** 
 * Find index of given   {@link RawContacts#_ID} when present.
 */
public int indexOfRawContactId(Long rawContactId){
  final int size=this.size();
  for (int i=0; i < size; i++) {
    final long currentId=getRawContactId(i);
    if (currentId == rawContactId) {
      return i;
    }
  }
  return -1;
}
Program: 7382
Project: 7382
Buggy source:
@Override protected void onRestoreInstanceState(Bundle savedInstanceState){
  mState=savedInstanceState.<EntitySet>getParcelable(KEY_EDIT_STATE);
  bindTabs();
  bindHeader();
  if (hasValidState()) {
    final long selectedId=savedInstanceState.getLong(KEY_SELECTED_RAW_CONTACT);
    setSelectedRawContactId(selectedId);
  }
  super.onRestoreInstanceState(savedInstanceState);
}

Fixed version (ground truth):
@Override protected void onRestoreInstanceState(Bundle savedInstanceState){
  mState=savedInstanceState.<EntitySet>getParcelable(KEY_EDIT_STATE);
  bindTabs();
  bindHeader();
  if (hasValidState()) {
    final Long selectedId=savedInstanceState.getLong(KEY_SELECTED_RAW_CONTACT);
    setSelectedRawContactId(selectedId);
  }
  super.onRestoreInstanceState(savedInstanceState);
}
Program: 7383
Project: 7383
Buggy source:
/** 
 * {@inheritDoc} 
 */
public void onTabSelectionChanged(int tabIndex,boolean clicked){
  if (!hasValidState())   return;
  if (tabIndex < 0 || tabIndex >= mState.size())   return;
  final EntityDelta entity=mState.get(tabIndex);
  final String accountType=entity.getValues().getAsString(RawContacts.ACCOUNT_TYPE);
  final Sources sources=Sources.getInstance(this);
  final ContactsSource source=sources.getInflatedSource(accountType,ContactsSource.LEVEL_CONSTRAINTS);
  mEditor.setState(entity,source);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public void onTabSelectionChanged(int tabIndex,boolean clicked){
  if (!hasValidState())   return;
  final EntityDelta entity=this.getSelectedEntityDelta();
  final String accountType=entity.getValues().getAsString(RawContacts.ACCOUNT_TYPE);
  final Sources sources=Sources.getInstance(this);
  final ContactsSource source=sources.getInflatedSource(accountType,ContactsSource.LEVEL_CONSTRAINTS);
  mEditor.setState(entity,source);
}
Program: 7384
Project: 7384
Buggy source:
/** 
 * {@inheritDoc} 
 */
public void onPhotoLongClick(View view){
  if (!hasValidState())   return;
  this.createPhotoDialog().show();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public void onPhotoLongClick(View view){
  if (!hasValidState())   return;
  showAndManageDialog(createPhotoDialog());
}
Program: 7385
Project: 7385
Buggy source:
/** 
 * Set the selected tab based on the given   {@link RawContacts#_ID}.
 */
protected void setSelectedRawContactId(long rawContactId){
  final int index=mState.indexOfRawContactId(rawContactId);
  mTabWidget.setCurrentTab(index);
}

Fixed version (ground truth):
/** 
 * Set the selected tab based on the given   {@link RawContacts#_ID}.
 */
protected void setSelectedRawContactId(Long rawContactId){
  int tabIndex=0;
  final int size=mTabRawContacts.size();
  for (int i=0; i < size; i++) {
    if (mTabRawContacts.valueAt(i) == rawContactId) {
      tabIndex=i;
      break;
    }
  }
  mTabWidget.setCurrentTab(tabIndex);
  this.onTabSelectionChanged(tabIndex,false);
}
Program: 7386
Project: 7386
Buggy source:
@Override protected void onPostExecute(EditContactActivity target,AlertDialog.Builder result){
  result.create().show();
}

Fixed version (ground truth):
@Override protected void onPostExecute(EditContactActivity target,AlertDialog.Builder result){
  target.showAndManageDialog(result.create());
}
Program: 7387
Project: 7387
Buggy source:
private Dialog createDeleteDialog(){
  final AlertDialog.Builder builder=new AlertDialog.Builder(this);
  builder.setTitle(R.string.deleteConfirmation_title);
  builder.setIcon(android.R.drawable.ic_dialog_alert);
  builder.setMessage(R.string.deleteConfirmation);
  builder.setPositiveButton(android.R.string.ok,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      final int index=mTabWidget.getCurrentTab();
      final EntityDelta delta=mState.get(index);
      delta.markDeleted();
      bindTabs();
      bindHeader();
    }
  }
);
  builder.setNegativeButton(android.R.string.cancel,null);
  builder.setCancelable(false);
  return builder.create();
}

Fixed version (ground truth):
private Dialog createDeleteDialog(){
  final AlertDialog.Builder builder=new AlertDialog.Builder(this);
  builder.setTitle(R.string.deleteConfirmation_title);
  builder.setIcon(android.R.drawable.ic_dialog_alert);
  builder.setMessage(R.string.deleteConfirmation);
  builder.setPositiveButton(android.R.string.ok,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      final EntityDelta delta=getSelectedEntityDelta();
      delta.markDeleted();
      bindTabs();
      bindHeader();
    }
  }
);
  builder.setNegativeButton(android.R.string.cancel,null);
  builder.setCancelable(false);
  return builder.create();
}
Program: 7388
Project: 7388
Buggy source:
@Override protected void onCreate(Bundle icicle){
  super.onCreate(icicle);
  final Context context=this;
  final LayoutInflater inflater=this.getLayoutInflater();
  final Intent intent=getIntent();
  final String action=intent.getAction();
  final Bundle extras=intent.getExtras();
  setContentView(R.layout.act_edit);
  mHeader=(ContactHeaderWidget)this.findViewById(R.id.contact_header_widget);
  mHeader.setContactHeaderListener(this);
  mHeader.showStar(true);
  mTabWidget=(ScrollingTabWidget)this.findViewById(R.id.tab_widget);
  mTabWidget.setTabSelectionListener(this);
  mEditor=(ContactEditorView)this.findViewById(android.R.id.tabcontent);
  mEditor.getPhotoEditor().setEditorListener(this);
  findViewById(R.id.btn_done).setOnClickListener(this);
  findViewById(R.id.btn_discard).setOnClickListener(this);
  if (Intent.ACTION_EDIT.equals(action) && icicle == null) {
    new QueryEntitiesTask(this).execute(intent);
  }
 else   if (Intent.ACTION_INSERT.equals(action) && icicle == null) {
    doAddAction();
  }
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle icicle){
  super.onCreate(icicle);
  final Context context=this;
  final LayoutInflater inflater=this.getLayoutInflater();
  final Intent intent=getIntent();
  final String action=intent.getAction();
  final Bundle extras=intent.getExtras();
  setContentView(R.layout.act_edit);
  mHeader=(ContactHeaderWidget)this.findViewById(R.id.contact_header_widget);
  mHeader.setContactHeaderListener(this);
  mHeader.showStar(true);
  mTabWidget=(ScrollingTabWidget)this.findViewById(R.id.tab_widget);
  mTabWidget.setTabSelectionListener(this);
  mEditor=(ContactEditorView)this.findViewById(android.R.id.tabcontent);
  mEditor.getPhotoEditor().setEditorListener(this);
  findViewById(R.id.btn_done).setOnClickListener(this);
  findViewById(R.id.btn_discard).setOnClickListener(this);
  final boolean hasIncomingState=icicle != null && icicle.containsKey(KEY_EDIT_STATE);
  if (Intent.ACTION_EDIT.equals(action) && !hasIncomingState) {
    new QueryEntitiesTask(this).execute(intent);
  }
 else   if (Intent.ACTION_INSERT.equals(action) && !hasIncomingState) {
    doAddAction();
  }
}
Program: 7389
Project: 7389
Buggy source:
/** 
 * Rebuild tabs to match our underlying   {@link #mState} object, usuallycalled once we've parsed  {@link Entity} data or have inserted a new{@link RawContacts}.
 */
protected void bindTabs(){
  if (!hasValidState())   return;
  final Sources sources=Sources.getInstance(this);
  int selectedTab=0;
  mTabWidget.removeAllTabs();
  for (  EntityDelta entity : mState) {
    ValuesDelta values=entity.getValues();
    final String accountType=values.getAsString(RawContacts.ACCOUNT_TYPE);
    final Long rawContactId=values.getAsLong(RawContacts._ID);
    final ContactsSource source=sources.getInflatedSource(accountType,ContactsSource.LEVEL_CONSTRAINTS);
    final View tabView=ContactsUtils.createTabIndicatorView(mTabWidget.getTabParent(),source);
    mTabWidget.addTab(tabView);
  }
  if (mState.size() > 0) {
    mTabWidget.setCurrentTab(selectedTab);
    this.onTabSelectionChanged(selectedTab,false);
  }
  mEditor.setVisibility(View.VISIBLE);
}

Fixed version (ground truth):
/** 
 * Rebuild tabs to match our underlying   {@link #mState} object, usuallycalled once we've parsed  {@link Entity} data or have inserted a new{@link RawContacts}.
 */
protected void bindTabs(){
  if (!hasValidState())   return;
  final Sources sources=Sources.getInstance(this);
  final Long selectedRawContactId=this.getSelectedRawContactId();
  mTabWidget.removeAllTabs();
  mTabRawContacts.clear();
  for (  EntityDelta entity : mState) {
    final ValuesDelta values=entity.getValues();
    if (!values.isVisible())     continue;
    final String accountType=values.getAsString(RawContacts.ACCOUNT_TYPE);
    final Long rawContactId=values.getAsLong(RawContacts._ID);
    final ContactsSource source=sources.getInflatedSource(accountType,ContactsSource.LEVEL_CONSTRAINTS);
    final int tabIndex=mTabWidget.getTabCount();
    final View tabView=ContactsUtils.createTabIndicatorView(mTabWidget.getTabParent(),source);
    mTabWidget.addTab(tabView);
    mTabRawContacts.put(tabIndex,rawContactId);
  }
  final boolean hasActiveTabs=mTabWidget.getTabCount() > 0;
  if (hasActiveTabs) {
    this.setSelectedRawContactId(selectedRawContactId);
  }
 else {
    this.doSaveAction();
  }
  mEditor.setVisibility(View.VISIBLE);
}
Program: 7390
Project: 7390
Buggy source:
/** 
 * Delete the entire contact currently being edited, which usually asks for user confirmation before continuing.
 */
private boolean doDeleteAction(){
  if (!hasValidState())   return false;
  this.createDeleteDialog().show();
  return true;
}

Fixed version (ground truth):
/** 
 * Delete the entire contact currently being edited, which usually asks for user confirmation before continuing.
 */
private boolean doDeleteAction(){
  if (!hasValidState())   return false;
  showAndManageDialog(createDeleteDialog());
  return true;
}
Program: 7391
Project: 7391
Buggy source:
/** 
 * Return the   {@link RawContacts#_ID} of the currently selected tab.
 */
protected long getSelectedRawContactId(){
  final int index=mTabWidget.getCurrentTab();
  return mState.getRawContactId(index);
}

Fixed version (ground truth):
/** 
 * Return the   {@link RawContacts#_ID} of the currently selected tab.
 */
protected Long getSelectedRawContactId(){
  final int tabIndex=mTabWidget.getCurrentTab();
  return this.mTabRawContacts.get(tabIndex);
}
Program: 7392
Project: 7392
Buggy source:
/** 
 * {@inheritDoc} 
 */
public void onDisplayNameLongClick(View view){
  if (!hasValidState())   return;
  this.createNameDialog().show();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public void onDisplayNameLongClick(View view){
  if (!hasValidState())   return;
  showAndManageDialog(createNameDialog());
}
Program: 7393
Project: 7393
Buggy source:
/** 
 * Saves or creates the contact based on the mode, and if successful finishes the activity.
 */
private boolean doSaveAction(){
  if (!hasValidState())   return false;
  final int selectedTab=mTabWidget.getCurrentTab();
  final long rawContactId=mState.getRawContactId(selectedTab);
  if (rawContactId != -1) {
    final Intent intent=new Intent();
    intent.putExtra(ViewContactActivity.RAW_CONTACT_ID_EXTRA,rawContactId);
    setResult(RESULT_OK,intent);
  }
  try {
    final PersistTask task=new PersistTask(this);
    task.execute(mState);
    task.get(TIMEOUT_PERSIST,TimeUnit.MILLISECONDS);
  }
 catch (  InterruptedException e) {
  }
catch (  TimeoutException e) {
  }
catch (  ExecutionException e) {
  }
  this.finish();
  return true;
}

Fixed version (ground truth):
/** 
 * Saves or creates the contact based on the mode, and if successful finishes the activity.
 */
private boolean doSaveAction(){
  if (!hasValidState())   return false;
  final Long rawContactId=this.getSelectedRawContactId();
  if (rawContactId != null) {
    final Intent intent=new Intent();
    intent.putExtra(ViewContactActivity.RAW_CONTACT_ID_EXTRA,(long)rawContactId);
    setResult(RESULT_OK,intent);
  }
  try {
    final PersistTask task=new PersistTask(this);
    task.execute(mState);
    task.get(TIMEOUT_PERSIST,TimeUnit.MILLISECONDS);
  }
 catch (  InterruptedException e) {
  }
catch (  TimeoutException e) {
  }
catch (  ExecutionException e) {
  }
  this.finish();
  return true;
}
Program: 7394
Project: 7394
Buggy source:
/** 
 * Parse a specific entry from the given   {@link Bundle} and insert into thegiven  {@link EntityDelta}. Silently skips the insert when missing value or no valid   {@link EditType} found.
 * @param typeExtra {@link Bundle} key that holds the incoming{@link EditType#rawValue} value.
 * @param valueExtra {@link Bundle} key that holds the incoming value.
 * @param valueColumn Column to write value into {@link ValuesDelta}.
 */
public static void parseExtras(EntityDelta state,DataKind kind,Bundle extras,String typeExtra,String valueExtra,String valueColumn){
  final CharSequence value=extras.getCharSequence(valueExtra);
  if (kind == null)   return;
  final boolean canInsert=EntityModifier.canInsert(state,kind);
  final boolean validValue=(value != null && TextUtils.isGraphic(value));
  if (!validValue || !canInsert)   return;
  final int typeValue=extras.getInt(typeExtra,BaseTypes.TYPE_CUSTOM);
  final EditType editType=EntityModifier.getBestValidType(state,kind,true,typeValue);
  final ValuesDelta child=EntityModifier.insertChild(state,kind,editType);
  child.put(valueColumn,value.toString());
  if (editType != null && editType.customColumn != null) {
    final CharSequence customType=extras.getCharSequence(typeExtra);
    child.put(editType.customColumn,customType.toString());
  }
}

Fixed version (ground truth):
/** 
 * Parse a specific entry from the given   {@link Bundle} and insert into thegiven  {@link EntityDelta}. Silently skips the insert when missing value or no valid   {@link EditType} found.
 * @param typeExtra {@link Bundle} key that holds the incoming{@link EditType#rawValue} value.
 * @param valueExtra {@link Bundle} key that holds the incoming value.
 * @param valueColumn Column to write value into {@link ValuesDelta}.
 */
public static void parseExtras(EntityDelta state,DataKind kind,Bundle extras,String typeExtra,String valueExtra,String valueColumn){
  final CharSequence value=extras.getCharSequence(valueExtra);
  if (kind == null)   return;
  final boolean canInsert=EntityModifier.canInsert(state,kind);
  final boolean validValue=(value != null && TextUtils.isGraphic(value));
  if (!validValue || !canInsert)   return;
  final int typeValue=extras.getInt(typeExtra,BaseTypes.TYPE_CUSTOM);
  final EditType editType=EntityModifier.getBestValidType(state,kind,true,typeValue);
  final ValuesDelta child=EntityModifier.insertChild(state,kind,editType);
  child.put(valueColumn,value.toString());
  if (editType != null && editType.customColumn != null) {
    final String customType=extras.getString(typeExtra);
    child.put(editType.customColumn,customType);
  }
}
Program: 7395
Project: 7395
Buggy source:
/** 
 * Find the best   {@link EditType} for a potential insert. The "best" is thefirst primary type that doesn't already exist. When all valid types exist, we pick the last valid option.
 */
public static EditType getBestValidType(EntityDelta state,DataKind kind,boolean includeSecondary,int exactValue){
  if (kind.typeColumn == null)   return null;
  final SparseIntArray typeCount=getTypeFrequencies(state,kind);
  final ArrayList<EditType> validTypes=getValidTypes(state,kind,null,includeSecondary,typeCount);
  if (validTypes.size() == 0)   return null;
  final EditType lastType=validTypes.get(validTypes.size() - 1);
  Iterator<EditType> iterator=validTypes.iterator();
  while (iterator.hasNext()) {
    final EditType type=iterator.next();
    final int count=typeCount.get(type.rawValue);
    if (count == exactValue) {
      return type;
    }
    if (count > 0) {
      iterator.remove();
    }
  }
  if (validTypes.size() > 0) {
    return validTypes.get(0);
  }
 else {
    return lastType;
  }
}

Fixed version (ground truth):
/** 
 * Find the best   {@link EditType} for a potential insert. The "best" is thefirst primary type that doesn't already exist. When all valid types exist, we pick the last valid option.
 */
public static EditType getBestValidType(EntityDelta state,DataKind kind,boolean includeSecondary,int exactValue){
  if (kind.typeColumn == null)   return null;
  final SparseIntArray typeCount=getTypeFrequencies(state,kind);
  final ArrayList<EditType> validTypes=getValidTypes(state,kind,null,includeSecondary,typeCount);
  if (validTypes.size() == 0)   return null;
  final EditType lastType=validTypes.get(validTypes.size() - 1);
  Iterator<EditType> iterator=validTypes.iterator();
  while (iterator.hasNext()) {
    final EditType type=iterator.next();
    final int count=typeCount.get(type.rawValue);
    if (exactValue == type.rawValue) {
      return type;
    }
    if (count > 0) {
      iterator.remove();
    }
  }
  if (validTypes.size() > 0) {
    return validTypes.get(0);
  }
 else {
    return lastType;
  }
}
Program: 7396
Project: 7396
Buggy source:
/** 
 * Find   {@link RawContacts#_ID} of the requested {@link EntityDelta}.
 */
public long getRawContactId(int index){
  if (index >= 0 && index < this.size()) {
    final EntityDelta delta=this.get(index);
    return delta.getValues().getAsLong(RawContacts._ID);
  }
 else {
    return 0;
  }
}

Fixed version (ground truth):
/** 
 * Find   {@link RawContacts#_ID} of the requested {@link EntityDelta}.
 */
public long getRawContactId(int index){
  if (index >= 0 && index < this.size()) {
    final EntityDelta delta=this.get(index);
    final ValuesDelta values=delta.getValues();
    if (values.isVisible()) {
      return values.getAsLong(RawContacts._ID);
    }
  }
  return 0;
}
Program: 7397
Project: 7397
Buggy source:
/** 
 * Find index of given   {@link RawContacts#_ID} when present.
 */
public int indexOfRawContactId(long rawContactId){
  final int size=this.size();
  for (int i=0; i < size; i++) {
    final long currentId=getRawContactId(i);
    if (currentId == rawContactId) {
      return i;
    }
  }
  return -1;
}

Fixed version (ground truth):
/** 
 * Find index of given   {@link RawContacts#_ID} when present.
 */
public int indexOfRawContactId(Long rawContactId){
  final int size=this.size();
  for (int i=0; i < size; i++) {
    final long currentId=getRawContactId(i);
    if (currentId == rawContactId) {
      return i;
    }
  }
  return -1;
}
Program: 7398
Project: 7398
Buggy source:
@Override protected void onRestoreInstanceState(Bundle savedInstanceState){
  mState=savedInstanceState.<EntitySet>getParcelable(KEY_EDIT_STATE);
  bindTabs();
  bindHeader();
  if (hasValidState()) {
    final long selectedId=savedInstanceState.getLong(KEY_SELECTED_RAW_CONTACT);
    setSelectedRawContactId(selectedId);
  }
  super.onRestoreInstanceState(savedInstanceState);
}

Fixed version (ground truth):
@Override protected void onRestoreInstanceState(Bundle savedInstanceState){
  mState=savedInstanceState.<EntitySet>getParcelable(KEY_EDIT_STATE);
  bindTabs();
  bindHeader();
  if (hasValidState()) {
    final Long selectedId=savedInstanceState.getLong(KEY_SELECTED_RAW_CONTACT);
    setSelectedRawContactId(selectedId);
  }
  super.onRestoreInstanceState(savedInstanceState);
}
Program: 7399
Project: 7399
Buggy source:
/** 
 * {@inheritDoc} 
 */
public void onTabSelectionChanged(int tabIndex,boolean clicked){
  if (!hasValidState())   return;
  if (tabIndex < 0 || tabIndex >= mState.size())   return;
  final EntityDelta entity=mState.get(tabIndex);
  final String accountType=entity.getValues().getAsString(RawContacts.ACCOUNT_TYPE);
  final Sources sources=Sources.getInstance(this);
  final ContactsSource source=sources.getInflatedSource(accountType,ContactsSource.LEVEL_CONSTRAINTS);
  mEditor.setState(entity,source);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public void onTabSelectionChanged(int tabIndex,boolean clicked){
  if (!hasValidState())   return;
  final EntityDelta entity=this.getSelectedEntityDelta();
  final String accountType=entity.getValues().getAsString(RawContacts.ACCOUNT_TYPE);
  final Sources sources=Sources.getInstance(this);
  final ContactsSource source=sources.getInflatedSource(accountType,ContactsSource.LEVEL_CONSTRAINTS);
  mEditor.setState(entity,source);
}
Program: 7400
Project: 7400
Buggy source:
/** 
 * {@inheritDoc} 
 */
public void onPhotoLongClick(View view){
  if (!hasValidState())   return;
  this.createPhotoDialog().show();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public void onPhotoLongClick(View view){
  if (!hasValidState())   return;
  showAndManageDialog(createPhotoDialog());
}
Program: 7401
Project: 7401
Buggy source:
/** 
 * Set the selected tab based on the given   {@link RawContacts#_ID}.
 */
protected void setSelectedRawContactId(long rawContactId){
  final int index=mState.indexOfRawContactId(rawContactId);
  mTabWidget.setCurrentTab(index);
}

Fixed version (ground truth):
/** 
 * Set the selected tab based on the given   {@link RawContacts#_ID}.
 */
protected void setSelectedRawContactId(Long rawContactId){
  int tabIndex=0;
  final int size=mTabRawContacts.size();
  for (int i=0; i < size; i++) {
    if (mTabRawContacts.valueAt(i) == rawContactId) {
      tabIndex=i;
      break;
    }
  }
  mTabWidget.setCurrentTab(tabIndex);
  this.onTabSelectionChanged(tabIndex,false);
}
Program: 7402
Project: 7402
Buggy source:
@Override protected void onPostExecute(EditContactActivity target,AlertDialog.Builder result){
  result.create().show();
}

Fixed version (ground truth):
@Override protected void onPostExecute(EditContactActivity target,AlertDialog.Builder result){
  target.showAndManageDialog(result.create());
}
Program: 7403
Project: 7403
Buggy source:
private Dialog createDeleteDialog(){
  final AlertDialog.Builder builder=new AlertDialog.Builder(this);
  builder.setTitle(R.string.deleteConfirmation_title);
  builder.setIcon(android.R.drawable.ic_dialog_alert);
  builder.setMessage(R.string.deleteConfirmation);
  builder.setPositiveButton(android.R.string.ok,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      final int index=mTabWidget.getCurrentTab();
      final EntityDelta delta=mState.get(index);
      delta.markDeleted();
      bindTabs();
      bindHeader();
    }
  }
);
  builder.setNegativeButton(android.R.string.cancel,null);
  builder.setCancelable(false);
  return builder.create();
}

Fixed version (ground truth):
private Dialog createDeleteDialog(){
  final AlertDialog.Builder builder=new AlertDialog.Builder(this);
  builder.setTitle(R.string.deleteConfirmation_title);
  builder.setIcon(android.R.drawable.ic_dialog_alert);
  builder.setMessage(R.string.deleteConfirmation);
  builder.setPositiveButton(android.R.string.ok,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      final EntityDelta delta=getSelectedEntityDelta();
      delta.markDeleted();
      bindTabs();
      bindHeader();
    }
  }
);
  builder.setNegativeButton(android.R.string.cancel,null);
  builder.setCancelable(false);
  return builder.create();
}
Program: 7404
Project: 7404
Buggy source:
@Override protected void onCreate(Bundle icicle){
  super.onCreate(icicle);
  final Context context=this;
  final LayoutInflater inflater=this.getLayoutInflater();
  final Intent intent=getIntent();
  final String action=intent.getAction();
  final Bundle extras=intent.getExtras();
  setContentView(R.layout.act_edit);
  mHeader=(ContactHeaderWidget)this.findViewById(R.id.contact_header_widget);
  mHeader.setContactHeaderListener(this);
  mHeader.showStar(true);
  mTabWidget=(ScrollingTabWidget)this.findViewById(R.id.tab_widget);
  mTabWidget.setTabSelectionListener(this);
  mEditor=(ContactEditorView)this.findViewById(android.R.id.tabcontent);
  mEditor.getPhotoEditor().setEditorListener(this);
  findViewById(R.id.btn_done).setOnClickListener(this);
  findViewById(R.id.btn_discard).setOnClickListener(this);
  if (Intent.ACTION_EDIT.equals(action) && icicle == null) {
    new QueryEntitiesTask(this).execute(intent);
  }
 else   if (Intent.ACTION_INSERT.equals(action) && icicle == null) {
    doAddAction();
  }
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle icicle){
  super.onCreate(icicle);
  final Context context=this;
  final LayoutInflater inflater=this.getLayoutInflater();
  final Intent intent=getIntent();
  final String action=intent.getAction();
  final Bundle extras=intent.getExtras();
  setContentView(R.layout.act_edit);
  mHeader=(ContactHeaderWidget)this.findViewById(R.id.contact_header_widget);
  mHeader.setContactHeaderListener(this);
  mHeader.showStar(true);
  mTabWidget=(ScrollingTabWidget)this.findViewById(R.id.tab_widget);
  mTabWidget.setTabSelectionListener(this);
  mEditor=(ContactEditorView)this.findViewById(android.R.id.tabcontent);
  mEditor.getPhotoEditor().setEditorListener(this);
  findViewById(R.id.btn_done).setOnClickListener(this);
  findViewById(R.id.btn_discard).setOnClickListener(this);
  final boolean hasIncomingState=icicle != null && icicle.containsKey(KEY_EDIT_STATE);
  if (Intent.ACTION_EDIT.equals(action) && !hasIncomingState) {
    new QueryEntitiesTask(this).execute(intent);
  }
 else   if (Intent.ACTION_INSERT.equals(action) && !hasIncomingState) {
    doAddAction();
  }
}
Program: 7405
Project: 7405
Buggy source:
/** 
 * Rebuild tabs to match our underlying   {@link #mState} object, usuallycalled once we've parsed  {@link Entity} data or have inserted a new{@link RawContacts}.
 */
protected void bindTabs(){
  if (!hasValidState())   return;
  final Sources sources=Sources.getInstance(this);
  int selectedTab=0;
  mTabWidget.removeAllTabs();
  for (  EntityDelta entity : mState) {
    ValuesDelta values=entity.getValues();
    final String accountType=values.getAsString(RawContacts.ACCOUNT_TYPE);
    final Long rawContactId=values.getAsLong(RawContacts._ID);
    final ContactsSource source=sources.getInflatedSource(accountType,ContactsSource.LEVEL_CONSTRAINTS);
    final View tabView=ContactsUtils.createTabIndicatorView(mTabWidget.getTabParent(),source);
    mTabWidget.addTab(tabView);
  }
  if (mState.size() > 0) {
    mTabWidget.setCurrentTab(selectedTab);
    this.onTabSelectionChanged(selectedTab,false);
  }
  mEditor.setVisibility(View.VISIBLE);
}

Fixed version (ground truth):
/** 
 * Rebuild tabs to match our underlying   {@link #mState} object, usuallycalled once we've parsed  {@link Entity} data or have inserted a new{@link RawContacts}.
 */
protected void bindTabs(){
  if (!hasValidState())   return;
  final Sources sources=Sources.getInstance(this);
  final Long selectedRawContactId=this.getSelectedRawContactId();
  mTabWidget.removeAllTabs();
  mTabRawContacts.clear();
  for (  EntityDelta entity : mState) {
    final ValuesDelta values=entity.getValues();
    if (!values.isVisible())     continue;
    final String accountType=values.getAsString(RawContacts.ACCOUNT_TYPE);
    final Long rawContactId=values.getAsLong(RawContacts._ID);
    final ContactsSource source=sources.getInflatedSource(accountType,ContactsSource.LEVEL_CONSTRAINTS);
    final int tabIndex=mTabWidget.getTabCount();
    final View tabView=ContactsUtils.createTabIndicatorView(mTabWidget.getTabParent(),source);
    mTabWidget.addTab(tabView);
    mTabRawContacts.put(tabIndex,rawContactId);
  }
  final boolean hasActiveTabs=mTabWidget.getTabCount() > 0;
  if (hasActiveTabs) {
    this.setSelectedRawContactId(selectedRawContactId);
  }
 else {
    this.doSaveAction();
  }
  mEditor.setVisibility(View.VISIBLE);
}
Program: 7406
Project: 7406
Buggy source:
/** 
 * Delete the entire contact currently being edited, which usually asks for user confirmation before continuing.
 */
private boolean doDeleteAction(){
  if (!hasValidState())   return false;
  this.createDeleteDialog().show();
  return true;
}

Fixed version (ground truth):
/** 
 * Delete the entire contact currently being edited, which usually asks for user confirmation before continuing.
 */
private boolean doDeleteAction(){
  if (!hasValidState())   return false;
  showAndManageDialog(createDeleteDialog());
  return true;
}
Program: 7407
Project: 7407
Buggy source:
/** 
 * Return the   {@link RawContacts#_ID} of the currently selected tab.
 */
protected long getSelectedRawContactId(){
  final int index=mTabWidget.getCurrentTab();
  return mState.getRawContactId(index);
}

Fixed version (ground truth):
/** 
 * Return the   {@link RawContacts#_ID} of the currently selected tab.
 */
protected Long getSelectedRawContactId(){
  final int tabIndex=mTabWidget.getCurrentTab();
  return this.mTabRawContacts.get(tabIndex);
}
Program: 7408
Project: 7408
Buggy source:
/** 
 * {@inheritDoc} 
 */
public void onDisplayNameLongClick(View view){
  if (!hasValidState())   return;
  this.createNameDialog().show();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public void onDisplayNameLongClick(View view){
  if (!hasValidState())   return;
  showAndManageDialog(createNameDialog());
}
Program: 7409
Project: 7409
Buggy source:
/** 
 * Saves or creates the contact based on the mode, and if successful finishes the activity.
 */
private boolean doSaveAction(){
  if (!hasValidState())   return false;
  final int selectedTab=mTabWidget.getCurrentTab();
  final long rawContactId=mState.getRawContactId(selectedTab);
  if (rawContactId != -1) {
    final Intent intent=new Intent();
    intent.putExtra(ViewContactActivity.RAW_CONTACT_ID_EXTRA,rawContactId);
    setResult(RESULT_OK,intent);
  }
  try {
    final PersistTask task=new PersistTask(this);
    task.execute(mState);
    task.get(TIMEOUT_PERSIST,TimeUnit.MILLISECONDS);
  }
 catch (  InterruptedException e) {
  }
catch (  TimeoutException e) {
  }
catch (  ExecutionException e) {
  }
  this.finish();
  return true;
}

Fixed version (ground truth):
/** 
 * Saves or creates the contact based on the mode, and if successful finishes the activity.
 */
private boolean doSaveAction(){
  if (!hasValidState())   return false;
  final Long rawContactId=this.getSelectedRawContactId();
  if (rawContactId != null) {
    final Intent intent=new Intent();
    intent.putExtra(ViewContactActivity.RAW_CONTACT_ID_EXTRA,(long)rawContactId);
    setResult(RESULT_OK,intent);
  }
  try {
    final PersistTask task=new PersistTask(this);
    task.execute(mState);
    task.get(TIMEOUT_PERSIST,TimeUnit.MILLISECONDS);
  }
 catch (  InterruptedException e) {
  }
catch (  TimeoutException e) {
  }
catch (  ExecutionException e) {
  }
  this.finish();
  return true;
}
Program: 7411
Project: 7411
Buggy source:
@Override public void handleMessage(Message message){
  if (ContactsListActivity.this.isFinishing()) {
    return;
  }
switch (message.what) {
case FETCH_IMAGE_MSG:
    ImageView imageView=(ImageView)message.obj;
  long photoId=(Long)imageView.getTag();
Bitmap photo=null;
try {
photo=ContactsUtils.loadContactPhoto(mContext,photoId,null);
if (photo != null) {
  mBitmapCache.put(photoId,new SoftReference<Bitmap>(photo));
  imageView.setImageBitmap(photo);
}
}
 catch (OutOfMemoryError e) {
}
mItemsMissingImages.remove(imageView);
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message message){
  if (ContactsListActivity.this.isFinishing()) {
    return;
  }
switch (message.what) {
case FETCH_IMAGE_MSG:
{
      ImageView imageView=(ImageView)message.obj;
      long photoId=(Long)imageView.getTag();
      if (photoId == 0) {
        break;
      }
      Bitmap photo=null;
      try {
        photo=ContactsUtils.loadContactPhoto(mContext,photoId,null);
      }
 catch (      OutOfMemoryError e) {
      }
      if (photo == null) {
        break;
      }
      mBitmapCache.put(photoId,new SoftReference<Bitmap>(photo));
synchronized (imageView) {
        long currentPhotoId=(Long)imageView.getTag();
        if (currentPhotoId == photoId) {
          imageView.setImageBitmap(photo);
          mItemsMissingImages.remove(imageView);
        }
      }
      break;
    }
}
}
Program: 7412
Project: 7412
Buggy source:
public void onScrollStateChanged(AbsListView view,int scrollState){
  mScrollState=scrollState;
  if (scrollState != OnScrollListener.SCROLL_STATE_IDLE) {
    clearImageFetching();
  }
 else   if (mDisplayPhotos) {
    processMissingImageItems(view);
  }
}

Fixed version (ground truth):
public void onScrollStateChanged(AbsListView view,int scrollState){
  mScrollState=scrollState;
  if (scrollState == OnScrollListener.SCROLL_STATE_FLING) {
    clearImageFetching();
  }
 else   if (mDisplayPhotos) {
    processMissingImageItems(view);
  }
}
Program: 7414
Project: 7414
Buggy source:
@Override public void handleMessage(Message message){
  if (ContactsListActivity.this.isFinishing()) {
    return;
  }
switch (message.what) {
case FETCH_IMAGE_MSG:
    ImageView imageView=(ImageView)message.obj;
  long photoId=(Long)imageView.getTag();
Bitmap photo=null;
try {
photo=ContactsUtils.loadContactPhoto(mContext,photoId,null);
if (photo != null) {
  mBitmapCache.put(photoId,new SoftReference<Bitmap>(photo));
  imageView.setImageBitmap(photo);
}
}
 catch (OutOfMemoryError e) {
}
mItemsMissingImages.remove(imageView);
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message message){
  if (ContactsListActivity.this.isFinishing()) {
    return;
  }
switch (message.what) {
case FETCH_IMAGE_MSG:
{
      ImageView imageView=(ImageView)message.obj;
      long photoId=(Long)imageView.getTag();
      if (photoId == 0) {
        break;
      }
      Bitmap photo=null;
      try {
        photo=ContactsUtils.loadContactPhoto(mContext,photoId,null);
      }
 catch (      OutOfMemoryError e) {
      }
      if (photo == null) {
        break;
      }
      mBitmapCache.put(photoId,new SoftReference<Bitmap>(photo));
synchronized (imageView) {
        long currentPhotoId=(Long)imageView.getTag();
        if (currentPhotoId == photoId) {
          imageView.setImageBitmap(photo);
          mItemsMissingImages.remove(imageView);
        }
      }
      break;
    }
}
}
Program: 7415
Project: 7415
Buggy source:
public void onScrollStateChanged(AbsListView view,int scrollState){
  mScrollState=scrollState;
  if (scrollState != OnScrollListener.SCROLL_STATE_IDLE) {
    clearImageFetching();
  }
 else   if (mDisplayPhotos) {
    processMissingImageItems(view);
  }
}

Fixed version (ground truth):
public void onScrollStateChanged(AbsListView view,int scrollState){
  mScrollState=scrollState;
  if (scrollState == OnScrollListener.SCROLL_STATE_FLING) {
    clearImageFetching();
  }
 else   if (mDisplayPhotos) {
    processMissingImageItems(view);
  }
}
Program: 7417
Project: 7417
Buggy source:
@Override public void handleMessage(Message message){
  if (ContactsListActivity.this.isFinishing()) {
    return;
  }
switch (message.what) {
case FETCH_IMAGE_MSG:
    ImageView imageView=(ImageView)message.obj;
  long photoId=(Long)imageView.getTag();
Bitmap photo=null;
try {
photo=ContactsUtils.loadContactPhoto(mContext,photoId,null);
if (photo != null) {
  mBitmapCache.put(photoId,new SoftReference<Bitmap>(photo));
  imageView.setImageBitmap(photo);
}
}
 catch (OutOfMemoryError e) {
}
mItemsMissingImages.remove(imageView);
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message message){
  if (ContactsListActivity.this.isFinishing()) {
    return;
  }
switch (message.what) {
case FETCH_IMAGE_MSG:
{
      ImageView imageView=(ImageView)message.obj;
      long photoId=(Long)imageView.getTag();
      if (photoId == 0) {
        break;
      }
      Bitmap photo=null;
      try {
        photo=ContactsUtils.loadContactPhoto(mContext,photoId,null);
      }
 catch (      OutOfMemoryError e) {
      }
      if (photo == null) {
        break;
      }
      mBitmapCache.put(photoId,new SoftReference<Bitmap>(photo));
synchronized (imageView) {
        long currentPhotoId=(Long)imageView.getTag();
        if (currentPhotoId == photoId) {
          imageView.setImageBitmap(photo);
          mItemsMissingImages.remove(imageView);
        }
      }
      break;
    }
}
}
Program: 7418
Project: 7418
Buggy source:
public void onScrollStateChanged(AbsListView view,int scrollState){
  mScrollState=scrollState;
  if (scrollState != OnScrollListener.SCROLL_STATE_IDLE) {
    clearImageFetching();
  }
 else   if (mDisplayPhotos) {
    processMissingImageItems(view);
  }
}

Fixed version (ground truth):
public void onScrollStateChanged(AbsListView view,int scrollState){
  mScrollState=scrollState;
  if (scrollState == OnScrollListener.SCROLL_STATE_FLING) {
    clearImageFetching();
  }
 else   if (mDisplayPhotos) {
    processMissingImageItems(view);
  }
}
Program: 7419
Project: 7419
Buggy source:
public CharSequence inflateUsing(Context context,ContentValues values){
  final EditType type=EntityModifier.getCurrentType(values,mKind);
  final boolean validString=(type != null && type.actionAltRes != 0);
  return validString ? context.getText(type.actionAltRes) : null;
}

Fixed version (ground truth):
public CharSequence inflateUsing(Context context,ContentValues values){
  final EditType type=EntityModifier.getCurrentType(values,mKind);
  final boolean validString=(type != null && type.actionAltRes != 0);
  CharSequence actionString;
  if (type.customColumn != null) {
    final String customLabel=values.getAsString(type.customColumn);
    actionString=String.format(context.getString(type.actionAltRes),customLabel);
  }
 else {
    actionString=context.getText(type.actionAltRes);
  }
  return validString ? actionString : null;
}