Beispiel #1
0
  @Override
  public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    // Handle select all/none first, and if it isn't those then don't do anything if we haven't
    // selected any items.
    if (item.getItemId() == R.id.action_select_all) {
      adapter.selectAll();
      return true;
    } else if (item.getItemId() == R.id.action_select_none) {
      adapter.clearSelections();
      return true;
    } else if (adapter.getSelectedItemCount() == 0) return true;

    // Handle actions.
    switch (item.getItemId()) {
      case R.id.action_tag:
        //noinspection unchecked
        TaggingActivity.start(this, adapter.getSelectedRealmObjects());
        return true;
      case R.id.action_rate:
        int initialRating =
            adapter.getSelectedItemCount() == 1
                ? ((RBook) adapter.getSelectedRealmObjects().get(0)).rating
                : 0;
        Dialogs.ratingDialog(getContext(), initialRating);
        return true;
      case R.id.action_mark_as:
        Dialogs.markAsDialog(getActivity());
        return true;
      case R.id.action_add_to_list:
        Dialogs.addToListDialogOrSnack(getActivity(), realm);
        return true;
      case R.id.action_re_import:
        Dialogs.simpleConfirmDialog(
            getContext(),
            R.string.title_re_import_books,
            R.string.prompt_re_import_books,
            R.string.action_re_import,
            R.id.action_re_import);
        return true;
      case R.id.action_remove:
        Dialogs.simpleConfirmDialog(
            getContext(),
            R.string.title_remove_books,
            R.string.prompt_remove_from_recents,
            R.string.action_remove,
            R.id.action_remove);
        return true;
      case R.id.action_delete:
        Dialogs.confirmCheckBoxDialog(
            getContext(),
            R.string.title_delete_books,
            R.string.prompt_delete_books,
            R.string.prompt_delete_from_device_too,
            R.string.action_delete,
            R.id.action_delete);
        return true;
      default:
        return false;
    }
  }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   if (item.getItemId() == R.id.action_add) {
     Intent intent = new Intent(getActivity(), ScreenActivity.class);
     intent.putExtra(ScreenFragment.EXTRA_TREE_ID, treeId);
     startActivity(intent);
   }
   if (item.getItemId() == R.id.action_export) {
     exportTree();
   }
   return super.onOptionsItemSelected(item);
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   if (item.getItemId() == android.R.id.home) {
     Intent myIntent = new Intent(this, Principal.class);
     myIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
     startActivity(myIntent);
     finish();
     return true;
   } else if (item.getItemId() == R.id.gotodirection) {
     if (marcador != null) {
       LocationResult locationResult =
           new LocationResult() {
             @Override
             public void gotLocation(Location location) {
               try {
                 Intent intent =
                     new Intent(
                         android.content.Intent.ACTION_VIEW,
                         Uri.parse(
                             "http://maps.google.com/maps?saddr="
                                 + location.getLatitude()
                                 + ","
                                 + location.getLongitude()
                                 + "&daddr="
                                 + marcador.getPosition().latitude
                                 + ","
                                 + marcador.getPosition().longitude));
                 pd.dismiss();
                 startActivity(intent);
               } catch (Exception e) {
               }
               pd.dismiss();
             }
           };
       pd =
           ProgressDialog.show(
               ctx,
               getResources().getText(R.string.procesando),
               getResources().getText(R.string.location));
       pd.setIndeterminate(false);
       pd.setCancelable(true);
       MyLocation myLocation = new MyLocation();
       myLocation.getLocation(ctx, locationResult);
     }
     return true;
   } else if (item.getItemId() == R.id.infoDetails) {
     Intent myIntent = new Intent(this, Info.class);
     startActivity(myIntent);
     return true;
   }
   return false;
 }
Beispiel #4
0
 @Override
 public boolean onContextItemSelected(MenuItem item) {
   final int position = ((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position;
   final ListView view = (ListView) getTabHost().getCurrentView();
   final Bookmark bookmark = ((BookmarksAdapter) view.getAdapter()).getItem(position);
   switch (item.getItemId()) {
     case OPEN_ITEM_ID:
       gotoBookmark(bookmark);
       return true;
     case EDIT_ITEM_ID:
       final Intent intent = new Intent(this, BookmarkEditActivity.class);
       OrientationUtil.startActivityForResult(this, intent, 1);
       // TODO: implement
       return true;
     case DELETE_ITEM_ID:
       myCollection.deleteBookmark(bookmark);
       if (myThisBookAdapter != null) {
         myThisBookAdapter.remove(bookmark);
       }
       if (myAllBooksAdapter != null) {
         myAllBooksAdapter.remove(bookmark);
       }
       if (mySearchResultsAdapter != null) {
         mySearchResultsAdapter.remove(bookmark);
       }
       return true;
   }
   return super.onContextItemSelected(item);
 }
Beispiel #5
0
  /** Called when one of the menu items is selected. */
  public boolean onOptionsItemSelected(MenuItem item) {

    int itemId = item.getItemId();
    Utilities.LogInfo("Option item selected - " + String.valueOf(item.getTitle()));

    switch (itemId) {
      case R.id.mnuSettings:
        Intent settingsActivity = new Intent(getApplicationContext(), GpsSettingsActivity.class);
        startActivity(settingsActivity);
        break;
      case R.id.mnuOSM:
        UploadToOpenStreetMap();
        break;
      case R.id.mnuDropBox:
        UploadToDropBox();
        break;
      case R.id.mnuAnnotate:
        Annotate();
        break;
      case R.id.mnuShare:
        Share();
        break;
      case R.id.mnuEmailnow:
        EmailNow();
        break;
      case R.id.mnuExit:
        loggingService.StopLogging();
        loggingService.stopSelf();
        finish();
        break;
    }
    return false;
  }
Beispiel #6
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.menu_main_state:
       if (fragmentMode == Statics.FRAGMENT_ENABLED) {
         CustomDialog confirmation =
             new CustomDialog(
                 getActivity(),
                 "Disable " + ((AppsAdapter) lvApps.getAdapter()).getSelectedItem().name + " ?",
                 "Do you really want to disable the app?\nIt won't be visible and/or usable afterwards.",
                 ((AppsAdapter) lvApps.getAdapter()).getSelectedItem().icon,
                 "Yes",
                 "No",
                 this);
         confirmation.show();
       } else {
         CustomDialog confirmation =
             new CustomDialog(
                 getActivity(),
                 "Enable " + ((AppsAdapter) lvApps.getAdapter()).getSelectedItem().name + " ?",
                 "Do you really want to enable the app?\nIt will be visible and/or usable afterwards.",
                 ((AppsAdapter) lvApps.getAdapter()).getSelectedItem().icon,
                 "Yes",
                 "No",
                 this);
         confirmation.show();
       }
       break;
     case R.id.menu_main_deselect:
       ((AppsAdapter) lvApps.getAdapter()).resetSelection();
       getActivity().invalidateOptionsMenu();
       break;
   }
   return super.onOptionsItemSelected(item);
 }
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info =
        (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

    ArrayList<Insert> items = new ArrayList<>();
    FragmentManager fm = getActivity().getSupportFragmentManager();
    Insert insert;

    switch (item.getItemId()) {
      case R.id.menu_toggle_fav:
        adapter.toggleSelection(info.position);
        break;

      case R.id.menu_edit:
        insert = (Insert) adapter.getItem(info.position);
        InsertDialogFragment dialog = InsertDialogFragment.newInstance(insert);
        dialog.show(fm, ARG_EDIT_INSERT);
        break;

      case R.id.menu_delete:
        insert = (Insert) adapter.getItem(info.position);
        items.add(insert);
        DeleteInsertDialogFragment deleteDialog = DeleteInsertDialogFragment.newInstance(items);
        deleteDialog.show(fm, ARG_DELETE_INSERT);
        break;
    }

    return super.onContextItemSelected(item);
  }
  public boolean onContextItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case 1:
        mBtn.setTextColor(Color.RED);
        return true;
      case 2:
        mBtn.setTextColor(Color.GREEN);
        return true;
      case 3:
        mBtn.setTextColor(Color.BLUE);
        return true;
      case 4:
        Toast.makeText(this, "번역했다.", Toast.LENGTH_SHORT).show();
        return true;
      case 5:
        Toast.makeText(this, "필기 인식했다.", Toast.LENGTH_SHORT).show();
        return true;
      case 100:
        Toast.makeText(this, "회전했다 치고.", Toast.LENGTH_SHORT).show();
        return true;
      case 101:
        Toast.makeText(this, "크기 변경 했다 치고.", Toast.LENGTH_SHORT).show();
        return true;
    }

    return true;
  }
Beispiel #9
0
 /** {@inheritDoc} */
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       if ((getActionBar().getDisplayOptions() & ActionBar.DISPLAY_HOME_AS_UP)
           == ActionBar.DISPLAY_HOME_AS_UP) {
         checkDirtyState();
       }
       break;
     case R.id.mnu_save:
       // Save the file
       writeFile();
       break;
     case R.id.mnu_word_wrap:
       toggleWordWrap();
       break;
     case R.id.mnu_settings:
       // Settings
       Intent settings = new Intent(EditorActivity.this, SettingsPreferences.class);
       settings.putExtra(
           PreferenceActivity.EXTRA_SHOW_FRAGMENT, EditorPreferenceFragment.class.getName());
       startActivity(settings);
       break;
   }
   return super.onOptionsItemSelected(item);
 }
        @Override
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
          switch (item.getItemId()) {
            case 0:
              // Call to getselectedId's method listViewAdapter
              SparseBooleanArray selected = adapter.getSelectedIds();
              // Get all selected id's through iteration
              for (int i = (selected.size() - 1); i >= 0; i--) {
                if (selected.valueAt(i)) {
                  Book selecteditem = adapter.getItem(selected.keyAt(i));
                  adapter.addSelectedBook(selecteditem); // Add item to recently removed items list
                }
              }
              // Close CAB
              mode.finish();

              try {
                requestUpdateData(BookshelfConstants.CONNECTION_URI);
              } catch (JSONException e) {
                e.printStackTrace();
              }

              return true;
            default:
              return false;
          }
        }
Beispiel #11
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // The action bar home/up action should open or close the drawer.
    // ActionBarDrawerToggle will take care of this.
    if (mDrawerToggle.onOptionsItemSelected(item)) {
      return true;
    }
    // Handle action buttons
    switch (item.getItemId()) {
      case R.id.action_share:
        //                updateShareIntent();
        showShare();
        return true;

      case R.id.action_share_wechat:
        //                updateShareIntent();
        showShareWeChat();
        return true;
        //            case R.id.action_about:
        //                showAbout();
        //                return true;

      default:
        return super.onOptionsItemSelected(item);
    }
  }
 @Override
 public boolean onContextItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case PLAY_SELECTION:
       {
         long[] list =
             MusicUtils.getSongListForAlbum(getActivity(), Long.parseLong(mCurrentAlbumId));
         MusicUtils.playAll(getActivity(), list, 0);
         break;
       }
     case ADD_TO_PLAYLIST:
       {
         Intent intent = new Intent(INTENT_ADD_TO_PLAYLIST);
         long[] list =
             MusicUtils.getSongListForAlbum(getActivity(), Long.parseLong(mCurrentAlbumId));
         intent.putExtra(INTENT_PLAYLIST_LIST, list);
         getActivity().startActivity(intent);
         break;
       }
     case SEARCH:
       {
         MusicUtils.doSearch(getActivity(), mCursor, mAlbumNameIndex);
         break;
       }
     default:
       break;
   }
   return super.onContextItemSelected(item);
 }
Beispiel #13
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == android.R.id.home) {
      finish();
    }
    if (id == R.id.action_send) {
      boolean hasError = false;

      if (etSubject.getText().toString().trim().length() == 0) {
        tilSubject.setErrorEnabled(true);
        tilSubject.setError("Entre com um assunto");
        hasError = true;
      } else {
        tilSubject.setErrorEnabled(false);
      }
      if (etMessage.getText().toString().trim().length() == 0) {
        tilMessage.setErrorEnabled(true);
        tilMessage.setError("Entre com uma mensagem de contato");
        hasError = true;
      } else {
        tilMessage.setErrorEnabled(false);
      }

      if (!hasError) {
        usuario = new Usuario();
        usuario.setEmail(UtilTCM.getEmailAccountManager(this));
        usuario.setMessage(etMessage.getText().toString());

        NetworkConnection.getInstance(this).execute(this, UsuarioActivity.class.getName());
      }
    }

    return true;
  }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   Intent intent;
   switch (item.getItemId()) {
     default:
       return super.onOptionsItemSelected(item);
   }
 }
 /**
  * Override to be notified when a menu item is selected
  *
  * @param item menu item
  * @return
  */
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   if (item.getItemId() == R.id.reset) {
     initAdapter();
     return (true);
   }
   return (super.onOptionsItemSelected(item));
 }
 public boolean onMenuItemClick(MenuItem item) {
   switch (item.getItemId()) {
     case 1:
       return onSearchRequested();
     default:
       return true;
   }
 }
Beispiel #17
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.menu_refresh:
       refresh();
       return true;
   }
   return true;
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   int id = item.getItemId();
   if (id == R.id.search_in_internet) {
     createLinkOnSite();
     return true;
   }
   return super.onOptionsItemSelected(item);
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       getActivity().finish();
     default:
       return super.onOptionsItemSelected(item);
   }
 }
 @Override
 public boolean onContextItemSelected(MenuItem item) {
   final int position = ((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position;
   final Book book = ((LibraryTree) getListAdapter().getItem(position)).getBook();
   if (book != null) {
     return onContextItemSelected(item.getItemId(), book);
   }
   return super.onContextItemSelected(item);
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       NavUtils.navigateUpFromSameTask(this);
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
Beispiel #22
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case CONFIG_ID:
        startActivity(new Intent(this, ConfigActivity.class));
        return true;
    }

    return super.onOptionsItemSelected(item);
  }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.logout:
       showLogoutDialog();
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }
Beispiel #24
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.settings:
       startActivity(new Intent(this, Settings.class));
       FlurryAgent.onEvent("Settings Button");
       return true;
   }
   return false;
 }
Beispiel #25
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       finish();
       // NavUtils.navigateUpFromSameTask(this);
       break;
   }
   return false;
 }
  @Override
  public boolean onMenuItemSelected(int featureId, MenuItem item) {
    if (item.getItemId() == R.id.add_item) {
      GroupClass newGroup = new GroupClass("New Group " + System.currentTimeMillis());
      newGroup.addChild(new ChildClass("New Child", "Child Text: " + System.currentTimeMillis()));
      this.groups.add(0, newGroup);

      this.adapter.notifyDataSetChanged();

      return true;
    } else if (item.getItemId() == R.id.remove_item) {
      this.groups.remove(0);

      this.adapter.notifyDataSetChanged();

      return true;
    } else {
      return super.onMenuItemSelected(featureId, item);
    }
  }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       Intent intent = new Intent(this, MainActivity.class);
       startActivity(intent);
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
      case R.id.contactMenu:
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(intent, 1);
        break;
    }
    return super.onOptionsItemSelected(item);
  }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   Helpers.removeCurItem(item, Menu.FIRST + 1, (ViewPager) getView().getParent());
   switch (item.getItemId()) {
     case R.id.app_settings:
       Intent intent = new Intent(context, PCSettings.class);
       startActivity(intent);
       break;
   }
   return true;
 }
 @Override
 public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
   switch (item.getItemId()) {
     case R.id.menu_remove:
       SparseBooleanArray positions = getListView().getCheckedItemPositions();
       long[] ids = getListView().getCheckedItemIds();
       removeItem(positions, ids, mode);
       return true;
   }
   return false;
 }