From 411707a3a1628ef3ac2d4b970857285c898231b1 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 29 Jun 2019 12:30:08 -0700 Subject: [PATCH] fix NPE with empty wordlist (and add note for Greek) --- .../android/xw4/DictBrowseDelegate.java | 22 +++++++++++-------- xwords4/dawg/Greek/Makefile | 2 ++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DictBrowseDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DictBrowseDelegate.java index 29ff4909b..be0c70e82 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DictBrowseDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DictBrowseDelegate.java @@ -90,14 +90,6 @@ public class DictBrowseDelegate extends DelegateBase setTitle( getString( format, m_name, m_nWords, m_browseState.m_minShown, m_browseState.m_maxShown )); - - String desc = XwJNI.dict_iter_getDesc( m_dictClosure ); - if ( null != desc ) { - TextView view = (TextView)findViewById( R.id.desc ); - Assert.assertNotNull( view ); - view.setVisibility( View.VISIBLE ); - view.setText( desc ); - } } public Object getItem( int position ) @@ -177,6 +169,15 @@ public class DictBrowseDelegate extends DelegateBase m_dictClosure = XwJNI.dict_iter_init( pairs.m_bytes[0], name, pairs.m_paths[0] ); + String desc = XwJNI.dict_iter_getDesc( m_dictClosure ); + Log.d( TAG, "got desc: %s", desc ); + if ( null != desc ) { + TextView view = (TextView)findViewById( R.id.desc ); + Assert.assertNotNull( view ); + view.setVisibility( View.VISIBLE ); + view.setText( desc ); + } + m_browseState = DBUtils.dictsGetOffset( m_activity, name, m_loc ); boolean newState = null == m_browseState; if ( newState ) { @@ -220,7 +221,8 @@ public class DictBrowseDelegate extends DelegateBase protected void onPause() { - if ( null != m_browseState ) { // already saved? + if ( null != m_browseState // already saved? + && null != m_list ) { // there are words? (don't NPE on empty dict) m_browseState.m_pos = m_list.getFirstVisiblePosition(); View view = m_list.getChildAt( 0 ); m_browseState.m_top = (view == null) ? 0 : view.getTop(); @@ -274,6 +276,7 @@ public class DictBrowseDelegate extends DelegateBase ////////////////////////////////////////////////// // AdapterView.OnItemSelectedListener interface ////////////////////////////////////////////////// + @Override public void onItemSelected( AdapterView parent, View view, int position, long id ) { @@ -296,6 +299,7 @@ public class DictBrowseDelegate extends DelegateBase } } + @Override public void onNothingSelected( AdapterView parent ) { } diff --git a/xwords4/dawg/Greek/Makefile b/xwords4/dawg/Greek/Makefile index 3d92bfa8d..ef74e748d 100644 --- a/xwords4/dawg/Greek/Makefile +++ b/xwords4/dawg/Greek/Makefile @@ -20,6 +20,8 @@ XWLANG = Greek LANGCODE = el_GK ENC = UTF-8 +DICTNOTE = "Tiles for Greek (no words, so robot and hint won't work)" + # DICT2DAWGARGS = -lang $(LANGCODE) # DICT2DAWGARGS = -debug