diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java index 3d402030e..7f9937f31 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java @@ -133,6 +133,7 @@ public class BoardDelegate extends DelegateBase private boolean m_haveStartedShowing; private Wrapper mNFCWrapper; + private GameOverAlert mGameOverAlert; // how to clear after? public class TimerRunnable implements Runnable { private int m_why; @@ -1449,10 +1450,20 @@ public class BoardDelegate extends DelegateBase } @Override - public void tpmCountChanged( int newCount ) + public void tpmCountChanged( final int newCount ) { Log.d( TAG, "tpmCountChanged(%d)", newCount ); ConnStatusHandler.updateMoveCount( m_activity, newCount ); + + final GameOverAlert goAlert = mGameOverAlert; + if ( null != goAlert ) { + runOnUiThread(new Runnable() { + @Override + public void run() { + goAlert.pendingCountChanged( newCount ); + } + }); + } } ////////////////////////////////////////////////// @@ -2217,12 +2228,13 @@ public class BoardDelegate extends DelegateBase public void run() { boolean hasPending = 0 < XwJNI. comms_countPendingPackets( m_jniGamePtr ); - show( GameOverAlert - .newInstance( m_summary, - msg.arg1, - (String)msg.obj, - hasPending, - inArchiveGroup() ) ); + mGameOverAlert = GameOverAlert + .newInstance( m_summary, + msg.arg1, + (String)msg.obj, + hasPending, + inArchiveGroup() ); + show( mGameOverAlert ); } } ); } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameOverAlert.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameOverAlert.java index cad1c8b9d..691d02267 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameOverAlert.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameOverAlert.java @@ -96,7 +96,7 @@ public class GameOverAlert extends XWDialogFragment mTitleID = sis.getInt( TITLE ); mMsg = sis.getString( MSG ); mInArchive = sis.getBoolean( IN_ARCH ); - boolean hasPending = sis.getBoolean( HAS_PENDING ); + mHasPending = sis.getBoolean( HAS_PENDING ); Activity activity = getActivity(); mView = (ViewGroup)LocUtils.inflate( activity, R.layout.game_over ); @@ -108,11 +108,7 @@ public class GameOverAlert extends XWDialogFragment .setPositiveButton( android.R.string.ok, this ) .setNeutralButton( R.string.button_rematch, this ) ; - if ( hasPending ) { - mArchiveBox.setVisibility( View.GONE ); - } else { - ab.setNegativeButton( R.string.button_delete, this ); - } + ab.setNegativeButton( R.string.button_delete, this ); mDialog = ab.create(); mDialog.setOnShowListener( new DialogInterface.OnShowListener() { @@ -120,6 +116,8 @@ public class GameOverAlert extends XWDialogFragment public void onShow( DialogInterface dialog ) { boolean nowChecked = mArchiveBox.isChecked(); onCheckedChanged( null, nowChecked ); + + updateForPending(); } }); @@ -167,6 +165,20 @@ public class GameOverAlert extends XWDialogFragment Utils.enableAlertButton( mDialog, AlertDialog.BUTTON_NEGATIVE, !isChecked ); } + public void pendingCountChanged( int newCount ) + { + if ( 0 == newCount && mHasPending ) { + mHasPending = false; + updateForPending(); + } + } + + private void updateForPending() + { + mArchiveBox.setVisibility( mHasPending ? View.GONE : View.VISIBLE ); + Utils.enableAlertButton( mDialog, AlertDialog.BUTTON_NEGATIVE, !mHasPending ); + } + private void initView() { ((TextView)mView.findViewById( R.id.msg )).setText( mMsg );