From d97784ba13fdd301a8d141f88014120502335d60 Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 7 Feb 2014 07:38:07 -0800 Subject: [PATCH] track which dialog is blocking rather than just that there is one --- .../eehouse/android/xw4/BoardActivity.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java index 169d1cc4a..0a9a2e9b2 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java @@ -70,6 +70,7 @@ public class BoardActivity extends XWActivity public static final String INTENT_KEY_CHAT = "chat"; + private static final int BLOCKING_DLG_NONE = -1; private static final int DLG_OKONLY = DlgDelegate.DIALOG_LAST + 1; private static final int DLG_BADWORDS_BLK = DLG_OKONLY + 1; private static final int QUERY_REQUEST_BLK = DLG_OKONLY + 2; @@ -167,7 +168,7 @@ public class BoardActivity extends XWActivity private Thread m_blockingThread; private JNIThread m_jniThread; private JNIThread.GameStateInfo m_gsi; - private boolean m_blockingDlgPosted = false; + private int m_blockingDlgID = BLOCKING_DLG_NONE; private String m_room; private String m_toastStr; @@ -533,6 +534,7 @@ public class BoardActivity extends XWActivity @Override public void onPrepareDialog( int id, Dialog dialog ) { + DbgUtils.logf( "BoardActivity:onPrepareDialog(id=%d)", id ); switch( id ) { case DLG_INVITE: AlertDialog ad = (AlertDialog)dialog; @@ -600,7 +602,7 @@ public class BoardActivity extends XWActivity { super.onResume(); m_handler = new Handler(); - m_blockingDlgPosted = false; + m_blockingDlgID = BLOCKING_DLG_NONE; setKeepScreenOn(); @@ -2018,27 +2020,29 @@ public class BoardActivity extends XWActivity private int waitBlockingDialog( final int dlgID, int cancelResult ) { int result = cancelResult; - if ( m_blockingDlgPosted ) { // this has been true; dunno why - DbgUtils.logf( "waitBlockingDialog: dropping dlgID %d", dlgID ); + // this has been true; dunno why + if ( BLOCKING_DLG_NONE != m_blockingDlgID ) { + DbgUtils.logf( "waitBlockingDialog: dropping dlgID %d b/c %d set", + dlgID, m_blockingDlgID ); } else { setBlockingThread(); m_resultCode = cancelResult; if ( post( new Runnable() { public void run() { + m_blockingDlgID = dlgID; showDialog( dlgID ); - m_blockingDlgPosted = true; } } ) ) { try { m_forResultWait.acquire(); - m_blockingDlgPosted = false; + m_blockingDlgID = BLOCKING_DLG_NONE; } catch ( java.lang.InterruptedException ie ) { DbgUtils.loge( ie ); - if ( m_blockingDlgPosted ) { - dismissDialog( dlgID ); - m_blockingDlgPosted = false; + if ( BLOCKING_DLG_NONE != m_blockingDlgID ) { + dismissDialog( m_blockingDlgID ); + m_blockingDlgID = BLOCKING_DLG_NONE; } } }