From 8084e63d093b35fd050273d3487732ef1d3afb4e Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 25 Mar 2014 06:26:28 -0700 Subject: [PATCH] add and use a showDialog() that takes a DlgID --- .../org/eehouse/android/xw4/DelegateBase.java | 5 +++++ .../eehouse/android/xw4/DictsDelegate.java | 20 +++++++++---------- .../org/eehouse/android/xw4/DlgDelegate.java | 5 +++++ .../android/xw4/GamesListDelegate.java | 18 ++++++++--------- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java index 31597deaf..07da001d4 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java @@ -36,6 +36,11 @@ public class DelegateBase implements DlgDelegate.DlgClickNotify { m_delegate = new DlgDelegate( activity, this, bundle ); } + protected void showDialog( DlgID dlgID ) + { + m_delegate.showDialog( dlgID ); + } + protected Dialog createDialog( int id ) { return m_delegate.createDialog( id ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsDelegate.java index 1e6cc6b7e..2de29face 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsDelegate.java @@ -402,7 +402,7 @@ public class DictsDelegate extends DelegateBase Intent intent = m_activity.getIntent(); if ( null != intent ) { if ( MultiService.isMissingDictIntent( intent ) ) { - m_activity.showDialog( DlgID.DICT_OR_DECLINE.ordinal() ); + showDialog( DlgID.DICT_OR_DECLINE ); } else { boolean downloadNow = intent.getBooleanExtra( DICT_DOLAUNCH, false ); if ( downloadNow ) { @@ -487,10 +487,10 @@ public class DictsDelegate extends DelegateBase deleteSelected(); break; case R.id.dicts_move: - askMoveSelDicts(); + showDialog( DlgID.MOVE_DICT ); break; case R.id.dicts_select: - m_activity.showDialog( DlgID.SET_DEFAULT.ordinal() ); + showDialog( DlgID.SET_DEFAULT ); break; default: handled = false; @@ -521,15 +521,9 @@ public class DictsDelegate extends DelegateBase 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 + ////////////////////////////////////////////////////////////////////// public boolean onItemLongClick( AdapterView parent, View view, int position, long id ) { boolean success = view instanceof SelectableItem.LongClickHandler; @@ -597,7 +591,9 @@ public class DictsDelegate extends DelegateBase (Object)items ); } // deleteSelected + ////////////////////////////////////////////////////////////////////// // MountEventReceiver.SDCardNotifiee interface + ////////////////////////////////////////////////////////////////////// public void cardMounted( boolean nowMounted ) { DbgUtils.logf( "DictsActivity.cardMounted(%b)", nowMounted ); @@ -611,7 +607,9 @@ public class DictsDelegate extends DelegateBase } ); } + ////////////////////////////////////////////////////////////////////// // DlgDelegate.DlgClickNotify interface + ////////////////////////////////////////////////////////////////////// public void dlgButtonClicked( Action action, int which, Object[] params ) { switch( action ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java index 7cdc8c192..d409a1750 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java @@ -154,6 +154,11 @@ public class DlgDelegate { } outState.putIntArray( IDS, ids ); } + + protected void showDialog( DlgID dlgID ) + { + m_activity.showDialog( dlgID.ordinal() ); + } public Dialog createDialog( int id ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java index c71dc5715..2d34cf8ba 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java @@ -182,7 +182,7 @@ public class GamesListDelegate extends DelegateBase if ( DlgID.WARN_NODICT_SUBST == dlgID ) { lstnr = new DialogInterface.OnClickListener() { 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 ); @@ -733,7 +733,7 @@ public class GamesListDelegate extends DelegateBase break; case R.id.games_menu_newgroup: - m_activity.showDialog( DlgID.NEW_GROUP.ordinal() ); + showDialog( DlgID.NEW_GROUP ); break; case R.id.games_game_config: @@ -803,7 +803,7 @@ public class GamesListDelegate extends DelegateBase showOKOnlyDialog( R.string.no_move_onegroup ); } else { m_rowids = selRowIDs; - m_activity.showDialog( DlgID.CHANGE_GROUP.ordinal() ); + showDialog( DlgID.CHANGE_GROUP ); } break; case R.id.games_game_new_from: @@ -844,7 +844,7 @@ public class GamesListDelegate extends DelegateBase case R.id.games_game_rename: m_rowid = selRowIDs[0]; - m_activity.showDialog( DlgID.RENAME_GAME.ordinal() ); + showDialog( DlgID.RENAME_GAME ); break; // Group menus @@ -876,7 +876,7 @@ public class GamesListDelegate extends DelegateBase break; case R.id.games_group_rename: m_groupid = groupID; - m_activity.showDialog( DlgID.RENAME_GROUP.ordinal() ); + showDialog( DlgID.RENAME_GROUP ); break; case R.id.games_group_moveup: changeContent = m_adapter.moveGroup( groupID, -1 ); @@ -958,7 +958,7 @@ public class GamesListDelegate extends DelegateBase m_netLaunchInfo = nli; m_missingDictLang = nli.lang; m_missingDictName = nli.dict; - m_activity.showDialog( DlgID.WARN_NODICT_NEW.ordinal() ); + showDialog( DlgID.WARN_NODICT_NEW ); } return haveDict; } @@ -978,9 +978,9 @@ public class GamesListDelegate extends DelegateBase } m_missingDictRowId = rowid; if ( 0 == DictLangCache.getLangCount( m_activity, m_missingDictLang ) ) { - m_activity.showDialog( DlgID.WARN_NODICT.ordinal() ); + showDialog( DlgID.WARN_NODICT ); } else if ( null != m_missingDictName ) { - m_activity.showDialog( DlgID.WARN_NODICT_SUBST.ordinal() ); + showDialog( DlgID.WARN_NODICT_SUBST ); } else { String dict = DictLangCache.getHaveLang( m_activity, m_missingDictLang)[0]; @@ -1146,7 +1146,7 @@ public class GamesListDelegate extends DelegateBase if ( null == CommonPrefs.getDefaultPlayerName( m_activity, 0, false ) ) { String name = CommonPrefs.getDefaultPlayerName( m_activity, 0, true ); CommonPrefs.setDefaultPlayerName( m_activity, name ); - m_activity.showDialog( DlgID.GET_NAME.ordinal() ); + showDialog( DlgID.GET_NAME ); } }