fix, by inspection, NPE reported through the Play Store.

This commit is contained in:
Eric House 2015-09-28 06:46:37 -07:00
parent e9059cba47
commit f363fadf39

View file

@ -788,54 +788,56 @@ public class GameConfigDelegate extends DelegateBase
private void loadPlayersList() private void loadPlayersList()
{ {
m_playerLayout.removeAllViews(); if ( null != m_gameLock ) {
m_playerLayout.removeAllViews();
String[] names = m_gi.visibleNames( false ); String[] names = m_gi.visibleNames( false );
// only enable delete if one will remain (or two if networked) // only enable delete if one will remain (or two if networked)
boolean canDelete = names.length > 2 boolean canDelete = names.length > 2
|| (localOnlyGame() && names.length > 1); || (localOnlyGame() && names.length > 1);
View.OnClickListener lstnr = new View.OnClickListener() { View.OnClickListener lstnr = new View.OnClickListener() {
@Override @Override
public void onClick( View view ) { public void onClick( View view ) {
m_whichPlayer = ((XWListItem)view).getPosition(); m_whichPlayer = ((XWListItem)view).getPosition();
showDialog( DlgID.PLAYER_EDIT ); showDialog( DlgID.PLAYER_EDIT );
}
};
boolean localGame = localOnlyGame();
for ( int ii = 0; ii < names.length; ++ii ) {
final XWListItem view = XWListItem.inflate( m_activity, null );
view.setPosition( ii );
view.setText( names[ii] );
if ( localGame && m_gi.players[ii].isLocal ) {
view.setComment( m_gi.dictName(ii) );
}
if ( canDelete ) {
view.setDeleteCallback( this );
} }
};
boolean localGame = localOnlyGame(); view.setOnClickListener( lstnr );
for ( int ii = 0; ii < names.length; ++ii ) { m_playerLayout.addView( view );
final XWListItem view = XWListItem.inflate( m_activity, null );
view.setPosition( ii ); View divider = inflate( R.layout.divider_view );
view.setText( names[ii] ); m_playerLayout.addView( divider );
if ( localGame && m_gi.players[ii].isLocal ) {
view.setComment( m_gi.dictName(ii) );
}
if ( canDelete ) {
view.setDeleteCallback( this );
} }
view.setOnClickListener( lstnr ); m_addPlayerButton
m_playerLayout.addView( view ); .setVisibility( names.length >= CurGameInfo.MAX_NUM_PLAYERS?
View.GONE : View.VISIBLE );
m_jugglePlayersButton
.setVisibility( names.length <= 1 ?
View.GONE : View.VISIBLE );
View divider = inflate( R.layout.divider_view ); showHideRelayStuff();
m_playerLayout.addView( divider );
if ( ! localOnlyGame()
&& ((0 == m_gi.remoteCount() )
|| (m_gi.nPlayers == m_gi.remoteCount()) ) ) {
showDialog( DlgID.FORCE_REMOTE );
}
adjustPlayersLabel();
} }
m_addPlayerButton
.setVisibility( names.length >= CurGameInfo.MAX_NUM_PLAYERS?
View.GONE : View.VISIBLE );
m_jugglePlayersButton
.setVisibility( names.length <= 1 ?
View.GONE : View.VISIBLE );
showHideRelayStuff();
if ( ! localOnlyGame()
&& ((0 == m_gi.remoteCount() )
|| (m_gi.nPlayers == m_gi.remoteCount()) ) ) {
showDialog( DlgID.FORCE_REMOTE );
}
adjustPlayersLabel();
} // loadPlayersList } // loadPlayersList
private void configDictSpinner( Spinner dictsSpinner, int lang, private void configDictSpinner( Spinner dictsSpinner, int lang,
@ -886,13 +888,15 @@ public class GameConfigDelegate extends DelegateBase
public void onItemSelected(AdapterView<?> parentView, public void onItemSelected(AdapterView<?> parentView,
View selectedItemView, View selectedItemView,
int position, long id ) { int position, long id ) {
String chosen = if ( null != m_gameLock ) { // not on the way out?
(String)parentView.getItemAtPosition( position ); String chosen =
if ( chosen.equals( m_browseText ) ) { (String)parentView.getItemAtPosition( position );
DictsDelegate.downloadForResult( m_activity, REQUEST_LANG ); if ( chosen.equals( m_browseText ) ) {
} else { DictsDelegate.downloadForResult( m_activity, REQUEST_LANG );
String langName = adapter.getLangAtPosition( position ); } else {
selLangChanged( langName ); String langName = adapter.getLangAtPosition( position );
selLangChanged( langName );
}
} }
} }