ActionMode startSupportActionModeFromWindow(ActionMode.Callback callback) {
    if (mActionMode != null) {
      mActionMode.finish();
    }

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

    if (mActionModeView == null) {
      // Use the action bar theme.
      final Context actionBarContext;
      actionBarContext =
          ThemeUtils.getActionBarThemedContext(
              mActivity, mThemed.getCurrentThemeResourceId(), mThemed.getCurrentThemeColor());

      mActionModeView = new ActionBarContextView(actionBarContext);
      mActionModePopup =
          new PopupWindow(
              actionBarContext,
              null,
              android.support.v7.appcompat.R.attr.actionModePopupWindowStyle);
      mActionModePopup.setContentView(mActionModeView);

      final TypedValue outValue = new TypedValue();
      actionBarContext
          .getTheme()
          .resolveAttribute(android.support.v7.appcompat.R.attr.actionBarSize, outValue, true);
      final int height =
          TypedValue.complexToDimensionPixelSize(
              outValue.data, actionBarContext.getResources().getDisplayMetrics());
      mActionModeView.setContentHeight(height);
      ThemeUtils.setActionBarContextViewBackground(
          mActionModeView,
          mThemed.getCurrentThemeResourceId(),
          mThemed.getCurrentThemeColor(),
          mThemed.getCurrentThemeBackgroundOption(),
          false);
      mActionModePopup.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
      final Rect actionModeBounds = getActionModeBounds();
      if (actionModeBounds != null) {
        mActionModePopup.setWidth(actionModeBounds.width());
      } else {
        mActionModePopup.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
      }
      mShowActionModePopup =
          new Runnable() {
            @Override
            public void run() {
              if (actionModeBounds != null) {
                mActionModePopup.showAtLocation(
                    mWindow.getDecorView(),
                    Gravity.TOP | Gravity.LEFT,
                    actionModeBounds.left,
                    actionModeBounds.top);
              } else {
                mActionModePopup.showAtLocation(
                    mWindow.getDecorView(), Gravity.TOP | Gravity.LEFT, 0, 0);
              }
            }
          };
    }

    if (mActionModeView != null) {
      mActionModeView.killMode();
      ActionMode mode =
          new StandaloneActionMode(
              mActionModeView.getContext(),
              mActionModeView,
              wrappedCallback,
              mActionModePopup == null);
      if (callback.onCreateActionMode(mode, mode.getMenu())) {
        mode.invalidate();
        mActionModeView.initForMode(mode);
        mActionModeView.setVisibility(View.VISIBLE);
        mActionMode = mode;
        if (mActionModePopup != null) {
          mWindow.getDecorView().post(mShowActionModePopup);
        }
        mActionModeView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);

        if (mActionModeView.getParent() != null) {
          ViewCompat.requestApplyInsets((View) mActionModeView.getParent());
        }
      } else {
        mActionMode = null;
      }
    }
    if (mActionMode != null && mAppCompatCallback != null) {
      mAppCompatCallback.onSupportActionModeStarted(mActionMode);
    }
    return mActionMode;
  }
 public void closeMode() {
   if (mClose == null) {
     killMode();
     return;
   }
 }