diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatActivity.java index e61fe4285..5a9904fd1 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatActivity.java @@ -51,17 +51,19 @@ public class ChatActivity extends XWActivity implements View.OnClickListener { } DBUtils.HistoryPair[] pairs = DBUtils.getChatHistory( this, m_path ); - LinearLayout layout = (LinearLayout)findViewById( R.id.chat_history ); - LayoutInflater factory = LayoutInflater.from( this ); + if ( null != pairs ) { + LinearLayout layout = (LinearLayout)findViewById( R.id.chat_history ); + LayoutInflater factory = LayoutInflater.from( this ); - for ( DBUtils.HistoryPair pair : pairs ) { - TextView view = - (TextView)factory.inflate( pair.sourceLocal - ? R.layout.chat_history_local - : R.layout.chat_history_remote, - null ); - view.setText( pair.msg ); - layout.addView( view ); + for ( DBUtils.HistoryPair pair : pairs ) { + TextView view = + (TextView)factory.inflate( pair.sourceLocal + ? R.layout.chat_history_local + : R.layout.chat_history_remote, + null ); + view.setText( pair.msg ); + layout.addView( view ); + } } ((Button)findViewById( R.id.send_button )).setOnClickListener( this ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java index 07e965e31..55b7e0b5a 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java @@ -164,7 +164,7 @@ public class DBUtils { saveSummary( context, file, summary ); } return summary; - } + } // getSummary public static void saveSummary( Context context, String path, GameSummary summary ) @@ -482,13 +482,17 @@ public class DBUtils { public static HistoryPair[] getChatHistory( Context context, String path ) { + HistoryPair[] result = null; final String localPrefix = context.getString( R.string.chat_local_id ); - String[] msgs = getChatHistoryStr( context, path ).split( "\n" ); - HistoryPair[] result = new HistoryPair[msgs.length]; - for ( int ii = 0; ii < result.length; ++ii ) { - String msg = msgs[ii]; - boolean isLocal = msg.startsWith( localPrefix ); - result[ii] = new HistoryPair( msg, isLocal ); + String history = getChatHistoryStr( context, path ); + if ( null != history ) { + String[] msgs = history.split( "\n" ); + result = new HistoryPair[msgs.length]; + for ( int ii = 0; ii < result.length; ++ii ) { + String msg = msgs[ii]; + boolean isLocal = msg.startsWith( localPrefix ); + result[ii] = new HistoryPair( msg, isLocal ); + } } return result; }