mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-23 07:27:22 +01:00
fix NPE
There was a way to get to the sender before its handler had been initialized. That can only happen on UI thread, so just drop the send rather than figure out a better way (for now).
This commit is contained in:
parent
193383bfa6
commit
73b6d0519f
1 changed files with 28 additions and 26 deletions
|
@ -29,7 +29,6 @@ import android.net.NetworkInfo;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
|
||||||
|
|
||||||
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -235,37 +234,40 @@ public class NetStateCache {
|
||||||
// will only fire if we go that long without coming
|
// will only fire if we go that long without coming
|
||||||
// through here again.
|
// through here again.
|
||||||
|
|
||||||
if ( null != mNotifyLater ) {
|
if ( null == mHandler ) {
|
||||||
mHandler.removeCallbacks( mNotifyLater );
|
Log.e( TAG, "notifyStateChanged(): handler null so dropping" );
|
||||||
mNotifyLater = null;
|
} else {
|
||||||
}
|
if ( null != mNotifyLater ) {
|
||||||
if ( mLastStateSent != s_netAvail ) {
|
mHandler.removeCallbacks( mNotifyLater );
|
||||||
mNotifyLater = new Runnable() {
|
mNotifyLater = null;
|
||||||
@Override
|
}
|
||||||
public void run() {
|
if ( mLastStateSent != s_netAvail ) {
|
||||||
if ( mLastStateSent != s_netAvail ) {
|
mNotifyLater = new Runnable() {
|
||||||
mLastStateSent = s_netAvail;
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if ( mLastStateSent != s_netAvail ) {
|
||||||
|
mLastStateSent = s_netAvail;
|
||||||
|
|
||||||
Log.i( TAG, "notifyStateChanged(%b)", s_netAvail );
|
Log.i( TAG, "notifyStateChanged(%b)", s_netAvail );
|
||||||
|
|
||||||
synchronized( s_ifs ) {
|
synchronized( s_ifs ) {
|
||||||
Iterator<StateChangedIf> iter = s_ifs.iterator();
|
Iterator<StateChangedIf> iter = s_ifs.iterator();
|
||||||
while ( iter.hasNext() ) {
|
while ( iter.hasNext() ) {
|
||||||
iter.next().onNetAvail( s_netAvail );
|
iter.next().onNetAvail( s_netAvail );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( s_netAvail ) {
|
||||||
|
CommsConnType typ = CommsConnType
|
||||||
|
.COMMS_CONN_RELAY;
|
||||||
|
GameUtils.resendAllIf( context, typ );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( s_netAvail ) {
|
|
||||||
CommsConnType typ = CommsConnType
|
|
||||||
.COMMS_CONN_RELAY;
|
|
||||||
GameUtils.resendAllIf( context, typ );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
mHandler.postDelayed( mNotifyLater, WAIT_STABLE_MILLIS );
|
||||||
mHandler.postDelayed( mNotifyLater, WAIT_STABLE_MILLIS );
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // class PvtBroadcastReceiver
|
} // class PvtBroadcastReceiver
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue