mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-04 20:46:28 +01:00
install listeners immediately after setting them
Fix a race condition introduced by making initing jnithread be asynchronous: all the layout that was supposed to happen after listeners were added instead happened before, so that they weren't there to be installed as part of layout. So now, after adding them, get them hooked up to the UI. (The complexity of this is all historical: at some point the listeners were getting added BEFORE there were views to attach them to, so they were cached and added later. Probably now they could simply be installed as part of adding them. But I'm not doing that now.)
This commit is contained in:
parent
95df560a40
commit
f436090c6f
3 changed files with 15 additions and 7 deletions
|
@ -738,6 +738,7 @@ public class BoardDelegate extends DelegateBase
|
|||
if ( null != findViewById( R.id.tbar_parent_hor ) ) {
|
||||
if ( null == m_toolbar ) {
|
||||
m_toolbar = new Toolbar( m_activity, this );
|
||||
populateToolbar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2150,7 +2151,6 @@ public class BoardDelegate extends DelegateBase
|
|||
}
|
||||
|
||||
initToolbar();
|
||||
populateToolbar();
|
||||
adjustTradeVisibility();
|
||||
|
||||
int flags = DBUtils.getMsgFlags( m_activity, m_rowid );
|
||||
|
@ -2245,7 +2245,7 @@ public class BoardDelegate extends DelegateBase
|
|||
}
|
||||
// Why this m_relayMissing thing?
|
||||
if ( 0 == nMissing /* || !m_relayMissing*/ ) {
|
||||
Log.d( TAG, "dismissing invite alert %H", m_inviteAlert );
|
||||
// Log.d( TAG, "dismissing invite alert %H", m_inviteAlert );
|
||||
dismissInviteAlert();
|
||||
}
|
||||
}
|
||||
|
@ -2285,6 +2285,7 @@ public class BoardDelegate extends DelegateBase
|
|||
|
||||
private void populateToolbar()
|
||||
{
|
||||
Assert.assertTrue( null != m_toolbar || !BuildConfig.DEBUG );
|
||||
if ( null != m_toolbar ) {
|
||||
m_toolbar.setListener( Buttons.BUTTON_BROWSE_DICT,
|
||||
R.string.not_again_browseall,
|
||||
|
@ -2321,7 +2322,8 @@ public class BoardDelegate extends DelegateBase
|
|||
.setListener( Buttons.BUTTON_CHAT,
|
||||
R.string.not_again_chat,
|
||||
R.string.key_notagain_chat,
|
||||
Action.CHAT_ACTION );
|
||||
Action.CHAT_ACTION )
|
||||
.installListeners();
|
||||
} else {
|
||||
Log.e( TAG, "not initing toolbar; still null" );
|
||||
}
|
||||
|
|
|
@ -134,11 +134,17 @@ public class Toolbar implements BoardContainer.SizeChangeListener {
|
|||
protected int enabledCount() { return m_enabled.size(); }
|
||||
|
||||
// SizeChangeListener
|
||||
@Override
|
||||
public void sizeChanged( int width, int height, boolean isPortrait )
|
||||
{
|
||||
installListeners();
|
||||
doShowHide();
|
||||
}
|
||||
|
||||
public void installListeners()
|
||||
{
|
||||
tryAddListeners( m_onClickListeners );
|
||||
tryAddListeners( m_onLongClickListeners );
|
||||
doShowHide();
|
||||
}
|
||||
|
||||
private void tryAddListeners( Map<Buttons, Object> map )
|
||||
|
@ -163,7 +169,7 @@ public class Toolbar implements BoardContainer.SizeChangeListener {
|
|||
} else if ( listener instanceof View.OnLongClickListener ) {
|
||||
button.setOnLongClickListener( (View.OnLongClickListener)listener );
|
||||
} else {
|
||||
Assert.fail();
|
||||
Assert.assertFalse( BuildConfig.DEBUG );
|
||||
}
|
||||
}
|
||||
return success;
|
||||
|
|
Loading…
Add table
Reference in a new issue