com.actionbarsherlock.view.ActionMode Java Examples

The following examples show how to use com.actionbarsherlock.view.ActionMode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ListHostsFragment.java    From hosts-editor-android with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    Host[] selectedItems = getSelectedItems();

    switch (item.getItemId()) {
        case R.id.cab_action_edit:
            mBus.post(new StartAddEditActivityEvent(selectedItems[0]));
            break;
        case R.id.cab_action_delete:
            displayDeleteConfirmationDialog(selectedItems);
            break;
        case R.id.cab_action_toggle:
            new ToggleHostsAsync(mApp, selectedItems.length == 1).execute(selectedItems);
            break;
        default:
            return false;
    }
    mode.finish();
    return true;
}
 
Example #2
Source File: ActionBarImpl.java    From zen4android with MIT License 6 votes vote down vote up
public ActionMode startActionMode(ActionMode.Callback callback) {
    boolean wasHidden = false;
    if (mActionMode != null) {
        wasHidden = mWasHiddenBeforeMode;
        mActionMode.finish();
    }

    mContextView.killMode();
    ActionModeImpl mode = new ActionModeImpl(callback);
    if (mode.dispatchOnCreate()) {
        mWasHiddenBeforeMode = !isShowing() || wasHidden;
        mode.invalidate();
        mContextView.initForMode(mode);
        animateToMode(true);
        if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) {
            // TODO animate this
            mSplitView.setVisibility(View.VISIBLE);
        }
        mContextView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
        mActionMode = mode;
        return mode;
    }
    return null;
}
 
Example #3
Source File: ActionBarImpl.java    From android-apps with MIT License 6 votes vote down vote up
public ActionMode startActionMode(ActionMode.Callback callback) {
    boolean wasHidden = false;
    if (mActionMode != null) {
        wasHidden = mWasHiddenBeforeMode;
        mActionMode.finish();
    }

    mContextView.killMode();
    ActionModeImpl mode = new ActionModeImpl(callback);
    if (mode.dispatchOnCreate()) {
        mWasHiddenBeforeMode = !isShowing() || wasHidden;
        mode.invalidate();
        mContextView.initForMode(mode);
        animateToMode(true);
        if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) {
            // TODO animate this
            mSplitView.setVisibility(View.VISIBLE);
        }
        mContextView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
        mActionMode = mode;
        return mode;
    }
    return null;
}
 
Example #4
Source File: ActionBarSherlockNative.java    From zen4android with MIT License 6 votes vote down vote up
@Override
public ActionMode startActionMode(com.actionbarsherlock.view.ActionMode.Callback callback) {
    if (ActionBarSherlock.DEBUG) Log.d(TAG, "[startActionMode] callback: " + callback);

    if (mActionMode != null) {
        mActionMode.finish();
    }
    ActionModeCallbackWrapper wrapped = null;
    if (callback != null) {
        wrapped = new ActionModeCallbackWrapper(callback);
    }

    //Calling this will trigger the callback wrapper's onCreate which
    //is where we will set the new instance to mActionMode since we need
    //to pass it through to the sherlock callbacks and the call below
    //will not have returned yet to store its value.
    if (mActivity.startActionMode(wrapped) == null) {
        mActionMode = null;
    }
    if (mActivity instanceof OnActionModeStartedListener && mActionMode != null) {
        ((OnActionModeStartedListener)mActivity).onActionModeStarted(mActionMode);
    }

    return mActionMode;
}
 
Example #5
Source File: ActionBarSherlockNative.java    From Libraries-for-Android-Developers with MIT License 6 votes vote down vote up
@Override
public ActionMode startActionMode(com.actionbarsherlock.view.ActionMode.Callback callback) {
    if (ActionBarSherlock.DEBUG) Log.d(TAG, "[startActionMode] callback: " + callback);

    if (mActionMode != null) {
        mActionMode.finish();
    }
    ActionModeCallbackWrapper wrapped = null;
    if (callback != null) {
        wrapped = new ActionModeCallbackWrapper(callback);
    }

    //Calling this will trigger the callback wrapper's onCreate which
    //is where we will set the new instance to mActionMode since we need
    //to pass it through to the sherlock callbacks and the call below
    //will not have returned yet to store its value.
    if (mActivity.startActionMode(wrapped) == null) {
        mActionMode = null;
    }
    if (mActivity instanceof OnActionModeStartedListener && mActionMode != null) {
        ((OnActionModeStartedListener)mActivity).onActionModeStarted(mActionMode);
    }

    return mActionMode;
}
 
Example #6
Source File: ActionBarSherlockNative.java    From Libraries-for-Android-Developers with MIT License 5 votes vote down vote up
@Override
public void onDestroyActionMode(android.view.ActionMode mode) {
    mCallback.onDestroyActionMode(mActionMode);
    if (mActivity instanceof OnActionModeFinishedListener) {
        ((OnActionModeFinishedListener)mActivity).onActionModeFinished(mActionMode);
    }
}
 
Example #7
Source File: ActionBarSherlockNative.java    From zhangshangwuda with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #8
Source File: CallLogListFragment.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
    Log.d(THIS_FILE, "onPrepareActionMode");
    ListView lv = getListView();
    int nbrCheckedItem = 0;

    for (int i = 0; i < lv.getCount(); i++) {
        if (lv.isItemChecked(i)) {
            nbrCheckedItem++;
        }
    }
    menu.findItem(R.id.delete).setVisible(nbrCheckedItem > 0);
    menu.findItem(R.id.dialpad).setVisible(nbrCheckedItem == 1);
    return false;
}
 
Example #9
Source File: FollowersAdapter.java    From buddycloud-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreateActionMode(ActionMode mode, Menu menu) {
	MenuInflater inflater = mode.getMenuInflater();
	inflater.inflate(R.menu.channel_followers_options, menu);
	if (!SubscribedChannelsModel.canMakeModerator(role)) {
		MenuItem menuModerator = menu.findItem(R.id.menu_role_moderator);
		menuModerator.setVisible(false);
	}
}
 
Example #10
Source File: CountriesAdapter.java    From MultiChoiceAdapter with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    if (item.getItemId() == R.id.menu_share) {
        Toast.makeText(getContext(), "Share", Toast.LENGTH_SHORT).show();
        return true;
    }
    if (item.getItemId() == R.id.menu_discard) {
        discardSelectedItems();
        return true;
    }
    return false;
}
 
Example #11
Source File: ActionBarSherlockCompat.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example #12
Source File: CallLogListFragment.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onDestroyActionMode(ActionMode mode) {
    Log.d(THIS_FILE, "onDestroyActionMode");

    ListView lv = getListView();
    // Uncheck all
    int count = lv.getAdapter().getCount();
    for (int i = 0; i < count; i++) {
        lv.setItemChecked(i, false);
    }
    mMode = null;
}
 
Example #13
Source File: MyArrayAdapter.java    From android-opensource-library-56 with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    Log.d(TAG, "onActionItemClicked");
    Set<Long> checkedSet = getCheckedItems();
    for(Long checked : checkedSet){
        Log.d(TAG, "checked:" + checked);
    }
    return false;
}
 
Example #14
Source File: ComplexItemLayoutAdapter.java    From MultiChoiceAdapter with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    if (item.getItemId() == R.id.menu_share) {
        Toast.makeText(getContext(), "Share", Toast.LENGTH_SHORT).show();
        return true;
    }
    if (item.getItemId() == R.id.menu_discard) {
        discardSelectedItems();
        return true;
    }
    return false;
}
 
Example #15
Source File: GalleryAdapter.java    From MultiChoiceAdapter with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    if (item.getItemId() == R.id.menu_share) {
        Toast.makeText(getContext(), "Share", Toast.LENGTH_SHORT).show();
        return true;
    }
    if (item.getItemId() == R.id.menu_discard) {
        discardSelectedItems();
        return true;
    }
    return false;
}
 
Example #16
Source File: ActionBarSherlockNative.java    From zen4android with MIT License 5 votes vote down vote up
@Override
public void onDestroyActionMode(android.view.ActionMode mode) {
    mCallback.onDestroyActionMode(mActionMode);
    if (mActivity instanceof OnActionModeFinishedListener) {
        ((OnActionModeFinishedListener)mActivity).onActionModeFinished(mActionMode);
    }
}
 
Example #17
Source File: CustomActionModeTitleAdapter.java    From MultiChoiceAdapter with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    if (item.getItemId() == R.id.menu_share) {
        Toast.makeText(getContext(), "Share", Toast.LENGTH_SHORT).show();
        return true;
    }
    if (item.getItemId() == R.id.menu_discard) {
        discardSelectedItems();
        return true;
    }
    return false;
}
 
Example #18
Source File: MyArrayAdapter.java    From MultiChoiceAdapter with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    if (item.getItemId() == R.id.menu_share) {
        Toast.makeText(getContext(), "Share", Toast.LENGTH_SHORT).show();
        return true;
    }
    if (item.getItemId() == R.id.menu_discard) {
        discardSelectedItems();
        return true;
    }
    return false;
}
 
Example #19
Source File: StandaloneActionMode.java    From zen4android with MIT License 5 votes vote down vote up
public StandaloneActionMode(Context context, ActionBarContextView view,
        ActionMode.Callback callback, boolean isFocusable) {
    mContext = context;
    mContextView = view;
    mCallback = callback;

    mMenu = new MenuBuilder(context).setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    mMenu.setCallback(this);
    mFocusable = isFocusable;
}
 
Example #20
Source File: ActionBarSherlockCompat.java    From android-apps with MIT License 5 votes vote down vote up
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;
}
 
Example #21
Source File: CallLogListFragment.java    From CSipSimple with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    Log.d(THIS_FILE, "onCreateActionMode");
    getSherlockActivity().getSupportMenuInflater().inflate(R.menu.call_log_menu, menu);
    return true;
}
 
Example #22
Source File: ActionBarSherlockCompat.java    From zhangshangwuda with Apache License 2.0 4 votes vote down vote up
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
    return mWrapped.onPrepareActionMode(mode, menu);
}
 
Example #23
Source File: ActionBarSherlockCompat.java    From android-apps with MIT License 4 votes vote down vote up
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    return mWrapped.onCreateActionMode(mode, menu);
}
 
Example #24
Source File: MyArrayAdapter.java    From android-opensource-library-56 with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    MenuInflater inflater = mode.getMenuInflater();
    inflater.inflate(R.menu.main, menu);
    return true;
}
 
Example #25
Source File: GalleryAdapter.java    From MultiChoiceAdapter with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
    return false;
}
 
Example #26
Source File: SherlockPreferenceActivity.java    From Libraries-for-Android-Developers with MIT License 4 votes vote down vote up
@Override
public void onActionModeStarted(ActionMode mode) {}
 
Example #27
Source File: SherlockListActivity.java    From Libraries-for-Android-Developers with MIT License 4 votes vote down vote up
@Override
public void onActionModeFinished(ActionMode mode) {}
 
Example #28
Source File: SherlockActivity.java    From Libraries-for-Android-Developers with MIT License 4 votes vote down vote up
public ActionMode startActionMode(ActionMode.Callback callback) {
    return getSherlock().startActionMode(callback);
}
 
Example #29
Source File: AlphabetIndexerCursorAdapter.java    From MultiChoiceAdapter with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
    return false;
}
 
Example #30
Source File: ActionBarImpl.java    From android-apps with MIT License 4 votes vote down vote up
public ActionModeImpl(ActionMode.Callback callback) {
    mCallback = callback;
    mMenu = new MenuBuilder(getThemedContext())
            .setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    mMenu.setCallback(this);
}