Skip to content

Commit

Permalink
fix radio group not retaining selection if radiobutton already selected
Browse files Browse the repository at this point in the history
  • Loading branch information
fractalwrench committed Dec 10, 2016
1 parent 508253e commit 950a2ae
Showing 1 changed file with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 950a2ae

Please sign in to comment.