Program: 64782
Project: 64782
Buggy source:
@Override public boolean onActionItemClicked(ActionMode mode,android.view.MenuItem item){
  final ArrayList<Integer> transIds=new ArrayList<Integer>();
  if (getListAdapter() != null && getListAdapter() instanceof AllDataAdapter) {
    AllDataAdapter adapter=(AllDataAdapter)getListAdapter();
    Cursor cursor=adapter.getCursor();
    if (cursor != null) {
      SparseBooleanArray positionChecked=getListView().getCheckedItemPositions();
      for (int i=0; i < getListView().getCheckedItemCount(); i++) {
        int position=positionChecked.keyAt(i);
        if (cursor.moveToPosition(position)) {
          transIds.add(cursor.getInt(cursor.getColumnIndex(QueryAllData.ID)));
        }
      }
    }
  }
switch (item.getItemId()) {
case R.id.menu_change_status:
    final DrawerMenuItemAdapter adapter=new DrawerMenuItemAdapter(getActivity());
  final Core core=new Core(getActivity());
final Boolean isDarkTheme=core.getThemeApplication() == R.style.Theme_Money_Manager;
adapter.add(new DrawerMenuItem(R.id.menu_none,getString(R.string.status_none),isDarkTheme ? R.drawable.ic_action_help_dark : R.drawable.ic_action_help_light,"String_Node_Str"));
adapter.add(new DrawerMenuItem(R.id.menu_reconciled,getString(R.string.status_reconciled),isDarkTheme ? R.drawable.ic_action_done_dark : R.drawable.ic_action_done_light,"String_Node_Str"));
adapter.add(new DrawerMenuItem(R.id.menu_follow_up,getString(R.string.status_follow_up),isDarkTheme ? R.drawable.ic_action_alarm_on_dark : R.drawable.ic_action_alarm_on_light,"String_Node_Str"));
adapter.add(new DrawerMenuItem(R.id.menu_duplicate,getString(R.string.status_duplicate),isDarkTheme ? R.drawable.ic_action_copy_dark : R.drawable.ic_action_copy_light,"String_Node_Str"));
adapter.add(new DrawerMenuItem(R.id.menu_void,getString(R.string.status_void),isDarkTheme ? R.drawable.ic_action_halt_dark : R.drawable.ic_action_halt_light,"String_Node_Str"));
final MaterialDialog dialog=new MaterialDialog.Builder(getActivity()).title(getString(R.string.change_status)).adapter(adapter).theme(core.getThemeApplication() == R.style.Theme_Money_Manager ? Theme.DARK : Theme.LIGHT).build();
ListView listView=dialog.getListView();
if (listView != null) listView.setOnItemClickListener(new OnItemClickListener(){
@Override public void onItemClick(AdapterView<?> parent,View view,int position,long id){
DrawerMenuItem item=adapter.getItem(position);
switch (item.getId()) {
case R.id.menu_none:
case R.id.menu_reconciled:
case R.id.menu_follow_up:
case R.id.menu_duplicate:
case R.id.menu_void:
String status=item.getAlphabeticShortcut();
if (setStatusCheckingAccount(convertArraryListToArray(transIds),status)) {
((AllDataAdapter)getListAdapter()).clearPositionChecked();
startLoaderData();
}
}
dialog.dismiss();
}
}
);
dialog.show();
mode.finish();
break;
case R.id.menu_duplicate_transactions:
int[] ids=convertArraryListToArray(transIds);
Intent[] intents=new Intent[ids.length];
for (int i=0; i < ids.length; i++) {
intents[i]=new Intent(getActivity(),CheckingAccountActivity.class);
intents[i].putExtra(CheckingAccountActivity.KEY_TRANS_ID,ids[i]);
intents[i].setAction(Intent.ACTION_PASTE);
}
getActivity().startActivities(intents);
mode.finish();
break;
case R.id.menu_delete:
showDialogDeleteCheckingAccount(convertArraryListToArray(transIds));
return true;
case R.id.menu_none:
case R.id.menu_reconciled:
case R.id.menu_follow_up:
case R.id.menu_duplicate:
case R.id.menu_void:
String status=Character.toString(item.getAlphabeticShortcut());
if (setStatusCheckingAccount(convertArraryListToArray(transIds),status)) {
((AllDataAdapter)getListAdapter()).clearPositionChecked();
startLoaderData();
mode.finish();
return true;
}
}
return false;
}

Fixed version (ground truth):
@Override public boolean onActionItemClicked(ActionMode mode,android.view.MenuItem item){
  final ArrayList<Integer> transIds=new ArrayList<Integer>();
  if (getListAdapter() != null && getListAdapter() instanceof AllDataAdapter) {
    AllDataAdapter adapter=(AllDataAdapter)getListAdapter();
    Cursor cursor=adapter.getCursor();
    if (cursor != null) {
      SparseBooleanArray positionChecked=getListView().getCheckedItemPositions();
      for (int i=0; i < getListView().getCheckedItemCount(); i++) {
        int position=positionChecked.keyAt(i);
        if (getListHeader() != null)         position--;
        if (cursor.moveToPosition(position)) {
          transIds.add(cursor.getInt(cursor.getColumnIndex(QueryAllData.ID)));
        }
      }
    }
  }
switch (item.getItemId()) {
case R.id.menu_change_status:
    final DrawerMenuItemAdapter adapter=new DrawerMenuItemAdapter(getActivity());
  final Core core=new Core(getActivity());
final Boolean isDarkTheme=core.getThemeApplication() == R.style.Theme_Money_Manager;
adapter.add(new DrawerMenuItem(R.id.menu_none,getString(R.string.status_none),isDarkTheme ? R.drawable.ic_action_help_dark : R.drawable.ic_action_help_light,"String_Node_Str"));
adapter.add(new DrawerMenuItem(R.id.menu_reconciled,getString(R.string.status_reconciled),isDarkTheme ? R.drawable.ic_action_done_dark : R.drawable.ic_action_done_light,"String_Node_Str"));
adapter.add(new DrawerMenuItem(R.id.menu_follow_up,getString(R.string.status_follow_up),isDarkTheme ? R.drawable.ic_action_alarm_on_dark : R.drawable.ic_action_alarm_on_light,"String_Node_Str"));
adapter.add(new DrawerMenuItem(R.id.menu_duplicate,getString(R.string.status_duplicate),isDarkTheme ? R.drawable.ic_action_copy_dark : R.drawable.ic_action_copy_light,"String_Node_Str"));
adapter.add(new DrawerMenuItem(R.id.menu_void,getString(R.string.status_void),isDarkTheme ? R.drawable.ic_action_halt_dark : R.drawable.ic_action_halt_light,"String_Node_Str"));
final MaterialDialog dialog=new MaterialDialog.Builder(getActivity()).title(getString(R.string.change_status)).adapter(adapter).theme(core.getThemeApplication() == R.style.Theme_Money_Manager ? Theme.DARK : Theme.LIGHT).build();
ListView listView=dialog.getListView();
if (listView != null) listView.setOnItemClickListener(new OnItemClickListener(){
@Override public void onItemClick(AdapterView<?> parent,View view,int position,long id){
DrawerMenuItem item=adapter.getItem(position);
switch (item.getId()) {
case R.id.menu_none:
case R.id.menu_reconciled:
case R.id.menu_follow_up:
case R.id.menu_duplicate:
case R.id.menu_void:
String status=item.getAlphabeticShortcut();
if (setStatusCheckingAccount(convertArraryListToArray(transIds),status)) {
((AllDataAdapter)getListAdapter()).clearPositionChecked();
startLoaderData();
}
}
dialog.dismiss();
}
}
);
dialog.show();
mode.finish();
break;
case R.id.menu_duplicate_transactions:
int[] ids=convertArraryListToArray(transIds);
Intent[] intents=new Intent[ids.length];
for (int i=0; i < ids.length; i++) {
intents[i]=new Intent(getActivity(),CheckingAccountActivity.class);
intents[i].putExtra(CheckingAccountActivity.KEY_TRANS_ID,ids[i]);
intents[i].setAction(Intent.ACTION_PASTE);
}
getActivity().startActivities(intents);
mode.finish();
break;
case R.id.menu_delete:
showDialogDeleteCheckingAccount(convertArraryListToArray(transIds));
return true;
case R.id.menu_none:
case R.id.menu_reconciled:
case R.id.menu_follow_up:
case R.id.menu_duplicate:
case R.id.menu_void:
String status=Character.toString(item.getAlphabeticShortcut());
if (setStatusCheckingAccount(convertArraryListToArray(transIds),status)) {
((AllDataAdapter)getListAdapter()).clearPositionChecked();
startLoaderData();
mode.finish();
return true;
}
}
return false;
}