From 950a2ae21664d1bde81b0be27d63541bf1dede54 Mon Sep 17 00:00:00 2001 From: Jamie Date: Sat, 10 Dec 2016 16:30:10 +0000 Subject: [PATCH] fix radio group not retaining selection if radiobutton already selected --- .../androidbootstrap/BootstrapButton.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapButton.java b/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapButton.java index eb8f8bd..5dc1af1 100644 --- a/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapButton.java +++ b/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapButton.java @@ -1,7 +1,6 @@ package com.beardedhen.androidbootstrap; import android.content.Context; -import android.content.DialogInterface; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.os.Bundle; @@ -10,7 +9,6 @@ import android.support.annotation.Nullable; import android.util.AttributeSet; import android.view.MotionEvent; -import android.view.View; import android.view.ViewParent; import com.beardedhen.androidbootstrap.api.attributes.BootstrapBrand; @@ -221,17 +219,12 @@ public void setSelected(boolean selected) { private boolean handleRadioEvent(@NonNull MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { - if (isSelected()) { - setSelected(false); - } - else { // notify parent to deselect any peers - setSelected(true); + setSelected(true); // notify parent to deselect any peers - ViewParent parent = getParent(); + ViewParent parent = getParent(); - if (parent instanceof BootstrapButtonGroup) { - ((BootstrapButtonGroup) parent).onRadioToggle(parentIndex); - } + if (parent instanceof BootstrapButtonGroup) { + ((BootstrapButtonGroup) parent).onRadioToggle(parentIndex); } return true; }