Example #1
0
 @Override
 public boolean onContextItemSelected(MenuItem item) {
   AdapterView.AdapterContextMenuInfo info;
   try {
     info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
   } catch (ClassCastException e) {
     Log.e("Bad menuInfo", e);
     return false;
   }
   File file = (File) mAdapter.getItem(info.position);
   int itemId = item.getItemId();
   if (itemId == MenuId.DELETE.getId()) {
     delete(file);
     return true;
   } else if (itemId == MenuId.RENAME.getId()) {
     rename(file);
     return true;
   } else if (itemId == MenuId.DECOMPILE.getId()) {
     if (!file.getAbsolutePath().endsWith(".pyc") && !file.isDirectory()) {
       // 非文件夹或者非pyc文件提示无法反编译
       Crouton.cancelAllCroutons();
       Crouton.showText(this, getString(R.string.s_Cannotdecompile), Style.ALERT);
       return true;
     }
     Decompile.show(this, file.getAbsolutePath());
     return true;
   } else if (itemId == MenuId.BUILD.getId()) {
     // 打包项目
   }
   return false;
 }
Example #2
0
 @Override
 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
   menu.add(Menu.NONE, MenuId.RENAME.getId(), Menu.NONE, getString(R.string.s_Rename));
   menu.add(Menu.NONE, MenuId.DELETE.getId(), Menu.NONE, getString(R.string.s_Delete));
   menu.add(Menu.NONE, MenuId.DECOMPILE.getId(), Menu.NONE, getString(R.string.s_Decompile));
   menu.add(Menu.NONE, MenuId.BUILD.getId(), Menu.NONE, getString(R.string.s_Build));
 }