mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-30 10:26:58 +01:00
put up an alert when unable to find any public rooms
This commit is contained in:
parent
0bfad7cd05
commit
f78b1747dd
3 changed files with 32 additions and 5 deletions
|
@ -383,5 +383,7 @@
|
|||
|
||||
<string name="public_names_progress">Fetching public rooms for
|
||||
%d-player games in %s.</string>
|
||||
<string name="no_name_found">No public rooms found. Try
|
||||
refreshing or creating your own.</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -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() );
|
||||
}
|
||||
|
|
|
@ -32,17 +32,25 @@ import java.util.ArrayList;
|
|||
import java.net.Socket;
|
||||
|
||||
public class RefreshNamesTask extends AsyncTask<Void, Void, String[]> {
|
||||
|
||||
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<Void, Void, String[]> {
|
|||
|
||||
m_progress.cancel();
|
||||
|
||||
if ( result.length == 0 ) {
|
||||
m_nnf.NoNameFound();
|
||||
}
|
||||
|
||||
Utils.logf( "onPostExecute() done" );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue