mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-01 06:19:57 +01:00
move socket creation inside Thread's run() in attempt to fix too-long
UI freeze when deleting individual games.
This commit is contained in:
parent
ae0860a047
commit
248b341aac
1 changed files with 31 additions and 36 deletions
|
@ -65,18 +65,16 @@ public class NetUtils {
|
|||
|
||||
private static class InformThread extends Thread {
|
||||
Context m_context;
|
||||
private Socket m_socket;
|
||||
DBUtils.Obit[] m_obits;
|
||||
public InformThread( Context context, DBUtils.Obit[] obits,
|
||||
Socket socket )
|
||||
public InformThread( Context context, DBUtils.Obit[] obits )
|
||||
{
|
||||
m_context = context;
|
||||
m_obits = obits;
|
||||
m_socket = socket;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
|
||||
Socket socket = MakeProxySocket( m_context, 10000 );
|
||||
if ( null != socket ) {
|
||||
int strLens = 0;
|
||||
for ( int ii = 0; ii < m_obits.length; ++ii ) {
|
||||
strLens += m_obits[ii].m_relayID.length() + 1; // 1 for /n
|
||||
|
@ -84,7 +82,7 @@ public class NetUtils {
|
|||
|
||||
try {
|
||||
DataOutputStream outStream =
|
||||
new DataOutputStream( m_socket.getOutputStream() );
|
||||
new DataOutputStream( socket.getOutputStream() );
|
||||
outStream.writeShort( 2 + 2 + (2*m_obits.length) + strLens );
|
||||
outStream.writeByte( NetUtils.PROTOCOL_VERSION );
|
||||
outStream.writeByte( NetUtils.PRX_DEVICE_GONE );
|
||||
|
@ -99,9 +97,9 @@ public class NetUtils {
|
|||
outStream.flush();
|
||||
|
||||
DataInputStream dis =
|
||||
new DataInputStream( m_socket.getInputStream() );
|
||||
new DataInputStream( socket.getInputStream() );
|
||||
short resLen = dis.readShort();
|
||||
m_socket.close();
|
||||
socket.close();
|
||||
|
||||
if ( resLen == 0 ) {
|
||||
DBUtils.clearObits( m_context, m_obits );
|
||||
|
@ -109,7 +107,7 @@ public class NetUtils {
|
|||
} catch ( java.io.IOException ioe ) {
|
||||
Utils.logf( ioe.toString() );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,13 +115,10 @@ public class NetUtils {
|
|||
{
|
||||
DBUtils.Obit[] obits = DBUtils.listObits( context );
|
||||
if ( null != obits && 0 < obits.length ) {
|
||||
Socket socket = MakeProxySocket( context, 10000 );
|
||||
if ( null != socket ) {
|
||||
InformThread thread = new InformThread( context, obits, socket );
|
||||
InformThread thread = new InformThread( context, obits );
|
||||
thread.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String[] QueryRelay( Context context )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue