ceryle / RadioRealButton

A custom radio button for Android API 12+
Apache License 2.0
259 stars 73 forks source link

Change the button position before all the things #32

Open guuilp opened 6 years ago

guuilp commented 6 years ago

One problem that I have today is: If I put a code that is a little bit slow, inside the radioGroup listener, the button position only changes when the processing finishes. This is very awkward when it comes to user experience. Could you change the button position before anything?

radioGroup.setOnClickedButtonListener(RadioRealButtonGroup.OnClickedButtonListener {
            button, position ->

            if(position != currentPosition) {
                when (button) {
                    ratingButton -> {
                        playersInFastAdapter.clear()
                        playersRating?.forEach {
                            playersInFastAdapter.add(PlayerListRankingComplete(this, it, App.CARD_RANKING_RATING_LIST))
                        }
                    }
            }
SBD580 commented 6 years ago

New selected position should be set before calling listeners (as a general rule)