Esempio n. 1
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   boolean connect = false;
   switch (item.getItemId()) {
     case OPTION_CONNECT:
       connect = true;
       break;
     case OPTION_LOCK_LANDSCAPE:
       setLockLandscape(!item.isChecked());
       item.setChecked(isLockLandscape());
       break;
     case OPTION_ENABLE_REMOTE_VIEW:
       controlFragment.setRemoteEnabled(!item.isChecked());
       item.setChecked(controlFragment.isRemoteEnabled());
       break;
     case OPTION_EXIT:
       finish();
       break;
     case OPTION_HELP:
       showHelp();
       break;
     case OPTION_EXAGGERATION:
       showVerticalExaggerationDialog();
       break;
     case OPTION_FLY_HOME:
       communicator.sendMessage(new FlyHomeMessage());
       break;
     case OPTION_SEND_LOCATION:
       setSendLocation(!item.isChecked());
       item.setChecked(isSendLocation());
       break;
     case android.R.id.home:
       getSupportActionBar().selectTab(getSupportActionBar().getTabAt(0));
       connect = communicator.getState() != State.CONNECTED;
       break;
   }
   if (connect) {
     connect();
   }
   return super.onOptionsItemSelected(item);
 }