mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-22 07:28:16 +01:00
remove a delegate's alerts when it stops
Fixing a crash when a game offers both to create a rematch and to delete itself because its opponent has been deleted. Deleting and then hitting rematch would crash because the rematch alert referred to a dead game. Now onStop() for delegates removes any pending alerts. In dual-pane mode only since when there's an activity going away the alerts go automatically.
This commit is contained in:
parent
a7795dd160
commit
80e1f588d0
4 changed files with 31 additions and 2 deletions
|
@ -92,7 +92,6 @@ public class DelegateBase implements DlgClickNotify,
|
||||||
protected void onCreateContextMenu( ContextMenu menu, View view,
|
protected void onCreateContextMenu( ContextMenu menu, View view,
|
||||||
ContextMenuInfo menuInfo ) {}
|
ContextMenuInfo menuInfo ) {}
|
||||||
protected boolean onContextItemSelected( MenuItem item ) { return false; }
|
protected boolean onContextItemSelected( MenuItem item ) { return false; }
|
||||||
protected void onStop() {}
|
|
||||||
protected void onDestroy() {}
|
protected void onDestroy() {}
|
||||||
protected void onWindowFocusChanged( boolean hasFocus ) {}
|
protected void onWindowFocusChanged( boolean hasFocus ) {}
|
||||||
protected boolean handleBackPressed() { return false; }
|
protected boolean handleBackPressed() { return false; }
|
||||||
|
@ -142,6 +141,15 @@ public class DelegateBase implements DlgClickNotify,
|
||||||
XWService.setListener( null );
|
XWService.setListener( null );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
// Alerts disappear on their own if not in dualpane mode
|
||||||
|
if ( m_activity instanceof MainActivity
|
||||||
|
&& ((MainActivity)m_activity).inDPMode() ) {
|
||||||
|
DlgDelegate.closeAlerts( m_activity, this );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected DelegateBase curThis()
|
protected DelegateBase curThis()
|
||||||
{
|
{
|
||||||
DelegateBase result = null;
|
DelegateBase result = null;
|
||||||
|
|
|
@ -552,9 +552,11 @@ public class DictsDelegate extends ListDelegateBase
|
||||||
setTitleBar();
|
setTitleBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void onStop()
|
protected void onStop()
|
||||||
{
|
{
|
||||||
MountEventReceiver.unregister( this );
|
MountEventReceiver.unregister( this );
|
||||||
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick( View view )
|
public void onClick( View view )
|
||||||
|
|
|
@ -938,6 +938,24 @@ public class DlgDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static void closeAlerts( Activity activity, DelegateBase base )
|
||||||
|
{
|
||||||
|
DbgUtils.assertOnUIThread();
|
||||||
|
Iterator<DlgID> iter = s_pendings.keySet().iterator();
|
||||||
|
while ( iter.hasNext() ) {
|
||||||
|
DlgID dlgID = iter.next();
|
||||||
|
DelegateBase oneBase = s_pendings.get( dlgID ).get();
|
||||||
|
if ( null == oneBase ) {
|
||||||
|
iter.remove(); // no point in keeping it
|
||||||
|
} else if ( base.equals( oneBase ) ) {
|
||||||
|
DbgUtils.logdf( "removing alert %s for %s", dlgID.toString(),
|
||||||
|
oneBase.toString() );
|
||||||
|
activity.removeDialog( dlgID.ordinal() );
|
||||||
|
iter.remove(); // no point in keeping this either
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String getString( int id, Object... params )
|
private String getString( int id, Object... params )
|
||||||
{
|
{
|
||||||
return m_dlgt.getString( id, params );
|
return m_dlgt.getString( id, params );
|
||||||
|
|
|
@ -1004,6 +1004,7 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
return true; // handled it
|
return true; // handled it
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void onStop()
|
protected void onStop()
|
||||||
{
|
{
|
||||||
// TelephonyManager mgr =
|
// TelephonyManager mgr =
|
||||||
|
@ -1012,7 +1013,7 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
// m_phoneStateListener = null;
|
// m_phoneStateListener = null;
|
||||||
long[] positions = m_adapter.getGroupPositions();
|
long[] positions = m_adapter.getGroupPositions();
|
||||||
XWPrefs.setGroupPositions( m_activity, positions );
|
XWPrefs.setGroupPositions( m_activity, positions );
|
||||||
// super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onDestroy()
|
protected void onDestroy()
|
||||||
|
|
Loading…
Reference in a new issue