mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-09 05:24:44 +01:00
switch from static final ints to an enum; no other change.
This commit is contained in:
parent
1d52a9afea
commit
a96c0c548f
3 changed files with 20 additions and 19 deletions
|
@ -598,23 +598,23 @@ public class RelayService extends XWService {
|
||||||
|
|
||||||
private String getDevID( byte[] typp )
|
private String getDevID( byte[] typp )
|
||||||
{
|
{
|
||||||
byte typ;
|
UtilCtxt.DevIDType typ;
|
||||||
String devid = XWPrefs.getRelayDevID( this );
|
String devid = XWPrefs.getRelayDevID( this );
|
||||||
if ( null != devid && 0 < devid.length() ) {
|
if ( null != devid && 0 < devid.length() ) {
|
||||||
typ = UtilCtxt.ID_TYPE_RELAY;
|
typ = UtilCtxt.DevIDType.ID_TYPE_RELAY;
|
||||||
} else {
|
} else {
|
||||||
devid = XWPrefs.getGCMDevID( this );
|
devid = XWPrefs.getGCMDevID( this );
|
||||||
if ( null != devid && 0 < devid.length() ) {
|
if ( null != devid && 0 < devid.length() ) {
|
||||||
typ = UtilCtxt.ID_TYPE_ANDROID_GCM;
|
typ = UtilCtxt.DevIDType.ID_TYPE_ANDROID_GCM;
|
||||||
} else {
|
} else {
|
||||||
devid = "";
|
devid = "";
|
||||||
typ = UtilCtxt.ID_TYPE_ANON;
|
typ = UtilCtxt.DevIDType.ID_TYPE_ANON;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( null != typp ) {
|
if ( null != typp ) {
|
||||||
typp[0] = typ;
|
typp[0] = (byte)typ.ordinal();
|
||||||
} else {
|
} else {
|
||||||
Assert.assertTrue( typ == UtilCtxt.ID_TYPE_RELAY );
|
Assert.assertTrue( typ == UtilCtxt.DevIDType.ID_TYPE_RELAY );
|
||||||
}
|
}
|
||||||
return devid;
|
return devid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,14 +57,15 @@ public interface UtilCtxt {
|
||||||
void setIsServer( boolean isServer );
|
void setIsServer( boolean isServer );
|
||||||
|
|
||||||
// Possible values for typ[0], these must match enum in xwrelay.sh
|
// Possible values for typ[0], these must match enum in xwrelay.sh
|
||||||
public static final int ID_TYPE_NONE = 0;
|
public enum DevIDType { ID_TYPE_NONE
|
||||||
public static final int ID_TYPE_RELAY = 1;
|
, ID_TYPE_RELAY
|
||||||
public static final int ID_TYPE_ANDROID_GCM = 3;
|
, ID_TYPE_ANDROID_GCM
|
||||||
public static final int ID_TYPE_ANDROID_OTHER = 4;
|
, ID_TYPE_ANDROID_OTHER
|
||||||
public static final int ID_TYPE_ANON = 5;
|
, ID_TYPE_ANON
|
||||||
|
}
|
||||||
|
|
||||||
String getDevID( /*out*/ byte[] typ );
|
String getDevID( /*out*/ byte[] typ );
|
||||||
void deviceRegistered( int devIDType, String idRelay );
|
void deviceRegistered( DevIDType devIDType, String idRelay );
|
||||||
|
|
||||||
void bonusSquareHeld( int bonus );
|
void bonusSquareHeld( int bonus );
|
||||||
void playerScoreHeld( int player );
|
void playerScoreHeld( int player );
|
||||||
|
|
|
@ -96,29 +96,29 @@ public class UtilCtxtImpl implements UtilCtxt {
|
||||||
|
|
||||||
public String getDevID( /*out*/ byte[] typa )
|
public String getDevID( /*out*/ byte[] typa )
|
||||||
{
|
{
|
||||||
byte typ = UtilCtxt.ID_TYPE_NONE;
|
UtilCtxt.DevIDType typ = UtilCtxt.DevIDType.ID_TYPE_NONE;
|
||||||
String result = XWPrefs.getRelayDevID( m_context );
|
String result = XWPrefs.getRelayDevID( m_context );
|
||||||
if ( null != result ) {
|
if ( null != result ) {
|
||||||
typ = UtilCtxt.ID_TYPE_RELAY;
|
typ = UtilCtxt.DevIDType.ID_TYPE_RELAY;
|
||||||
} else {
|
} else {
|
||||||
result = XWPrefs.getGCMDevID( m_context );
|
result = XWPrefs.getGCMDevID( m_context );
|
||||||
if ( result.equals("") ) {
|
if ( result.equals("") ) {
|
||||||
result = null;
|
result = null;
|
||||||
} else {
|
} else {
|
||||||
typ = UtilCtxt.ID_TYPE_ANDROID_GCM;
|
typ = UtilCtxt.DevIDType.ID_TYPE_ANDROID_GCM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
typa[0] = typ;
|
typa[0] = (byte)typ.ordinal();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deviceRegistered( int devIDType, String idRelay )
|
public void deviceRegistered( UtilCtxt.DevIDType devIDType, String idRelay )
|
||||||
{
|
{
|
||||||
switch ( devIDType ) {
|
switch ( devIDType ) {
|
||||||
case UtilCtxt.ID_TYPE_RELAY:
|
case ID_TYPE_RELAY:
|
||||||
XWPrefs.setRelayDevID( m_context, idRelay );
|
XWPrefs.setRelayDevID( m_context, idRelay );
|
||||||
break;
|
break;
|
||||||
case UtilCtxt.ID_TYPE_NONE:
|
case ID_TYPE_NONE:
|
||||||
XWPrefs.clearRelayDevID( m_context );
|
XWPrefs.clearRelayDevID( m_context );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue