@@ -76,6 +76,8 @@ public class BaseAncHomeVisitFragment extends BaseHomeVisitFragment implements V
7676 private SimpleDateFormat dateFormat = new SimpleDateFormat ("dd-MM-yyyy" , Locale .getDefault ());
7777 private List <JSONObject > optionList = new ArrayList <>();
7878 private Map <String , String > dateConstraints = new HashMap <>();
79+ private String value ;
80+ private RadioButton radioButtonChecked ;
7981
8082 public static BaseAncHomeVisitFragment getInstance (final BaseAncHomeVisitContract .VisitView view , String form_name , JSONObject json , Map <String , List <VisitDetail >> details , String count ) {
8183 JSONObject jsonObject = json ;
@@ -228,12 +230,19 @@ private void prepareRadioView() {
228230
229231 try {
230232 rb .setText (object .getString (JsonFormConstants .TEXT ));
231-
232233 String key = object .getString (JsonFormConstants .KEY );
234+ if (key .equalsIgnoreCase (value )) {
235+ rb .setChecked (true );
236+ radioButtonChecked = rb ;
237+ }
233238 rb .setTag (R .id .home_visit_radio_key , key );
234239 rb .setOnClickListener (v -> {
235- if (rb .isChecked ())
240+ if (rb .isChecked () && !radioButtonChecked .equals (rb )) {
241+ radioButtonChecked .setChecked (false );
242+ rb .setChecked (true );
236243 onSelectOption (key );
244+ radioButtonChecked = rb ;
245+ }
237246 });
238247 } catch (JSONException e ) {
239248 Timber .e (e );
@@ -370,6 +379,7 @@ public void setCount(String count) {
370379
371380 @ Override
372381 public void setValue (String value ) {
382+ this .value = value ;
373383 if (getQuestionType () == QuestionType .BOOLEAN ) {
374384 if (radioButtonNo != null && radioButtonYes != null ) {
375385 setYesNoListenersActive (false );
0 commit comments