mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-02 20:46:15 +01:00
force re-layout of board when toolbar populated
Sometimes when a new game is created the board winds up with the toolbar drawn over the tray. That's because when it was laid out the game wasn't running yet and so none of the toolbar buttons was enabled, giving the toolbar a height of 0. So now the first time the updated toolbar reports that at least one button is enabled we force the board to lay itself out again.
This commit is contained in:
parent
f488e727f8
commit
04a39f9251
2 changed files with 21 additions and 0 deletions
|
@ -2570,6 +2570,7 @@ public class BoardDelegate extends DelegateBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean m_needsResize = false;
|
||||||
private void updateToolbar()
|
private void updateToolbar()
|
||||||
{
|
{
|
||||||
if ( null != m_toolbar ) {
|
if ( null != m_toolbar ) {
|
||||||
|
@ -2582,6 +2583,14 @@ public class BoardDelegate extends DelegateBase
|
||||||
m_toolbar.update( Buttons.BUTTON_CHAT, m_gsi.canChat );
|
m_toolbar.update( Buttons.BUTTON_CHAT, m_gsi.canChat );
|
||||||
m_toolbar.update( Buttons.BUTTON_BROWSE_DICT,
|
m_toolbar.update( Buttons.BUTTON_BROWSE_DICT,
|
||||||
null != m_gi.dictName( m_view.getCurPlayer() ) );
|
null != m_gi.dictName( m_view.getCurPlayer() ) );
|
||||||
|
|
||||||
|
int count = m_toolbar.enabledCount();
|
||||||
|
if ( 0 == count ) {
|
||||||
|
m_needsResize = true;
|
||||||
|
} else if ( m_needsResize && 0 < count ) {
|
||||||
|
m_needsResize = false;
|
||||||
|
m_view.orientationChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,12 @@ import android.widget.HorizontalScrollView;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
@ -62,6 +65,7 @@ public class Toolbar implements BoardContainer.SizeChangeListener {
|
||||||
private boolean m_visible;
|
private boolean m_visible;
|
||||||
private Map<Buttons, Object> m_onClickListeners;
|
private Map<Buttons, Object> m_onClickListeners;
|
||||||
private Map<Buttons, Object> m_onLongClickListeners;
|
private Map<Buttons, Object> m_onLongClickListeners;
|
||||||
|
private Set<Buttons> m_enabled = new HashSet<Buttons>();
|
||||||
|
|
||||||
public Toolbar( Activity activity, HasDlgDelegate dlgDlgt )
|
public Toolbar( Activity activity, HasDlgDelegate dlgDlgt )
|
||||||
{
|
{
|
||||||
|
@ -123,7 +127,15 @@ public class Toolbar implements BoardContainer.SizeChangeListener {
|
||||||
if ( null != button ) {
|
if ( null != button ) {
|
||||||
button.setVisibility( enable ? View.VISIBLE : View.GONE );
|
button.setVisibility( enable ? View.VISIBLE : View.GONE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( enable ) {
|
||||||
|
m_enabled.add( index );
|
||||||
|
} else {
|
||||||
|
m_enabled.remove( index );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int enabledCount() { return m_enabled.size(); }
|
||||||
|
|
||||||
// SizeChangeListener
|
// SizeChangeListener
|
||||||
public void sizeChanged( int width, int height, boolean isPortrait )
|
public void sizeChanged( int width, int height, boolean isPortrait )
|
||||||
|
|
Loading…
Add table
Reference in a new issue