From 96ca4f9946fc67ffb783ea739ed2f8636b2db3fb Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 5 May 2014 07:27:06 -0700 Subject: [PATCH] fix NPE: not all spinners have adapters --- .../XWords4/src/org/eehouse/android/xw4/loc/LocUtils.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocUtils.java index 6c02827c2..cef8c292e 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocUtils.java @@ -425,8 +425,8 @@ public class LocUtils { private static void xlateView( Context context, View view, int depth ) { - DbgUtils.logf( "xlateView(depth=%d, view=%s, canRecurse=%b)", depth, - view.getClass().getName(), view instanceof ViewGroup ); + // DbgUtils.logf( "xlateView(depth=%d, view=%s, canRecurse=%b)", depth, + // view.getClass().getName(), view instanceof ViewGroup ); if ( view instanceof Button ) { Button button = (Button)view; String str = xlateString( context, button.getText().toString() ); @@ -444,7 +444,9 @@ public class LocUtils { } } SpinnerAdapter adapter = sp.getAdapter(); - sp.setAdapter( new XlatingSpinnerAdapter( context, adapter ) ); + if ( null != adapter ) { + sp.setAdapter( new XlatingSpinnerAdapter( context, adapter ) ); + } } // A Spinner, for instance, ISA ViewGroup, so this is a separate test.