nus-yam/ex-repair huggingface dataset:
Program: 114165
Project: 114165
Buggy source:
private void setOnlineStatus(User friend){
  if (friend != null) {
    ActionBar actionBar=getActionBar();
  }
}

Fixed version (ground truth):
private void setOnlineStatus(User friend){
  if (friend != null) {
    ActionBar actionBar=getActionBar();
    actionBar.setSubtitle(OnlineStatusHelper.getOnlineStatus(friend.isOnline()));
  }
}
Program: 114166
Project: 114166
Buggy source:
private void registerContentObservers(){
  statusContentObserver=new ContentObserver(new Handler()){
    @Override public void onChange(    boolean selfChange){
      opponentFriend=UsersDatabaseManager.getUserById(PrivateDialogActivity.this,PrivateDialogActivity.this.opponentFriend.getUserId());
      setOnlineStatus(opponentFriend);
    }
  }
;
  friendCursor.registerContentObserver(statusContentObserver);
  friendsTableContentObserver=new ContentObserver(new Handler()){
    @Override public void onChange(    boolean selfChange){
      checkMessageSendingPossibility();
    }
  }
;
  getContentResolver().registerContentObserver(FriendTable.CONTENT_URI,true,friendsTableContentObserver);
}

Fixed version (ground truth):
private void registerContentObservers(){
  statusContentObserver=new ContentObserver(new Handler()){
    @Override public void onChange(    boolean selfChange){
      opponentFriend=DatabaseManager.getInstance().getUserManager().get(PrivateDialogActivity.this.opponentFriend.getUserId());
      setOnlineStatus(opponentFriend);
    }
  }
;
  friendCursor.registerContentObserver(statusContentObserver);
  friendsTableContentObserver=new ContentObserver(new Handler()){
    @Override public void onChange(    boolean selfChange){
      checkMessageSendingPossibility();
    }
  }
;
  getContentResolver().registerContentObserver(FriendTable.CONTENT_URI,true,friendsTableContentObserver);
}
Program: 114167
Project: 114167
Buggy source:
public User getOccupantById(int occupantId){
  User friend=UsersDatabaseManager.getUserById(context,occupantId);
  if (friend == null) {
    friend=new User();
    friend.setUserId(occupantId);
    friend.setFullName(occupantId + ConstsCore.EMPTY_STRING);
  }
  return friend;
}

Fixed version (ground truth):
public User getOccupantById(int occupantId){
  User friend=DatabaseManager.getInstance().getUserManager().get(occupantId);
  if (friend == null) {
    friend=new User();
    friend.setUserId(occupantId);
    friend.setFullName(occupantId + ConstsCore.EMPTY_STRING);
  }
  return friend;
}
Program: 114168
Project: 114168
Buggy source:
private void startNewDialogPage(){
  boolean isFriends=UsersDatabaseManager.getAllFriends(baseActivity).getCount() > ConstsCore.ZERO_INT_VALUE;
  if (isFriends) {
    NewDialogActivity.start(baseActivity);
  }
 else {
    DialogUtils.showLong(baseActivity,getResources().getString(R.string.ndl_no_friends_for_new_chat));
  }
}

Fixed version (ground truth):
private void startNewDialogPage(){
  boolean isFriends=!DatabaseManager.getInstance().getFriendManager().getAll().isEmpty();
  if (isFriends) {
    NewDialogActivity.start(baseActivity);
  }
 else {
    DialogUtils.showLong(baseActivity,getResources().getString(R.string.ndl_no_friends_for_new_chat));
  }
}
Program: 114169
Project: 114169
Buggy source:
private void setOnlineStatus(User user){
  if (user != null) {
    if (user.isOnline()) {
      onlineImageView.setVisibility(View.VISIBLE);
    }
 else {
      onlineImageView.setVisibility(View.GONE);
    }
  }
}

Fixed version (ground truth):
private void setOnlineStatus(User user){
  if (user != null) {
    if (user.isOnline()) {
      onlineImageView.setVisibility(View.VISIBLE);
    }
 else {
      onlineImageView.setVisibility(View.GONE);
    }
    onlineStatusTextView.setText(OnlineStatusHelper.getOnlineStatus(user.isOnline()));
  }
}
Program: 114170
Project: 114170
Buggy source:
private void checkVisibilityItemsMyContacts(ViewHolder viewHolder,User user){
  Friend friend=DatabaseManager.getInstance().getFriendManager().getByUserId(user.getUserId());
  User pendingUser=DatabaseManager.getInstance().getUserRequestManager().getUserById(user.getUserId());
  if (friend == null && pendingUser == null) {
    return;
  }
  String status;
  if (pendingUser != null) {
    viewHolder.onlineImageView.setVisibility(View.GONE);
    status=resources.getString(R.string.frl_pending_request_status);
  }
 else {
    status="String_Node_Str";
  }
  viewHolder.addFriendImageView.setVisibility(View.GONE);
  viewHolder.statusTextView.setText(status);
  viewHolder.statusTextView.setVisibility(View.VISIBLE);
  setStatusVisibility(viewHolder,user.isOnline());
}

Fixed version (ground truth):
private void checkVisibilityItemsMyContacts(ViewHolder viewHolder,User user){
  Friend friend=DatabaseManager.getInstance().getFriendManager().getByUserId(user.getUserId());
  User pendingUser=DatabaseManager.getInstance().getUserRequestManager().getUserById(user.getUserId());
  if (friend == null && pendingUser == null) {
    return;
  }
  String status;
  if (pendingUser != null) {
    viewHolder.onlineImageView.setVisibility(View.GONE);
    status=resources.getString(R.string.frl_pending_request_status);
  }
 else {
    status=resources.getString(OnlineStatusHelper.getOnlineStatus(user.isOnline()));
  }
  viewHolder.addFriendImageView.setVisibility(View.GONE);
  viewHolder.statusTextView.setText(status);
  viewHolder.statusTextView.setVisibility(View.VISIBLE);
  setStatusVisibility(viewHolder,user.isOnline());
}
Program: 114171
Project: 114171
Buggy source:
private void startDialog(){
  String dialogId=PrefsHelper.getPrefsHelper().getPref(PrefsHelper.PREF_PUSH_MESSAGE_DIALOG_ID,null);
  long userId=PrefsHelper.getPrefsHelper().getPref(PrefsHelper.PREF_PUSH_MESSAGE_USER_ID,ConstsCore.NOT_INITIALIZED_VALUE);
  QBDialog dialog=ChatDatabaseManager.getDialogByDialogId(this,dialogId);
  if (dialog == null) {
    return;
  }
  if (dialog.getType() == QBDialogType.PRIVATE) {
    startPrivateChatActivity(dialog,userId);
  }
 else {
    startGroupChatActivity(dialog);
  }
  PrefsHelper.getPrefsHelper().savePref(PrefsHelper.PREF_PUSH_MESSAGE_NEED_TO_OPEN_DIALOG,false);
}

Fixed version (ground truth):
private void startDialog(){
  String dialogId=PrefsHelper.getPrefsHelper().getPref(PrefsHelper.PREF_PUSH_MESSAGE_DIALOG_ID,null);
  int userId=PrefsHelper.getPrefsHelper().getPref(PrefsHelper.PREF_PUSH_MESSAGE_USER_ID,ConstsCore.NOT_INITIALIZED_VALUE);
  QBDialog dialog=ChatDatabaseManager.getDialogByDialogId(this,dialogId);
  if (dialog == null) {
    return;
  }
  if (dialog.getType() == QBDialogType.PRIVATE) {
    startPrivateChatActivity(dialog,userId);
  }
 else {
    startGroupChatActivity(dialog);
  }
  PrefsHelper.getPrefsHelper().savePref(PrefsHelper.PREF_PUSH_MESSAGE_NEED_TO_OPEN_DIALOG,false);
}
Program: 114172
Project: 114172
Buggy source:
private void startPrivateChatActivity(QBDialog dialog,long userId){
  User occupantUser=UsersDatabaseManager.getUserById(this,userId);
  if (occupantUser != null && userId != ConstsCore.ZERO_INT_VALUE) {
    PrivateDialogActivity.start(this,occupantUser,dialog);
  }
}

Fixed version (ground truth):
private void startPrivateChatActivity(QBDialog dialog,int userId){
  User occupantUser=DatabaseManager.getInstance().getUserManager().get(userId);
  if (occupantUser != null && userId != ConstsCore.ZERO_INT_VALUE) {
    PrivateDialogActivity.start(this,occupantUser,dialog);
  }
}
Program: 114173
Project: 114173
Buggy source:
private void initLocalBroadcastManagers(){
  typingMessageBroadcastReceiver=new TypingStatusBroadcastReceiver();
  LocalBroadcastManager.getInstance(this).registerReceiver(typingMessageBroadcastReceiver,new IntentFilter(QBServiceConsts.TYPING_MESSAGE));
  updatingDialogBroadcastReceiver=new UpdatingDialogBroadcastReceiver();
  LocalBroadcastManager.getInstance(this).registerReceiver(updatingDialogBroadcastReceiver,new IntentFilter(QBServiceConsts.UPDATE_DIALOG));
}

Fixed version (ground truth):
private void initLocalBroadcastManagers(){
  BroadcastReceiver typingMessageBroadcastReceiver=new TypingStatusBroadcastReceiver();
  LocalBroadcastManager.getInstance(this).registerReceiver(typingMessageBroadcastReceiver,new IntentFilter(QBServiceConsts.TYPING_MESSAGE));
  BroadcastReceiver updatingDialogBroadcastReceiver=new UpdatingDialogBroadcastReceiver();
  LocalBroadcastManager.getInstance(this).registerReceiver(updatingDialogBroadcastReceiver,new IntentFilter(QBServiceConsts.UPDATE_DIALOG));
}
Program: 114174
Project: 114174
Buggy source:
@Override public void onReceive(Context context,Intent intent){
  if (intent.getAction().equals(QBServiceConsts.UPDATE_DIALOG)) {
    updateDialogData();
  }
}

Fixed version (ground truth):
@Override public void onReceive(Context context,Intent intent){
  if (intent.getAction().equals(QBServiceConsts.UPDATE_DIALOG)) {
    updateData();
  }
}
Program: 114175
Project: 114175
Buggy source:
private void deleteObservers(){
  databaseManager.getMessageManager().deleteObserver(messageObserver);
}

Fixed version (ground truth):
private void deleteObservers(){
  databaseManager.getMessageManager().deleteObserver(messageObserver);
  databaseManager.getDialogNotificationManager().deleteObserver(dialogNotificationObserver);
}
Program: 114176
Project: 114176
Buggy source:
@Override public void update(Observable observable,Object data){
  if (data != null && data.equals(MessageManager.OBSERVE_MESSAGE)) {
    updateMessagesList();
  }
}

Fixed version (ground truth):
@Override public void update(Observable observable,Object data){
  if (data != null && data.equals(DialogNotificationManager.OBSERVE_DIALOG_NOTIFICATION)) {
    updateMessagesList();
  }
}
Program: 114177
Project: 114177
Buggy source:
private void addObservers(){
  databaseManager.getMessageManager().addObserver(messageObserver);
}

Fixed version (ground truth):
private void addObservers(){
  databaseManager.getMessageManager().addObserver(messageObserver);
  databaseManager.getDialogNotificationManager().addObserver(dialogNotificationObserver);
}
Program: 114178
Project: 114178
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  rootView=getLayoutInflater().inflate(layoutResID,null);
  setContentView(rootView);
  resources=getResources();
  databaseManager=DatabaseManager.getInstance();
  imageUtils=new ImageUtils(this);
  loadAttachFileSuccessAction=new LoadAttachFileSuccessAction();
  loadDialogMessagesSuccessAction=new LoadDialogMessagesSuccessAction();
  loadDialogMessagesFailAction=new LoadDialogMessagesFailAction();
  typingTimer=new Timer();
  messageObserver=new MessageObserver();
  initUI();
  initListeners();
  initActionBar();
  addActions();
  isNeedToScrollMessages=true;
  initLocalBroadcastManagers();
  addObservers();
  hideSmileLayout();
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  rootView=getLayoutInflater().inflate(layoutResID,null);
  setContentView(rootView);
  resources=getResources();
  databaseManager=DatabaseManager.getInstance();
  imageUtils=new ImageUtils(this);
  loadAttachFileSuccessAction=new LoadAttachFileSuccessAction();
  loadDialogMessagesSuccessAction=new LoadDialogMessagesSuccessAction();
  loadDialogMessagesFailAction=new LoadDialogMessagesFailAction();
  typingTimer=new Timer();
  messageObserver=new MessageObserver();
  dialogNotificationObserver=new DialogNotificationObserver();
  initUI();
  initListeners();
  initActionBar();
  addActions();
  isNeedToScrollMessages=true;
  initLocalBroadcastManagers();
  addObservers();
  hideSmileLayout();
}
Program: 114179
Project: 114179
Buggy source:
@Override protected void onDestroy(){
  super.onDestroy();
  if (baseChatHelper != null) {
    baseChatHelper.closeChat(ChatUtils.createQBDialogFromLocalDialog(dialog),generateBundleToInitDialog());
  }
  removeActions();
  deleteObservers();
}

Fixed version (ground truth):
@Override protected void onDestroy(){
  super.onDestroy();
  if (baseChatHelper != null) {
    baseChatHelper.closeChat(ChatUtils.createQBDialogFromLocalDialog(dialog),generateBundleToInitDialog());
  }
  removeActions();
  deleteObservers();
  readAllMessages();
}
Program: 114180
Project: 114180
Buggy source:
@Override protected void onResume(){
  super.onResume();
  updateDialogData();
  if (messagesAdapter != null && !messagesAdapter.isEmpty()) {
    scrollListView();
  }
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  updateData();
  if (messagesAdapter != null && !messagesAdapter.isEmpty()) {
    scrollListView();
  }
}
Program: 114181
Project: 114181
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_group_dialog_details);
  dialogId=(String)getIntent().getExtras().getSerializable(QBServiceConsts.EXTRA_DIALOG_ID);
  imageUtils=new ImageUtils(this);
  friendOperationAction=new FriendOperationAction();
  loadedDialogInfo=false;
  currentNotificationTypeList=new ArrayList<DialogNotification.NotificationType>();
  initUI();
  initDialogs();
  initUIWithData();
  addActions();
  initLocalBroadcastManagers();
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_group_dialog_details);
  dialogId=(String)getIntent().getExtras().getSerializable(QBServiceConsts.EXTRA_DIALOG_ID);
  databaseManager=DatabaseManager.getInstance();
  imageUtils=new ImageUtils(this);
  friendOperationAction=new FriendOperationAction();
  loadedDialogInfo=false;
  currentNotificationTypeList=new ArrayList<DialogNotification.NotificationType>();
  initUI();
  initDialogs();
  initUIWithData();
  addActions();
  initLocalBroadcastManagers();
}
Program: 114183
Project: 114183
Buggy source:
@Override protected void updateMessagesList(){
  List<CombinationMessage> combinationMessagesList=createCombinationMessagesList();
  messagesAdapter.setNewData(combinationMessagesList);
  messagesAdapter.notifyDataSetChanged();
}

Fixed version (ground truth):
@Override protected void updateMessagesList(){
  initListView();
}
Program: 114184
Project: 114184
Buggy source:
@Override public void update(Observable observable,Object data){
  if (data != null && data.equals(DialogManager.OBSERVE_DIALOG)) {
    updateDialogsList();
  }
}

Fixed version (ground truth):
@Override public void update(Observable observable,Object data){
  if (data != null && data.equals(MessageManager.OBSERVE_MESSAGE)) {
    updateDialogsList();
  }
}
Program: 114185
Project: 114185
Buggy source:
@Override public void onResume(){
  super.onResume();
  addObservers();
  Crouton.cancelAllCroutons();
  if (dialogsAdapter != null) {
    checkVisibilityEmptyLabel();
  }
}

Fixed version (ground truth):
@Override public void onResume(){
  super.onResume();
  addObservers();
  Crouton.cancelAllCroutons();
  if (dialogsAdapter != null) {
    checkVisibilityEmptyLabel();
  }
  if (dialogsAdapter != null) {
    dialogsAdapter.notifyDataSetChanged();
  }
}
Program: 114186
Project: 114186
Buggy source:
private void deleteObservers(){
  databaseManager.getDialogManager().deleteObserver(dialogObserver);
}

Fixed version (ground truth):
private void deleteObservers(){
  databaseManager.getDialogManager().deleteObserver(dialogObserver);
  databaseManager.getMessageManager().deleteObserver(messageObserver);
}
Program: 114187
Project: 114187
Buggy source:
private void initFields(){
  databaseManager=DatabaseManager.getInstance();
  dialogObserver=new DialogObserver();
}

Fixed version (ground truth):
private void initFields(){
  databaseManager=DatabaseManager.getInstance();
  dialogObserver=new DialogObserver();
  messageObserver=new MessageObserver();
}
Program: 114188
Project: 114188
Buggy source:
private void addObservers(){
  databaseManager.getDialogManager().addObserver(dialogObserver);
}

Fixed version (ground truth):
private void addObservers(){
  databaseManager.getDialogManager().addObserver(dialogObserver);
  databaseManager.getMessageManager().addObserver(messageObserver);
}
Program: 114189
Project: 114189
Buggy source:
@Override public Bundle perform(Bundle extras) throws Exception {
  QBDialog dialog=(QBDialog)extras.getSerializable(QBServiceConsts.EXTRA_DIALOG);
  File file=(File)extras.getSerializable(QBServiceConsts.EXTRA_FILE);
  if (file == null) {
    dialog=multiChatHelper.updateDialog(dialog);
  }
 else {
    dialog=multiChatHelper.updateDialog(dialog,file);
  }
  Bundle bundle=new Bundle();
  bundle.putSerializable(QBServiceConsts.EXTRA_DIALOG,dialog);
  return bundle;
}

Fixed version (ground truth):
@Override public Bundle perform(Bundle extras) throws Exception {
  QBDialog dialog=(QBDialog)extras.getSerializable(QBServiceConsts.EXTRA_DIALOG);
  File file=(File)extras.getSerializable(QBServiceConsts.EXTRA_FILE);
  if (file == null) {
    dialog=multiChatHelper.updateDialog(dialog);
  }
 else {
    dialog=multiChatHelper.updateDialog(dialog,file);
  }
  Bundle bundle=new Bundle();
  bundle.putSerializable(QBServiceConsts.EXTRA_DIALOG,ChatUtils.createLocalDialog(dialog));
  return bundle;
}
Program: 114190
Project: 114190
Buggy source:
protected Message parseReceivedMessage(QBChatMessage qbChatMessage){
  long createdDate=Long.parseLong(qbChatMessage.getProperty(ChatNotificationUtils.PROPERTY_DATE_SENT));
  String attachUrl=ChatUtils.getAttachUrlIfExists(qbChatMessage);
  String dialogId=qbChatMessage.getProperty(ChatNotificationUtils.PROPERTY_DIALOG_ID);
  Message message=new Message();
  message.setMessageId(qbChatMessage.getId());
  message.setBody(qbChatMessage.getBody());
  message.setCreatedDate(createdDate);
  DialogOccupant dialogOccupant=new DialogOccupant();
  Dialog dialog=databaseManager.getDialogManager().getByDialogId(dialogId);
  dialogOccupant.setDialog(dialog);
  User user=databaseManager.getUserManager().get(qbChatMessage.getSenderId());
  dialogOccupant.setUser(user);
  message.setDialogOccupant(dialogOccupant);
  if (qbChatMessage.getAttachments().size() != 0) {
    Attachment attachment=new Attachment();
    attachment.setType(Attachment.Type.PICTURE);
    attachment.setRemoteUrl(attachUrl);
    message.setAttachment(attachment);
  }
  return message;
}

Fixed version (ground truth):
protected Message parseReceivedMessage(QBChatMessage qbChatMessage){
  long createdDate=Long.parseLong(qbChatMessage.getProperty(ChatNotificationUtils.PROPERTY_DATE_SENT));
  String attachUrl=ChatUtils.getAttachUrlIfExists(qbChatMessage);
  String dialogId=qbChatMessage.getProperty(ChatNotificationUtils.PROPERTY_DIALOG_ID);
  Message message=new Message();
  message.setMessageId(qbChatMessage.getId());
  message.setBody(qbChatMessage.getBody());
  message.setCreatedDate(createdDate);
  DialogOccupant dialogOccupant=new DialogOccupant();
  Dialog dialog=databaseManager.getDialogManager().getByDialogId(dialogId);
  dialogOccupant.setDialog(dialog);
  User user=databaseManager.getUserManager().get(qbChatMessage.getSenderId());
  dialogOccupant.setUser(user);
  message.setDialogOccupant(dialogOccupant);
  if (qbChatMessage.getAttachments() != null && !qbChatMessage.getAttachments().isEmpty()) {
    Attachment attachment=new Attachment();
    attachment.setType(Attachment.Type.PICTURE);
    attachment.setRemoteUrl(attachUrl);
    message.setAttachment(attachment);
  }
  return message;
}
Program: 114191
Project: 114191
Buggy source:
protected void saveDialogNotificationToCache(String dialogId,DialogOccupant dialogOccupant,QBChatMessage qbChatMessage){
  DialogNotification dialogNotification=ChatUtils.createLocalDialogNotification(context,qbChatMessage,dialogOccupant);
  databaseManager.getDialogNotificationManager().createOrUpdate(dialogNotification);
}

Fixed version (ground truth):
protected void saveDialogNotificationToCache(DialogOccupant dialogOccupant,QBChatMessage qbChatMessage){
  DialogNotification dialogNotification=ChatUtils.createLocalDialogNotification(context,qbChatMessage,dialogOccupant);
  databaseManager.getDialogNotificationManager().createOrUpdate(dialogNotification);
}
Program: 114192
Project: 114192
Buggy source:
protected void saveMessageToCache(String dialogId,QBChatMessage qbChatMessage,State state){
  DialogOccupant dialogOccupant;
  if (qbChatMessage.getSenderId() == null) {
    dialogOccupant=databaseManager.getDialogOccupantManager().getDialogOccupant(dialogId,chatCreator.getId());
  }
 else {
    dialogOccupant=databaseManager.getDialogOccupantManager().getDialogOccupant(dialogId,qbChatMessage.getSenderId());
  }
  boolean isDialogNotification=qbChatMessage.getProperty(ChatNotificationUtils.PROPERTY_NOTIFICATION_TYPE) != null;
  if (isDialogNotification) {
    saveDialogNotificationToCache(dialogId,dialogOccupant,qbChatMessage);
  }
 else {
    Message message=ChatUtils.createLocalMessage(qbChatMessage,dialogOccupant,state);
    if (qbChatMessage.getAttachments() != null && !qbChatMessage.getAttachments().isEmpty()) {
      ArrayList<QBAttachment> attachmentsList=new ArrayList<QBAttachment>(qbChatMessage.getAttachments());
      Attachment attachment=ChatUtils.createLocalAttachment(attachmentsList.get(0));
      message.setAttachment(attachment);
      databaseManager.getAttachmentManager().createOrUpdate(attachment);
    }
    databaseManager.getMessageManager().createOrUpdate(message);
  }
}

Fixed version (ground truth):
protected void saveMessageToCache(String dialogId,QBChatMessage qbChatMessage,State state){
  DialogOccupant dialogOccupant;
  if (qbChatMessage.getSenderId() == null) {
    dialogOccupant=databaseManager.getDialogOccupantManager().getDialogOccupant(dialogId,chatCreator.getId());
  }
 else {
    dialogOccupant=databaseManager.getDialogOccupantManager().getDialogOccupant(dialogId,qbChatMessage.getSenderId());
  }
  boolean isDialogNotification=qbChatMessage.getProperty(ChatNotificationUtils.PROPERTY_NOTIFICATION_TYPE) != null;
  if (isDialogNotification) {
    saveDialogNotificationToCache(dialogOccupant,qbChatMessage);
  }
 else {
    Message message=ChatUtils.createLocalMessage(qbChatMessage,dialogOccupant,state);
    if (qbChatMessage.getAttachments() != null && !qbChatMessage.getAttachments().isEmpty()) {
      ArrayList<QBAttachment> attachmentsList=new ArrayList<QBAttachment>(qbChatMessage.getAttachments());
      Attachment attachment=ChatUtils.createLocalAttachment(attachmentsList.get(0));
      message.setAttachment(attachment);
      databaseManager.getAttachmentManager().createOrUpdate(attachment);
    }
    databaseManager.getMessageManager().createOrUpdate(message);
  }
}
Program: 114193
Project: 114193
Buggy source:
private void friendRequestMessageReceived(QBChatMessage qbChatMessage,DialogNotification.NotificationType notificationType){
  Message message=parseReceivedMessage(qbChatMessage);
  DialogNotification dialogNotification=ChatUtils.convertMessageToDialogNotification(message);
  dialogNotification.setNotificationType(notificationType);
  QBDialog dialog=ChatUtils.createQBDialogFromLocalDialog(DatabaseManager.getInstance().getDialogManager().getByDialogId(qbChatMessage.getDialogId()));
  if (dialog == null) {
    dialog=ChatNotificationUtils.parseDialogFromQBMessage(context,qbChatMessage,QBDialogType.PRIVATE);
    ArrayList<Integer> occupantsIdsList=ChatUtils.createOccupantsIdsFromPrivateMessage(chatCreator.getId(),qbChatMessage.getSenderId());
    dialog.setOccupantsIds(occupantsIdsList);
    saveDialogToCache(dialog);
  }
  DialogOccupant dialogOccupant=databaseManager.getDialogOccupantManager().getDialogOccupant(qbChatMessage.getDialogId(),qbChatMessage.getSenderId());
  saveDialogNotificationToCache(qbChatMessage.getDialogId(),dialogOccupant,qbChatMessage);
}

Fixed version (ground truth):
private void friendRequestMessageReceived(QBChatMessage qbChatMessage,DialogNotification.NotificationType notificationType){
  Message message=parseReceivedMessage(qbChatMessage);
  DialogNotification dialogNotification=ChatUtils.convertMessageToDialogNotification(message);
  dialogNotification.setNotificationType(notificationType);
  QBDialog dialog=ChatUtils.createQBDialogFromLocalDialog(DatabaseManager.getInstance().getDialogManager().getByDialogId(qbChatMessage.getDialogId()));
  if (dialog == null) {
    dialog=ChatNotificationUtils.parseDialogFromQBMessage(context,qbChatMessage,QBDialogType.PRIVATE);
    ArrayList<Integer> occupantsIdsList=ChatUtils.createOccupantsIdsFromPrivateMessage(chatCreator.getId(),qbChatMessage.getSenderId());
    dialog.setOccupantsIds(occupantsIdsList);
    saveDialogToCache(dialog);
  }
  DialogOccupant dialogOccupant=databaseManager.getDialogOccupantManager().getDialogOccupant(qbChatMessage.getDialogId(),qbChatMessage.getSenderId());
  saveDialogNotificationToCache(dialogOccupant,qbChatMessage);
}
Program: 114194
Project: 114194
Buggy source:
@Override public void bindView(View view,Context context,final Cursor cursor){
  final ViewHolder viewHolder=(ViewHolder)view.getTag();
  final User friend=UsersDatabaseManager.getUserFromCursor(cursor);
  viewHolder.nameTextView.setText(friend.getFullName());
  viewHolder.statusMessageTextView.setText(friend.getStatus());
  viewHolder.nameTextView.setText(friend.getFullName());
  if (friend.isOnline()) {
    viewHolder.onlineImageView.setVisibility(View.VISIBLE);
  }
 else {
    viewHolder.onlineImageView.setVisibility(View.GONE);
  }
  final int position=cursor.getPosition();
  viewHolder.selectFriendCheckBox.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      CheckBox checkBox=(CheckBox)view;
      sparseArrayCheckBoxes.put(position,checkBox.isChecked());
      friend.setSelected(checkBox.isChecked());
      notifyCounterChanged(checkBox.isChecked());
      if (checkBox.isChecked()) {
        selectedFriends.add(friend);
      }
 else       if (selectedFriends.contains(friend)) {
        selectedFriends.remove(friend);
      }
      viewHolder.contentRelativeLayout.setBackgroundColor(getBackgroundColorItem(viewHolder.selectFriendCheckBox.isChecked()));
    }
  }
);
  boolean checked=sparseArrayCheckBoxes.get(position);
  viewHolder.selectFriendCheckBox.setChecked(checked);
  String avatarUrl=getAvatarUrlForFriend(friend);
  displayAvatarImage(avatarUrl,viewHolder.avatarImageView);
  viewHolder.contentRelativeLayout.setBackgroundColor(getBackgroundColorItem(checked));
}

Fixed version (ground truth):
@Override public void bindView(View view,Context context,final Cursor cursor){
  final ViewHolder viewHolder=(ViewHolder)view.getTag();
  final User friend=UsersDatabaseManager.getUserFromCursor(cursor);
  viewHolder.nameTextView.setText(friend.getFullName());
  viewHolder.statusMessageTextView.setText(friend.getOnlineStatus(context));
  viewHolder.nameTextView.setText(friend.getFullName());
  if (friend.isOnline()) {
    viewHolder.onlineImageView.setVisibility(View.VISIBLE);
  }
 else {
    viewHolder.onlineImageView.setVisibility(View.GONE);
  }
  final int position=cursor.getPosition();
  viewHolder.selectFriendCheckBox.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      CheckBox checkBox=(CheckBox)view;
      sparseArrayCheckBoxes.put(position,checkBox.isChecked());
      friend.setSelected(checkBox.isChecked());
      notifyCounterChanged(checkBox.isChecked());
      if (checkBox.isChecked()) {
        selectedFriends.add(friend);
      }
 else       if (selectedFriends.contains(friend)) {
        selectedFriends.remove(friend);
      }
      viewHolder.contentRelativeLayout.setBackgroundColor(getBackgroundColorItem(viewHolder.selectFriendCheckBox.isChecked()));
    }
  }
);
  boolean checked=sparseArrayCheckBoxes.get(position);
  viewHolder.selectFriendCheckBox.setChecked(checked);
  String avatarUrl=getAvatarUrlForFriend(friend);
  displayAvatarImage(avatarUrl,viewHolder.avatarImageView);
  viewHolder.contentRelativeLayout.setBackgroundColor(getBackgroundColorItem(checked));
}
Program: 114195
Project: 114195
Buggy source:
@Override public View newView(Context context,Cursor cursor,ViewGroup parent){
  ViewHolder viewHolder;
  View view=layoutInflater.inflate(R.layout.list_item_chat_friend_selectable,null);
  viewHolder=new ViewHolder();
  viewHolder.contentRelativeLayout=(RelativeLayout)view.findViewById(R.id.contentRelativeLayout);
  viewHolder.avatarImageView=(RoundedImageView)view.findViewById(R.id.avatar_imageview);
  viewHolder.nameTextView=(TextView)view.findViewById(R.id.name_textview);
  viewHolder.onlineImageView=(ImageView)view.findViewById(R.id.online_imageview);
  viewHolder.statusMessageTextView=(TextView)view.findViewById(R.id.statusMessageTextView);
  viewHolder.selectFriendCheckBox=(CheckBox)view.findViewById(R.id.selected_friend_checkbox);
  view.setTag(viewHolder);
  return view;
}

Fixed version (ground truth):
@Override public View newView(Context context,Cursor cursor,ViewGroup parent){
  ViewHolder viewHolder;
  View view=layoutInflater.inflate(R.layout.list_item_chat_friend_selectable,null);
  viewHolder=new ViewHolder();
  viewHolder.contentRelativeLayout=(RelativeLayout)view.findViewById(R.id.contentRelativeLayout);
  viewHolder.avatarImageView=(RoundedImageView)view.findViewById(R.id.avatar_imageview);
  viewHolder.nameTextView=(TextView)view.findViewById(R.id.name_textview);
  viewHolder.onlineImageView=(ImageView)view.findViewById(R.id.online_imageview);
  viewHolder.statusMessageTextView=(TextView)view.findViewById(R.id.status_textview);
  viewHolder.selectFriendCheckBox=(CheckBox)view.findViewById(R.id.selected_friend_checkbox);
  view.setTag(viewHolder);
  return view;
}
Program: 114196
Project: 114196
Buggy source:
protected GroupDialogOccupantsAdapter getFriendsAdapter(){
  return new GroupDialogOccupantsAdapter(this,groupDialog.getOccupantList());
}

Fixed version (ground truth):
protected GroupDialogOccupantsAdapter getFriendsAdapter(){
  return new GroupDialogOccupantsAdapter(this,friendOperationAction,groupDialog.getOccupantList());
}
Program: 114197
Project: 114197
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_group_dialog_details);
  dialogId=(String)getIntent().getExtras().getSerializable(QBServiceConsts.EXTRA_DIALOG_ID);
  currentDialog=ChatDatabaseManager.getDialogByDialogId(this,dialogId);
  groupDialog=new GroupDialog(currentDialog);
  imageUtils=new ImageUtils(this);
  initUI();
  initUIWithData();
  addActions();
  startLoadGroupDialog();
  currentNotificationTypeList=new ArrayList<MessagesNotificationType>();
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_group_dialog_details);
  dialogId=(String)getIntent().getExtras().getSerializable(QBServiceConsts.EXTRA_DIALOG_ID);
  currentDialog=ChatDatabaseManager.getDialogByDialogId(this,dialogId);
  groupDialog=new GroupDialog(currentDialog);
  imageUtils=new ImageUtils(this);
  friendOperationAction=new FriendOperationAction();
  initUI();
  initUIWithData();
  addActions();
  startLoadGroupDialog();
  currentNotificationTypeList=new ArrayList<MessagesNotificationType>();
}
Program: 114198
Project: 114198
Buggy source:
private void addActions(){
  UpdateGroupFailAction updateGroupFailAction=new UpdateGroupFailAction();
  addAction(QBServiceConsts.LOAD_GROUP_DIALOG_SUCCESS_ACTION,new LoadGroupDialogSuccessAction());
  addAction(QBServiceConsts.LOAD_GROUP_DIALOG_FAIL_ACTION,failAction);
  addAction(QBServiceConsts.LEAVE_GROUP_DIALOG_SUCCESS_ACTION,new LeaveGroupDialogSuccessAction());
  addAction(QBServiceConsts.LEAVE_GROUP_DIALOG_FAIL_ACTION,failAction);
  addAction(QBServiceConsts.UPDATE_GROUP_DIALOG_SUCCESS_ACTION,new UpdateGroupDialogSuccessAction());
  addAction(QBServiceConsts.UPDATE_GROUP_DIALOG_FAIL_ACTION,updateGroupFailAction);
  updateBroadcastActionList();
}

Fixed version (ground truth):
private void addActions(){
  UpdateGroupFailAction updateGroupFailAction=new UpdateGroupFailAction();
  addAction(QBServiceConsts.LOAD_GROUP_DIALOG_SUCCESS_ACTION,new LoadGroupDialogSuccessAction());
  addAction(QBServiceConsts.LOAD_GROUP_DIALOG_FAIL_ACTION,failAction);
  addAction(QBServiceConsts.LEAVE_GROUP_DIALOG_SUCCESS_ACTION,new LeaveGroupDialogSuccessAction());
  addAction(QBServiceConsts.LEAVE_GROUP_DIALOG_FAIL_ACTION,failAction);
  addAction(QBServiceConsts.UPDATE_GROUP_DIALOG_SUCCESS_ACTION,new UpdateGroupDialogSuccessAction());
  addAction(QBServiceConsts.UPDATE_GROUP_DIALOG_FAIL_ACTION,updateGroupFailAction);
  addAction(QBServiceConsts.ADD_FRIEND_SUCCESS_ACTION,new AddFriendSuccessAction());
  addAction(QBServiceConsts.ADD_FRIEND_FAIL_ACTION,failAction);
  updateBroadcastActionList();
}
Program: 114199
Project: 114199
Buggy source:
private void setOnlineStatusVisibility(ViewHolder viewHolder,User user){
  if (isMe(user)) {
    user.setOnline(true);
  }
  viewHolder.onlineStatusMessageTextView.setText(user.getOnlineStatus(baseActivity));
  if (user.isOnline()) {
    viewHolder.onlineImageView.setVisibility(View.VISIBLE);
  }
 else {
    viewHolder.onlineImageView.setVisibility(View.GONE);
  }
}

Fixed version (ground truth):
private void setOnlineStatusVisibility(ViewHolder viewHolder,User user){
  if (isMe(user)) {
    user.setOnline(true);
  }
  viewHolder.onlineStatusTextView.setText(user.getOnlineStatus(baseActivity));
  if (user.isOnline()) {
    viewHolder.onlineImageView.setVisibility(View.VISIBLE);
  }
 else {
    viewHolder.onlineImageView.setVisibility(View.GONE);
  }
}
Program: 114200
Project: 114200
Buggy source:
private boolean isFriend(User user){
  return user.getFullName() != null;
}

Fixed version (ground truth):
private boolean isFriend(User user){
  boolean isFriend;
  isFriend=isMe(user) ? true : UsersDatabaseManager.isFriendInBaseWithPending(baseActivity,user.getUserId());
  return isFriend;
}
Program: 114201
Project: 114201
Buggy source:
@Override public View getView(int position,View convertView,ViewGroup parent){
  ViewHolder viewHolder;
  User user=getItem(position);
  if (convertView == null) {
    convertView=layoutInflater.inflate(R.layout.list_item_dialog_friend,null);
    viewHolder=new ViewHolder();
    viewHolder.avatarImageView=(RoundedImageView)convertView.findViewById(R.id.avatar_imageview);
    viewHolder.nameTextView=(TextView)convertView.findViewById(R.id.name_textview);
    viewHolder.onlineImageView=(ImageView)convertView.findViewById(R.id.online_imageview);
    viewHolder.onlineStatusMessageTextView=(TextView)convertView.findViewById(R.id.statusMessageTextView);
    convertView.setTag(viewHolder);
  }
 else {
    viewHolder=(ViewHolder)convertView.getTag();
  }
  String fullName;
  if (isFriend(user)) {
    fullName=user.getFullName();
    viewHolder.onlineStatusMessageTextView.setVisibility(View.VISIBLE);
  }
 else {
    fullName=String.valueOf(user.getUserId());
    viewHolder.onlineStatusMessageTextView.setVisibility(View.GONE);
  }
  viewHolder.nameTextView.setText(fullName);
  setOnlineStatusVisibility(viewHolder,user);
  displayImage(user.getAvatarUrl(),viewHolder.avatarImageView);
  return convertView;
}

Fixed version (ground truth):
@Override public View getView(int position,View convertView,ViewGroup parent){
  ViewHolder viewHolder;
  User user=getItem(position);
  if (convertView == null) {
    convertView=layoutInflater.inflate(R.layout.list_item_dialog_friend,null);
    viewHolder=new ViewHolder();
    viewHolder.avatarImageView=(RoundedImageView)convertView.findViewById(R.id.avatar_imageview);
    viewHolder.nameTextView=(TextView)convertView.findViewById(R.id.name_textview);
    viewHolder.onlineImageView=(ImageView)convertView.findViewById(R.id.online_imageview);
    viewHolder.onlineStatusTextView=(TextView)convertView.findViewById(R.id.status_textview);
    viewHolder.addFriendImageView=(ImageView)convertView.findViewById(R.id.add_friend_imagebutton);
    convertView.setTag(viewHolder);
  }
 else {
    viewHolder=(ViewHolder)convertView.getTag();
  }
  String fullName;
  if (isFriendValid(user)) {
    fullName=user.getFullName();
    viewHolder.onlineStatusTextView.setVisibility(View.VISIBLE);
  }
 else {
    fullName=String.valueOf(user.getUserId());
    viewHolder.onlineStatusTextView.setVisibility(View.GONE);
  }
  viewHolder.nameTextView.setText(fullName);
  setOnlineStatusVisibility(viewHolder,user);
  viewHolder.addFriendImageView.setVisibility(isFriend(user) ? View.GONE : View.VISIBLE);
  initListeners(viewHolder,user.getUserId());
  displayImage(user.getAvatarUrl(),viewHolder.avatarImageView);
  return convertView;
}
Program: 114202
Project: 114202
Buggy source:
public GroupDialogOccupantsAdapter(BaseActivity baseActivity,List<User> objectsList){
  super(baseActivity,objectsList);
}

Fixed version (ground truth):
public GroupDialogOccupantsAdapter(BaseActivity baseActivity,FriendOperationListener friendOperationListener,List<User> objectsList){
  super(baseActivity,objectsList);
  this.friendOperationListener=friendOperationListener;
}
Program: 114203
Project: 114203
Buggy source:
private void setName(){
  nameTextView.setText(friend.getFullName());
}

Fixed version (ground truth):
private void setName(){
  nameTextView.setText(user.getFullName());
}
Program: 114204
Project: 114204
Buggy source:
private void initUI(){
  avatarImageView=_findViewById(R.id.avatar_imageview);
  nameTextView=_findViewById(R.id.name_textview);
  onlineImageView=_findViewById(R.id.online_imageview);
  onlineStatusTextView=_findViewById(R.id.online_status_textview);
  phoneTextView=_findViewById(R.id.phone_textview);
  phoneView=_findViewById(R.id.phone_relativelayout);
}

Fixed version (ground truth):
private void initUI(){
  avatarImageView=_findViewById(R.id.avatar_imageview);
  nameTextView=_findViewById(R.id.name_textview);
  statusTextView=_findViewById(R.id.status_textview);
  onlineImageView=_findViewById(R.id.online_imageview);
  onlineStatusTextView=_findViewById(R.id.online_status_textview);
  phoneTextView=_findViewById(R.id.phone_textview);
  phoneView=_findViewById(R.id.phone_relativelayout);
}
Program: 114205
Project: 114205
Buggy source:
public void voiceCallClickListener(View view){
  callToUser(friend,com.quickblox.videochat.webrtc.Consts.MEDIA_STREAM.AUDIO);
}

Fixed version (ground truth):
public void voiceCallClickListener(View view){
  callToUser(user,com.quickblox.videochat.webrtc.Consts.MEDIA_STREAM.AUDIO);
}
Program: 114206
Project: 114206
Buggy source:
public void chatClickListener(View view){
  if (checkFriendStatus(friend.getUserId())) {
    try {
      QBDialog existingPrivateDialog=privateChatHelper.createPrivateDialogIfNotExist(friend.getUserId());
      PrivateDialogActivity.start(FriendDetailsActivity.this,friend,existingPrivateDialog);
    }
 catch (    QBResponseException e) {
      ErrorUtils.showError(this,e);
    }
  }
}

Fixed version (ground truth):
public void chatClickListener(View view){
  if (checkFriendStatus(user.getUserId())) {
    try {
      QBDialog existingPrivateDialog=privateChatHelper.createPrivateDialogIfNotExist(user.getUserId());
      PrivateDialogActivity.start(FriendDetailsActivity.this,user,existingPrivateDialog);
    }
 catch (    QBResponseException e) {
      ErrorUtils.showError(this,e);
    }
  }
}
Program: 114207
Project: 114207
Buggy source:
private void loadAvatar(){
  String url=friend.getAvatarUrl();
  ImageLoader.getInstance().displayImage(url,avatarImageView,Consts.UIL_USER_AVATAR_DISPLAY_OPTIONS);
}

Fixed version (ground truth):
private void loadAvatar(){
  String url=user.getAvatarUrl();
  ImageLoader.getInstance().displayImage(url,avatarImageView,Consts.UIL_USER_AVATAR_DISPLAY_OPTIONS);
}
Program: 114208
Project: 114208
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_friend_details);
  canPerformLogout.set(true);
  int friendId=getIntent().getExtras().getInt(QBServiceConsts.EXTRA_FRIEND_ID);
  friendCursor=UsersDatabaseManager.getFriendCursorById(this,friendId);
  friend=UsersDatabaseManager.getUserById(this,friendId);
  initUI();
  registerStatusChangingObserver();
  initUIWithFriendsData();
  initBroadcastActionList();
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_friend_details);
  canPerformLogout.set(true);
  int friendId=getIntent().getExtras().getInt(QBServiceConsts.EXTRA_FRIEND_ID);
  friendCursor=UsersDatabaseManager.getFriendCursorById(this,friendId);
  user=UsersDatabaseManager.getUserById(this,friendId);
  initUI();
  registerStatusChangingObserver();
  initUIWithFriendsData();
  initBroadcastActionList();
}
Program: 114209
Project: 114209
Buggy source:
@Override public void onChange(boolean selfChange){
  if (FriendDetailsActivity.this.friend != null) {
    friend=UsersDatabaseManager.getUserById(FriendDetailsActivity.this,FriendDetailsActivity.this.friend.getUserId());
    setOnlineStatus(friend);
  }
}

Fixed version (ground truth):
@Override public void onChange(boolean selfChange){
  if (FriendDetailsActivity.this.user != null) {
    user=UsersDatabaseManager.getUserById(FriendDetailsActivity.this,FriendDetailsActivity.this.user.getUserId());
    setOnlineStatus(user);
  }
}
Program: 114210
Project: 114210
Buggy source:
private void deleteDialog(){
  String dialogId=ChatDatabaseManager.getPrivateDialogIdByOpponentId(this,friend.getUserId());
  QBDeleteDialogCommand.start(this,dialogId,QBDialogType.PRIVATE);
}

Fixed version (ground truth):
private void deleteDialog(){
  String dialogId=ChatDatabaseManager.getPrivateDialogIdByOpponentId(this,user.getUserId());
  QBDeleteDialogCommand.start(this,dialogId,QBDialogType.PRIVATE);
}
Program: 114211
Project: 114211
Buggy source:
private void setPhone(){
  if (friend.getPhone() != null) {
    phoneView.setVisibility(View.VISIBLE);
  }
 else {
    phoneView.setVisibility(View.GONE);
  }
  phoneTextView.setText(friend.getPhone());
}

Fixed version (ground truth):
private void setPhone(){
  if (user.getPhone() != null) {
    phoneView.setVisibility(View.VISIBLE);
  }
 else {
    phoneView.setVisibility(View.GONE);
  }
  phoneTextView.setText(user.getPhone());
}
Program: 114212
Project: 114212
Buggy source:
@Override public void execute(Bundle bundle){
  deleteDialog();
  DialogUtils.showLong(FriendDetailsActivity.this,getString(R.string.dlg_friend_removed,friend.getFullName()));
  finish();
}

Fixed version (ground truth):
@Override public void execute(Bundle bundle){
  deleteDialog();
  DialogUtils.showLong(FriendDetailsActivity.this,getString(R.string.dlg_friend_removed,user.getFullName()));
  finish();
}
Program: 114213
Project: 114213
Buggy source:
private void showRemoveUserDialog(){
  AlertDialog alertDialog=AlertDialog.newInstance(getResources().getString(R.string.frd_dlg_remove_friend,friend.getFullName()));
  alertDialog.setPositiveButton(new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      showProgress();
      QBRemoveFriendCommand.start(FriendDetailsActivity.this,friend.getUserId());
    }
  }
);
  alertDialog.setNegativeButton(new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
    }
  }
);
  alertDialog.show(getFragmentManager(),null);
}

Fixed version (ground truth):
private void showRemoveUserDialog(){
  AlertDialog alertDialog=AlertDialog.newInstance(getResources().getString(R.string.frd_dlg_remove_friend,user.getFullName()));
  alertDialog.setPositiveButton(new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      showProgress();
      QBRemoveFriendCommand.start(FriendDetailsActivity.this,user.getUserId());
    }
  }
);
  alertDialog.setNegativeButton(new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
    }
  }
);
  alertDialog.show(getFragmentManager(),null);
}
Program: 114214
Project: 114214
Buggy source:
public void videoCallClickListener(View view){
  callToUser(friend,com.quickblox.videochat.webrtc.Consts.MEDIA_STREAM.VIDEO);
}

Fixed version (ground truth):
public void videoCallClickListener(View view){
  callToUser(user,com.quickblox.videochat.webrtc.Consts.MEDIA_STREAM.VIDEO);
}
Program: 114215
Project: 114215
Buggy source:
private void registerStatusChangingObserver(){
  statusContentObserver=new ContentObserver(new Handler()){
    @Override public boolean deliverSelfNotifications(){
      return true;
    }
    @Override public void onChange(    boolean selfChange){
      if (FriendDetailsActivity.this.friend != null) {
        friend=UsersDatabaseManager.getUserById(FriendDetailsActivity.this,FriendDetailsActivity.this.friend.getUserId());
        setOnlineStatus(friend);
      }
    }
  }
;
  friendCursor.registerContentObserver(statusContentObserver);
}

Fixed version (ground truth):
private void registerStatusChangingObserver(){
  statusContentObserver=new ContentObserver(new Handler()){
    @Override public boolean deliverSelfNotifications(){
      return true;
    }
    @Override public void onChange(    boolean selfChange){
      if (FriendDetailsActivity.this.user != null) {
        user=UsersDatabaseManager.getUserById(FriendDetailsActivity.this,FriendDetailsActivity.this.user.getUserId());
        setOnlineStatus(user);
      }
    }
  }
;
  friendCursor.registerContentObserver(statusContentObserver);
}
Program: 114216
Project: 114216
Buggy source:
private void initUIWithFriendsData(){
  loadAvatar();
  setName();
  setOnlineStatus(friend);
  setPhone();
}

Fixed version (ground truth):
private void initUIWithFriendsData(){
  loadAvatar();
  setName();
  setOnlineStatus(user);
  setStatus();
  setPhone();
}
Program: 114217
Project: 114217
Buggy source:
@Override public View getGroupView(int groupPosition,boolean isLastChild,View view,ViewGroup parent){
  FriendGroup friendGroup=(FriendGroup)getGroup(groupPosition);
  if (view == null) {
    view=layoutInflater.inflate(R.layout.view_section_title_friends_list,null);
  }
  TextView headerName=(TextView)view.findViewById(R.id.list_title_textview);
  headerName.setText(friendGroup.getHeaderName());
  view.setVisibility(friendGroup.getUserList().isEmpty() ? View.GONE : View.VISIBLE);
  return view;
}

Fixed version (ground truth):
@Override public View getGroupView(int groupPosition,boolean isLastChild,View view,ViewGroup parent){
  FriendGroup friendGroup=(FriendGroup)getGroup(groupPosition);
  View hiddenView=new FrameLayout(context);
  if (friendGroup.getUserList().isEmpty()) {
    return hiddenView;
  }
 else {
    view=layoutInflater.inflate(R.layout.view_section_title_friends_list,null);
  }
  TextView headerName=(TextView)view.findViewById(R.id.list_title_textview);
  headerName.setText(friendGroup.getHeaderName());
  return view;
}
Program: 114218
Project: 114218
Buggy source:
private void checkVisibilityItemsMyContacts(ViewHolder viewHolder,User user){
  String status=null;
  Friend friend=UsersDatabaseManager.getFriendById(context,user.getUserId());
  String relationStatus=friend.getRelationStatus();
  boolean isAddedFriend;
  isAddedFriend=relationStatus.equals(QBFriendListHelper.RELATION_STATUS_NONE) && friend.isPendingStatus();
  if (isAddedFriend) {
    viewHolder.onlineImageView.setVisibility(View.GONE);
    status=resources.getString(R.string.frl_pending_request_status);
  }
  viewHolder.addFriendImageView.setVisibility(View.GONE);
  viewHolder.statusTextView.setText(status);
  viewHolder.statusTextView.setVisibility(View.VISIBLE);
  setStatusVisibility(viewHolder,user.isOnline());
}

Fixed version (ground truth):
private void checkVisibilityItemsMyContacts(ViewHolder viewHolder,User user){
  String status=null;
  Friend friend=UsersDatabaseManager.getFriendById(context,user.getUserId());
  if (friend == null) {
    return;
  }
  String relationStatus=friend.getRelationStatus();
  boolean isAddedFriend;
  isAddedFriend=relationStatus.equals(QBFriendListHelper.RELATION_STATUS_NONE) && friend.isPendingStatus();
  if (isAddedFriend) {
    viewHolder.onlineImageView.setVisibility(View.GONE);
    status=resources.getString(R.string.frl_pending_request_status);
  }
  viewHolder.addFriendImageView.setVisibility(View.GONE);
  viewHolder.statusTextView.setText(status);
  viewHolder.statusTextView.setVisibility(View.VISIBLE);
  setStatusVisibility(viewHolder,user.isOnline());
}