Program: 60366
Project: 60366
Buggy source:
@Override public void onMenuItemClick(final File file,MenuItem item){
switch (item.getItemId()) {
case R.id.pin:
    Shortcuts.add(getActivity(),new Shortcuts.Item(file));
  ((DrawerActivity)getActivity()).reloadNavDrawer(true);
break;
case R.id.openAs:
Utils.openFile((DrawerActivity)getActivity(),file,true);
break;
case R.id.copy:
{
BaseCab cab=((DrawerActivity)getActivity()).getCab();
boolean shouldCreateCopy=cab == null || !cab.isActive() || !(cab instanceof CopyCab);
if (shouldCreateCopy) {
if (cab != null && cab instanceof BaseFileCab) {
((BaseFileCab)cab).overrideDestroy=true;
}
((DrawerActivity)getActivity()).setCab(new CopyCab().setFragment(this).setFile(file).start());
}
 else ((BaseFileCab)cab).setFragment(this).addFile(file);
break;
}
case R.id.cut:
{
BaseCab cab=((DrawerActivity)getActivity()).getCab();
boolean shouldCreateCut=cab == null || !cab.isActive() || !(cab instanceof CutCab);
if (shouldCreateCut) {
if (cab != null && cab instanceof BaseFileCab) {
((BaseFileCab)cab).overrideDestroy=true;
}
((DrawerActivity)getActivity()).setCab(new CutCab().setFragment(this).setFile(file).start());
}
 else ((BaseFileCab)cab).setFragment(this).addFile(file);
break;
}
case R.id.rename:
Utils.showInputDialog(getActivity(),R.string.rename,0,file.getName(),new Utils.InputCallback(){
@Override public void onInput(String text){
if (!text.contains("String_Node_Str")) text+=file.getExtension();
final File newFile=file.isRemote() ? new CloudFile(getActivity(),(CloudFile)file.getParent(),text,file.isDirectory()) : new LocalFile(getActivity(),file.getParent(),text);
file.rename(newFile,new SftpClient.CompletionCallback(){
@Override public void onComplete(){
reload();
if (((DrawerActivity)getActivity()).getCab() != null && ((DrawerActivity)getActivity()).getCab() instanceof BaseFileCab) {
int cabIndex=((BaseFileCab)((DrawerActivity)getActivity()).getCab()).findFile(file);
if (cabIndex > -1) ((BaseFileCab)((DrawerActivity)getActivity()).getCab()).setFile(cabIndex,newFile);
Toast.makeText(getActivity(),getString(R.string.renamed_to,newFile.getPath()),Toast.LENGTH_SHORT).show();
}
}
@Override public void onError(Exception e){
}
}
);
}
}
);
break;
case R.id.zip:
final List<File> files=new ArrayList<File>();
files.add(file);
if (file.getExtension().equals("String_Node_Str")) {
Unzipper.unzip(this,files,null);
}
 else {
Zipper.zip(this,files,null);
}
break;
case R.id.share:
try {
getActivity().startActivity(new Intent(Intent.ACTION_SEND).setType(file.getMimeType()).putExtra(Intent.EXTRA_STREAM,Uri.fromFile(file.toJavaFile())));
}
 catch (ActivityNotFoundException e) {
Toast.makeText(getActivity(),R.string.no_apps_for_sharing,Toast.LENGTH_SHORT).show();
}
break;
case R.id.delete:
Utils.showConfirmDialog(getActivity(),R.string.delete,R.string.confirm_delete,file.getName(),new CustomDialog.SimpleClickListener(){
@Override public void onPositive(int which,View view){
file.delete(new SftpClient.CompletionCallback(){
@Override public void onComplete(){
if (Shortcuts.remove(getActivity(),file)) ((DrawerActivity)getActivity()).reloadNavDrawer();
mAdapter.remove(file);
}
@Override public void onError(Exception e){
}
}
);
}
}
);
break;
case R.id.details:
DetailsDialog.create(file).show(getActivity().getFragmentManager(),"String_Node_Str");
break;
}
}

Fixed version (ground truth):
@Override public void onMenuItemClick(final File file,MenuItem item){
switch (item.getItemId()) {
case R.id.pin:
    Shortcuts.add(getActivity(),new Shortcuts.Item(file));
  ((DrawerActivity)getActivity()).reloadNavDrawer(true);
break;
case R.id.openAs:
Utils.openFile((DrawerActivity)getActivity(),file,true);
break;
case R.id.copy:
{
BaseCab cab=((DrawerActivity)getActivity()).getCab();
boolean shouldCreateCopy=cab == null || !cab.isActive() || !(cab instanceof CopyCab);
if (shouldCreateCopy) {
if (cab != null && cab instanceof BaseFileCab) {
((BaseFileCab)cab).overrideDestroy=true;
}
((DrawerActivity)getActivity()).setCab(new CopyCab().setFragment(this).setFile(file).start());
}
 else ((BaseFileCab)cab).setFragment(this).addFile(file);
break;
}
case R.id.cut:
{
BaseCab cab=((DrawerActivity)getActivity()).getCab();
boolean shouldCreateCut=cab == null || !cab.isActive() || !(cab instanceof CutCab);
if (shouldCreateCut) {
if (cab != null && cab instanceof BaseFileCab) {
((BaseFileCab)cab).overrideDestroy=true;
}
((DrawerActivity)getActivity()).setCab(new CutCab().setFragment(this).setFile(file).start());
}
 else ((BaseFileCab)cab).setFragment(this).addFile(file);
break;
}
case R.id.rename:
Utils.showInputDialog(getActivity(),R.string.rename,0,file.getName(),new Utils.InputCallback(){
@Override public void onInput(String text){
if (!text.contains("String_Node_Str")) text+=file.getExtension();
final File newFile=file.isRemote() ? new CloudFile(getActivity(),(CloudFile)file.getParent(),text,file.isDirectory()) : new LocalFile(getActivity(),file.getParent(),text);
file.rename(newFile,new SftpClient.CompletionCallback(){
@Override public void onComplete(){
reload();
if (((DrawerActivity)getActivity()).getCab() != null && ((DrawerActivity)getActivity()).getCab() instanceof BaseFileCab) {
int cabIndex=((BaseFileCab)((DrawerActivity)getActivity()).getCab()).findFile(file);
if (cabIndex > -1) ((BaseFileCab)((DrawerActivity)getActivity()).getCab()).setFile(cabIndex,newFile);
Toast.makeText(getActivity(),getString(R.string.renamed_to,newFile.getPath()),Toast.LENGTH_SHORT).show();
}
}
@Override public void onError(Exception e){
}
}
);
}
}
);
break;
case R.id.zip:
final List<File> files=new ArrayList<File>();
files.add(file);
if (file.getExtension().equals("String_Node_Str")) {
Unzipper.unzip(this,files,null);
}
 else {
Zipper.zip(this,files,null);
}
break;
case R.id.share:
try {
getActivity().startActivity(new Intent(Intent.ACTION_SEND).setType(file.getMimeType()).putExtra(Intent.EXTRA_STREAM,Uri.fromFile(file.toJavaFile())));
}
 catch (ActivityNotFoundException e) {
Toast.makeText(getActivity(),R.string.no_apps_for_sharing,Toast.LENGTH_SHORT).show();
}
break;
case R.id.delete:
Utils.showConfirmDialog(getActivity(),R.string.delete,R.string.confirm_delete,file.getName(),new CustomDialog.SimpleClickListener(){
@Override public void onPositive(int which,View view){
file.delete(new SftpClient.CompletionCallback(){
@Override public void onComplete(){
if (Shortcuts.remove(getActivity(),file)) ((DrawerActivity)getActivity()).reloadNavDrawer();
DrawerActivity act=(DrawerActivity)getActivity();
if (act.getCab() != null && act.getCab() instanceof BaseFileCab) {
((BaseFileCab)act.getCab()).removeFile(file);
}
mAdapter.remove(file);
}
@Override public void onError(Exception e){
}
}
);
}
}
);
break;
case R.id.details:
DetailsDialog.create(file).show(getActivity().getFragmentManager(),"String_Node_Str");
break;
}
}