Exemple #1
0
  @Override
  public void onLookChecked() {
    if (isRenameActionMode || actionMode == null) {
      return;
    }

    int numberOfSelectedItems = adapter.getAmountOfCheckedItems();

    if (numberOfSelectedItems == 0) {
      actionMode.setTitle(actionModeTitle);
    } else {
      String appendix = multipleItemAppendixActionMode;

      if (numberOfSelectedItems == 1) {
        appendix = singleItemAppendixActionMode;
      }

      String numberOfItems = Integer.toString(numberOfSelectedItems);
      String completeTitle = actionModeTitle + " " + numberOfItems + " " + appendix;

      int titleLength = actionModeTitle.length();

      Spannable completeSpannedTitle = new SpannableString(completeTitle);
      completeSpannedTitle.setSpan(
          new ForegroundColorSpan(getResources().getColor(R.color.actionbar_title_color)),
          titleLength + 1,
          titleLength + (1 + numberOfItems.length()),
          Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

      actionMode.setTitle(completeSpannedTitle);
    }
  }
  @Override
  public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    MenuInflater inflater = getSherlockActivity().getSupportMenuInflater();
    inflater.inflate(R.menu.conversation_list_batch, menu);

    mode.setTitle(R.string.conversation_fragment_cab__batch_selection_mode);
    mode.setSubtitle(null);

    return true;
  }
 @Override
 public boolean onCreateActionMode(ActionMode mode, Menu menu) {
   mode.setTitle("Class Info");
   MenuInflater inflater = parentAct.getSupportMenuInflater();
   inflater.inflate(R.menu.schedule_action_mode, menu);
   return true;
 }
 private void handleUnselectAllThreads() {
   ((ConversationListAdapter) this.getListAdapter()).selectAllThreads();
   actionMode.setSubtitle(
       getString(
           R.string.conversation_fragment_cab__batch_selection_amount,
           ((ConversationListAdapter) this.getListAdapter()).getBatchSelections().size()));
 }
 @SuppressLint("NewApi")
 @Override
 public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
   mWrapped.onItemCheckedStateChanged(mode, position, id, checked);
   if (getCheckedItemCount() == 0) {
     mode.finish();
   }
 }
  private void deshacer(final Modelo[] recibidos) {

    int j = 0;
    int total = recibidos.length;
    elegidos = new boolean[total];
    ActionMode bar = action;
    bar.setTitle(Integer.toString(total) + "   Recomendaciones");
    for (i = 0; i < total; i++) {

      elegidos[i] = false;
    }
    i = 0;
    final Button[] parecidos = new Button[total];
    for (i = 0; i < total; i++) {
      parecidos[i] = new Button(this);
      parecidos[i] = (Button) findViewById(100 + i);
      parecidos[i].setBackgroundColor(Color.BLACK);
      final Intent preview = new Intent(getApplication(), Preview.class);

      parecidos[i].setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              // TODO Auto-generated method stub
              int id = v.getId() - 100;

              Selecciones.setMarcaElegida(recibidos[id].getMarca());
              Selecciones.setModeloElegido(recibidos[id].getModelo());
              Selecciones.setColorElegido(recibidos[id].getColor());
              Selecciones.setFormaElegida(recibidos[id].getForma());
              Selecciones.setMaterialElegido(recibidos[id].getMaterial());
              Selecciones.setSkuElegido(recibidos[id].getSKU());
              Selecciones.setPrecioElegido(Integer.parseInt(recibidos[id].getPrecio().trim()));
              Selecciones.setStockElegido(recibidos[id].getStock());
              Selecciones.setBaseElegida(recibidos[id].getBase());
              Selecciones.setAroAltoElegido(recibidos[id].getAroAlto());
              Selecciones.setAroAnchoElegido(recibidos[id].getAroAncho());
              Selecciones.setDiagonalElegida(recibidos[id].getDiagonal());
              Selecciones.setPuenteElegido(recibidos[id].getPuente());

              startActivity(preview);
            }
          });
    }
  }
  @Override
  public ActionMode startActionMode(ActionMode.Callback callback) {
    if (DEBUG) Log.d(TAG, "[startActionMode] callback: " + callback);

    if (mActionMode != null) {
      mActionMode.finish();
    }

    final ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapper(callback);
    ActionMode mode = null;

    // Emulate Activity's onWindowStartingActionMode:
    initActionBar();
    if (aActionBar != null) {
      mode = aActionBar.startActionMode(wrappedCallback);
    }

    if (mode != null) {
      mActionMode = mode;
    } else {
      if (mActionModeView == null) {
        ViewStub stub = (ViewStub) mDecor.findViewById(R.id.abs__action_mode_bar_stub);
        if (stub != null) {
          mActionModeView = (ActionBarContextView) stub.inflate();
        }
      }
      if (mActionModeView != null) {
        mActionModeView.killMode();
        mode = new StandaloneActionMode(mActivity, mActionModeView, wrappedCallback, true);
        if (callback.onCreateActionMode(mode, mode.getMenu())) {
          mode.invalidate();
          mActionModeView.initForMode(mode);
          mActionModeView.setVisibility(View.VISIBLE);
          mActionMode = mode;
          mActionModeView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
        } else {
          mActionMode = null;
        }
      }
    }
    if (mActionMode != null && mActivity instanceof OnActionModeStartedListener) {
      ((OnActionModeStartedListener) mActivity).onActionModeStarted(mActionMode);
    }
    return mActionMode;
  }
  /**
   * Update the contextual action bar for the number of item selected
   *
   * @param numSelected
   */
  private void updateCAB(int numSelected) {
    if (actionMode == null) return;

    Menu menu = actionMode.getMenu();
    if (numSelected == 1) {
      if (selected.get(0).canEdit()) {
        menu.findItem(R.id.edit).setVisible(true);
      } else {
        menu.findItem(R.id.edit).setVisible(false);
      }
    } else {
      menu.findItem(R.id.edit).setVisible(false);
    }
    String title =
        getResources()
            .getQuantityString(R.plurals.quantity_sources_selected, numSelected, numSelected);
    actionMode.setTitle(title);
  }
Exemple #9
0
        @Override
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
          setSelectMode(ListView.CHOICE_MODE_SINGLE);
          mode.setTitle(getString(R.string.edit_in_pocket_paint));

          setActionModeActive(true);

          return true;
        }
  private void getClicks(Modelo[] recibidos) {
    // TODO Auto-generated method stub
    int total = recibidos.length;
    elegidos = new boolean[total];
    ActionMode bar = action;
    bar.setTitle("0 Seleccionados");
    for (i = 0; i < total; i++) {
      elegidos[i] = false;
    }
    i = 0;
    final Button[] parecidos = new Button[total];
    for (i = 0; i < total; i++) {
      parecidos[i] = new Button(this);
      parecidos[i] = (Button) findViewById(100 + i);
      parecidos[i].setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View v) {
              // TODO Auto-generated method stub
              int id = v.getId() - 100;

              ActionMode bar = action;

              if (!elegidos[id]) {
                elegidos[id] = true;
                parecidos[id].setBackgroundColor(Color.GRAY);
                seleccionados++;
                bar.setTitle(Integer.toString(seleccionados) + " Seleccionados");

              } else {
                elegidos[id] = false;
                parecidos[id].setBackgroundColor(Color.BLACK);
                seleccionados--;
                bar.setTitle(Integer.toString(seleccionados) + " Seleccionados");
              }
            }
          });
    }
  }
Exemple #11
0
        @Override
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
          setSelectMode(ListView.CHOICE_MODE_MULTIPLE);
          setActionModeActive(true);

          actionModeTitle = getString(R.string.delete);
          singleItemAppendixActionMode = getString(R.string.look);
          multipleItemAppendixActionMode = getString(R.string.looks);

          mode.setTitle(actionModeTitle);

          return true;
        }
  @Override
  public boolean dispatchKeyEvent(KeyEvent event) {
    if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] event: " + event);

    final int keyCode = event.getKeyCode();

    // Not handled by the view hierarchy, does the action bar want it
    // to cancel out of something special?
    if (keyCode == KeyEvent.KEYCODE_BACK) {
      final int action = event.getAction();
      // Back cancels action modes first.
      if (mActionMode != null) {
        if (action == KeyEvent.ACTION_UP) {
          mActionMode.finish();
        }
        if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning true");
        return true;
      }

      // Next collapse any expanded action views.
      if (wActionBar != null && wActionBar.hasExpandedActionView()) {
        if (action == KeyEvent.ACTION_UP) {
          wActionBar.collapseActionView();
        }
        if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning true");
        return true;
      }
    }

    boolean result = false;
    if (keyCode == KeyEvent.KEYCODE_MENU && isReservingOverflow()) {
      if (event.getAction() == KeyEvent.ACTION_DOWN && event.isLongPress()) {
        mMenuKeyIsLongPress = true;
      } else if (event.getAction() == KeyEvent.ACTION_UP) {
        if (!mMenuKeyIsLongPress) {
          if (mActionMode == null && wActionBar != null) {
            if (wActionBar.isOverflowMenuShowing()) {
              wActionBar.hideOverflowMenu();
            } else {
              wActionBar.showOverflowMenu();
            }
          }
          result = true;
        }
        mMenuKeyIsLongPress = false;
      }
    }

    if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning " + result);
    return result;
  }
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    slidingDrawer.close();
    currentClasstime = (Classtime) parent.getItemAtPosition(position);

    if (currentClasstime != null) {
      mode = parentAct.startActionMode(new ScheduleActionMode());
      slidingDrawer.setVisibility(View.VISIBLE);

      String text = " ";
      text += currentClasstime.getCourseId() + " - " + currentClasstime.getName() + " ";

      String daytext = "\n\t";
      String building =
          currentClasstime.getBuilding().getId() + " " + currentClasstime.getBuilding().getRoom();
      String unique = currentClasstime.getUnique();

      String time = currentClasstime.getStartTime();
      String end = currentClasstime.getEndTime();

      if (currentClasstime.getDay() == 'H') {
        daytext += "TH";
      } else {
        daytext += currentClasstime.getDay();
      }

      // TODO: stringbuilder
      text += (daytext + " from " + time + "-" + end + " in " + building) + "\n";

      text += "\tUnique: " + unique + "\n";

      classInfoImageView.setBackgroundColor(Color.parseColor("#" + currentClasstime.getColor()));
      classInfoImageView.setMinimumHeight(10);
      classInfoImageView.setMinimumWidth(10);

      classInfoTextView.setTextColor(Color.BLACK);
      classInfoTextView.setTextSize(14f);
      classInfoTextView.setBackgroundColor(TRANSLUCENT_GRAY);
      classInfoTextView.setText(text);

      slidingDrawer.open();
    }
    // they clicked an empty cell
    else {
      if (mode != null) {
        mode.finish();
      }
      slidingDrawer.setVisibility(View.INVISIBLE);
    }
  }
 /** reloadStores and clean Contextual Action Bar if present */
 public void reloadStores() {
   Log.v("SOURCES", "reloading sources");
   Loader l = getSherlockActivity().getSupportLoaderManager().getLoader(LOADER_INDEX);
   if (l != null) {
     adapter.clear();
     l.forceLoad();
   }
   if (actionMode != null) {
     actionMode.finish();
     selected = new ArrayList<LayerStore>();
     getListView().clearChoices();
     getListView().clearFocus();
   }
 }
  @Override
  public void onListItemClick(ListView l, View v, int position, long id) {
    if (v instanceof ConversationListItem) {
      ConversationListItem headerView = (ConversationListItem) v;
      if (actionMode == null) {
        handleCreateConversation(
            headerView.getThreadId(), headerView.getRecipients(), headerView.getDistributionType());
      } else {
        ConversationListAdapter adapter = (ConversationListAdapter) getListAdapter();
        adapter.toggleThreadInBatchSet(headerView.getThreadId());

        if (adapter.getBatchSelections().size() == 0) {
          actionMode.finish();
        } else {
          actionMode.setSubtitle(
              getString(
                  R.string.conversation_fragment_cab__batch_selection_amount,
                  adapter.getBatchSelections().size()));
        }

        adapter.notifyDataSetChanged();
      }
    }
  }
  public boolean onActionItemClicked(ActionMode mode, MenuItem menu) {

    if (menu.getItemId() == R.id.delete) {
      stores.removeAll(selected);
      saveSources(stores);
    } else if (menu.getItemId() == R.id.edit) {
      LayerStore ls = selected.get(0);
      if (ls != null) {
        ls.openEdit(getSherlockActivity());
      }
    }
    selected = new ArrayList<LayerStore>();
    getListView().clearChoices();
    getListView().clearFocus();
    mode.finish();
    reloadStores();
    actionMode = null;
    return true;
  }
 @Override
 public void setChoiceMode(int choiceMode) {
   mChoiceMode = choiceMode;
   if (mChoiceActionMode != null) {
     mChoiceActionMode.finish();
     mChoiceActionMode = null;
   }
   if (mChoiceMode != CHOICE_MODE_NONE) {
     if (mCheckStates == null) {
       mCheckStates = new SparseBooleanArray();
     }
     if (mCheckedIdStates == null && mAdapter != null && mAdapter.hasStableIds()) {
       mCheckedIdStates = new LongSparseArray<Integer>();
     }
     if (mChoiceMode == CHOICE_MODE_MULTIPLE_MODAL) {
       clearChoices();
       setLongClickable(true);
     }
   }
 }
 /**
  * This method will be called whenever an item has been checked or unchecked. This will inform
  * the listener and finish the ActionMode, if the last item has been unchecked.
  *
  * @param mode The ActionMode providing the selection mode.
  * @param position Adapter position of the item that was checked or unchecked.
  * @param id Adapter ID of the item that was checked or unchecked.
  * @param checked Whether the item is now checked.
  */
 public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
   listener.onItemCheckedStateChanged(mode, position, id, checked);
   if (ABSListView.this.getCheckedItemCount() == 0) {
     mode.finish();
   }
 }
  public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    mode.getMenuInflater().inflate(R.menu.delete_menu, menu);
    this.actionMode = mode;

    return true;
  }