mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-07 05:24:46 +01:00
enable delete and archive when msg queue empties
Recent change added Delete button to game-over alert, but only when no unacked messages remained (since deleted games can't continue trying to send messages other games might still need to know the game's over.) Typically the alert would go up and then, if the remote device is online, shortly after acks would arrive. Now when that happens the alert gets updated to offer to delete and archive.
This commit is contained in:
parent
d5546b484d
commit
073b5f6bf3
2 changed files with 37 additions and 13 deletions
|
@ -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 );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
|
|
Loading…
Reference in a new issue