nus-yam/ex-repair huggingface dataset:
Program: 114539
Project: 114539
Buggy source:
@Override public boolean onMenuItemActionCollapse(MenuItem item){
  state=State.FRIENDS_LIST;
  baseActivity.getActionBar().setDisplayShowHomeEnabled(true);
  if (isHideSearchView) {
    isHideSearchView=false;
    friendsListAdapter.setSearchCharacters(null);
    friendsListAdapter.setFilterQueryProvider(null);
    friendsListView.removeFooterView(globalSearchLayout);
    friendsListView.removeHeaderView(friendsListViewTitle);
    positionCounter--;
    initFriendsList();
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onMenuItemActionCollapse(MenuItem item){
  state=State.FRIENDS_LIST;
  baseActivity.getActionBar().setDisplayShowHomeEnabled(true);
  if (isNeedToHideSearchView) {
    isNeedToHideSearchView=false;
    friendsListAdapter.setSearchCharacters(null);
    friendsListAdapter.setFilterQueryProvider(null);
    friendsListView.removeFooterView(globalSearchLayout);
    friendsListView.removeHeaderView(friendsListViewTitle);
    positionCounter--;
    initFriendsList();
  }
  return true;
}
Program: 114540
Project: 114540
Buggy source:
private void initFriendsList(){
  if (friendsCursor != null && !friendsCursor.isClosed()) {
    friendsCursor.close();
  }
  friendsCursor=getAllFriends();
  friendsListAdapter=new FriendsListCursorAdapter(baseActivity,friendsCursor);
  friendsListView.setAdapter(friendsListAdapter);
  friendsListView.setSelector(R.drawable.list_item_background_selector);
  friendsListView.setOnItemClickListener(this);
  if (isFriendsListLoaded) {
    checkVisibilityEmptyLabel();
  }
}

Fixed version (ground truth):
private void initFriendsList(){
  if (friendsCursor != null && !friendsCursor.isClosed()) {
    friendsCursor.close();
  }
  friendsCursor=getAllFriends();
  friendsListAdapter=new FriendsListCursorAdapter(baseActivity,friendsCursor);
  friendsListView.setAdapter(friendsListAdapter);
  friendsListView.setSelector(R.drawable.list_item_background_selector);
  friendsListView.setOnItemClickListener(this);
  friendsListAdapter.registerDataSetObserver(new DataSetObserver(){
    @Override public void onChanged(){
      super.onChanged();
      if (state.equals(State.GLOBAL_LIST) && isNeedToHideSearchView) {
        checkVisibilityEmptyLabel();
      }
    }
  }
);
  if (isFriendsListLoaded) {
    checkVisibilityEmptyLabel();
  }
}
Program: 114541
Project: 114541
Buggy source:
@Override public boolean onMenuItemActionExpand(MenuItem item){
  isHideSearchView=true;
  emptyListTextView.setVisibility(View.GONE);
  return true;
}

Fixed version (ground truth):
@Override public boolean onMenuItemActionExpand(MenuItem item){
  isNeedToHideSearchView=true;
  emptyListTextView.setVisibility(View.GONE);
  return true;
}
Program: 114542
Project: 114542
Buggy source:
@Override public boolean onQueryTextChange(String newText){
  constraint=newText;
  friendsListAdapter.setFilterQueryProvider(this);
  if (state == State.FRIENDS_LIST && isHideSearchView) {
    friendsListAdapter.getFilter().filter(newText);
    friendsListAdapter.setSearchCharacters(newText);
  }
 else   if (state == State.GLOBAL_LIST) {
    startUsersListLoader(newText);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onQueryTextChange(String newText){
  constraint=newText;
  friendsListAdapter.setFilterQueryProvider(this);
  if (state == State.FRIENDS_LIST && isNeedToHideSearchView) {
    friendsListAdapter.getFilter().filter(newText);
    friendsListAdapter.setSearchCharacters(newText);
  }
 else   if (state == State.GLOBAL_LIST) {
    startUsersListLoader(newText);
  }
  return true;
}
Program: 114543
Project: 114543
Buggy source:
@Override protected void onResume(){
  super.onResume();
  gsmHelper.checkPlayServices();
  addActions();
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  gsmHelper.checkPlayServices();
}
Program: 114544
Project: 114544
Buggy source:
public static void saveChatMessages(Context context,List<QBHistoryMessage> messagesList,String roomJidId,boolean isPrivate){
  for (  QBHistoryMessage historyMessage : messagesList) {
    String message=historyMessage.getBody();
    int senderId=historyMessage.getSenderId();
    String attachURL;
    if (TextUtils.isEmpty(message)) {
      attachURL=ChatUtils.getAttachUrlFromMessage(historyMessage.getAttachments());
    }
 else {
      attachURL=Consts.EMPTY_STRING;
    }
    if (TextUtils.isEmpty(message) && TextUtils.isEmpty(attachURL)) {
      message=getMessageForNotification(context,senderId);
    }
    DialogMessageCache dialogMessageCache=new DialogMessageCache(roomJidId,senderId,message,attachURL,historyMessage.getDateSent(),true);
    saveChatMessage(context,dialogMessageCache);
  }
}

Fixed version (ground truth):
public static void saveChatMessages(Context context,List<QBHistoryMessage> messagesList,String roomJidId,boolean isPrivate){
  for (  QBHistoryMessage historyMessage : messagesList) {
    String message=historyMessage.getBody();
    int senderId=historyMessage.getSenderId();
    String attachURL;
    if (TextUtils.isEmpty(message)) {
      attachURL=ChatUtils.getAttachUrlFromMessage(historyMessage.getAttachments());
    }
 else {
      attachURL=Consts.EMPTY_STRING;
    }
    DialogMessageCache dialogMessageCache=new DialogMessageCache(roomJidId,senderId,message,attachURL,historyMessage.getDateSent(),true);
    saveChatMessage(context,dialogMessageCache);
  }
}
Program: 114545
Project: 114545
Buggy source:
private void notifyFriendAboutInvitation(QBDialog dialog,Integer friendId) throws XMPPException, SmackException {
  long time=DateUtils.getCurrentTime();
  QBPrivateChat chat=privateChatManager.createChat(friendId,privateChatMessageListener);
  QBChatMessage chatMessage=ChatUtils.createRoomNotificationMessage(dialog);
  chatMessage.setProperty(propertyDateSent,time + Consts.EMPTY_STRING);
  chatMessage.setProperty(propertySaveToHistory,valuePropertySaveToHistory);
  chat.sendMessage(chatMessage);
}

Fixed version (ground truth):
private void notifyFriendAboutInvitation(QBDialog dialog,Integer friendId) throws XMPPException, SmackException {
  long time=DateUtils.getCurrentTime();
  QBUser user=App.getInstance().getUser();
  QBPrivateChat chat=privateChatManager.createChat(friendId,privateChatMessageListener);
  QBChatMessage chatMessage=ChatUtils.createRoomNotificationMessage(dialog);
  chatMessage.setBody(context.getResources().getString(R.string.user_created_room,user.getFullName()));
  chatMessage.setProperty(propertyDateSent,time + Consts.EMPTY_STRING);
  chatMessage.setProperty(propertySaveToHistory,valuePropertySaveToHistory);
  chatMessage.setProperty(propertyNotificationTypeCreating,valuePropertyNotificationTypeCreating);
  chat.sendMessage(chatMessage);
}
Program: 114546
Project: 114546
Buggy source:
@Override public boolean onMenuItemActionCollapse(MenuItem item){
  state=State.FRIENDS_LIST;
  baseActivity.getActionBar().setDisplayShowHomeEnabled(true);
  emptyListTextView.setVisibility(friendsListAdapter.isEmpty() ? View.VISIBLE : View.GONE);
  if (isHideSearchView) {
    isHideSearchView=false;
    friendsListAdapter.setSearchCharacters(null);
    friendsListAdapter.setFilterQueryProvider(null);
    friendsListView.removeFooterView(globalSearchLayout);
    friendsListView.removeHeaderView(friendsListViewTitle);
    positionCounter--;
    initFriendsList();
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onMenuItemActionCollapse(MenuItem item){
  state=State.FRIENDS_LIST;
  baseActivity.getActionBar().setDisplayShowHomeEnabled(true);
  if (isHideSearchView) {
    isHideSearchView=false;
    friendsListAdapter.setSearchCharacters(null);
    friendsListAdapter.setFilterQueryProvider(null);
    friendsListView.removeFooterView(globalSearchLayout);
    friendsListView.removeHeaderView(friendsListViewTitle);
    positionCounter--;
    initFriendsList();
  }
  return true;
}
Program: 114547
Project: 114547
Buggy source:
private void initFriendsList(){
  if (friendsCursor != null && !friendsCursor.isClosed()) {
    friendsCursor.close();
  }
  friendsCursor=getAllFriends();
  friendsListAdapter=new FriendsListCursorAdapter(baseActivity,friendsCursor);
  friendsListView.setAdapter(friendsListAdapter);
  friendsListView.setSelector(R.drawable.list_item_background_selector);
  friendsListView.setOnItemClickListener(this);
}

Fixed version (ground truth):
private void initFriendsList(){
  if (friendsCursor != null && !friendsCursor.isClosed()) {
    friendsCursor.close();
  }
  friendsCursor=getAllFriends();
  friendsListAdapter=new FriendsListCursorAdapter(baseActivity,friendsCursor);
  friendsListView.setAdapter(friendsListAdapter);
  friendsListView.setSelector(R.drawable.list_item_background_selector);
  friendsListView.setOnItemClickListener(this);
  if (isFriendsListLoaded) {
    checkVisibilityEmptyLabel();
  }
}
Program: 114548
Project: 114548
Buggy source:
@Override public void execute(Bundle bundle){
  if (getActivity() != null) {
    emptyListTextView.setVisibility(friendsListAdapter.isEmpty() ? View.VISIBLE : View.GONE);
  }
}

Fixed version (ground truth):
@Override public void execute(Bundle bundle){
  isFriendsListLoaded=true;
  if (baseActivity != null) {
    emptyListTextView.setVisibility(friendsListAdapter.isEmpty() ? View.VISIBLE : View.GONE);
  }
}
Program: 114549
Project: 114549
Buggy source:
private void initUI(View view){
  setHasOptionsMenu(true);
  dialogsListView=(ListView)view.findViewById(R.id.chats_listview);
}

Fixed version (ground truth):
private void initUI(View view){
  setHasOptionsMenu(true);
  dialogsListView=(ListView)view.findViewById(R.id.chats_listview);
  emptyListTextView=(TextView)view.findViewById(R.id.empty_list_textview);
}
Program: 114550
Project: 114550
Buggy source:
@Override public void onResume(){
  Crouton.cancelAllCroutons();
  super.onResume();
}

Fixed version (ground truth):
@Override public void onResume(){
  Crouton.cancelAllCroutons();
  checkVisibilityEmptyLabel();
  super.onResume();
}
Program: 114551
Project: 114551
Buggy source:
@Override public Bundle perform(Bundle extras) throws Exception {
  try {
    authHelper.logout();
  }
 catch (  QBResponseException e) {
    e.printStackTrace();
  }
  return extras;
}

Fixed version (ground truth):
@Override public Bundle perform(Bundle extras) throws Exception {
  authHelper.logout();
  return extras;
}
Program: 114552
Project: 114552
Buggy source:
@Override public View getView(int position,View convertView,ViewGroup parent){
  ViewHolder holder;
  final String data=getItem(position);
  String chatItem=resources.getStringArray(R.array.nvd_items_array)[MainActivity.ID_CHATS_LIST_FRAGMENT];
  if (convertView == null) {
    convertView=layoutInflater.inflate(R.layout.list_item_navigation_drawer,null);
    holder=new ViewHolder();
    holder.nameTextView=(TextView)convertView.findViewById(R.id.name_textview);
    holder.unreadMessagesTextView=(TextView)convertView.findViewById(R.id.unread_messages_textview);
    convertView.setTag(holder);
  }
 else {
    holder=(ViewHolder)convertView.getTag();
  }
  if (data.equals(chatItem)) {
    counterUnreadChatsDialogs=holder.unreadMessagesTextView;
  }
  holder.nameTextView.setText(data);
  return convertView;
}

Fixed version (ground truth):
@Override public View getView(int position,View convertView,ViewGroup parent){
  final ViewHolder holder;
  final String data=getItem(position);
  String chatItem=resources.getStringArray(R.array.nvd_items_array)[MainActivity.ID_CHATS_LIST_FRAGMENT];
  if (convertView == null) {
    convertView=layoutInflater.inflate(R.layout.list_item_navigation_drawer,null);
    holder=new ViewHolder();
    holder.nameTextView=(TextView)convertView.findViewById(R.id.name_textview);
    holder.unreadMessagesTextView=(TextView)convertView.findViewById(R.id.unread_messages_textview);
    convertView.setTag(holder);
  }
 else {
    holder=(ViewHolder)convertView.getTag();
  }
  if (data.equals(chatItem)) {
    int count=getCounterUnreadDialogs();
    holder.unreadMessagesTextView.setText(count + Consts.EMPTY_STRING);
    if (count > Consts.ZERO_INT_VALUE) {
      holder.unreadMessagesTextView.setVisibility(View.VISIBLE);
    }
 else {
      holder.unreadMessagesTextView.setVisibility(View.GONE);
    }
  }
  holder.nameTextView.setText(data);
  return convertView;
}
Program: 114553
Project: 114553
Buggy source:
@Override public void onDrawerOpened(View drawerView){
  super.onDrawerOpened(drawerView);
  Crouton.cancelAllCroutons();
  baseActivity.invalidateOptionsMenu();
  if (!userLearnedDrawer) {
    userLearnedDrawer=true;
    saveUserLearnedDrawer();
  }
  updateCountUnreadDialogsListener.onUpdateCountUnreadDialogs(getCounterUnreadDialogs());
}

Fixed version (ground truth):
@Override public void onDrawerOpened(View drawerView){
  super.onDrawerOpened(drawerView);
  Crouton.cancelAllCroutons();
  baseActivity.invalidateOptionsMenu();
  if (!userLearnedDrawer) {
    userLearnedDrawer=true;
    saveUserLearnedDrawer();
  }
}
Program: 114554
Project: 114554
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View rootView=inflater.inflate(R.layout.fragment_navigation_drawer,container,false);
  initUI(rootView);
  initListeners();
  NavigationDrawerAdapter navigationDrawerAdapter=new NavigationDrawerAdapter(baseActivity,getNavigationDrawerItems());
  drawerListView.setAdapter(navigationDrawerAdapter);
  drawerListView.setItemChecked(currentSelectedPosition,true);
  updateCountUnreadDialogsListener=navigationDrawerAdapter;
  return rootView;
}

Fixed version (ground truth):
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View rootView=inflater.inflate(R.layout.fragment_navigation_drawer,container,false);
  initUI(rootView);
  initListeners();
  initNavigationAdapter();
  drawerListView.setItemChecked(currentSelectedPosition,true);
  return rootView;
}
Program: 114555
Project: 114555
Buggy source:
private static ContentValues getContentValuesForCreateDialogTable(QBDialog dialog,String roomJidId){
  ContentValues values=new ContentValues();
  values.put(DialogTable.Cols.DIALOG_ID,dialog.getDialogId());
  values.put(DialogTable.Cols.ROOM_JID_ID,roomJidId);
  values.put(DialogTable.Cols.NAME,dialog.getName());
  values.put(DialogTable.Cols.COUNT_UNREAD_MESSAGES,dialog.getUnreadMessageCount());
  values.put(DialogTable.Cols.LAST_MESSAGE,dialog.getLastMessage());
  values.put(DialogTable.Cols.LAST_MESSAGE_USER_ID,dialog.getLastMessageUserId());
  values.put(DialogTable.Cols.LAST_DATE_SENT,dialog.getLastMessageDateSent());
  String occupantsIdsString=ChatUtils.getOccupantsIdsStringFromList(dialog.getOccupants());
  values.put(DialogTable.Cols.OCCUPANTS_IDS,occupantsIdsString);
  values.put(DialogTable.Cols.TYPE,dialog.getType().name());
  return values;
}

Fixed version (ground truth):
private static ContentValues getContentValuesForCreateDialogTable(Context context,QBDialog dialog,String roomJidId){
  ContentValues values=new ContentValues();
  values.put(DialogTable.Cols.DIALOG_ID,dialog.getDialogId());
  values.put(DialogTable.Cols.ROOM_JID_ID,roomJidId);
  values.put(DialogTable.Cols.NAME,dialog.getName());
  values.put(DialogTable.Cols.COUNT_UNREAD_MESSAGES,dialog.getUnreadMessageCount());
  values.put(DialogTable.Cols.LAST_MESSAGE,TextUtils.isEmpty(dialog.getLastMessage()) ? context.getString(R.string.dlg_attached_last_message) : dialog.getLastMessage());
  values.put(DialogTable.Cols.LAST_MESSAGE_USER_ID,dialog.getLastMessageUserId());
  values.put(DialogTable.Cols.LAST_DATE_SENT,dialog.getLastMessageDateSent());
  String occupantsIdsString=ChatUtils.getOccupantsIdsStringFromList(dialog.getOccupants());
  values.put(DialogTable.Cols.OCCUPANTS_IDS,occupantsIdsString);
  values.put(DialogTable.Cols.TYPE,dialog.getType().name());
  return values;
}
Program: 114556
Project: 114556
Buggy source:
private static ContentValues getContentValuesForUpdateDialogTable(QBDialog dialog){
  ContentValues values=new ContentValues();
  if (!TextUtils.isEmpty(dialog.getDialogId())) {
    values.put(DialogTable.Cols.DIALOG_ID,dialog.getDialogId());
  }
  values.put(DialogTable.Cols.NAME,dialog.getName());
  values.put(DialogTable.Cols.OCCUPANTS_IDS,ChatUtils.getOccupantsIdsStringFromList(dialog.getOccupants()));
  if (!TextUtils.isEmpty(dialog.getLastMessage())) {
    values.put(DialogTable.Cols.LAST_MESSAGE,dialog.getLastMessage());
  }
  if (dialog.getLastMessageUserId() != null) {
    values.put(DialogTable.Cols.LAST_MESSAGE_USER_ID,dialog.getLastMessageUserId());
  }
  values.put(DialogTable.Cols.LAST_DATE_SENT,dialog.getLastMessageDateSent());
  values.put(DialogTable.Cols.COUNT_UNREAD_MESSAGES,dialog.getUnreadMessageCount());
  return values;
}

Fixed version (ground truth):
private static ContentValues getContentValuesForUpdateDialogTable(Context context,QBDialog dialog){
  ContentValues values=new ContentValues();
  if (!TextUtils.isEmpty(dialog.getDialogId())) {
    values.put(DialogTable.Cols.DIALOG_ID,dialog.getDialogId());
  }
  values.put(DialogTable.Cols.NAME,dialog.getName());
  values.put(DialogTable.Cols.OCCUPANTS_IDS,ChatUtils.getOccupantsIdsStringFromList(dialog.getOccupants()));
  if (!TextUtils.isEmpty(dialog.getLastMessage())) {
    values.put(DialogTable.Cols.LAST_MESSAGE,dialog.getLastMessage());
  }
  values.put(DialogTable.Cols.LAST_MESSAGE,TextUtils.isEmpty(dialog.getLastMessage()) ? context.getString(R.string.dlg_attached_last_message) : dialog.getLastMessage());
  values.put(DialogTable.Cols.LAST_DATE_SENT,dialog.getLastMessageDateSent());
  values.put(DialogTable.Cols.COUNT_UNREAD_MESSAGES,dialog.getUnreadMessageCount());
  return values;
}
Program: 114557
Project: 114557
Buggy source:
public static void saveDialog(Context context,QBDialog dialog,String roomJidId){
  ContentValues values;
  String condition=DialogTable.Cols.ROOM_JID_ID + "String_Node_Str" + roomJidId+ "String_Node_Str";
  ContentResolver resolver=context.getContentResolver();
  Cursor cursor=resolver.query(DialogTable.CONTENT_URI,null,condition,null,null);
  if (cursor != null && cursor.getCount() > Consts.ZERO_INT_VALUE) {
    values=getContentValuesForUpdateDialogTable(dialog);
    resolver.update(DialogTable.CONTENT_URI,values,condition,null);
  }
 else {
    values=getContentValuesForCreateDialogTable(dialog,roomJidId);
    resolver.insert(DialogTable.CONTENT_URI,values);
  }
  cursor.close();
}

Fixed version (ground truth):
public static void saveDialog(Context context,QBDialog dialog,String roomJidId){
  ContentValues values;
  String condition=DialogTable.Cols.ROOM_JID_ID + "String_Node_Str" + roomJidId+ "String_Node_Str";
  ContentResolver resolver=context.getContentResolver();
  Cursor cursor=resolver.query(DialogTable.CONTENT_URI,null,condition,null,null);
  if (cursor != null && cursor.getCount() > Consts.ZERO_INT_VALUE) {
    values=getContentValuesForUpdateDialogTable(context,dialog);
    resolver.update(DialogTable.CONTENT_URI,values,condition,null);
  }
 else {
    values=getContentValuesForCreateDialogTable(context,dialog,roomJidId);
    resolver.insert(DialogTable.CONTENT_URI,values);
  }
  cursor.close();
}
Program: 114558
Project: 114558
Buggy source:
@Override public Bundle perform(Bundle extras) throws Exception {
  String socialProvider=(String)extras.getSerializable(QBServiceConsts.EXTRA_SOCIAL_PROVIDER);
  String accessToken=(String)extras.getSerializable(QBServiceConsts.EXTRA_ACCESS_TOKEN);
  String accessTokenSecret=(String)extras.getSerializable(QBServiceConsts.EXTRA_ACCESS_TOKEN_SECRET);
  QBUser user=authHelper.login(socialProvider,accessToken,accessTokenSecret);
  extras.putSerializable(QBServiceConsts.EXTRA_USER,user);
  return extras;
}

Fixed version (ground truth):
@Override public Bundle perform(Bundle extras) throws Exception {
  String socialProvider=(String)extras.getSerializable(QBServiceConsts.EXTRA_SOCIAL_PROVIDER);
  String accessToken=(String)extras.getSerializable(QBServiceConsts.EXTRA_ACCESS_TOKEN);
  String accessTokenSecret=(String)extras.getSerializable(QBServiceConsts.EXTRA_ACCESS_TOKEN_SECRET);
  QBUser user=authHelper.login(socialProvider,accessToken,accessTokenSecret);
  if (TextUtils.isEmpty(user.getWebsite())) {
    QBUser newUser=new QBUser();
    newUser.setId(user.getId());
    newUser.setPassword(user.getPassword());
    newUser.setWebsite(context.getString(R.string.inf_url_to_facebook_avatar,user.getFacebookId()));
    extras.putSerializable(QBServiceConsts.EXTRA_USER,newUser);
  }
 else {
    extras.putSerializable(QBServiceConsts.EXTRA_USER,user);
  }
  return extras;
}
Program: 114559
Project: 114559
Buggy source:
private void updateUser(QBUser user,File file,String status) throws QBResponseException, SmackException.NotConnectedException {
  if (file == null) {
    authHelper.updateUser(user);
  }
 else {
    authHelper.updateUser(user,file);
  }
  friendListHelper.sendStatus(status);
}

Fixed version (ground truth):
private void updateUser(QBUser user,File file,String status) throws QBResponseException, SmackException.NotConnectedException {
  if (file == null) {
    authHelper.updateUser(user);
  }
 else {
    authHelper.updateUser(user,file);
  }
}
Program: 114560
Project: 114560
Buggy source:
@Override public void processMessage(QBRoomChat roomChat,QBChatMessage chatMessage){
  Friend friend=DatabaseManager.getFriendById(context,chatMessage.getSenderId());
  String attachUrl=getAttachUrlIfExists(chatMessage);
  String roomJid=roomChat.getJid();
  long time=Long.parseLong(chatMessage.getProperty(propertyDateSent).toString());
  saveMessageToCache(new DialogMessageCache(roomJid,chatMessage.getSenderId(),chatMessage.getBody(),attachUrl,time,false));
  if (!chatMessage.getSenderId().equals(user.getId())) {
    notifyMessageReceived(chatMessage,friend);
  }
}

Fixed version (ground truth):
@Override public void processMessage(QBRoomChat roomChat,QBChatMessage chatMessage){
  Friend friend=DatabaseManager.getFriendById(context,chatMessage.getSenderId());
  String attachUrl=ChatUtils.getAttachUrlIfExists(chatMessage);
  String roomJid=roomChat.getJid();
  long time=Long.parseLong(chatMessage.getProperty(propertyDateSent).toString());
  saveMessageToCache(new DialogMessageCache(roomJid,chatMessage.getSenderId(),chatMessage.getBody(),attachUrl,time,false));
  if (!chatMessage.getSenderId().equals(user.getId())) {
    notifyMessageReceived(chatMessage,friend);
  }
}
Program: 114561
Project: 114561
Buggy source:
private void registerLoginWithSocialCommand(){
  QBLoginWithSocialCommand loginCommand=new QBLoginWithSocialCommand(this,QBServiceConsts.LOGIN_SUCCESS_ACTION,QBServiceConsts.LOGIN_FAIL_ACTION);
  QBLoginRestWithSocialCommand loginRestCommand=new QBLoginRestWithSocialCommand(this,authHelper,QBServiceConsts.LOGIN_REST_SUCCESS_ACTION,QBServiceConsts.LOGIN_REST_FAIL_ACTION);
  loginCommand.addCommand(loginRestCommand);
  addLoginChatAndInitCommands(loginCommand);
  serviceCommandMap.put(QBServiceConsts.SOCIAL_LOGIN_ACTION,loginCommand);
}

Fixed version (ground truth):
private void registerLoginWithSocialCommand(){
  QBLoginWithSocialCommand loginCommand=new QBLoginWithSocialCommand(this,QBServiceConsts.LOGIN_SUCCESS_ACTION,QBServiceConsts.LOGIN_FAIL_ACTION);
  QBLoginRestWithSocialCommand loginRestCommand=new QBLoginRestWithSocialCommand(this,authHelper,QBServiceConsts.LOGIN_REST_SUCCESS_ACTION,QBServiceConsts.LOGIN_REST_FAIL_ACTION);
  QBUpdateUserCommand updateUserCommand=new QBUpdateUserCommand(this,authHelper,friendListHelper,QBServiceConsts.UPDATE_USER_SUCCESS_ACTION,QBServiceConsts.UPDATE_USER_FAIL_ACTION);
  loginCommand.addCommand(loginRestCommand);
  loginCommand.addCommand(updateUserCommand);
  addLoginChatAndInitCommands(loginCommand);
  serviceCommandMap.put(QBServiceConsts.SOCIAL_LOGIN_ACTION,loginCommand);
}
Program: 114562
Project: 114562
Buggy source:
@Override public void bindView(View view,final Context context,Cursor cursor){
  final ViewHolder viewHolder=(ViewHolder)view.getTag();
  QBDialog dialog=DatabaseManager.getDialogFromCursor(cursor);
  if (dialog.getType().equals(QBDialogType.PRIVATE)) {
    int occupantId=ChatUtils.getOccupantIdFromList(dialog.getOccupants());
    Friend occupant=getOccupantById(occupantId);
    viewHolder.nameTextView.setText(occupant.getFullname());
    viewHolder.userCountTextView.setVisibility(View.GONE);
    displayAvatarImage(getAvatarUrlForFriend(occupant),viewHolder.avatarImageView);
  }
 else {
    viewHolder.nameTextView.setText(dialog.getName());
    viewHolder.userCountTextView.setVisibility(View.VISIBLE);
    viewHolder.userCountTextView.setText(dialog.getOccupants().size() + Consts.EMPTY_STRING);
    viewHolder.avatarImageView.setImageResource(R.drawable.placeholder_group);
  }
  if (dialog.getUnreadMessageCount() > Consts.ZERO_INT_VALUE) {
    viewHolder.unreadMessagesTextView.setText(dialog.getUnreadMessageCount() + Consts.EMPTY_STRING);
    viewHolder.unreadMessagesTextView.setVisibility(View.VISIBLE);
  }
 else {
    viewHolder.unreadMessagesTextView.setVisibility(View.GONE);
  }
  if (dialog.getLastMessage() == null && dialog.getLastMessageUserId() != Consts.ZERO_INT_VALUE) {
    viewHolder.lastMessageTextView.setText(resources.getString(R.string.dlg_attached_last_message));
  }
 else {
    viewHolder.lastMessageTextView.setText(dialog.getLastMessage());
  }
}

Fixed version (ground truth):
@Override public void bindView(View view,final Context context,Cursor cursor){
  final ViewHolder viewHolder=(ViewHolder)view.getTag();
  QBDialog dialog=DatabaseManager.getDialogFromCursor(cursor);
  if (dialog.getType().equals(QBDialogType.PRIVATE)) {
    int occupantId=ChatUtils.getOccupantIdFromList(dialog.getOccupants());
    Friend occupant=getOccupantById(occupantId);
    viewHolder.nameTextView.setText(occupant.getFullname());
    viewHolder.userCountTextView.setVisibility(View.GONE);
    displayAvatarImage(getAvatarUrlForFriend(occupant),viewHolder.avatarImageView);
  }
 else {
    viewHolder.nameTextView.setText(dialog.getName());
    viewHolder.userCountTextView.setVisibility(View.VISIBLE);
    viewHolder.userCountTextView.setText(dialog.getOccupants().size() + Consts.EMPTY_STRING);
    viewHolder.avatarImageView.setImageResource(R.drawable.placeholder_group);
  }
  if (dialog.getUnreadMessageCount() > Consts.ZERO_INT_VALUE) {
    viewHolder.unreadMessagesTextView.setText(dialog.getUnreadMessageCount() + Consts.EMPTY_STRING);
    viewHolder.unreadMessagesTextView.setVisibility(View.VISIBLE);
  }
 else {
    viewHolder.unreadMessagesTextView.setVisibility(View.GONE);
  }
  viewHolder.lastMessageTextView.setText(dialog.getLastMessage());
}
Program: 114563
Project: 114563
Buggy source:
private boolean isUserDataCorrect(){
  return fullnameCurrent.length() > Consts.ZERO_INT_VALUE && emailCurrent.length() > Consts.ZERO_INT_VALUE;
}

Fixed version (ground truth):
private boolean isUserDataCorrect(){
  return fullnameCurrent.length() > Consts.ZERO_INT_VALUE;
}
Program: 114564
Project: 114564
Buggy source:
@Override public void onClick(View v){
switch (v.getId()) {
case R.id.avatar_textview:
case R.id.changeAvatarLinearLayout:
case R.id.avatar_imageview:
    changeAvatarOnClick();
  break;
case R.id.changeFullNameRelativeLayout:
changeFullNameOnClick();
break;
case R.id.changeStatusLinearLayout:
changeStatusOnClick();
break;
}
}

Fixed version (ground truth):
@Override public void onClick(View v){
switch (v.getId()) {
case R.id.avatar_textview:
case R.id.change_avatar_linearlayout:
case R.id.avatar_imageview:
    changeAvatarOnClick();
  break;
case R.id.change_fullname_relativelayout:
changeFullNameOnClick();
break;
case R.id.changeStatusLinearLayout:
changeStatusOnClick();
break;
}
}
Program: 114565
Project: 114565
Buggy source:
private void initUI(){
  changeAvatarLinearLayout=_findViewById(R.id.changeAvatarLinearLayout);
  avatarTextView=_findViewById(R.id.avatar_textview);
  changeFullNameRelativeLayout=_findViewById(R.id.changeFullNameRelativeLayout);
  changeStatusLinearLayout=_findViewById(R.id.changeStatusLinearLayout);
  avatarImageView=_findViewById(R.id.avatar_imageview);
  avatarImageView.setOval(true);
  fullNameEditText=_findViewById(R.id.fullNameEditText);
  emailTextView=_findViewById(R.id.email_textview);
  statusMessageEditText=_findViewById(R.id.statusMessageEditText);
}

Fixed version (ground truth):
private void initUI(){
  changeAvatarLinearLayout=_findViewById(R.id.change_avatar_linearlayout);
  avatarTextView=_findViewById(R.id.avatar_textview);
  changeFullNameRelativeLayout=_findViewById(R.id.change_fullname_relativelayout);
  emailLinearLayout=_findViewById(R.id.email_linearlayout);
  changeStatusLinearLayout=_findViewById(R.id.changeStatusLinearLayout);
  avatarImageView=_findViewById(R.id.avatar_imageview);
  avatarImageView.setOval(true);
  fullNameEditText=_findViewById(R.id.fullname_edittext);
  emailTextView=_findViewById(R.id.email_textview);
  statusMessageEditText=_findViewById(R.id.statusMessageEditText);
}
Program: 114566
Project: 114566
Buggy source:
private void initUIWithUsersData(){
  loadAvatar();
  fullNameEditText.setText(user.getFullName());
  emailTextView.setText(user.getEmail());
  String status=App.getInstance().getPrefsHelper().getPref(PrefsHelper.PREF_STATUS,Consts.EMPTY_STRING);
  statusMessageEditText.setText(status);
}

Fixed version (ground truth):
private void initUIWithUsersData(){
  loadAvatar();
  fullNameEditText.setText(user.getFullName());
  if (TextUtils.isEmpty(user.getEmail())) {
    emailLinearLayout.setVisibility(View.GONE);
  }
 else {
    emailLinearLayout.setVisibility(View.VISIBLE);
    emailTextView.setText(user.getEmail());
  }
  String status=App.getInstance().getPrefsHelper().getPref(PrefsHelper.PREF_STATUS,Consts.EMPTY_STRING);
  statusMessageEditText.setText(status);
}
Program: 114567
Project: 114567
Buggy source:
private void checkFields(){
  AlertDialog dialog=(AlertDialog)getDialog();
  final Button yesButton=dialog == null ? null : dialog.getButton(AlertDialog.BUTTON_POSITIVE);
  if (yesButton != null) {
    yesButton.setOnTouchListener(new View.OnTouchListener(){
      @Override public boolean onTouch(      View v,      MotionEvent event){
        String oldPasswordText=oldPassword.getText().toString();
        String newPasswordText=newPassword.getText().toString();
        String confirmPasswordText=confirmPassword.getText().toString();
        boolean isOldPasswordEmpty=TextUtils.isEmpty(oldPasswordText);
        boolean isNewPasswordEmpty=TextUtils.isEmpty(newPasswordText);
        boolean isConfirmPasswordEmpty=TextUtils.isEmpty(confirmPasswordText);
        if (isOldPasswordEmpty || isNewPasswordEmpty || isConfirmPasswordEmpty) {
          DialogUtils.showLong(getActivity(),getString(R.string.dlg_not_all_fields_entered));
          yesButton.setClickable(false);
          return false;
        }
        if (!newPasswordText.equals(confirmPasswordText)) {
          DialogUtils.showLong(getActivity(),getString(R.string.dlg_passwords_not_equal));
          yesButton.setClickable(false);
          return false;
        }
        yesButton.setClickable(true);
        return false;
      }
    }
);
  }
}

Fixed version (ground truth):
private void checkFields(){
  AlertDialog dialog=(AlertDialog)getDialog();
  final Button yesButton=dialog == null ? null : dialog.getButton(AlertDialog.BUTTON_POSITIVE);
  if (yesButton != null) {
    yesButton.setOnTouchListener(new View.OnTouchListener(){
      @Override public boolean onTouch(      View v,      MotionEvent event){
        String oldPasswordText=oldPassword.getText().toString();
        String newPasswordText=newPassword.getText().toString();
        String confirmPasswordText=confirmPassword.getText().toString();
        QBUser user=App.getInstance().getUser();
        boolean isOldPasswordEmpty=TextUtils.isEmpty(oldPasswordText);
        boolean isNewPasswordEmpty=TextUtils.isEmpty(newPasswordText);
        boolean isConfirmPasswordEmpty=TextUtils.isEmpty(confirmPasswordText);
        if (isOldPasswordEmpty || isNewPasswordEmpty || isConfirmPasswordEmpty) {
          DialogUtils.showLong(getActivity(),getString(R.string.dlg_not_all_fields_entered));
          yesButton.setClickable(false);
          return false;
        }
        if (!newPasswordText.equals(confirmPasswordText)) {
          DialogUtils.showLong(getActivity(),getString(R.string.dlg_passwords_not_equal));
          yesButton.setClickable(false);
          return false;
        }
        if (!user.getPassword().equals(oldPasswordText)) {
          DialogUtils.showLong(getActivity(),getString(R.string.dlg_old_password_wrong));
          yesButton.setClickable(false);
          return false;
        }
        yesButton.setClickable(true);
        return false;
      }
    }
);
  }
}
Program: 114568
Project: 114568
Buggy source:
@Override public boolean onTouch(View v,MotionEvent event){
  String oldPasswordText=oldPassword.getText().toString();
  String newPasswordText=newPassword.getText().toString();
  String confirmPasswordText=confirmPassword.getText().toString();
  boolean isOldPasswordEmpty=TextUtils.isEmpty(oldPasswordText);
  boolean isNewPasswordEmpty=TextUtils.isEmpty(newPasswordText);
  boolean isConfirmPasswordEmpty=TextUtils.isEmpty(confirmPasswordText);
  if (isOldPasswordEmpty || isNewPasswordEmpty || isConfirmPasswordEmpty) {
    DialogUtils.showLong(getActivity(),getString(R.string.dlg_not_all_fields_entered));
    yesButton.setClickable(false);
    return false;
  }
  if (!newPasswordText.equals(confirmPasswordText)) {
    DialogUtils.showLong(getActivity(),getString(R.string.dlg_passwords_not_equal));
    yesButton.setClickable(false);
    return false;
  }
  yesButton.setClickable(true);
  return false;
}

Fixed version (ground truth):
@Override public boolean onTouch(View v,MotionEvent event){
  String oldPasswordText=oldPassword.getText().toString();
  String newPasswordText=newPassword.getText().toString();
  String confirmPasswordText=confirmPassword.getText().toString();
  QBUser user=App.getInstance().getUser();
  boolean isOldPasswordEmpty=TextUtils.isEmpty(oldPasswordText);
  boolean isNewPasswordEmpty=TextUtils.isEmpty(newPasswordText);
  boolean isConfirmPasswordEmpty=TextUtils.isEmpty(confirmPasswordText);
  if (isOldPasswordEmpty || isNewPasswordEmpty || isConfirmPasswordEmpty) {
    DialogUtils.showLong(getActivity(),getString(R.string.dlg_not_all_fields_entered));
    yesButton.setClickable(false);
    return false;
  }
  if (!newPasswordText.equals(confirmPasswordText)) {
    DialogUtils.showLong(getActivity(),getString(R.string.dlg_passwords_not_equal));
    yesButton.setClickable(false);
    return false;
  }
  if (!user.getPassword().equals(oldPasswordText)) {
    DialogUtils.showLong(getActivity(),getString(R.string.dlg_old_password_wrong));
    yesButton.setClickable(false);
    return false;
  }
  yesButton.setClickable(true);
  return false;
}
Program: 114569
Project: 114569
Buggy source:
@Override public boolean onMenuItemActionCollapse(MenuItem item){
  state=State.FRIENDS_LIST;
  baseActivity.getActionBar().setDisplayShowHomeEnabled(true);
  if (isHideSearchView) {
    isHideSearchView=false;
    emptyListTextView.setVisibility(friendsListAdapter.isEmpty() ? View.VISIBLE : View.GONE);
    friendsListAdapter.setSearchCharacters(null);
    friendsListAdapter.setFilterQueryProvider(null);
    friendsListView.removeFooterView(globalSearchLayout);
    friendsListView.removeHeaderView(friendsListViewTitle);
    positionCounter--;
    initFriendsList();
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onMenuItemActionCollapse(MenuItem item){
  state=State.FRIENDS_LIST;
  baseActivity.getActionBar().setDisplayShowHomeEnabled(true);
  emptyListTextView.setVisibility(friendsListAdapter.isEmpty() ? View.VISIBLE : View.GONE);
  if (isHideSearchView) {
    isHideSearchView=false;
    friendsListAdapter.setSearchCharacters(null);
    friendsListAdapter.setFilterQueryProvider(null);
    friendsListView.removeFooterView(globalSearchLayout);
    friendsListView.removeHeaderView(friendsListViewTitle);
    positionCounter--;
    initFriendsList();
  }
  return true;
}
Program: 114570
Project: 114570
Buggy source:
public void execute(Bundle bundle){
  Bundle result;
  try {
    result=perform(bundle);
    sendResult(result,successAction);
  }
 catch (  Exception e) {
    ErrorUtils.logError(e);
    result=new Bundle();
    result.putSerializable(QBServiceConsts.EXTRA_ERROR,e);
    sendResult(result,failAction);
  }
}

Fixed version (ground truth):
public void execute(Bundle bundle){
  Bundle result;
  try {
    result=perform(bundle);
    sendResult(result,successAction);
  }
 catch (  Exception e) {
    ErrorUtils.logError(e);
    result=new Bundle();
    result.putSerializable(QBServiceConsts.EXTRA_ERROR,e);
    result.putString(QBServiceConsts.COMMAND_ACTION,failAction);
    sendResult(result,failAction);
  }
}
Program: 114571
Project: 114571
Buggy source:
@Override public Bundle perform(Bundle extras) throws Exception {
  super.perform(extras);
  resetFriendList();
  resetRememberMe();
  resetUserData();
  return extras;
}

Fixed version (ground truth):
@Override public Bundle perform(Bundle extras) throws Exception {
  try {
    super.perform(extras);
  }
 catch (  Exception e) {
    ErrorUtils.logError(TAG,e);
  }
  resetFriendList();
  resetRememberMe();
  resetUserData();
  return extras;
}
Program: 114572
Project: 114572
Buggy source:
@Override public Bundle perform(Bundle extras) throws Exception {
  authHelper.logout();
  return extras;
}

Fixed version (ground truth):
@Override public Bundle perform(Bundle extras) throws Exception {
  try {
    authHelper.logout();
  }
 catch (  QBResponseException e) {
    e.printStackTrace();
  }
  return extras;
}
Program: 114573
Project: 114573
Buggy source:
@Override public void execute(Bundle bundle){
  Exception e=(Exception)bundle.getSerializable(QBServiceConsts.EXTRA_ERROR);
  ErrorUtils.showError(BaseFragmentActivity.this,e);
  hideProgress();
}

Fixed version (ground truth):
@Override public void execute(Bundle bundle){
  Exception e=(Exception)bundle.getSerializable(QBServiceConsts.EXTRA_ERROR);
  ErrorUtils.showError(BaseFragmentActivity.this,e);
  hideProgress();
  onFailAction(bundle.getString(QBServiceConsts.COMMAND_ACTION));
}
Program: 114574
Project: 114574
Buggy source:
@Override protected void onUpdateChatDialog(){
  if (!messagesAdapter.isEmpty()) {
    startUpdateChatDialog();
  }
}

Fixed version (ground truth):
@Override protected void onUpdateChatDialog(){
  if (messagesAdapter != null && !messagesAdapter.isEmpty()) {
    startUpdateChatDialog();
  }
}
Program: 114575
Project: 114575
Buggy source:
public QBService(){
  threadQueue=new LinkedBlockingQueue<Runnable>();
  threadPool=new ThreadPoolExecutor(NUMBER_OF_CORES,NUMBER_OF_CORES,KEEP_ALIVE_TIME,KEEP_ALIVE_TIME_UNIT,threadQueue);
  initHelpers();
  initCommands();
}

Fixed version (ground truth):
public QBService(){
  threadQueue=new LinkedBlockingQueue<Runnable>();
  initThreads();
  initHelpers();
  initCommands();
}
Program: 114576
Project: 114576
Buggy source:
private void startAsync(final ServiceCommand command,final Intent intent){
  threadPool.execute(new Runnable(){
    @Override public void run(){
      command.execute(intent.getExtras());
    }
  }
);
}

Fixed version (ground truth):
private void startAsync(final ServiceCommand command,final Intent intent){
  if (threadPool.getActiveCount() >= NUMBER_OF_CORES) {
    initThreads();
  }
  threadPool.execute(new Runnable(){
    @Override public void run(){
      command.execute(intent.getExtras());
    }
  }
);
}
Program: 114577
Project: 114577
Buggy source:
protected void displayAvatarImage(String uri,ImageView imageView){
  if (uri != null) {
    ImageLoader.getInstance().displayImage(uri,imageView,Consts.UIL_AVATAR_DISPLAY_OPTIONS);
  }
}

Fixed version (ground truth):
protected void displayAvatarImage(String uri,ImageView imageView){
  ImageLoader.getInstance().displayImage(uri,imageView,Consts.UIL_AVATAR_DISPLAY_OPTIONS);
}
Program: 114578
Project: 114578
Buggy source:
public static void saveChatMessage(Context context,DialogMessageCache dialogMessageCache){
  ContentValues values=new ContentValues();
  values.put(DialogMessageTable.Cols.ROOM_JID_ID,dialogMessageCache.getRoomJidId());
  values.put(DialogMessageTable.Cols.SENDER_ID,dialogMessageCache.getSenderId());
  values.put(DialogMessageTable.Cols.BODY,dialogMessageCache.getMessage());
  values.put(DialogMessageTable.Cols.TIME,dialogMessageCache.getTime());
  values.put(DialogMessageTable.Cols.ATTACH_FILE_ID,dialogMessageCache.getAttachUrl());
  values.put(DialogMessageTable.Cols.IS_READ,dialogMessageCache.isRead());
  context.getContentResolver().insert(DialogMessageTable.CONTENT_URI,values);
  updateDialog(context,dialogMessageCache.getRoomJidId(),dialogMessageCache.getMessage(),dialogMessageCache.getTime());
}

Fixed version (ground truth):
public static void saveChatMessage(Context context,DialogMessageCache dialogMessageCache){
  ContentValues values=new ContentValues();
  values.put(DialogMessageTable.Cols.ROOM_JID_ID,dialogMessageCache.getRoomJidId());
  values.put(DialogMessageTable.Cols.SENDER_ID,dialogMessageCache.getSenderId());
  values.put(DialogMessageTable.Cols.BODY,dialogMessageCache.getMessage());
  values.put(DialogMessageTable.Cols.TIME,dialogMessageCache.getTime());
  values.put(DialogMessageTable.Cols.ATTACH_FILE_ID,dialogMessageCache.getAttachUrl());
  values.put(DialogMessageTable.Cols.IS_READ,dialogMessageCache.isRead());
  Uri uri=context.getContentResolver().insert(DialogMessageTable.CONTENT_URI,values);
  updateDialog(context,dialogMessageCache.getRoomJidId(),dialogMessageCache.getMessage(),dialogMessageCache.getTime());
}
Program: 114579
Project: 114579
Buggy source:
@Override public void processMessage(QBRoomChat roomChat,QBChatMessage chatMessage){
  Friend friend=DatabaseManager.getFriendById(context,chatMessage.getSenderId());
  String attachUrl=getAttachUrlIfExists(chatMessage);
  long time=Long.parseLong(chatMessage.getProperty(propertyDateSent).toString());
  saveMessageToCache(new DialogMessageCache(roomChat.getJid(),chatMessage.getSenderId(),chatMessage.getBody(),attachUrl,time,false));
  if (!chatMessage.getSenderId().equals(user.getId())) {
    notifyMessageReceived(chatMessage,friend);
  }
}

Fixed version (ground truth):
@Override public void processMessage(QBRoomChat roomChat,QBChatMessage chatMessage){
  Friend friend=DatabaseManager.getFriendById(context,chatMessage.getSenderId());
  String attachUrl=getAttachUrlIfExists(chatMessage);
  String roomJid=roomChat.getJid();
  long time=Long.parseLong(chatMessage.getProperty(propertyDateSent).toString());
  saveMessageToCache(new DialogMessageCache(roomJid,chatMessage.getSenderId(),chatMessage.getBody(),attachUrl,time,false));
  if (!chatMessage.getSenderId().equals(user.getId())) {
    notifyMessageReceived(chatMessage,friend);
  }
}
Program: 114580
Project: 114580
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(layoutResID);
  imageHelper=new ImageHelper(this);
  messagesAdapter=getMessagesAdapter();
  initUI();
  initListeners();
  initSmileWidgets();
  initSmiles();
  addActions();
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(layoutResID);
  imageHelper=new ImageHelper(this);
  initUI();
  initListeners();
  initSmileWidgets();
  initSmiles();
  addActions();
}
Program: 114581
Project: 114581
Buggy source:
private void initListView(){
  messagesAdapter=getMessagesAdapter();
  messagesListView.setAdapter(messagesAdapter);
}

Fixed version (ground truth):
private void initListView(){
  messagesAdapter=new GroupDialogMessagesAdapter(this,getAllDialogMessagesByRoomJidId(),dialog,this);
  messagesListView.setAdapter(messagesAdapter);
}
Program: 114582
Project: 114582
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (getIntent().hasExtra(EXTRA_ROOM_JID)) {
    roomJid=getIntent().getStringExtra(EXTRA_ROOM_JID);
  }
  initListView();
  registerForContextMenu(messagesListView);
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (getIntent().hasExtra(EXTRA_ROOM_JID)) {
    roomJid=getIntent().getStringExtra(EXTRA_ROOM_JID);
  }
  if (roomJid != null) {
    dialog=DatabaseManager.getDialogByRoomJidId(this,roomJid);
    groupName=dialog.getName();
  }
  initListView();
  initChat();
  initActionBar();
  initStartLoadDialogMessages();
  registerForContextMenu(messagesListView);
}
Program: 114583
Project: 114583
Buggy source:
@Override protected void onResume(){
  super.onResume();
  initChat();
  initStartLoadDialogMessages();
  addActions();
  initActionBar();
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  scrollListView();
  addActions();
}
Program: 114584
Project: 114584
Buggy source:
private void initChat(){
  if (roomJid != null) {
    dialog=DatabaseManager.getDialogByRoomJidId(this,roomJid);
    groupName=dialog.getName();
  }
 else {
    showProgress();
    friendList=(ArrayList<Friend>)getIntent().getSerializableExtra(EXTRA_FRIENDS);
    groupName=createChatName();
    QBCreateGroupDialogCommand.start(this,groupName,friendList);
  }
}

Fixed version (ground truth):
private void initChat(){
  if (roomJid == null) {
    showProgress();
    friendList=(ArrayList<Friend>)getIntent().getSerializableExtra(EXTRA_FRIENDS);
    groupName=createChatName();
    QBCreateGroupDialogCommand.start(this,groupName,friendList);
  }
}
Program: 114585
Project: 114585
Buggy source:
private void initListView(){
  messagesAdapter=getMessagesAdapter();
  messagesListView.setAdapter(messagesAdapter);
}

Fixed version (ground truth):
private void initListView(){
  messagesAdapter=new PrivateDialogMessagesAdapter(this,getAllDialogMessagesByRoomJidId(),opponentFriend,dialog,this);
  messagesListView.setAdapter(messagesAdapter);
}
Program: 114586
Project: 114586
Buggy source:
protected String getAvatarUrlForCurrentUser(){
  if (currentLoginType == LoginType.FACEBOOK) {
    return context.getString(R.string.inf_url_to_facebook_avatar,currentUser.getFacebookId());
  }
 else   if (currentLoginType == LoginType.EMAIL) {
    return currentUser.getWebsite();
  }
  return null;
}

Fixed version (ground truth):
protected String getAvatarUrlForCurrentUser(){
  return currentUser.getWebsite();
}
Program: 114587
Project: 114587
Buggy source:
private void startUpdateChatDialog(){
  QBUpdateDialogCommand.start(this,getQBDialog(),roomJid);
}

Fixed version (ground truth):
private void startUpdateChatDialog(){
  QBDialog dialog=getQBDialog();
  if (dialog != null) {
    QBUpdateDialogCommand.start(this,getQBDialog(),roomJid);
  }
}
Program: 114588
Project: 114588
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_landing);
  useDoubleBackPressed=true;
  addAction(QBServiceConsts.LOGIN_SUCCESS_ACTION,new SocialLoginSuccessAction());
  addAction(QBServiceConsts.LOGIN_FAIL_ACTION,failAction);
  facebookHelper=new FacebookHelper(this,savedInstanceState,new FacebookSessionStatusCallback());
  initVersionName();
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_landing);
  useDoubleBackPressed=true;
  addActions();
  facebookHelper=new FacebookHelper(this,savedInstanceState,new FacebookSessionStatusCallback());
  initVersionName();
}
Program: 114589
Project: 114589
Buggy source:
@Override public void execute(Bundle bundle){
  QBUser user=(QBUser)bundle.getSerializable(QBServiceConsts.EXTRA_USER);
  App.getInstance().setUser(getUserWithAvatar(user));
  App.getInstance().getPrefsHelper().savePref(PrefsHelper.PREF_IMPORT_INITIALIZED,true);
  DatabaseManager.clearAllCache(LandingActivity.this);
  MainActivity.start(LandingActivity.this);
  finish();
}

Fixed version (ground truth):
@Override public void execute(Bundle bundle){
  QBUser user=(QBUser)bundle.getSerializable(QBServiceConsts.EXTRA_USER);
  user.setWebsite(getAvatarUrl(user));
  DatabaseManager.clearAllCache(LandingActivity.this);
  QBUpdateUserCommand.start(LandingActivity.this,user,null,null);
}