fix invite alert not being dismissed on game connect

At least where QR was being used, it didn't go away. Not sure why, but a
global was getting nulled when it shouldn't have been. Race condition I
guess.
This commit is contained in:
Eric House 2021-03-22 12:19:26 -07:00
parent 177bb28a67
commit a11db395d5
4 changed files with 11 additions and 7 deletions

View file

@ -671,7 +671,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
final int CLIP_SAVE_FLAG = 0x02;
try {
sSaveMethod.invoke( this, CLIP_SAVE_FLAG );
Log.d( TAG, "saveImpl() worked" );
// Log.d( TAG, "saveImpl() worked" );
} catch ( java.lang.reflect.InvocationTargetException
| IllegalAccessException ex ) {
Log.e( TAG, "%s", ex );

View file

@ -1457,7 +1457,7 @@ public class BoardDelegate extends DelegateBase
@Override
public void tpmCountChanged( final int newCount )
{
Log.d( TAG, "tpmCountChanged(%d)", newCount );
Log.d( TAG, "tpmCountChanged(newCount=%d)", newCount );
ConnStatusHandler.updateMoveCount( m_activity, newCount );
final GameOverAlert goAlert = mGameOverAlert;

View file

@ -54,15 +54,18 @@ public class InviteChoicesAlert extends DlgDelegateAlert
return result;
}
public static void dismissAny()
public static boolean dismissAny()
{
boolean dismissed = false;
WeakReference<InviteChoicesAlert> ref = sSelf;
if ( null != ref ) {
InviteChoicesAlert self = ref.get();
if ( null != self ) {
self.dismiss();
dismissed = true;
}
}
return dismissed;
}
public InviteChoicesAlert() {}

View file

@ -75,8 +75,7 @@ class InvitesNeededAlert {
{
Log.d( TAG, "dismiss()" );
DbgUtils.assertOnUIThread();
if ( null != mSelf ) {
mSelf.close();
if ( null != mSelf && mSelf.close() ) {
mSelf = null;
}
}
@ -113,17 +112,19 @@ class InvitesNeededAlert {
void onInfoClicked();
}
private void close()
private boolean close()
{
boolean dismissed = false;
DbgUtils.assertOnUIThread();
if ( null != mAlert ) {
InviteChoicesAlert.dismissAny();
dismissed = InviteChoicesAlert.dismissAny();
try {
mAlert.dismiss(); // I've seen this throw a NPE inside
} catch ( Exception ex ) {
Log.ex( TAG, ex );
}
}
return dismissed;
}
private InvitesNeededAlert( DelegateBase delegate, State state )