mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
add nextRandomInt() to Utils and use it
This commit is contained in:
parent
6226efe8d6
commit
6bdec885b1
2 changed files with 8 additions and 4 deletions
|
@ -36,7 +36,6 @@ import android.content.res.AssetManager;
|
|||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
import android.text.Html;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
@ -49,7 +48,6 @@ public class GameUtils {
|
|||
public static final String INVITED = "invited";
|
||||
public static final String INTENT_KEY_ROWID = "rowid";
|
||||
public static final String INTENT_FORRESULT_ROWID = "forresult";
|
||||
private static Random s_random = new Random();
|
||||
|
||||
// Implements read-locks and write-locks per game. A read lock is
|
||||
// obtainable when other read locks are granted but not when a
|
||||
|
@ -524,7 +522,6 @@ public class GameUtils {
|
|||
String room, String inviteID,
|
||||
int lang, int nPlayers )
|
||||
{
|
||||
Random random = new Random();
|
||||
if ( null == inviteID ) {
|
||||
inviteID = makeRandomID();
|
||||
}
|
||||
|
@ -861,7 +858,7 @@ public class GameUtils {
|
|||
{
|
||||
int rint;
|
||||
do {
|
||||
rint = s_random.nextInt();
|
||||
rint = Utils.nextRandomInt();
|
||||
} while ( 0 == rint );
|
||||
DbgUtils.logf( "newGameID()=>%X", rint );
|
||||
return rint;
|
||||
|
|
|
@ -44,6 +44,7 @@ import android.widget.EditText;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eehouse.android.xw4.jni.*;
|
||||
|
@ -62,9 +63,15 @@ public class Utils {
|
|||
new HashMap<String,String>();
|
||||
private static int s_nextCode = 0; // keep PendingIntents unique
|
||||
private static Boolean s_hasSmallScreen = null;
|
||||
private static Random s_random = new Random();
|
||||
|
||||
private Utils() {}
|
||||
|
||||
public static int nextRandomInt()
|
||||
{
|
||||
return s_random.nextInt();
|
||||
}
|
||||
|
||||
public static boolean firstBootEver( Context context )
|
||||
{
|
||||
if ( null == s_isFirstBootEver ) {
|
||||
|
|
Loading…
Add table
Reference in a new issue