restore some default after download cancelled

Don't leave the text "download more" as the spinner's value when
onActivityResult() is called with a cancel.
This commit is contained in:
Eric House 2020-08-24 08:52:10 -07:00
parent 99d47fd067
commit 7cb2560b2d

View file

@ -377,7 +377,8 @@ public class GameConfigDelegate extends DelegateBase
} else { } else {
dictLabel.setVisibility( View.GONE ); dictLabel.setVisibility( View.GONE );
} }
m_playerDictSpinner = ((LabeledSpinner)playerView.findViewById( R.id.player_dict_spinner )) m_playerDictSpinner = ((LabeledSpinner)playerView
.findViewById( R.id.player_dict_spinner ))
.getSpinner(); .getSpinner();
if ( localOnlyGame() ) { if ( localOnlyGame() ) {
configDictSpinner( m_playerDictSpinner, m_gi.dictLang, m_gi.dictName(lp) ); configDictSpinner( m_playerDictSpinner, m_gi.dictLang, m_gi.dictName(lp) );
@ -553,16 +554,20 @@ public class GameConfigDelegate extends DelegateBase
@Override @Override
protected void onActivityResult( RequestCode requestCode, int resultCode, Intent data ) protected void onActivityResult( RequestCode requestCode, int resultCode, Intent data )
{ {
if ( Activity.RESULT_CANCELED != resultCode ) { boolean cancelled = Activity.RESULT_CANCELED == resultCode;
loadGame(); loadGame();
switch( requestCode ) { switch( requestCode ) {
case REQUEST_DICT: case REQUEST_DICT:
String dictName = data.getStringExtra( DictsDelegate.RESULT_LAST_DICT ); String dictName = cancelled ? m_gi.dictName
: data.getStringExtra( DictsDelegate.RESULT_LAST_DICT );
configDictSpinner( m_dictSpinner, m_gi.dictLang, dictName ); configDictSpinner( m_dictSpinner, m_gi.dictLang, dictName );
configDictSpinner( m_playerDictSpinner, m_gi.dictLang, dictName ); configDictSpinner( m_playerDictSpinner, m_gi.dictLang, dictName );
break; break;
case REQUEST_LANG_GC: case REQUEST_LANG_GC:
String langName = data.getStringExtra( DictsDelegate.RESULT_LAST_LANG ); String langName = cancelled
? DictLangCache.getLangName( m_activity, m_gi.dictLang )
: data.getStringExtra( DictsDelegate.RESULT_LAST_LANG );
selLangChanged( langName ); selLangChanged( langName );
setLangSpinnerSelection( langName ); setLangSpinnerSelection( langName );
break; break;
@ -570,7 +575,6 @@ public class GameConfigDelegate extends DelegateBase
Assert.failDbg(); Assert.failDbg();
} }
} }
}
private void loadGame() private void loadGame()
{ {
@ -1206,7 +1210,6 @@ public class GameConfigDelegate extends DelegateBase
private void adjustPlayersLabel() private void adjustPlayersLabel()
{ {
Log.i( TAG, "adjustPlayersLabel()" );
String label; String label;
if ( localOnlyGame() ) { if ( localOnlyGame() ) {
label = getString( R.string.players_label_standalone ); label = getString( R.string.players_label_standalone );