Program: 186297
Project: 186297
Buggy source:
/** 
 * Central point where we handle actions for single selection, for every API level.
 * @param mItem The selected menu option/action.
 * @param fItem The data to act upon.
 */
public static boolean handleSingleSelectionAction(final SimpleFileListFragment navigator,MenuItem mItem,FileHolder fItem,Context context){
  DialogFragment dialog;
  Bundle args;
switch (mItem.getItemId()) {
case R.id.menu_open:
    navigator.open(fItem);
  return true;
case R.id.menu_create_shortcut:
createShortcut(fItem,context);
return true;
case R.id.menu_move:
((FileManagerApplication)navigator.getActivity().getApplication()).getCopyHelper().cut(fItem);
return true;
case R.id.menu_copy:
((FileManagerApplication)navigator.getActivity().getApplication()).getCopyHelper().copy(fItem);
return true;
case R.id.menu_delete:
dialog=new SingleDeleteDialog();
dialog.setTargetFragment(navigator,0);
args=new Bundle();
args.putParcelable(FileManagerIntents.EXTRA_DIALOG_FILE_HOLDER,fItem);
dialog.setArguments(args);
dialog.show(navigator.getFragmentManager(),SingleDeleteDialog.class.getName());
return true;
case R.id.menu_rename:
dialog=new RenameDialog();
dialog.setTargetFragment(navigator,0);
args=new Bundle();
args.putParcelable(FileManagerIntents.EXTRA_DIALOG_FILE_HOLDER,fItem);
dialog.setArguments(args);
dialog.show(navigator.getFragmentManager(),RenameDialog.class.getName());
return true;
case R.id.menu_send:
sendFile(fItem,context);
return true;
case R.id.menu_details:
dialog=new DetailsDialog();
dialog.setTargetFragment(navigator,0);
args=new Bundle();
args.putParcelable(FileManagerIntents.EXTRA_DIALOG_FILE_HOLDER,fItem);
dialog.setArguments(args);
dialog.show(navigator.getFragmentManager(),DetailsDialog.class.getName());
return true;
case R.id.menu_compress:
dialog=new SingleCompressDialog();
dialog.setTargetFragment(navigator,0);
args=new Bundle();
args.putParcelable(FileManagerIntents.EXTRA_DIALOG_FILE_HOLDER,fItem);
dialog.setArguments(args);
dialog.show(navigator.getFragmentManager(),SingleCompressDialog.class.getName());
return true;
case R.id.menu_extract:
File dest=new File(fItem.getFile().getParentFile(),FileUtils.getNameWithoutExtension(fItem.getFile()));
dest.mkdirs();
new ExtractManager(context).setOnExtractFinishedListener(new ExtractManager.OnExtractFinishedListener(){
@Override public void extractFinished(){
navigator.refresh();
}
}
).extract(fItem.getFile(),dest.getAbsolutePath());
return true;
case R.id.menu_bookmark:
String path=fItem.getFile().getAbsolutePath();
Cursor query=context.getContentResolver().query(BookmarksProvider.CONTENT_URI,new String[]{BookmarksProvider._ID},BookmarksProvider.PATH + "String_Node_Str",new String[]{path},null);
if (!query.moveToFirst()) {
ContentValues values=new ContentValues();
values.put(BookmarksProvider.NAME,fItem.getName());
values.put(BookmarksProvider.PATH,path);
context.getContentResolver().insert(BookmarksProvider.CONTENT_URI,values);
Toast.makeText(context,R.string.bookmark_added,Toast.LENGTH_SHORT).show();
}
 else {
Toast.makeText(context,R.string.bookmark_already_exists,Toast.LENGTH_SHORT).show();
}
query.close();
return true;
case R.id.menu_more:
if (!PreferenceActivity.getShowAllWarning(context)) {
showMoreCommandsDialog(fItem,context);
return true;
}
showWarningDialog(fItem,context);
return true;
}
return false;
}

Fixed version (ground truth):
/** 
 * Central point where we handle actions for single selection, for every API level.
 * @param mItem The selected menu option/action.
 * @param fItem The data to act upon.
 */
public static boolean handleSingleSelectionAction(final SimpleFileListFragment navigator,MenuItem mItem,FileHolder fItem,Context context){
  DialogFragment dialog;
  Bundle args;
switch (mItem.getItemId()) {
case R.id.menu_open:
    navigator.openInformingPathBar(fItem);
  return true;
case R.id.menu_create_shortcut:
createShortcut(fItem,context);
return true;
case R.id.menu_move:
((FileManagerApplication)navigator.getActivity().getApplication()).getCopyHelper().cut(fItem);
return true;
case R.id.menu_copy:
((FileManagerApplication)navigator.getActivity().getApplication()).getCopyHelper().copy(fItem);
return true;
case R.id.menu_delete:
dialog=new SingleDeleteDialog();
dialog.setTargetFragment(navigator,0);
args=new Bundle();
args.putParcelable(FileManagerIntents.EXTRA_DIALOG_FILE_HOLDER,fItem);
dialog.setArguments(args);
dialog.show(navigator.getFragmentManager(),SingleDeleteDialog.class.getName());
return true;
case R.id.menu_rename:
dialog=new RenameDialog();
dialog.setTargetFragment(navigator,0);
args=new Bundle();
args.putParcelable(FileManagerIntents.EXTRA_DIALOG_FILE_HOLDER,fItem);
dialog.setArguments(args);
dialog.show(navigator.getFragmentManager(),RenameDialog.class.getName());
return true;
case R.id.menu_send:
sendFile(fItem,context);
return true;
case R.id.menu_details:
dialog=new DetailsDialog();
dialog.setTargetFragment(navigator,0);
args=new Bundle();
args.putParcelable(FileManagerIntents.EXTRA_DIALOG_FILE_HOLDER,fItem);
dialog.setArguments(args);
dialog.show(navigator.getFragmentManager(),DetailsDialog.class.getName());
return true;
case R.id.menu_compress:
dialog=new SingleCompressDialog();
dialog.setTargetFragment(navigator,0);
args=new Bundle();
args.putParcelable(FileManagerIntents.EXTRA_DIALOG_FILE_HOLDER,fItem);
dialog.setArguments(args);
dialog.show(navigator.getFragmentManager(),SingleCompressDialog.class.getName());
return true;
case R.id.menu_extract:
File dest=new File(fItem.getFile().getParentFile(),FileUtils.getNameWithoutExtension(fItem.getFile()));
dest.mkdirs();
new ExtractManager(context).setOnExtractFinishedListener(new ExtractManager.OnExtractFinishedListener(){
@Override public void extractFinished(){
navigator.refresh();
}
}
).extract(fItem.getFile(),dest.getAbsolutePath());
return true;
case R.id.menu_bookmark:
String path=fItem.getFile().getAbsolutePath();
Cursor query=context.getContentResolver().query(BookmarksProvider.CONTENT_URI,new String[]{BookmarksProvider._ID},BookmarksProvider.PATH + "String_Node_Str",new String[]{path},null);
if (!query.moveToFirst()) {
ContentValues values=new ContentValues();
values.put(BookmarksProvider.NAME,fItem.getName());
values.put(BookmarksProvider.PATH,path);
context.getContentResolver().insert(BookmarksProvider.CONTENT_URI,values);
Toast.makeText(context,R.string.bookmark_added,Toast.LENGTH_SHORT).show();
}
 else {
Toast.makeText(context,R.string.bookmark_already_exists,Toast.LENGTH_SHORT).show();
}
query.close();
return true;
case R.id.menu_more:
if (!PreferenceActivity.getShowAllWarning(context)) {
showMoreCommandsDialog(fItem,context);
return true;
}
showWarningDialog(fItem,context);
return true;
}
return false;
}