Java 类android.view.ActionMode 实例源码

项目:Todule-android    文件:ToduleListFragment.java   
@Override
public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
    if(loaderId == INCOMPLETE_LOADER_ID || loaderId == EXPIRED_LOADER_ID){
        // remove edit action
        menu.removeItem(R.id.action_edit);
    }
    if (loaderId == DELETED_LOADER_ID){
        menu.removeItem(R.id.action_empty_bin);
    }
    return true;
}
项目:letv    文件:AbsHListView.java   
@TargetApi(11)
public void setChoiceMode(int choiceMode) {
    this.mChoiceMode = choiceMode;
    if (VERSION.SDK_INT >= 11 && this.mChoiceActionMode != null) {
        if (VERSION.SDK_INT >= 11) {
            ((ActionMode) this.mChoiceActionMode).finish();
        }
        this.mChoiceActionMode = null;
    }
    if (this.mChoiceMode != 0) {
        if (this.mCheckStates == null) {
            this.mCheckStates = new SparseArrayCompat();
        }
        if (this.mCheckedIdStates == null && this.mAdapter != null && this.mAdapter.hasStableIds()) {
            this.mCheckedIdStates = new LongSparseArray();
        }
        if (VERSION.SDK_INT >= 11 && this.mChoiceMode == 3) {
            clearChoices();
            setLongClickable(true);
        }
    }
}
项目:Todule-android    文件:ToduleListFragment.java   
@Override
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
    MenuInflater inflater = actionMode.getMenuInflater();
    inflater.inflate(getMenuRes(loaderId), menu);

    // Show checkboxes
    if(mAdapter instanceof HistoryAdapter){
        ((HistoryAdapter) mAdapter).setShowCheckbox(true);
    } else if (mAdapter instanceof MainCursorAdapter){
        ((MainCursorAdapter) mAdapter).setShowCheckbox(true);
    }

    actionMode.setTitle(selectedIds.size() + " selected");
    mActionMode = actionMode;
    return true;
}
项目:CustomActionWebView    文件:CustomActionWebView.java   
/**
 * 处理item,处理点击
 * @param actionMode
 */
private ActionMode resolveActionMode(ActionMode actionMode) {
    if (actionMode != null) {
        final Menu menu = actionMode.getMenu();
        mActionMode = actionMode;
        menu.clear();
        for (int i = 0; i < mActionList.size(); i++) {
            menu.add(mActionList.get(i));
        }
        for (int i = 0; i < menu.size(); i++) {
            MenuItem menuItem = menu.getItem(i);
            menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    getSelectedData((String) item.getTitle());
                    releaseAction();
                    return true;
                }
            });
        }
    }
    mActionMode = actionMode;
    return actionMode;
}
项目:letv    文件:AbsHListView.java   
boolean performLongPress(View child, int longPressPosition, long longPressId) {
    boolean z = true;
    if (VERSION.SDK_INT < 11 || this.mChoiceMode != 3) {
        z = false;
        if (this.mOnItemLongClickListener != null) {
            z = this.mOnItemLongClickListener.onItemLongClick(this, child, longPressPosition, longPressId);
        }
        if (!z) {
            this.mContextMenuInfo = createContextMenuInfo(child, longPressPosition, longPressId);
            z = super.showContextMenuForChild(this);
        }
        if (z) {
            performHapticFeedback(0);
        }
    } else if (this.mChoiceActionMode == null) {
        ActionMode startActionMode = startActionMode((MultiChoiceModeWrapper) this.mMultiChoiceModeCallback);
        this.mChoiceActionMode = startActionMode;
        if (startActionMode != null) {
            setItemChecked(longPressPosition, true);
            performHapticFeedback(0);
        }
    }
    return z;
}
项目:simple-share-android    文件:DirectoryFragment.java   
@Override
public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
    if (checked) {
        // Directories and footer items cannot be checked
        boolean valid = false;

        final Cursor cursor = mAdapter.getItem(position);
        if (cursor != null) {
            final String docMimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
            final int docFlags = getCursorInt(cursor, Document.COLUMN_FLAGS);
            // if (!Document.MIME_TYPE_DIR.equals(docMimeType)) {
            valid = isDocumentEnabled(docMimeType, docFlags);
            // }
        }

        if (!valid) {
            mCurrentView.setItemChecked(position, false);
        }
    }

    int count = mCurrentView.getCheckedItemCount();
    mode.setTitle(getResources().getString(R.string.mode_selected_count, count));
    if (count == 1 || count == 2) {
        mode.invalidate();
    }
}
项目:q-mail    文件:MessageListFragment.java   
@Override
public void onDestroyActionMode(ActionMode mode) {
    actionMode = null;
    mSelectAll = null;
    mMarkAsRead = null;
    mMarkAsUnread = null;
    mFlag = null;
    mUnflag = null;
    setSelectionState(false);
}
项目:q-mail    文件:MessageListFragment.java   
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    MenuInflater inflater = mode.getMenuInflater();
    inflater.inflate(R.menu.message_list_context, menu);

    // check capabilities
    setContextCapabilities(account, menu);

    return true;
}
项目:Todule-android    文件:MainActivity.java   
@Override
public void onActionModeStarted(ActionMode mode) {
    super.onActionModeStarted(mode);
    Window window = getWindow();
    // clear FLAG_TRANSLUCENT_STATUS flag:
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

    // add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.setStatusBarColor(ContextCompat.getColor(this, R.color.colorAccentDark));
}
项目:GitHub    文件:FreeFlowContainer.java   
@Override
public void onDestroyActionMode(ActionMode mode) {
    mWrapped.onDestroyActionMode(mode);
    mChoiceActionMode = null;

    // Ending selection mode means deselecting everything.
    clearChoices();
    updateOnScreenCheckedViews();

    // rememberSyncState();
    requestLayout();

    setLongClickable(true);
}
项目:FireFiles    文件:DirectoryFragment.java   
@Override
public void onClick(final View v) {

    final int position = mCurrentView.getPositionForView(v);
    if (position != ListView.INVALID_POSITION) {
        int count = mCurrentView.getCheckedItemCount();
        switch (v.getId()) {
        case android.R.id.icon:
            if (count == 0) {
                ActionMode mChoiceActionMode = null;
                if (mChoiceActionMode == null && (mChoiceActionMode = mCurrentView.startActionMode(mMultiListener)) != null) {
                    mCurrentView.setItemChecked(position, true);
                    mCurrentView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
                }
            } else {
                mCurrentView.setItemChecked(position, !mCurrentView.isItemChecked(position));
                mCurrentView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            }
            break;

        case R.id.button_popup:
            v.post(new Runnable() {
                @Override
                public void run() {
                    showPopupMenu(v, position);
                }
            });
            break;
        }
    }

}
项目:GitHub    文件:PullToRefreshActivity.java   
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    URLogs.d("actionmode---" + (mode == null));
    mode.getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
    //  return false;
}
项目:browser    文件:CustomWebView.java   
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    mActionMode = mode;
    MenuInflater inflater = mode.getMenuInflater();
    inflater.inflate(R.menu.menu_main, menu);
    return true;
}
项目:letv    文件:AbsHListView.java   
void confirmCheckedPositionsById() {
    this.mCheckStates.clear();
    boolean checkedCountChanged = false;
    int checkedIndex = 0;
    while (checkedIndex < this.mCheckedIdStates.size()) {
        long id = this.mCheckedIdStates.keyAt(checkedIndex);
        int lastPos = ((Integer) this.mCheckedIdStates.valueAt(checkedIndex)).intValue();
        if (id != this.mAdapter.getItemId(lastPos)) {
            int start = Math.max(0, lastPos - 20);
            int end = Math.min(lastPos + 20, this.mItemCount);
            boolean found = false;
            for (int searchPos = start; searchPos < end; searchPos++) {
                if (id == this.mAdapter.getItemId(searchPos)) {
                    found = true;
                    this.mCheckStates.put(searchPos, Boolean.valueOf(true));
                    this.mCheckedIdStates.setValueAt(checkedIndex, Integer.valueOf(searchPos));
                    break;
                }
            }
            if (!found) {
                this.mCheckedIdStates.delete(id);
                checkedIndex--;
                this.mCheckedItemCount--;
                checkedCountChanged = true;
                if (!(VERSION.SDK_INT <= 11 || this.mChoiceActionMode == null || this.mMultiChoiceModeCallback == null)) {
                    ((MultiChoiceModeWrapper) this.mMultiChoiceModeCallback).onItemCheckedStateChanged((ActionMode) this.mChoiceActionMode, lastPos, id, false);
                }
            }
        } else {
            this.mCheckStates.put(lastPos, Boolean.valueOf(true));
        }
        checkedIndex++;
    }
    if (checkedCountChanged && this.mChoiceActionMode != null && VERSION.SDK_INT > 11) {
        ((ActionMode) this.mChoiceActionMode).invalidate();
    }
}
项目:GitHub    文件:TerminalTextViewOverlay.java   
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    TerminalTextViewOverlay.this.selectionActionMode = mode;

    menu.clear();

    menu.add(0, COPY, 0, R.string.console_menu_copy)
            .setIcon(R.drawable.ic_action_copy)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT | MenuItem.SHOW_AS_ACTION_IF_ROOM);
    menu.add(0, PASTE, 1, R.string.console_menu_paste)
            .setIcon(R.drawable.ic_action_paste)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT | MenuItem.SHOW_AS_ACTION_IF_ROOM);

    return true;
}
项目:GitHub    文件:TerminalTextViewOverlay.java   
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    switch (item.getItemId()) {
    case COPY:
        copyCurrentSelectionToClipboard();
        return true;
    case PASTE:
        pasteClipboard();
        mode.finish();
        return true;
    }

    return false;
}
项目:ceji_android    文件:InnerView.java   
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public ActionMode startActionMode(ActionMode.Callback callback) {

    if (System.currentTimeMillis() > blockUntil) {

        LOG.debug("InnerView starting action-mode");
        return super.startActionMode(callback);

    } else {
        LOG.debug("Not starting action-mode yet, since block time hasn't expired.");
        clearFocus();
        return null;
    }
}
项目:SimpleNotes    文件:MultiChoiceImplementation.java   
private void setSubtitle(ActionMode mode, int selectedCount) {
    switch (selectedCount) {
        case 0:
            mode.setSubtitle(null);
            break;
        default:
            mode.setTitle(SimpleNotesApplication.getResourceStringNotesSelectedNumber() + String.valueOf(selectedCount));
            break;
    }
}
项目:FireFiles    文件:DirectoryFragment.java   
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    editMode = root != null && root.isEditSupported();
    int menuId = R.menu.mode_simple_directory;
    if (null != root && root.isApp()) {
        menuId = R.menu.mode_apps;
    } else {
        menuId = R.menu.mode_directory;
    }

    mode.getMenuInflater().inflate(menuId, menu);
    int count = mCurrentView.getCheckedItemCount();
    mode.setTitle(count+"");
    return true;
}
项目:IslamicLibraryAndroid    文件:ReadingActivity.java   
@Override
public void onActionModeFinished(ActionMode mode) {
    mActionMode = null;
    mHighlightClickedFlag = false;
    super.onActionModeFinished(mode);
    for (ActionModeChangeListener actionModeChangeListener : mActionModeChangeListener) {
        actionModeChangeListener.actionModeFinished();
    }

}
项目:FlickLauncher    文件:WallpaperPickerActivity.java   
/**
 * Called when the user exits the action mode
 */
@Override
public void onDestroyActionMode(ActionMode mode) {
    int childCount = mWallpapersView.getChildCount();
    for (int i = 0; i < childCount; i++) {
        CheckableFrameLayout c = (CheckableFrameLayout) mWallpapersView.getChildAt(i);
        c.setChecked(false);
    }
    if (mSelectedTile != null) {
        mSelectedTile.setSelected(true);
    }
    mActionMode = null;
}
项目:airgram    文件:LaunchActivity.java   
@Override
public void onActionModeStarted(ActionMode mode) {
    super.onActionModeStarted(mode);
    if (Build.VERSION.SDK_INT >= 23 && mode.getType() == ActionMode.TYPE_FLOATING) {
        return;
    }
    actionBarLayout.onActionModeStarted(mode);
    if (AndroidUtilities.isTablet()) {
        rightActionBarLayout.onActionModeStarted(mode);
        layersActionBarLayout.onActionModeStarted(mode);
    }
}
项目:PlusGram    文件:PhotoViewerCaptionEnterView.java   
@SuppressWarnings("unchecked")
private void fixActionMode(ActionMode mode) {
    try {
        Class classActionMode = Class.forName("com.android.internal.view.FloatingActionMode");
        Field fieldToolbar = classActionMode.getDeclaredField("mFloatingToolbar");
        fieldToolbar.setAccessible(true);
        Object toolbar = fieldToolbar.get(mode);

        Class classToolbar = Class.forName("com.android.internal.widget.FloatingToolbar");
        Field fieldToolbarPopup = classToolbar.getDeclaredField("mPopup");
        Field fieldToolbarWidth = classToolbar.getDeclaredField("mWidthChanged");
        fieldToolbarPopup.setAccessible(true);
        fieldToolbarWidth.setAccessible(true);
        Object popup = fieldToolbarPopup.get(toolbar);

        Class classToolbarPopup = Class.forName("com.android.internal.widget.FloatingToolbar$FloatingToolbarPopup");
        Field fieldToolbarPopupParent = classToolbarPopup.getDeclaredField("mParent");
        fieldToolbarPopupParent.setAccessible(true);

        View currentView = (View) fieldToolbarPopupParent.get(popup);
        if (currentView != windowView) {
            fieldToolbarPopupParent.set(popup, windowView);

            Method method = classActionMode.getDeclaredMethod("updateViewLocationInWindow");
            method.setAccessible(true);
            method.invoke(mode);
        }
    } catch (Throwable e) {
        FileLog.e("tmessages", e);
    }
}
项目:Bigbang    文件:CopyActivity.java   
public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
    for(int i = 0; i < menu.size(); ++i) {
        menu.getItem(i).setVisible(false);
    }

    return false;
}
项目:ProgressManager    文件:a.java   
/**
 * {@inheritDoc}
 */
@Nullable
@Override
public ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int type) {
    try {
        mActionModeTypeStarting = type;
        return onWindowStartingActionMode(callback);
    } finally {
        mActionModeTypeStarting = ActionMode.TYPE_PRIMARY;
    }
}
项目:Veggietizer    文件:HistoryMultiChoiceModeListener.java   
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    MenuInflater inflater = historyActivity.getMenuInflater();

    inflater.inflate(R.menu.history, menu);
    activeMode = mode;

    return true;
}
项目:ProgressManager    文件:a.java   
/**
 * Give the Activity a chance to control the UI for an action mode requested
 * by the system.
 *
 * <p>Note: If you are looking for a notification callback that an action mode
 * has been started for this activity, see {@link #onActionModeStarted(ActionMode)}.</p>
 *
 * @param callback The callback that should control the new action mode
 * @return The new action mode, or <code>null</code> if the activity does not want to
 *         provide special handling for this action mode. (It will be handled by the system.)
 */
@Nullable
@Override
public ActionMode onWindowStartingActionMode(ActionMode.Callback callback) {
    // Only Primary ActionModes are represented in the ActionBar.
    if (mActionModeTypeStarting == ActionMode.TYPE_PRIMARY) {
        initWindowDecorActionBar();
        if (mActionBar != null) {
            return mActionBar.startActionMode(callback);
        }
    }
    return null;
}
项目:RecyclerView-Multiselect    文件:ActionModeCallback.java   
private void setActionMode(final ActionMode mActionMode) {
    this.mActionMode = mActionMode;
    LayoutInflater inflator = (LayoutInflater) mActivity
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflator.inflate(R.layout.action_mode_layout, null);
    mActionMode.setCustomView(v);
    mSelectTv = (TextView) v.findViewById(R.id.select_all_btn);
    mMenuItemClickInterface.setTextView(mSelectTv);
    mSelectTv.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            PopupMenu popupMenu = new PopupMenu(mActivity, mSelectTv);
            popupMenu.getMenuInflater().inflate(R.menu.pop_menu, popupMenu.getMenu());
            popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem menuItem) {
                    if (menuItem.getItemId() == R.id.select_all) {
                        mMenuItemClickInterface.onAllItemSelect();
                        return true;
                    }
                    return false;
                }
            });
            popupMenu.show();
        }
    });

}
项目:Bigbang    文件:CopyActivity.java   
public boolean onActionItemClicked(ActionMode actionMode, MenuItem item) {
    switch(item.getItemId()) {
        case R.id.fab_copy:
            UrlCountUtil.onEvent(UrlCountUtil.CLICK_UNIVERSAL_COPY_COPY_FAB);
            setSelectTextToClipboard(textView);
            finish();
            return true;
        default:
            return false;
    }
}
项目:FireFiles    文件:DirectoryFragment.java   
@Override
public void onDestroyActionMode(ActionMode mode) {
          selectAll = true;
    final Context context = getActivity();
    if(null != context){
        final BaseActivity activity = (BaseActivity) context;
        activity.setActionMode(false);
              activity.setUpStatusBar();
    }
}
项目:Todule-android    文件:ToduleLabelFragment.java   
@Override
public void onItemCheckedStateChanged(ActionMode actionMode, int i, long l, boolean b) {
    if(b){
        selectedIds.put(l, b);
    } else {
        selectedIds.remove(l);
    }
    actionMode.setTitle(selectedIds.size() + " selected");
}
项目:ProgressManager    文件:a.java   
/**
 * {@inheritDoc}
 */
@Nullable
@Override
public ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int type) {
    try {
        mActionModeTypeStarting = type;
        return onWindowStartingActionMode(callback);
    } finally {
        mActionModeTypeStarting = ActionMode.TYPE_PRIMARY;
    }
}
项目:Veggietizer    文件:HistoryMultiChoiceModeListener.java   
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    if (BuildConfig.DEBUG && item.getItemId() != R.id.action_discard) {
        throw new IllegalStateException("No action except 'discard' implemented currently");
    }

    // historyActivity.deleteSelectedEntries();
    return true;
}
项目:SimpleNotes    文件:MultiChoiceImplementation.java   
@Override
//Здесь надуваем наше меню из xml
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
    Log.d(TAG, "onCreateActionMode");
    MenuInflater inflater = actionMode.getMenuInflater();
    inflater.inflate(R.menu.action_mode_menu, menu);
    return true;
}
项目:ProgressManager    文件:a.java   
/**
 * Give the Activity a chance to control the UI for an action mode requested
 * by the system.
 *
 * <p>Note: If you are looking for a notification callback that an action mode
 * has been started for this activity, see {@link #onActionModeStarted(ActionMode)}.</p>
 *
 * @param callback The callback that should control the new action mode
 * @return The new action mode, or <code>null</code> if the activity does not want to
 *         provide special handling for this action mode. (It will be handled by the system.)
 */
@Nullable
@Override
public ActionMode onWindowStartingActionMode(ActionMode.Callback callback) {
    // Only Primary ActionModes are represented in the ActionBar.
    if (mActionModeTypeStarting == ActionMode.TYPE_PRIMARY) {
        initWindowDecorActionBar();
        if (mActionBar != null) {
            return mActionBar.startActionMode(callback);
        }
    }
    return null;
}
项目:boohee_v5.6    文件:AppCompatDelegateImplV23.java   
public ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int type) {
    if (AppCompatDelegateImplV23.this.isHandleNativeActionModesEnabled()) {
        switch (type) {
            case 0:
                return startAsSupportActionMode(callback);
        }
    }
    return super.onWindowStartingActionMode(callback, type);
}
项目:airgram    文件:LaunchActivity.java   
@Override
public void onActionModeFinished(ActionMode mode) {
    super.onActionModeFinished(mode);
    if (Build.VERSION.SDK_INT >= 23 && mode.getType() == ActionMode.TYPE_FLOATING) {
        return;
    }
    actionBarLayout.onActionModeFinished(mode);
    if (AndroidUtilities.isTablet()) {
        rightActionBarLayout.onActionModeFinished(mode);
        layersActionBarLayout.onActionModeFinished(mode);
    }
}
项目:PlusGram    文件:LaunchActivity.java   
@Override
public void onActionModeStarted(ActionMode mode) {
    super.onActionModeStarted(mode);
    if (Build.VERSION.SDK_INT >= 23 && mode.getType() == ActionMode.TYPE_FLOATING) {
        return;
    }
    actionBarLayout.onActionModeStarted(mode);
    if (AndroidUtilities.isTablet()) {
        rightActionBarLayout.onActionModeStarted(mode);
        layersActionBarLayout.onActionModeStarted(mode);
    }
}
项目:IslamicLibraryAndroid    文件:ReadingActivity.java   
@Override
public void onActionModeStarted(ActionMode mode) {
    if (mActionMode == null) {
        mActionMode = mode;
        Menu menu = mode.getMenu();

        menu.clear();

        if (!shouldDisplayFloatingSelectionMenu()) {
            MenuInflater inflater = new MenuInflater(this);

            inflater.inflate(R.menu.text_selection_context_menu, menu);
            mode.setTitle(null);

            menu.findItem(R.id.action_copy_text).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
            menu.findItem(R.id.action_select_all_text).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
            menu.findItem(R.id.action_add_comment).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
            menu.findItem(R.id.action_share_text).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
            menu.findItem(R.id.action_add_highlight).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

            if (mHighlightClickedFlag) {
                menu.findItem(R.id.action_add_comment).setVisible(true);
                menu.findItem(R.id.highlight_remove).setVisible(true);
            }
        }
    }

    super.onActionModeStarted(mode);
    for (ActionModeChangeListener actionModeChangeListener : mActionModeChangeListener) {
        actionModeChangeListener.actionModeStarted();
    }
}
项目:ProgressManager    文件:a.java   
/**
 * Give the Activity a chance to control the UI for an action mode requested
 * by the system.
 *
 * <p>Note: If you are looking for a notification callback that an action mode
 * has been started for this activity, see {@link #onActionModeStarted(ActionMode)}.</p>
 *
 * @param callback The callback that should control the new action mode
 * @return The new action mode, or <code>null</code> if the activity does not want to
 *         provide special handling for this action mode. (It will be handled by the system.)
 */
@Nullable
@Override
public ActionMode onWindowStartingActionMode(ActionMode.Callback callback) {
    // Only Primary ActionModes are represented in the ActionBar.
    if (mActionModeTypeStarting == ActionMode.TYPE_PRIMARY) {
        initWindowDecorActionBar();
        if (mActionBar != null) {
            return mActionBar.startActionMode(callback);
        }
    }
    return null;
}