add and use a showDialog() that takes a DlgID

This commit is contained in:
Eric House 2014-03-25 06:26:28 -07:00
parent e0c0ff219f
commit 8084e63d09
4 changed files with 28 additions and 20 deletions

View file

@ -36,6 +36,11 @@ public class DelegateBase implements DlgDelegate.DlgClickNotify {
m_delegate = new DlgDelegate( activity, this, bundle ); m_delegate = new DlgDelegate( activity, this, bundle );
} }
protected void showDialog( DlgID dlgID )
{
m_delegate.showDialog( dlgID );
}
protected Dialog createDialog( int id ) protected Dialog createDialog( int id )
{ {
return m_delegate.createDialog( id ); return m_delegate.createDialog( id );

View file

@ -402,7 +402,7 @@ public class DictsDelegate extends DelegateBase
Intent intent = m_activity.getIntent(); Intent intent = m_activity.getIntent();
if ( null != intent ) { if ( null != intent ) {
if ( MultiService.isMissingDictIntent( intent ) ) { if ( MultiService.isMissingDictIntent( intent ) ) {
m_activity.showDialog( DlgID.DICT_OR_DECLINE.ordinal() ); showDialog( DlgID.DICT_OR_DECLINE );
} else { } else {
boolean downloadNow = intent.getBooleanExtra( DICT_DOLAUNCH, false ); boolean downloadNow = intent.getBooleanExtra( DICT_DOLAUNCH, false );
if ( downloadNow ) { if ( downloadNow ) {
@ -487,10 +487,10 @@ public class DictsDelegate extends DelegateBase
deleteSelected(); deleteSelected();
break; break;
case R.id.dicts_move: case R.id.dicts_move:
askMoveSelDicts(); showDialog( DlgID.MOVE_DICT );
break; break;
case R.id.dicts_select: case R.id.dicts_select:
m_activity.showDialog( DlgID.SET_DEFAULT.ordinal() ); showDialog( DlgID.SET_DEFAULT );
break; break;
default: default:
handled = false; handled = false;
@ -521,15 +521,9 @@ public class DictsDelegate extends DelegateBase
editor.commit(); editor.commit();
} }
// Move dict. Put up dialog asking user to confirm move from XX //////////////////////////////////////////////////////////////////////
// to YY. So we need both XX and YY. There may be several
// options for YY?
private void askMoveSelDicts()
{
m_activity.showDialog( DlgID.MOVE_DICT.ordinal() );
}
// OnItemLongClickListener interface // OnItemLongClickListener interface
//////////////////////////////////////////////////////////////////////
public boolean onItemLongClick( AdapterView<?> parent, View view, public boolean onItemLongClick( AdapterView<?> parent, View view,
int position, long id ) { int position, long id ) {
boolean success = view instanceof SelectableItem.LongClickHandler; boolean success = view instanceof SelectableItem.LongClickHandler;
@ -597,7 +591,9 @@ public class DictsDelegate extends DelegateBase
(Object)items ); (Object)items );
} // deleteSelected } // deleteSelected
//////////////////////////////////////////////////////////////////////
// MountEventReceiver.SDCardNotifiee interface // MountEventReceiver.SDCardNotifiee interface
//////////////////////////////////////////////////////////////////////
public void cardMounted( boolean nowMounted ) public void cardMounted( boolean nowMounted )
{ {
DbgUtils.logf( "DictsActivity.cardMounted(%b)", nowMounted ); DbgUtils.logf( "DictsActivity.cardMounted(%b)", nowMounted );
@ -611,7 +607,9 @@ public class DictsDelegate extends DelegateBase
} ); } );
} }
//////////////////////////////////////////////////////////////////////
// DlgDelegate.DlgClickNotify interface // DlgDelegate.DlgClickNotify interface
//////////////////////////////////////////////////////////////////////
public void dlgButtonClicked( Action action, int which, Object[] params ) public void dlgButtonClicked( Action action, int which, Object[] params )
{ {
switch( action ) { switch( action ) {

View file

@ -154,6 +154,11 @@ public class DlgDelegate {
} }
outState.putIntArray( IDS, ids ); outState.putIntArray( IDS, ids );
} }
protected void showDialog( DlgID dlgID )
{
m_activity.showDialog( dlgID.ordinal() );
}
public Dialog createDialog( int id ) public Dialog createDialog( int id )
{ {

View file

@ -182,7 +182,7 @@ public class GamesListDelegate extends DelegateBase
if ( DlgID.WARN_NODICT_SUBST == dlgID ) { if ( DlgID.WARN_NODICT_SUBST == dlgID ) {
lstnr = new DialogInterface.OnClickListener() { lstnr = new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dlg, int item ) { public void onClick( DialogInterface dlg, int item ) {
m_activity.showDialog( DlgID.SHOW_SUBST.ordinal() ); showDialog( DlgID.SHOW_SUBST );
} }
}; };
ab.setNeutralButton( R.string.button_substdict, lstnr ); ab.setNeutralButton( R.string.button_substdict, lstnr );
@ -733,7 +733,7 @@ public class GamesListDelegate extends DelegateBase
break; break;
case R.id.games_menu_newgroup: case R.id.games_menu_newgroup:
m_activity.showDialog( DlgID.NEW_GROUP.ordinal() ); showDialog( DlgID.NEW_GROUP );
break; break;
case R.id.games_game_config: case R.id.games_game_config:
@ -803,7 +803,7 @@ public class GamesListDelegate extends DelegateBase
showOKOnlyDialog( R.string.no_move_onegroup ); showOKOnlyDialog( R.string.no_move_onegroup );
} else { } else {
m_rowids = selRowIDs; m_rowids = selRowIDs;
m_activity.showDialog( DlgID.CHANGE_GROUP.ordinal() ); showDialog( DlgID.CHANGE_GROUP );
} }
break; break;
case R.id.games_game_new_from: case R.id.games_game_new_from:
@ -844,7 +844,7 @@ public class GamesListDelegate extends DelegateBase
case R.id.games_game_rename: case R.id.games_game_rename:
m_rowid = selRowIDs[0]; m_rowid = selRowIDs[0];
m_activity.showDialog( DlgID.RENAME_GAME.ordinal() ); showDialog( DlgID.RENAME_GAME );
break; break;
// Group menus // Group menus
@ -876,7 +876,7 @@ public class GamesListDelegate extends DelegateBase
break; break;
case R.id.games_group_rename: case R.id.games_group_rename:
m_groupid = groupID; m_groupid = groupID;
m_activity.showDialog( DlgID.RENAME_GROUP.ordinal() ); showDialog( DlgID.RENAME_GROUP );
break; break;
case R.id.games_group_moveup: case R.id.games_group_moveup:
changeContent = m_adapter.moveGroup( groupID, -1 ); changeContent = m_adapter.moveGroup( groupID, -1 );
@ -958,7 +958,7 @@ public class GamesListDelegate extends DelegateBase
m_netLaunchInfo = nli; m_netLaunchInfo = nli;
m_missingDictLang = nli.lang; m_missingDictLang = nli.lang;
m_missingDictName = nli.dict; m_missingDictName = nli.dict;
m_activity.showDialog( DlgID.WARN_NODICT_NEW.ordinal() ); showDialog( DlgID.WARN_NODICT_NEW );
} }
return haveDict; return haveDict;
} }
@ -978,9 +978,9 @@ public class GamesListDelegate extends DelegateBase
} }
m_missingDictRowId = rowid; m_missingDictRowId = rowid;
if ( 0 == DictLangCache.getLangCount( m_activity, m_missingDictLang ) ) { if ( 0 == DictLangCache.getLangCount( m_activity, m_missingDictLang ) ) {
m_activity.showDialog( DlgID.WARN_NODICT.ordinal() ); showDialog( DlgID.WARN_NODICT );
} else if ( null != m_missingDictName ) { } else if ( null != m_missingDictName ) {
m_activity.showDialog( DlgID.WARN_NODICT_SUBST.ordinal() ); showDialog( DlgID.WARN_NODICT_SUBST );
} else { } else {
String dict = String dict =
DictLangCache.getHaveLang( m_activity, m_missingDictLang)[0]; DictLangCache.getHaveLang( m_activity, m_missingDictLang)[0];
@ -1146,7 +1146,7 @@ public class GamesListDelegate extends DelegateBase
if ( null == CommonPrefs.getDefaultPlayerName( m_activity, 0, false ) ) { if ( null == CommonPrefs.getDefaultPlayerName( m_activity, 0, false ) ) {
String name = CommonPrefs.getDefaultPlayerName( m_activity, 0, true ); String name = CommonPrefs.getDefaultPlayerName( m_activity, 0, true );
CommonPrefs.setDefaultPlayerName( m_activity, name ); CommonPrefs.setDefaultPlayerName( m_activity, name );
m_activity.showDialog( DlgID.GET_NAME.ordinal() ); showDialog( DlgID.GET_NAME );
} }
} }