From bdd92baf550806f5103fc05b7d23b81da9c521b3 Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 28 Dec 2018 07:09:15 -0800 Subject: [PATCH] fix NPE when game isn't connected yet --- .../main/java/org/eehouse/android/xw4/BoardDelegate.java | 3 ++- .../java/org/eehouse/android/xw4/ConnStatusHandler.java | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java index 8a970aa59..7fbdef057 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java @@ -1486,8 +1486,9 @@ public class BoardDelegate extends DelegateBase public void onStatusClicked() { CommsAddrRec[] addrs = XwJNI.comms_getAddrs( m_jniGamePtr ); + CommsAddrRec addr = null != addrs && 0 < addrs.length ? addrs[0] : null; final String msg = ConnStatusHandler - .getStatusText( m_activity, m_connTypes, addrs[0] ); + .getStatusText( m_activity, m_connTypes, addr ); post( new Runnable() { @Override diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConnStatusHandler.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConnStatusHandler.java index b6e460161..92005f910 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConnStatusHandler.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConnStatusHandler.java @@ -553,10 +553,14 @@ public class ConnStatusHandler { result = WiDirService.formatNetStateInfo(); break; case COMMS_CONN_BT: - result = addr.bt_hostName; + if ( null != addr ) { + result = addr.bt_hostName; + } break; case COMMS_CONN_SMS: - result = addr.sms_phone; + if ( null != addr ) { + result = addr.sms_phone; + } break; default: break;