mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-06 05:24:46 +01:00
Don't store current network connType in ConnStatusHandler; instead
pass the one for which we want icon displayed or status text generated.
This commit is contained in:
parent
0c02103d42
commit
7f087181e5
4 changed files with 27 additions and 29 deletions
|
@ -1424,7 +1424,6 @@ public class BoardActivity extends XWActivity
|
|||
final int nMissingPlayers )
|
||||
{
|
||||
m_connType = connType;
|
||||
ConnStatusHandler.setType( connType );
|
||||
|
||||
int msgID = 0;
|
||||
int action = 0;
|
||||
|
@ -1609,7 +1608,8 @@ public class BoardActivity extends XWActivity
|
|||
m_jniThread.setDaemon( true );
|
||||
m_jniThread.start();
|
||||
|
||||
m_view.startHandling( this, m_jniThread, m_jniGamePtr, m_gi );
|
||||
m_view.startHandling( this, m_jniThread, m_jniGamePtr, m_gi,
|
||||
m_connType );
|
||||
if ( null != m_xport ) {
|
||||
m_xport.setReceiver( m_jniThread );
|
||||
}
|
||||
|
|
|
@ -44,10 +44,6 @@ import junit.framework.Assert;
|
|||
public class BoardView extends View implements DrawCtx, BoardHandler,
|
||||
SyncedDraw {
|
||||
|
||||
public interface MultiHandlerIface {
|
||||
boolean inactive();
|
||||
}
|
||||
|
||||
private static final float MIN_FONT_DIPS = 14.0f;
|
||||
private static final int MULTI_INACTIVE = -1;
|
||||
private static final boolean FRAME_TRAY_RECTS = false; // for debugging
|
||||
|
@ -95,8 +91,9 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
private int m_lastTimerPlayer;
|
||||
private int m_pendingScore;
|
||||
private Handler m_viewHandler;
|
||||
private CommsAddrRec.CommsConnType m_connType =
|
||||
CommsAddrRec.CommsConnType.COMMS_CONN_NONE;
|
||||
|
||||
private MultiHandlerIface m_multiHandler = null;
|
||||
private int m_lastSpacing = MULTI_INACTIVE;
|
||||
|
||||
|
||||
|
@ -217,7 +214,8 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
if ( ConnStatusHandler.handleUp( xx, yy ) ) {
|
||||
String msg = ConnStatusHandler.getStatusText(m_context);
|
||||
String msg = ConnStatusHandler.getStatusText( m_context,
|
||||
m_connType );
|
||||
m_parent.showOKOnlyDialog( msg );
|
||||
} else {
|
||||
m_jniThread.handle( JNIThread.JNICmd.CMD_PEN_UP, xx, yy );
|
||||
|
@ -319,7 +317,8 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
synchronized( this ) {
|
||||
if ( layoutBoardOnce() ) {
|
||||
canvas.drawBitmap( s_bitmap, m_left, m_top, m_drawPaint );
|
||||
ConnStatusHandler.draw( canvas, getResources(), m_left, m_top );
|
||||
ConnStatusHandler.draw( canvas, getResources(), m_left, m_top,
|
||||
m_connType );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -428,12 +427,14 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
|
||||
// BoardHandler interface implementation
|
||||
public void startHandling( XWActivity parent, JNIThread thread,
|
||||
int gamePtr, CurGameInfo gi )
|
||||
int gamePtr, CurGameInfo gi,
|
||||
CommsAddrRec.CommsConnType connType )
|
||||
{
|
||||
m_parent = parent;
|
||||
m_jniThread = thread;
|
||||
m_jniGamePtr = gamePtr;
|
||||
m_gi = gi;
|
||||
m_connType = connType;
|
||||
m_layoutWidth = 0;
|
||||
m_layoutHeight = 0;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,6 @@ public class ConnStatusHandler {
|
|||
private static final int GREEN = 0xFF00FF00;
|
||||
private static final int RED = 0xFFFF0000;
|
||||
|
||||
private static CommsConnType s_connType = CommsConnType.COMMS_CONN_NONE;
|
||||
private static Rect s_rect;
|
||||
private static boolean s_downOnMe = false;
|
||||
private static Handler s_handler;
|
||||
|
@ -132,11 +131,6 @@ public class ConnStatusHandler {
|
|||
s_rect = new Rect( left, top, right, bottom );
|
||||
}
|
||||
|
||||
public static void setType( CommsConnType connType )
|
||||
{
|
||||
s_connType = connType;
|
||||
}
|
||||
|
||||
public static void setHandler( Handler handler )
|
||||
{
|
||||
s_handler = handler;
|
||||
|
@ -160,16 +154,17 @@ public class ConnStatusHandler {
|
|||
return s_downOnMe && s_rect.contains( xx, yy );
|
||||
}
|
||||
|
||||
public static String getStatusText( Context context )
|
||||
public static String getStatusText( Context context, CommsConnType connType )
|
||||
{
|
||||
String msg;
|
||||
if ( CommsConnType.COMMS_CONN_NONE == s_connType ) {
|
||||
if ( CommsConnType.COMMS_CONN_NONE == connType ) {
|
||||
msg = "This is a standalone game. There is no network status.";
|
||||
} else {
|
||||
synchronized( s_lockObj ) {
|
||||
msg = "Network status for game connected via " + connType2Str();
|
||||
msg = "Network status for game connected via "
|
||||
+ connType2Str( connType );
|
||||
msg += ":\n\n";
|
||||
SuccessRecord record = recordFor( s_connType, false );
|
||||
SuccessRecord record = recordFor( connType, false );
|
||||
msg +=
|
||||
String.format( "Last send was %s (at %s)\n",
|
||||
record.successNewer? "successful":"unsuccessful",
|
||||
|
@ -190,7 +185,7 @@ public class ConnStatusHandler {
|
|||
}
|
||||
msg += "\n";
|
||||
|
||||
record = recordFor( s_connType, true );
|
||||
record = recordFor( connType, true );
|
||||
if ( record.haveSuccess() ) {
|
||||
msg +=
|
||||
String.format( "Last receipt was at %s",
|
||||
|
@ -233,12 +228,12 @@ public class ConnStatusHandler {
|
|||
}
|
||||
|
||||
public static void draw( Canvas canvas, Resources res,
|
||||
int offsetX, int offsetY )
|
||||
int offsetX, int offsetY, CommsConnType connType )
|
||||
{
|
||||
synchronized( s_lockObj ) {
|
||||
if ( null != s_rect ) {
|
||||
int iconID;
|
||||
switch( s_connType ) {
|
||||
switch( connType ) {
|
||||
case COMMS_CONN_RELAY:
|
||||
iconID = R.drawable.relaygame;
|
||||
break;
|
||||
|
@ -258,18 +253,18 @@ public class ConnStatusHandler {
|
|||
int quarterHeight = rect.height() / 4;
|
||||
rect.offset( offsetX, offsetY );
|
||||
|
||||
if ( CommsConnType.COMMS_CONN_NONE != s_connType ) {
|
||||
if ( CommsConnType.COMMS_CONN_NONE != connType ) {
|
||||
int saveTop = rect.top;
|
||||
SuccessRecord record;
|
||||
|
||||
// Do the background coloring
|
||||
rect.bottom = rect.top + quarterHeight * 2;
|
||||
record = recordFor( s_connType, false );
|
||||
record = recordFor( connType, false );
|
||||
s_fillPaint.setColor( record.successNewer ? GREEN : RED );
|
||||
canvas.drawRect( rect, s_fillPaint );
|
||||
rect.top = rect.bottom;
|
||||
rect.bottom = rect.top + quarterHeight * 2;
|
||||
record = recordFor( s_connType, true );
|
||||
record = recordFor( connType, true );
|
||||
s_fillPaint.setColor( record.successNewer ? GREEN : RED );
|
||||
canvas.drawRect( rect, s_fillPaint );
|
||||
|
||||
|
@ -344,10 +339,10 @@ public class ConnStatusHandler {
|
|||
icon.draw( canvas );
|
||||
}
|
||||
|
||||
private static String connType2Str()
|
||||
private static String connType2Str( CommsConnType connType )
|
||||
{
|
||||
String result = null;
|
||||
switch( s_connType ) {
|
||||
switch( connType ) {
|
||||
case COMMS_CONN_RELAY:
|
||||
result = "internet/relay";
|
||||
break;
|
||||
|
|
|
@ -21,10 +21,12 @@
|
|||
package org.eehouse.android.xw4.jni;
|
||||
|
||||
import org.eehouse.android.xw4.XWActivity;
|
||||
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
||||
|
||||
public interface BoardHandler {
|
||||
|
||||
void startHandling( XWActivity parent, JNIThread thread,
|
||||
int gamePtr, CurGameInfo gi );
|
||||
int gamePtr, CurGameInfo gi,
|
||||
CommsConnType connType );
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue