示例#1
0
    @Override
    public boolean onCreateActionMode(android.view.ActionMode mode, android.view.Menu menu) {
      // See ActionBarSherlockNative#startActionMode
      mActionMode = new ActionModeWrapper(mode);

      return mCallback.onCreateActionMode(mActionMode, mActionMode.getMenu());
    }
 public void onDestroyActionMode(ActionMode mode) {
   mWrapped.onDestroyActionMode(mode);
   if (mActionModeView != null) {
     mActionModeView.setVisibility(View.GONE);
     mActionModeView.removeAllViews();
   }
   if (mActivity instanceof OnActionModeFinishedListener) {
     ((OnActionModeFinishedListener) mActivity).onActionModeFinished(mActionMode);
   }
   mActionMode = null;
 }
  @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;
  }
 public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
   return mWrapped.onActionItemClicked(mode, item);
 }
 public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
   return mWrapped.onPrepareActionMode(mode, menu);
 }
示例#6
0
 @Override
 public void onDestroyActionMode(android.view.ActionMode mode) {
   mCallback.onDestroyActionMode(mActionMode);
 }
示例#7
0
 @Override
 public boolean onActionItemClicked(android.view.ActionMode mode, android.view.MenuItem item) {
   return mCallback.onActionItemClicked(mActionMode, mActionMode.getMenu().findItem(item));
 }
示例#8
0
 @Override
 public boolean onPrepareActionMode(android.view.ActionMode mode, android.view.Menu menu) {
   return mCallback.onPrepareActionMode(mActionMode, mActionMode.getMenu());
 }