cleanup: switch on ids rather than test views

This commit is contained in:
Eric House 2017-02-04 10:28:23 -08:00
parent 99664a8360
commit 69eee734e2

View file

@ -80,7 +80,6 @@ public class GameConfigDelegate extends DelegateBase
private Button m_addPlayerButton;
private Button m_changeConnButton;
private Button m_jugglePlayersButton;
private Button m_playButton;
private ImageButton m_refreshRoomsButton;
private View m_connectSetRelay;
private Spinner m_dictSpinner;
@ -330,12 +329,6 @@ public class GameConfigDelegate extends DelegateBase
case PLAYER_EDIT:
setPlayerSettings( dialog );
break;
// case ROLE_EDIT_RELAY:
// case ROLE_EDIT_SMS:
// case ROLE_EDIT_BT:
// setRoleHints( id, dialog );
// setRoleSettings();
// break;
case FORCE_REMOTE:
ListView listview = (ListView)dialog.findViewById( R.id.players );
listview.setAdapter( new RemoteChoices() );
@ -497,8 +490,7 @@ public class GameConfigDelegate extends DelegateBase
m_changeConnButton.setOnClickListener( this );
m_jugglePlayersButton = (Button)findViewById(R.id.juggle_players);
m_jugglePlayersButton.setOnClickListener( this );
m_playButton = (Button)findViewById( R.id.play_button );
m_playButton.setOnClickListener( this );
findViewById( R.id.play_button ).setOnClickListener( this );
m_playerLayout = (LinearLayout)findViewById( R.id.player_list );
m_phoniesSpinner = (Spinner)findViewById( R.id.phonies_spinner );
@ -739,27 +731,35 @@ public class GameConfigDelegate extends DelegateBase
{
if ( isFinishing() ) {
// do nothing; we're on the way out
} else if ( m_addPlayerButton == view ) {
} else {
switch ( view.getId() ) {
case R.id.add_player:
int curIndex = m_gi.nPlayers;
if ( curIndex < CurGameInfo.MAX_NUM_PLAYERS ) {
m_gi.addPlayer(); // ups nPlayers
loadPlayersList();
}
} else if ( m_jugglePlayersButton == view ) {
break;
case R.id.juggle_players:
m_gi.juggle();
loadPlayersList();
} else if ( m_joinPublicCheck == view ) {
break;
case R.id.join_public_room_check:
adjustConnectStuff();
} else if ( m_gameLockedCheck == view ) {
break;
case R.id.game_locked_check:
makeNotAgainBuilder( R.string.not_again_unlock,
R.string.key_notagain_unlock,
Action.LOCKED_CHANGE_ACTION )
.show();
} else if ( m_refreshRoomsButton == view ) {
break;
case R.id.refresh_button:
refreshNames();
} else if ( m_changeConnButton == view ) {
break;
case R.id.change_connection:
showConnAfterCheck();
} else if ( m_playButton == view ) {
break;
case R.id.play_button:
// Launch BoardActivity for m_name, but ONLY IF user
// confirms any changes required. So we either launch
// from here if there's no confirmation needed, or launch
@ -780,9 +780,11 @@ public class GameConfigDelegate extends DelegateBase
} else {
finishAndLaunch();
}
} else {
break;
default:
DbgUtils.logw( TAG, "unknown v: " + view.toString() );
Assert.assertFalse( BuildConfig.DEBUG );
}
}
} // onClick