mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-04 20:46:28 +01:00
cleanup: I like the call-chain style better these days
This commit is contained in:
parent
20359e50da
commit
a8872df5ed
2 changed files with 53 additions and 54 deletions
|
@ -2276,39 +2276,41 @@ public class BoardDelegate extends DelegateBase
|
||||||
m_toolbar.setListener( Buttons.BUTTON_BROWSE_DICT,
|
m_toolbar.setListener( Buttons.BUTTON_BROWSE_DICT,
|
||||||
R.string.not_again_browseall,
|
R.string.not_again_browseall,
|
||||||
R.string.key_na_browseall,
|
R.string.key_na_browseall,
|
||||||
Action.BUTTON_BROWSEALL_ACTION );
|
Action.BUTTON_BROWSEALL_ACTION )
|
||||||
m_toolbar.setLongClickListener( Buttons.BUTTON_BROWSE_DICT,
|
.setLongClickListener( Buttons.BUTTON_BROWSE_DICT,
|
||||||
R.string.not_again_browse,
|
R.string.not_again_browse,
|
||||||
R.string.key_na_browse,
|
R.string.key_na_browse,
|
||||||
Action.BUTTON_BROWSE_ACTION );
|
Action.BUTTON_BROWSE_ACTION )
|
||||||
m_toolbar.setListener( Buttons.BUTTON_HINT_PREV,
|
.setListener( Buttons.BUTTON_HINT_PREV,
|
||||||
R.string.not_again_hintprev,
|
R.string.not_again_hintprev,
|
||||||
R.string.key_notagain_hintprev,
|
R.string.key_notagain_hintprev,
|
||||||
Action.PREV_HINT_ACTION );
|
Action.PREV_HINT_ACTION )
|
||||||
m_toolbar.setListener( Buttons.BUTTON_HINT_NEXT,
|
.setListener( Buttons.BUTTON_HINT_NEXT,
|
||||||
R.string.not_again_hintnext,
|
R.string.not_again_hintnext,
|
||||||
R.string.key_notagain_hintnext,
|
R.string.key_notagain_hintnext,
|
||||||
Action.NEXT_HINT_ACTION );
|
Action.NEXT_HINT_ACTION )
|
||||||
m_toolbar.setListener( Buttons.BUTTON_JUGGLE,
|
.setListener( Buttons.BUTTON_JUGGLE,
|
||||||
R.string.not_again_juggle,
|
R.string.not_again_juggle,
|
||||||
R.string.key_notagain_juggle,
|
R.string.key_notagain_juggle,
|
||||||
Action.JUGGLE_ACTION );
|
Action.JUGGLE_ACTION )
|
||||||
m_toolbar.setListener( Buttons.BUTTON_FLIP,
|
.setListener( Buttons.BUTTON_FLIP,
|
||||||
R.string.not_again_flip,
|
R.string.not_again_flip,
|
||||||
R.string.key_notagain_flip,
|
R.string.key_notagain_flip,
|
||||||
Action.FLIP_ACTION );
|
Action.FLIP_ACTION )
|
||||||
m_toolbar.setListener( Buttons.BUTTON_VALUES,
|
.setListener( Buttons.BUTTON_VALUES,
|
||||||
R.string.not_again_values,
|
R.string.not_again_values,
|
||||||
R.string.key_na_values,
|
R.string.key_na_values,
|
||||||
Action.VALUES_ACTION );
|
Action.VALUES_ACTION )
|
||||||
m_toolbar.setListener( Buttons.BUTTON_UNDO,
|
.setListener( Buttons.BUTTON_UNDO,
|
||||||
R.string.not_again_undo,
|
R.string.not_again_undo,
|
||||||
R.string.key_notagain_undo,
|
R.string.key_notagain_undo,
|
||||||
Action.UNDO_ACTION );
|
Action.UNDO_ACTION )
|
||||||
m_toolbar.setListener( Buttons.BUTTON_CHAT,
|
.setListener( Buttons.BUTTON_CHAT,
|
||||||
R.string.not_again_chat,
|
R.string.not_again_chat,
|
||||||
R.string.key_notagain_chat,
|
R.string.key_notagain_chat,
|
||||||
Action.CHAT_ACTION );
|
Action.CHAT_ACTION );
|
||||||
|
} else {
|
||||||
|
Log.e( TAG, "not initing toolbar; still null" );
|
||||||
}
|
}
|
||||||
} // populateToolbar
|
} // populateToolbar
|
||||||
|
|
||||||
|
@ -2499,15 +2501,15 @@ public class BoardDelegate extends DelegateBase
|
||||||
private void updateToolbar()
|
private void updateToolbar()
|
||||||
{
|
{
|
||||||
if ( null != m_toolbar ) {
|
if ( null != m_toolbar ) {
|
||||||
m_toolbar.update( Buttons.BUTTON_FLIP, m_gsi.visTileCount >= 1 );
|
m_toolbar.update( Buttons.BUTTON_FLIP, m_gsi.visTileCount >= 1 )
|
||||||
m_toolbar.update( Buttons.BUTTON_VALUES, m_gsi.visTileCount >= 1 );
|
.update( Buttons.BUTTON_VALUES, m_gsi.visTileCount >= 1 )
|
||||||
m_toolbar.update( Buttons.BUTTON_JUGGLE, m_gsi.canShuffle );
|
.update( Buttons.BUTTON_JUGGLE, m_gsi.canShuffle )
|
||||||
m_toolbar.update( Buttons.BUTTON_UNDO, m_gsi.canRedo );
|
.update( Buttons.BUTTON_UNDO, m_gsi.canRedo )
|
||||||
m_toolbar.update( Buttons.BUTTON_HINT_PREV, m_gsi.canHint );
|
.update( Buttons.BUTTON_HINT_PREV, m_gsi.canHint )
|
||||||
m_toolbar.update( Buttons.BUTTON_HINT_NEXT, m_gsi.canHint );
|
.update( Buttons.BUTTON_HINT_NEXT, m_gsi.canHint )
|
||||||
m_toolbar.update( Buttons.BUTTON_CHAT, m_gsi.canChat );
|
.update( Buttons.BUTTON_CHAT, m_gsi.canChat )
|
||||||
m_toolbar.update( Buttons.BUTTON_BROWSE_DICT,
|
.update( Buttons.BUTTON_BROWSE_DICT,
|
||||||
null != m_gi.dictName( m_view.getCurPlayer() ) );
|
null != m_gi.dictName( m_view.getCurPlayer() ) );
|
||||||
|
|
||||||
int count = m_toolbar.enabledCount();
|
int count = m_toolbar.enabledCount();
|
||||||
if ( 0 == count ) {
|
if ( 0 == count ) {
|
||||||
|
|
|
@ -62,8 +62,8 @@ public class Toolbar implements BoardContainer.SizeChangeListener {
|
||||||
private DlgDelegate.HasDlgDelegate m_dlgDlgt;
|
private DlgDelegate.HasDlgDelegate m_dlgDlgt;
|
||||||
private LinearLayout m_layout;
|
private LinearLayout m_layout;
|
||||||
private boolean m_visible;
|
private boolean m_visible;
|
||||||
private Map<Buttons, Object> m_onClickListeners;
|
private Map<Buttons, Object> m_onClickListeners = new HashMap<>();
|
||||||
private Map<Buttons, Object> m_onLongClickListeners;
|
private Map<Buttons, Object> m_onLongClickListeners = new HashMap<>();
|
||||||
private Set<Buttons> m_enabled = new HashSet<Buttons>();
|
private Set<Buttons> m_enabled = new HashSet<Buttons>();
|
||||||
|
|
||||||
public Toolbar( Activity activity, HasDlgDelegate dlgDlgt )
|
public Toolbar( Activity activity, HasDlgDelegate dlgDlgt )
|
||||||
|
@ -87,12 +87,9 @@ public class Toolbar implements BoardContainer.SizeChangeListener {
|
||||||
return (ImageButton)m_activity.findViewById( index.getResId() );
|
return (ImageButton)m_activity.findViewById( index.getResId() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setListener( Buttons index, final int msgID,
|
public Toolbar setListener( Buttons index, final int msgID,
|
||||||
final int prefsKey, final Action action )
|
final int prefsKey, final Action action )
|
||||||
{
|
{
|
||||||
if ( null == m_onClickListeners ) {
|
|
||||||
m_onClickListeners = new HashMap<Buttons, Object>();
|
|
||||||
}
|
|
||||||
m_onClickListeners.put( index, new View.OnClickListener() {
|
m_onClickListeners.put( index, new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick( View view ) {
|
public void onClick( View view ) {
|
||||||
|
@ -102,14 +99,12 @@ public class Toolbar implements BoardContainer.SizeChangeListener {
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLongClickListener( Buttons index, final int msgID,
|
public Toolbar setLongClickListener( Buttons index, final int msgID,
|
||||||
final int prefsKey, final Action action )
|
final int prefsKey, final Action action )
|
||||||
{
|
{
|
||||||
if ( null == m_onLongClickListeners ) {
|
|
||||||
m_onLongClickListeners = new HashMap<Buttons, Object>();
|
|
||||||
}
|
|
||||||
m_onLongClickListeners.put( index, new View.OnLongClickListener() {
|
m_onLongClickListeners.put( index, new View.OnLongClickListener() {
|
||||||
public boolean onLongClick( View view ) {
|
public boolean onLongClick( View view ) {
|
||||||
m_dlgDlgt.makeNotAgainBuilder( msgID, prefsKey, action )
|
m_dlgDlgt.makeNotAgainBuilder( msgID, prefsKey, action )
|
||||||
|
@ -117,9 +112,10 @@ public class Toolbar implements BoardContainer.SizeChangeListener {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update( Buttons index, boolean enable )
|
public Toolbar update( Buttons index, boolean enable )
|
||||||
{
|
{
|
||||||
int id = index.getResId();
|
int id = index.getResId();
|
||||||
ImageButton button = (ImageButton)m_activity.findViewById( id );
|
ImageButton button = (ImageButton)m_activity.findViewById( id );
|
||||||
|
@ -132,6 +128,7 @@ public class Toolbar implements BoardContainer.SizeChangeListener {
|
||||||
} else {
|
} else {
|
||||||
m_enabled.remove( index );
|
m_enabled.remove( index );
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int enabledCount() { return m_enabled.size(); }
|
protected int enabledCount() { return m_enabled.size(); }
|
||||||
|
|
Loading…
Add table
Reference in a new issue