diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml index 7dae17dc0..aae83091c 100644 --- a/xwords4/android/XWords4/res/values/strings.xml +++ b/xwords4/android/XWords4/res/values/strings.xml @@ -383,5 +383,7 @@ Fetching public rooms for %d-player games in %s. + No public rooms found. Try + refreshing or creating your own. diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java index a0c9e2869..5b9b2a8da 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java @@ -57,8 +57,9 @@ import junit.framework.Assert; import org.eehouse.android.xw4.jni.*; import org.eehouse.android.xw4.jni.CurGameInfo.DeviceRole; -public class GameConfig extends Activity implements View.OnClickListener, - XWListItem.DeleteCallback { +public class GameConfig extends Activity implements View.OnClickListener + ,XWListItem.DeleteCallback + ,RefreshNamesTask.NoNameFound { private static final int PLAYER_EDIT = 1; // private static final int ROLE_EDIT_RELAY = 2; @@ -66,6 +67,7 @@ public class GameConfig extends Activity implements View.OnClickListener, // private static final int ROLE_EDIT_BT = 4; private static final int FORCE_REMOTE = 5; private static final int CONFIRM_CHANGE = 6; + private static final int NO_NAME_FOUND = 7; private CheckBox m_notNetworkedGameCheckbx; private CheckBox m_joinPublicCheck; @@ -218,6 +220,11 @@ public class GameConfig extends Activity implements View.OnClickListener, }) .create(); break; + case NO_NAME_FOUND: + dialog = new AlertDialog.Builder( this ) + .setPositiveButton( R.string.button_ok, null ) + .setMessage( R.string.no_name_found ) + .create(); } return dialog; } @@ -437,6 +444,12 @@ public class GameConfig extends Activity implements View.OnClickListener, } } + // NoNameFound interface + public void NoNameFound() + { + showDialog( NO_NAME_FOUND ); + } + public void onClick( View view ) { if ( m_addPlayerButton == view ) { @@ -477,8 +490,8 @@ public class GameConfig extends Activity implements View.OnClickListener, // break; // } } else if ( m_refreshRoomsButton == view ) { - new RefreshNamesTask( this, m_gi.dictLang, m_gi.nPlayers, - m_roomChoose ).execute(); + new RefreshNamesTask( this, this, m_gi.dictLang, + m_gi.nPlayers, m_roomChoose ).execute(); } else { Utils.logf( "unknown v: " + view.toString() ); } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/RefreshNamesTask.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/RefreshNamesTask.java index 363681c3e..60202205a 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/RefreshNamesTask.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/RefreshNamesTask.java @@ -32,17 +32,25 @@ import java.util.ArrayList; import java.net.Socket; public class RefreshNamesTask extends AsyncTask { + + public interface NoNameFound { + public void NoNameFound(); + }; + private Context m_context; private Spinner m_resultSpinner; private int m_lang; private int m_nInGame; private ProgressDialog m_progress; + private NoNameFound m_nnf; - public RefreshNamesTask( Context context, int lang, int nInGame, + public RefreshNamesTask( Context context, NoNameFound nnf, + int lang, int nInGame, Spinner getsResults ) { super(); m_context = context; + m_nnf = nnf; m_resultSpinner = getsResults; m_lang = lang; m_nInGame = nInGame; @@ -118,6 +126,10 @@ public class RefreshNamesTask extends AsyncTask { m_progress.cancel(); + if ( result.length == 0 ) { + m_nnf.NoNameFound(); + } + Utils.logf( "onPostExecute() done" ); } }