Java Code Examples for android.support.v7.view.ActionMode#finish()

The following examples show how to use android.support.v7.view.ActionMode#finish() . 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: DownloadAdapter.java    From OneTapVideoDownload with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
    switch (menuItem.getItemId()) {
        case R.id.menu_delete:
            ArrayList<Integer> keys = getSelectedItems();
            Collections.sort(keys);
            Collections.reverse(keys);
            for (Integer pos : keys) {
                mDownloadManager.removeDownloadByIndex(pos);
            }
            actionMode.finish();
            return true;
        default:
            return false;
    }
}
 
Example 2
Source File: InviteFriendsActivity.java    From q-municate-android with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
    switch (menuItem.getItemId()) {
        case R.id.action_send:
            if (checkNetworkAvailableWithError()) {
                performActionNext();
                actionMode.finish();
            }
            return true;
        case R.id.action_select_all:
            checkAllContacts();
            return true;
    }

    return false;
}
 
Example 3
Source File: FilesListFragment.java    From secrecy with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    switch (item.getItemId()) {
        case R.id.action_send:
            sendRawSelectedItems();
            mode.finish();
            return true;
        case R.id.action_decrypt:
            decryptSelectedItems();
            mode.finish();
            return true;
        case R.id.action_delete:
            deleteSelectedItems();
            mode.finish();
            return true;
        case R.id.action_rename:
            renameSelectedItems();
            mode.finish();
            return true;
        case R.id.action_select_all:
            selectAll();
            return true;
        default:
            return false;
    }
}
 
Example 4
Source File: MainActivity.java    From Android-9-Development-Cookbook with MIT License 5 votes vote down vote up
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    switch (item.getItemId()) {
        case R.id. delete_all:
            myAdapter.deleteAllSelected();
            mode.finish();
            return true;
        default:
            return false;
    }
}
 
Example 5
Source File: MainActivity.java    From Android-9-Development-Cookbook with MIT License 5 votes vote down vote up
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    switch (item.getItemId()) {
        case R.id. menu_cast:
            Toast.makeText(MainActivity.this, "Cast", Toast.LENGTH_SHORT).show();
            mode.finish();
            return true;
        case R.id. menu_print:
            Toast.makeText(MainActivity.this, "Print", Toast.LENGTH_SHORT).show();
            mode.finish();
            return true;
        default:
            return false;
    }
}
 
Example 6
Source File: PostDetailsActivity.java    From social-app-android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    switch (item.getItemId()) {
        case R.id.editMenuItem:
            openEditCommentDialog(selectedComment);
            mode.finish(); // Action picked, so close the CAB
            return true;
        case R.id.deleteMenuItem:
            presenter.removeComment(selectedComment.getId());
            mode.finish();
            return true;
        default:
            return false;
    }
}
 
Example 7
Source File: AssignmentViewFragment.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
    switch (menuItem.getItemId()) {
        case R.id.action_close:
            actionMode.finish();
            break;
        case R.id.action_next:
            getBinding().mdView.findNext(true);
            break;
        case R.id.action_last:
            getBinding().mdView.findNext(false);
            break;
    }
    return true;
}
 
Example 8
Source File: ToolbarActionMode.java    From Android-FileBrowser-FilePicker with MIT License 5 votes vote down vote up
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    List<FileItem> selectedItems = mAdapter.getSelectedItems();;
    if (item.getItemId() == R.id.action_properties) {
        if (io != null)
            io.getProperties(selectedItems);
        mode.finish();
    }
    else if (item.getItemId() == R.id.action_share) {
        if (io != null)
            io.shareMultipleFiles(selectedItems);
        mode.finish();//Finish action mode
    }
    else if (item.getItemId() == R.id.action_rename) {
        if (selectedItems.size() != 1) {
            UIUtils.ShowToast(mActivity.getString(R.string.selection_error_single), mActivity);
            return false;
        }
        if (!selectedItems.get(0).getFile().canWrite()) {
            UIUtils.ShowToast(mActivity.getString(R.string.permission_error), mActivity);
            return false;
        }
        io.renameFile(selectedItems.get(0));
        mode.finish();//Finish action mode
    }
    else if (item.getItemId() == R.id.action_selectall) {
        mAdapter.selectAll();
    }
    else if (item.getItemId() == R.id.action_unselectall) {
        mAdapter.unSelectAll();
    }
    return false;
}
 
Example 9
Source File: PostDetailsActivity.java    From social-app-android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    switch (item.getItemId()) {
        case R.id.editMenuItem:
            openEditCommentDialog(selectedComment);
            mode.finish(); // Action picked, so close the CAB
            return true;
        case R.id.deleteMenuItem:
            presenter.removeComment(selectedComment.getId());
            mode.finish();
            return true;
        default:
            return false;
    }
}
 
Example 10
Source File: MainActivity.java    From journaldev with MIT License 5 votes vote down vote up
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    Log.d("API123", "here");
    switch (item.getItemId()) {


        case R.id.action_delete:
            // delete all the selected rows
            deleteRows();
            mode.finish();
            return true;

        case R.id.action_color:
            updateColoredRows();
            mode.finish();
            return true;

        case R.id.action_select_all:
            selectAll();
            return true;

        case R.id.action_refresh:
            populateDataAndSetAdapter();
            mode.finish();
            return true;

        default:
            return false;
    }
}
 
Example 11
Source File: MultipleSelectFragment.java    From TitanRecyclerView with MIT License 5 votes vote down vote up
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
    switch (menuItem.getItemId()) {
        case R.id.action_delete:
            onDeleteItems();
            actionMode.finish();
            return true;
        default:
            break;
    }
    return false;
}
 
Example 12
Source File: MultipleSelectFragment.java    From AndroidRecyclerViewDemo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
    switch (menuItem.getItemId()) {
        case R.id.action_delete:
            onDeleteItems();
            actionMode.finish();
            return true;
        default:
            break;
    }
    return false;
}
 
Example 13
Source File: SelectionList.java    From PlayMusicExporter with MIT License 5 votes vote down vote up
/**
 * Updates the action mode menu
 * @param doNotCloseActivity Prevent the closing of the activity
 */
private void updateActionModeMenu(boolean doNotCloseActivity) {
    // Null check
    if (mActionModeCallback != null && mActivity != null && !mActivity.isFinishing()) {

        // Some items are selected, shows the action mode
        if (mItems.size() > 0 && mActionMode == null) {
            mActionMode = mActivity.startSupportActionMode(mActionModeCallback);
        }

        // Close the action mode
        if (mItems.size() == 0 && mActionMode != null) {
            // Set mActionMode to null before call finish to prevent recursion
            ActionMode actionMode = mActionMode;
            mActionMode = null;


            // Close the action mode
            actionMode.finish();
        }

        // Set the text
        if (mActionMode != null) {
            // Update the action mode
            mActionMode.invalidate();
        }
    }
}
 
Example 14
Source File: GroupDialogDetailsActivity.java    From q-municate-android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
    switch (menuItem.getItemId()) {
        case R.id.action_done:
            if (checkNetworkAvailableWithError()) {
                checkForSaving();
            } else {
                onDestroyActionMode(actionMode);
            }
            actionMode.finish();
            return true;
    }

    return false;
}
 
Example 15
Source File: MainActivity.java    From ui with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onActionItemClicked( ActionMode mode, MenuItem item )
{
	boolean ret = false;
	if(item.getItemId() == R.id.actionmode_cancel) {
		mode.finish();
		ret = true;
	}
	return ret;
}
 
Example 16
Source File: ScheduleActivity.java    From utexas-utilities with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageSelected(int location) {
    for (int i = 0; i < mPagerAdapter.getCount(); i++) {
        if (mPagerAdapter.getExistingFragment(i) != null) {
            ActionMode mode = mPagerAdapter.getExistingFragment(i).getActionMode();
            if (mode != null) {
                mode.finish();
            }
        }
    }
}