Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link a button with chosen Bubble #8

Open
nurlan-dzhavadov opened this issue Oct 19, 2019 · 4 comments
Open

Link a button with chosen Bubble #8

nurlan-dzhavadov opened this issue Oct 19, 2019 · 4 comments

Comments

@nurlan-dzhavadov
Copy link

Hello, @hantrungkien !
Thank you for your library! The question is this: How can I link one selected activity with a button? I need my app to understand what bubble was selected and then move user to another activity.
If anyone else knows you to do so, please be free to answer here :)

P.S. I'm new at coding

@nurlan-dzhavadov
Copy link
Author

@hantrungkien

@ApoloRossi
Copy link

@dvlpd if I have understand what you need, you want open an specific Activity according to what bubble was clicked right?

You could solve this with 2 steps:

1 Step:

In the adapter bellow you could Store each PickerItem that was created in a pickerItemList

picker.adapter = object : BubblePickerAdapter {
            override val totalCount = titles.size

            override fun getItem(position: Int): PickerItem {
                return PickerItem().apply {
                  pickerItemList.add(this)
                }
            }
        }

2 Step:

You can compare if the item returned when clicked is equals for some item in yout list position, and then you call the activity you want in the specific Item that was clicked.

picker.listener = object : BubblePickerListener {
            override fun onBubbleSelected(item: PickerItem) {
                 if (item == pickerItemList.first()) {
                        openActivityA()
                 } else if (item == pickerItemList[1]){
                        openActivityB()
                 } //... and so son
            }

            override fun onBubbleDeselected(item: PickerItem) {

            }
}

Map thecondition to open the acitivity you want depending on what buble was clicked.

This sample is not the best one but represents a possible solution for what you want =)

@nurlan-dzhavadov
Copy link
Author

@dvlpd if I have understand what you need, you want open an specific Activity according to what bubble was clicked right?

You could solve this with 2 steps:

1 Step:

In the adapter bellow you could Store each PickerItem that was created in a pickerItemList

picker.adapter = object : BubblePickerAdapter {
            override val totalCount = titles.size

            override fun getItem(position: Int): PickerItem {
                return PickerItem().apply {
                  pickerItemList.add(this)
                }
            }
        }

2 Step:

You can compare if the item returned when clicked is equals for some item in yout list position, and then you call the activity you want in the specific Item that was clicked.

picker.listener = object : BubblePickerListener {
            override fun onBubbleSelected(item: PickerItem) {
                 if (item == pickerItemList.first()) {
                        openActivityA()
                 } else if (item == pickerItemList[1]){
                        openActivityB()
                 } //... and so son
            }

            override fun onBubbleDeselected(item: PickerItem) {

            }
}

Map thecondition to open the acitivity you want depending on what buble was clicked.

This sample is not the best one but represents a possible solution for what you want =)

Thank you for your answer, Sir
I have one more question. I like the 2nd option you presented. However I don't know how and where to write "pickerItemList". Can you please help me with that?

@nurlan-dzhavadov
Copy link
Author

Here is the answer ;)
https://stackoverflow.com/questions/58460281/link-a-bubble-in-bubble-picker-with-a-button

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants