Example usage for android.view ActionMode finish

List of usage examples for android.view ActionMode finish

Introduction

In this page you can find the example usage for android.view ActionMode finish.

Prototype

public abstract void finish();

Source Link

Document

Finish and close this action mode.

Usage

From source file:de.vanita5.twittnuker.fragment.BaseFiltersFragment.java

@Override
public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) {
    switch (item.getItemId()) {
    case MENU_DELETE: {
        final Where where = Where.in(new Column(Filters._ID), new RawItemArray(mListView.getCheckedItemIds()));
        mResolver.delete(getContentUri(), where.getSQL(), null);
        break;/*from   w w w .j  a v a2  s  .  c o  m*/
    }
    default: {
        return false;
    }
    }
    mode.finish();
    return true;
}

From source file:net.lp.actionbarpoirot.helpers.FragmentHelperHoneycomb.java

@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    if (mSelectedPositionsUris.size() > 1) {
        //Not used currently
        return mMultiChoiceModeUser.onContextItemSelectedWithMultipleSelection(item, mSelectedPositionsUris);
    } else {/*www.  j  a  v a 2 s  .c o  m*/
        boolean result = mFragment.onContextItemSelected(item);
        if (!result)
            mode.finish();// Alternative intent action picked, so close the CAB
        return result;
    }
    //Most of the times, returns false, and then the intent in the menuItem will be executed.
}

From source file:com.btmura.android.reddit.app.NavigationFragment.java

@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_add_subreddit:
        handleAddSubreddit();/*from w  ww . j av  a 2  s  .  c o m*/
        mode.finish();
        return true;

    case R.id.menu_subreddit:
        handleSubreddit();
        mode.finish();
        return true;

    case R.id.menu_delete:
        handleDelete();
        mode.finish();
        return true;

    case R.id.menu_share:
        handleShare();
        mode.finish();
        return true;

    case R.id.menu_copy_url:
        handleCopyUrl();
        mode.finish();
        return true;
    }
    return false;
}

From source file:org.ambient.control.home.roomitems.LightObjectStrategy.java

/**
 * edit the renderingconfiguration of the light object. preview, and save actions are handled in the editActivity.
 *///from  w  ww  .  j av  a2s .  com
@Override
public void onLongClick(View view, final Room room, final RoomFragment roomFragment, final Entity entity) {

    final RenderingProgramConfiguration itemConfig = ((Renderable) entity).getRenderingProgrammConfiguration();

    roomFragment.getActivity().startActionMode(new ActionMode.Callback() {

        @Override
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {

            switch (item.getItemId()) {

            case R.id.menuEntryEditActorConduct:

                EditRenderingConfigActivity.createInstanceForEditObject(roomFragment.getActivity(), itemConfig,
                        entity.getId(), room.roomName, room);
                break;

            case R.id.menuEntryAddActorConduct:

                EditRenderingConfigActivity.createInstanceForNewObject(roomFragment.getActivity(), itemConfig,
                        entity.getId(), room.roomName, room);
                break;

            }
            mode.finish();
            return true;
        }

        @Override
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            mode.getMenuInflater().inflate(R.menu.fragment_room_cab, menu);
            return true;
        }

        @Override
        public void onDestroyActionMode(ActionMode mode) {
        }

        @Override
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return false;
        }
    });
}

From source file:org.getlantern.firetweet.fragment.CustomTabsFragment.java

@Override
public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) {
    switch (item.getItemId()) {
    case MENU_DELETE: {
        final long[] itemIds = mListView.getCheckedItemIds();
        final Expression where = Expression.in(new Column(Tabs._ID), new RawItemArray(itemIds));
        mResolver.delete(Tabs.CONTENT_URI, where.getSQL(), null);
        break;//  w ww  . j ava  2s .  c om
    }
    }
    mode.finish();
    return true;
}

From source file:com.fortysevendeg.android.swipelistview.sample.activities.SwipeListViewExampleActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.swipe_list_view_activity);

    data = new ArrayList<PackageItem>();

    adapter = new PackageAdapter(this, data);

    swipeListView = (SwipeListView) findViewById(R.id.example_lv_list);

    swipeListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        swipeListView.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {

            @Override/*from w  w  w . j  a v  a 2s .  c om*/
            public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
                mode.setTitle("Selected (" + swipeListView.getCountSelected() + ")");
            }

            @Override
            public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
                switch (item.getItemId()) {
                case R.id.menu_delete:
                    swipeListView.dismissSelected();
                    mode.finish();
                    return true;
                default:
                    return false;
                }
            }

            @Override
            public boolean onCreateActionMode(ActionMode mode, Menu menu) {
                MenuInflater inflater = mode.getMenuInflater();
                inflater.inflate(R.menu.menu_choice_items, menu);
                return true;
            }

            @Override
            public void onDestroyActionMode(ActionMode mode) {
                swipeListView.unselectedChoiceStates();
            }

            @Override
            public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                return false;
            }
        });
    }

    swipeListView.setSwipeListViewListener(new BaseSwipeListViewListener() {
        @Override
        public void onOpened(int position, boolean toRight) {
        }

        @Override
        public void onClosed(int position, boolean fromRight) {
        }

        @Override
        public void onListChanged() {
        }

        @Override
        public void onMove(int position, float x) {
        }

        @Override
        public void onStartOpen(int position, int action, boolean right) {
            Log.d("swipe", String.format("onStartOpen %d - action %d", position, action));
        }

        @Override
        public void onStartClose(int position, boolean right) {
            Log.d("swipe", String.format("onStartClose %d", position));
        }

        @Override
        public void onClickFrontView(int position) {
            Log.d("swipe", String.format("onClickFrontView %d", position));
        }

        @Override
        public void onClickBackView(int position) {
            Log.d("swipe", String.format("onClickBackView %d", position));
        }

        @Override
        public void onDismiss(int[] reverseSortedPositions) {
            for (int position : reverseSortedPositions) {
                data.remove(position);
            }
            adapter.notifyDataSetChanged();
        }

    });

    swipeListView.setAdapter(adapter);

    reload();

    new ListAppTask().execute();

    progressDialog = new ProgressDialog(this);
    progressDialog.setMessage(getString(R.string.loading));
    progressDialog.setCancelable(false);
    progressDialog.show();

}

From source file:com.parking.swipelistview.sample.activities.SwipeListViewExampleActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.swipe_list_view_activity);
    ctx = SwipeListViewExampleActivity.this;
    data = new ArrayList<MallItem>();

    adapter = new MallAdapter(this, data);

    swipeListView = (SwipeListView) findViewById(R.id.example_lv_list);

    swipeListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        swipeListView.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {

            @Override//www .ja v  a 2s.  co  m
            public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
                mode.setTitle("Selected (" + swipeListView.getCountSelected() + ")");
            }

            @Override
            public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
                switch (item.getItemId()) {
                case R.id.menu_delete:
                    swipeListView.dismissSelected();
                    mode.finish();
                    return true;
                default:
                    return false;
                }
            }

            @Override
            public boolean onCreateActionMode(ActionMode mode, Menu menu) {
                MenuInflater inflater = mode.getMenuInflater();
                inflater.inflate(R.menu.menu_choice_items, menu);
                return true;
            }

            @Override
            public void onDestroyActionMode(ActionMode mode) {
                swipeListView.unselectedChoiceStates();
            }

            @Override
            public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                return false;
            }
        });
    }

    swipeListView.setSwipeListViewListener(new BaseSwipeListViewListener() {
        @Override
        public void onOpened(int position, boolean toRight) {
        }

        @Override
        public void onClosed(int position, boolean fromRight) {
        }

        @Override
        public void onListChanged() {
        }

        @Override
        public void onMove(int position, float x) {
        }

        @Override
        public void onStartOpen(int position, int action, boolean right) {
            Log.d("swipe", String.format("onStartOpen %d - action %d", position, action));
        }

        @Override
        public void onStartClose(int position, boolean right) {
            Log.d("swipe", String.format("onStartClose %d", position));
        }

        @Override
        public void onClickFrontView(int position) {
            Log.d("swipe", String.format("onClickFrontView %d", position));
        }

        @Override
        public void onClickBackView(int position) {
            Log.d("swipe", String.format("onClickBackView %d", position));
        }

        @Override
        public void onDismiss(int[] reverseSortedPositions) {
            for (int position : reverseSortedPositions) {
                data.remove(position);
            }
            adapter.notifyDataSetChanged();
        }

    });

    swipeListView.setAdapter(adapter);

    reload();

    new ListAppTask().execute();

    progressDialog = new ProgressDialog(this);
    progressDialog.setMessage(getString(R.string.loading));
    progressDialog.setCancelable(false);
    progressDialog.show();

}

From source file:com.github.capone.controller.favorites.FavoritesFragment.java

@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
    final ServerRecord server = adapter.getItem(position);

    getActivity().startActionMode(new ActionMode.Callback() {
        @Override//from  w  ww  .j  ava2 s . com
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            MenuInflater inflater = getActivity().getMenuInflater();
            inflater.inflate(R.menu.favorites, menu);
            return true;
        }

        @Override
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        @Override
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            switch (item.getItemId()) {
            case R.id.edit:
                onEditClicked(server);
                mode.finish();
                return true;
            case R.id.remove:
                onRemoveClicked(server);
                mode.finish();
                return true;
            default:
                return false;
            }
        }

        @Override
        public void onDestroyActionMode(ActionMode mode) {
        }
    });
    return true;
}

From source file:email.schaal.ocreader.ListActivity.java

@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_mark_read:
        Queries.setItemsUnread(getRealm(), false, adapter.getSelectedItems());
        mode.finish();
        return true;
    case R.id.action_mark_unread:
        Queries.setItemsUnread(getRealm(), true, adapter.getSelectedItems());
        mode.finish();/*  w w  w .  j  av a  2 s . c o  m*/
        return true;
    case R.id.action_mark_starred:
        Queries.setItemsStarred(getRealm(), true, adapter.getSelectedItems());
        mode.finish();
        return true;
    case R.id.action_mark_unstarred:
        Queries.setItemsStarred(getRealm(), false, adapter.getSelectedItems());
        mode.finish();
        return true;
    case R.id.action_mark_above_read:
        Queries.markAboveAsRead(getRealm(), adapter.getItems(), adapter.getSelectedItems()[0].getId());
        mode.finish();
        return true;
    }
    return false;
}

From source file:org.amahi.anywhere.fragment.ServerFilesFragment.java

@RequiresApi(api = Build.VERSION_CODES.M)
@Override//  w  w w .ja  v a  2  s.c om
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
    switch (menuItem.getItemId()) {
    case R.id.menu_share:
        checkPermissions();
        break;

    default:
        return false;
    }

    actionMode.finish();

    return true;
}