igalata / Bubble-Picker

An easy-to-use animation which can be used for content picking for Android
https://medium.com/@igalata13/how-to-create-a-bubble-selection-animation-on-android-627044da4854#.js8nebsx6
1.4k stars 249 forks source link

How to Select and deselect any items pragmatically? #58

Open parmarravi opened 6 years ago

parmarravi commented 6 years ago

Hello, Thank you for library .Please add some features asap it would be awesome to include this feature in the production app. I have a Feature in which when i select the second item in the bubble view ,the focus of previous item should get deselected . so at a time only one item will get on. If the user presses the second item the focus will get shifted to the next item. Let me know how can i achieve this?

MilanVucic commented 6 years ago

@parmarravi Did you find a way to do this? I need this right now, I tried many things, but since there's only a getter for selectedItems, I tried clearing that list, setting each item's "isSelected" manually to false, but neither worked. @igalata Can you jump in and guide us on how we could do this?

trbasoglu commented 6 years ago

You can use below code. But it need to reload view. @parmarravi @MilanVucic @igalata I think set selected should work without using onPause and On Resume but not. ` public void onBubbleSelected(PickerItem pickerItem) {

            if(picker.getSelectedItems().size()>=2)
            {
                picker.onPause();
                lastItem.setSelected(false);
                pickerItem.setSelected(true);
                picker.onResume();
                //onBubbleDeselected(pickerItem);
            }lastItem=pickerItem;
        }`
MilanVucic commented 6 years ago

Did you test this? @trbasoglu I think I tried something similar to no avail. setSelected on items that I get from getSelectedItems didn't seem to change much. It would be really cool if this worked. I'll give it a go asap.

nurlan-dzhavadov commented 4 years ago

If you want to go from each bubble to another activity, this one might help https://stackoverflow.com/questions/58460281/link-a-bubble-in-bubble-picker-with-a-button