@Override
 public boolean onCreateActionMode(ActionMode mode, Menu menu) {
   MenuInflater inflater = mode.getMenuInflater();
   inflater.inflate(R.menu.cab_jsonarray, menu);
   mode.setTitle(mCheckedCount + getString(R.string.desc_selected));
   return true;
 }
  /**
   * https://android.googlesource.com/platform/frameworks/base/+/cd92588/core/java/android/webkit/SelectActionModeCallback.java
   *
   * @param actionMode
   * @return ActionMode
   */
  @Override
  public ActionMode onWebViewStartActionMode(ActionMode actionMode) {
    Menu menu = actionMode.getMenu();

    for (int i = 0; i < menu.size(); i++) {
      MenuItem item = menu.getItem(i);
      item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
    }

    MenuInflater inflater = actionMode.getMenuInflater();
    inflater.inflate(R.menu.browser_action_mode, menu);
    translatePanelFragment.hide();

    menu.findItem(R.id.action_search)
        .setOnMenuItemClickListener(
            new MenuItem.OnMenuItemClickListener() {
              @Override
              public boolean onMenuItemClick(MenuItem menuItem) {
                startGettingSelectionInBrowser(JAVASCRIPT_CALLBACK_SEARCH);
                return false;
              }
            });
    menu.findItem(R.id.action_speech)
        .setOnMenuItemClickListener(
            new MenuItem.OnMenuItemClickListener() {
              @Override
              public boolean onMenuItemClick(MenuItem menuItem) {
                startGettingSelectionInBrowser(JAVASCRIPT_CALLBACK_SPEECH);
                return false;
              }
            });

    return actionMode;
  }
 @Override
 public boolean onCreateActionMode(ActionMode mode, Menu menu) {
   selectedPos = new HashSet<Integer>();
   mode.setSubtitle(R.string.selected);
   mode.getMenuInflater().inflate(R.menu.action_contact_list, menu);
   return true;
 }
  @Override
  public boolean onActionItemClicked(ActionMode mode, MenuItem item) {

    switch (item.getItemId()) {
      case R.id.menu_at:
        Intent intent = new Intent(getActivity(), WriteWeiboActivity.class);
        intent.putExtra("token", GlobalContext.getInstance().getSpecialToken());
        intent.putExtra("content", "@" + bean.getScreen_name());
        intent.putExtra("account", GlobalContext.getInstance().getAccountBean());
        getActivity().startActivity(intent);
        listView.clearChoices();
        mode.finish();
        break;
      case R.id.menu_follow:
        if (followOrUnfollowTask == null
            || followOrUnfollowTask.getStatus() == MyAsyncTask.Status.FINISHED) {
          followOrUnfollowTask = new FollowTask();
          followOrUnfollowTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
        }
        listView.clearChoices();
        mode.finish();
        break;
      case R.id.menu_unfollow:
        if (followOrUnfollowTask == null
            || followOrUnfollowTask.getStatus() == MyAsyncTask.Status.FINISHED) {
          followOrUnfollowTask = new UnFollowTask();
          followOrUnfollowTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
        }
        listView.clearChoices();
        mode.finish();
        break;
    }

    return true;
  }
示例#5
0
文件: Home.java 项目: HKMOpen/KAM
 @Override
 public void onItemLongClickListener(View view, int position) {
   if (selectedApps.get(position) == null) {
     selectedApps.put(position, adapter.getModelList().get(position));
     adapter.setItemChecked(position, true);
   } else {
     selectedApps.remove(position);
     adapter.setItemChecked(position, false);
   }
   if (selectedApps.size() != 0) {
     if (actionMode == null) {
       actionMode = toolbar.startActionMode(this);
       AppHelper.actionModeColor(this);
     }
     if (selectedApps.size() > 1) {
       actionMode.setTitle("Backup ( " + selectedApps.size() + " Apps )");
     } else {
       actionMode.setTitle("Backup ( " + selectedApps.size() + " App )");
     }
     enableDisableMenuItem(false);
   } else {
     actionMode.finish();
     actionMode = null;
   }
 }
  @Override
  public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    // Respond to clicks on the actions in the CAB
    switch (item.getItemId()) {
      case R.id.action_delete_item:
        System.out.println("Clicked action");
        List<Host> selected = getSelectedHosts();
        hosts.removeAll(selected);
        hostListAdapter.notifyDataSetChanged();

        for (Host h : selected) {
          h.delete();
        }
        mode.finish();
        return true;
      case R.id.action_edit_item:
        Intent i = new Intent(parent, EditHostActivity.class);
        i.putExtra("hostYaml", ((Host) getSelectedHosts().get(0)).saveToYamlString());
        parent.startActivityForResult(i, ConnectionChooser.EDIT_HOST);
        mode.finish();
        return true;
      default:
        return false;
    }
  }
    @Override
    public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
      // TODO Auto-generated method stub
      int selectCount = img_grid.getCheckedItemCount();
      switch (selectCount) {
        case 1:
          mode.setTitle("" + selectCount);
          break;
        default:
          mode.setTitle("" + selectCount);
          break;
      }

      if (checked) {
        adapter.addSelection(position);
      } else {
        int count = adapter.getSelectedCount();
        for (int i = 0; i < count; i++) {
          if (adapter.getSelected(i) == position) adapter.removeSelection(i);
        }

        //                ArrayList<Integer> indexes = adapter.getSelecteds();
        //                for (Integer i : indexes ) {
        //                    adapter.removeSelection(i);
        //                }
      }
    }
    @Override
    public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
      boolean result;
      switch (item.getItemId()) {
        case R.id.menu_context_remove:
          onRemoveItemsClicked(mCheckedItems);
          mode.finish();
          result = true;
          break;

        case R.id.menu_context_retain:
          onRetainItemsClicked(mCheckedItems);
          mode.finish();
          result = true;
          break;

        default:
          result = false;
          break;
      }

      if (result && mEventListener != null) {
        mEventListener.onAdapterCountUpdated();
      }
      return result;
    }
 @Override
 public boolean onCreateActionMode(ActionMode mode, Menu menu) {
   mode.setTitle(null);
   mode.setSubtitle(null);
   mEditable = mActionHandler.isSelectionEditable();
   createActionMenu(mode, menu);
   return true;
 }
示例#10
0
 public static void updateActionModeTitle(ActionMode mode, Context context, int selectedNum) {
   if (mode != null) {
     mode.setTitle(context.getString(R.string.multi_select_title, selectedNum));
     if (selectedNum == 0) {
       mode.finish();
     }
   }
 }
 /** ** Contextual ActionBar (CAB) routines * */
 private void updateActionModeTitle() {
   if (mActionMode == null) return;
   int numSelected = getSelectedCommentCount();
   if (numSelected > 0) {
     mActionMode.setTitle(Integer.toString(numSelected));
   } else {
     mActionMode.setTitle("");
   }
 }
示例#12
0
 // Cambia el estado de selección del elemento situado en dicha posición.
 private void toggleSelection(int position) {
   // Se cambia el estado de selección
   mAdaptador.toggleSelection(position);
   // Se actualiza el texto del action mode contextual.
   mActionMode.setTitle(mAdaptador.getSelectedItemCount() + " / " + mAdaptador.getItemCount());
   // Si ya no hay ningún elemento seleccionado se finaliza el modo de
   // acción contextual
   if (mAdaptador.getSelectedItemCount() == 0) {
     mActionMode.finish();
   }
 }
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
          if (actionMode == null) {
            actionMode = ImageSelectActivity.this.startActionMode(callback);
          }
          toggleSelection(position);
          actionMode.setTitle(countSelected + " " + getString(R.string.selected));

          if (countSelected == 0) {
            actionMode.finish();
          }
        }
 public void onTabSelected(Tab tab, FragmentTransaction ft) {
   Object tag = tab.getTag();
   for (int i = 0; i < mTabs.size(); i++) {
     if (mTabs.get(i) == tag) {
       mViewPager.setCurrentItem(i);
     }
   }
   if (!tab.getText().equals(mContext.getString(R.string.tab_sd))) {
     ActionMode actionMode = ((FileExplorerTabActivity) mContext).getActionMode();
     if (actionMode != null) {
       actionMode.finish();
     }
   }
 }
示例#15
0
 @Override
 public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
   switch (item.getItemId()) {
     case R.id.action_done:
       mCropping = true;
       mode.finish();
       crop();
       return true;
     case R.id.action_cancel:
       mode.finish();
       return true;
   }
   return true;
 }
  @Override
  public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
    MenuInflater inflater = mode.getMenuInflater();
    menu.clear();

    // sina weibo has bug,everyone's following is false
    inflater.inflate(R.menu.contextual_menu_fragment_user_listview, menu);
    //        if(bean.isFollowing()){
    //           menu.findItem(R.id.menu_follow).setVisible(false);
    //        }

    mode.setTitle(bean.getScreen_name());

    return true;
  }
 @Override
 public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
   menu.clear();
   MenuInflater inflater = mode.getMenuInflater();
   inflater.inflate(R.menu.newconversation_context, menu);
   SparseBooleanArray checkedItems = contactsView.getCheckedItemPositions();
   selectedContacts.clear();
   for (int i = 0; i < aggregatedContacts.size(); ++i) {
     if (checkedItems.get(i, false)) {
       selectedContacts.add(aggregatedContacts.get(i));
     }
   }
   if (selectedContacts.size() == 0) {
     menu.findItem(R.id.action_start_conversation).setVisible(false);
     menu.findItem(R.id.action_contact_details).setVisible(false);
     menu.findItem(R.id.action_invite).setVisible(false);
     menu.findItem(R.id.action_invite_to_existing).setVisible(false);
   } else if ((selectedContacts.size() == 1) && (!inviteIntent)) {
     menu.findItem(R.id.action_start_conversation).setVisible(true);
     menu.findItem(R.id.action_contact_details).setVisible(true);
     menu.findItem(R.id.action_invite).setVisible(false);
     menu.findItem(R.id.action_invite_to_existing).setVisible(true);
   } else if (!inviteIntent) {
     menu.findItem(R.id.action_start_conversation).setVisible(true);
     menu.findItem(R.id.action_contact_details).setVisible(false);
     menu.findItem(R.id.action_invite).setVisible(false);
     menu.findItem(R.id.action_invite_to_existing).setVisible(true);
   } else {
     menu.findItem(R.id.action_invite).setVisible(true);
     menu.findItem(R.id.action_start_conversation).setVisible(false);
     menu.findItem(R.id.action_contact_details).setVisible(false);
     menu.findItem(R.id.action_invite_to_existing).setVisible(false);
   }
   return true;
 }
示例#18
0
  @Override
  public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    // TODO Auto-generated method stub
    switch (item.getItemId()) {
      case R.id.show:
        SparseBooleanArray checked = content.getCheckedItemPositions();
        ArrayList<Integer> positions = new ArrayList<Integer>();
        for (int i = 0; i < checked.size(); i++) {
          if (checked.valueAt(i)) {
            positions.add(checked.keyAt(i));
          }
        }
        int[] arr = new int[positions.size()];
        int[] arr1 = new int[positions.size()];
        int k = 0;
        for (int position : positions) {
          arr[k] = mySQL.getID(position);
          arr1[k] = position;
          k++;
        }
        for (int j = 0; j < arr.length; j++) {

          mySQL.DeleteEntry(values[arr1[j]], arr[j]);
        }
        onCreate(new Bundle());
        mode.finish();
        return true;
    }
    return false;
  }
示例#19
0
 @Override
 public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
   switch (item.getItemId()) {
     case R.id.cab_item_delete:
       if (modoViagemDAO.delModoViagem((int) id_selecionado)) {
         Toast.makeText(getActivity(), "Apagado " + id_selecionado, Toast.LENGTH_SHORT)
             .show();
         atualizarAdapter();
       } else {
         Toast.makeText(
                 getActivity(), "Erro ao apagar " + id_selecionado, Toast.LENGTH_SHORT)
             .show();
       }
       mode.finish();
       return true;
     case R.id.cab_item_edit:
       Intent intent = new Intent(getActivity(), NovoModoViagemActivity.class);
       modoViagem = modoViagemDAO.getModoViagem((int) id_selecionado);
       modoViagem.setId((int) id_selecionado);
       intent.putExtra(Opcoes.isEditTag, true);
       intent.putExtra(Opcoes.modoTag, modoViagem);
       startActivity(intent);
       return true;
     default:
       return false;
   }
 }
 @Override
 public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) {
   final ListView listView = getListView();
   switch (item.getItemId()) {
     case R.id.delete:
       {
         final Expression where =
             Expression.in(
                 new Column(Filters._ID), new RawItemArray(listView.getCheckedItemIds()));
         mResolver.delete(getContentUri(), where.getSQL(), null);
         break;
       }
     case R.id.inverse_selection:
       {
         final SparseBooleanArray positions = listView.getCheckedItemPositions();
         for (int i = 0, j = listView.getCount(); i < j; i++) {
           listView.setItemChecked(i, !positions.get(i));
         }
         return true;
       }
     default:
       {
         return false;
       }
   }
   mode.finish();
   return true;
 }
示例#21
0
 @Override
 public void onResume() {
   super.onResume();
   atualizarAdapter();
   getListView().setItemChecked(position_selecionado, false);
   if (mActionMode != null) mActionMode.finish();
 }
 /* (non-Javadoc)
  * @see android.view.ActionMode.Callback#onCreateActionMode(android.view.ActionMode, android.view.Menu)
  */
 @Override
 public boolean onCreateActionMode(ActionMode mode, Menu menu) {
   MenuInflater inflater = mode.getMenuInflater();
   inflater.inflate(R.menu.activity_client_connections_contextual, menu);
   clientConnections.contextualActionBarActive = true;
   return true;
 }
 @Override
 public boolean onCreateActionMode(ActionMode mode, Menu menu) {
   // Inflate the menu for the CAB
   MenuInflater inflater = mode.getMenuInflater();
   inflater.inflate(R.menu.context, menu);
   return true;
 }
        @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;
          }
        }
  private void ensureActionModeOrFallback() {
    if (mActionMode != null) return;
    if (mFallbackPastePopupMenu != null) return;

    ActionMode.Callback2 callback2 =
        new FloatingWebActionModeCallback(
            new WebActionModeCallback(mParent.getContext(), getActionHandler()));
    ActionMode actionMode = mParent.startActionMode(callback2, ActionMode.TYPE_FLOATING);
    if (actionMode != null) {
      assert actionMode.getType() == ActionMode.TYPE_FLOATING;
      mActionMode = actionMode;
    } else {
      mFallbackPastePopupMenu = new LegacyPastePopupMenu(mParent, mDelegate);
      mFallbackPastePopupMenu.show(mRawPositionX, mRawPositionY);
    }
  }
示例#26
0
 private void updateToEditNull() {
   if (mActionMode != null) {
     mActionMode.finish();
   }
   invalidateOptionsMenu();
   mTodosListAdapter.setEditingType(TodosListAdapter.EDIT_NULL);
 }
 // Called when the action mode is created; startActionMode() was called
 @Override
 public boolean onCreateActionMode(ActionMode mode, Menu menu) {
   // Inflate a menu resource providing context menu items
   MenuInflater inflater = mode.getMenuInflater();
   inflater.inflate(R.menu.menu_cab, menu);
   return true;
 }
 @Override
 public void setUserVisibleHint(final boolean isVisibleToUser) {
   super.setUserVisibleHint(isVisibleToUser);
   if (!isVisibleToUser && mActionMode != null) {
     mActionMode.finish();
   }
 }
示例#29
0
 @Override
 public MenuWrapper getMenu() {
   if (mMenu == null) {
     mMenu = new MenuWrapper(mActionMode.getMenu());
   }
   return mMenu;
 }
 @Override
 public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
   // TODO Auto-generated method stub
   String name = (String) soccerData.getItem(position).get("name");
   mode.setTitle(name);
   return false;
 }