From 63262ba9b329a300255043bed55c81abd540f3e6 Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 31 Mar 2021 15:29:52 -0700 Subject: [PATCH] fix crash when no radio's been chosen --- .../eehouse/android/xw4/NewWithKnowns.java | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NewWithKnowns.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NewWithKnowns.java index fdf5334eb..a438a8319 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NewWithKnowns.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NewWithKnowns.java @@ -128,27 +128,29 @@ public class NewWithKnowns extends LinearLayout void onButtonPressed( ButtonCallbacks procs ) { - Context context = getContext(); - String gameName = gameName(); - switch ( mCurRadio ) { - case R.id.radio_known: - DBUtils.setStringFor( context, KP_NAME_KEY, mCurKnown ); - procs.onUseKnown( mCurKnown, gameName ); - break; - case R.id.radio_unknown: - case R.id.radio_default: - procs.onStartGame( gameName, mStandalone, false ); - break; - case R.id.radio_configure: - procs.onStartGame( gameName, mStandalone, true ); - break; - default: - Assert.failDbg(); - break; - } + if ( 0 != mCurRadio ) { + Context context = getContext(); + String gameName = gameName(); + switch ( mCurRadio ) { + case R.id.radio_known: + DBUtils.setStringFor( context, KP_NAME_KEY, mCurKnown ); + procs.onUseKnown( mCurKnown, gameName ); + break; + case R.id.radio_unknown: + case R.id.radio_default: + procs.onStartGame( gameName, mStandalone, false ); + break; + case R.id.radio_configure: + procs.onStartGame( gameName, mStandalone, true ); + break; + default: + Assert.failDbg(); // fired + break; + } - String key = mStandalone ? KP_PREVSOLO_KEY : KP_PREVNET_KEY; - DBUtils.setIntFor( context, key, mCurRadio ); + String key = mStandalone ? KP_PREVSOLO_KEY : KP_PREVNET_KEY; + DBUtils.setIntFor( context, key, mCurRadio ); + } } private String gameName()