mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
fix NPE: if there's no history string don't try to split it.
This commit is contained in:
parent
d2fda267e5
commit
0726cefb10
2 changed files with 23 additions and 17 deletions
|
@ -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 );
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue