mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
move onCreateOptionsMenu into superclass
This commit is contained in:
parent
2ae6ecb125
commit
86cc8f6dbf
11 changed files with 38 additions and 38 deletions
5
xwords4/android/XWords4/res/menu/loc_menu.xml
Normal file
5
xwords4/android/XWords4/res/menu/loc_menu.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- Nothing goes here - though Translate may get added -->
|
||||
</menu>
|
|
@ -514,7 +514,7 @@ public class BoardDelegate extends DelegateBase
|
|||
|
||||
public BoardDelegate( Activity activity, Bundle savedInstanceState )
|
||||
{
|
||||
super( activity, savedInstanceState );
|
||||
super( activity, savedInstanceState, R.menu.board_menu );
|
||||
m_activity = activity;
|
||||
init( savedInstanceState );
|
||||
}
|
||||
|
@ -679,15 +679,6 @@ public class BoardDelegate extends DelegateBase
|
|||
return handled;
|
||||
}
|
||||
|
||||
protected boolean onCreateOptionsMenu( Menu menu )
|
||||
{
|
||||
MenuInflater inflater = m_activity.getMenuInflater();
|
||||
inflater.inflate( R.menu.board_menu, menu );
|
||||
LocUtils.xlateMenu( m_activity, menu );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean onPrepareOptionsMenu( Menu menu )
|
||||
{
|
||||
boolean inTrade = false;
|
||||
|
|
|
@ -52,9 +52,7 @@ public class ChatActivity extends Activity {
|
|||
@Override
|
||||
public boolean onCreateOptionsMenu( Menu menu )
|
||||
{
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate( R.menu.chat_menu, menu );
|
||||
return true;
|
||||
return m_dlgt.onCreateOptionsMenu( menu );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -41,7 +41,7 @@ public class ChatDelegate extends DelegateBase
|
|||
|
||||
public ChatDelegate( Activity activity, Bundle savedInstanceState )
|
||||
{
|
||||
super( activity, savedInstanceState );
|
||||
super( activity, savedInstanceState, R.menu.chat_menu );
|
||||
m_activity = activity;
|
||||
init( savedInstanceState );
|
||||
}
|
||||
|
|
|
@ -22,8 +22,10 @@ package org.eehouse.android.xw4;
|
|||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
|
||||
import org.eehouse.android.xw4.DlgDelegate.Action;
|
||||
import org.eehouse.android.xw4.loc.LocUtils;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
|
@ -32,10 +34,25 @@ public class DelegateBase implements DlgDelegate.DlgClickNotify,
|
|||
MultiService.MultiEventListener {
|
||||
|
||||
private DlgDelegate m_delegate;
|
||||
private Activity m_activity;
|
||||
private int m_optionsMenuID = 0;
|
||||
|
||||
public DelegateBase( Activity activity, Bundle bundle )
|
||||
public DelegateBase( Activity activity, Bundle bundle, int optionsMenu )
|
||||
{
|
||||
m_activity = activity;
|
||||
m_delegate = new DlgDelegate( activity, this, bundle );
|
||||
m_optionsMenuID = optionsMenu;
|
||||
}
|
||||
|
||||
public boolean onCreateOptionsMenu( Menu menu )
|
||||
{
|
||||
boolean handled = 0 < m_optionsMenuID;
|
||||
if ( handled ) {
|
||||
m_activity.getMenuInflater().inflate( m_optionsMenuID, menu );
|
||||
LocUtils.xlateMenu( m_activity, menu );
|
||||
}
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
protected void showDialog( DlgID dlgID )
|
||||
|
|
|
@ -233,7 +233,7 @@ public class DictsDelegate extends DelegateBase
|
|||
|
||||
protected DictsDelegate( ExpandableListActivity activity, Bundle savedInstanceState )
|
||||
{
|
||||
super( activity, savedInstanceState );
|
||||
super( activity, savedInstanceState, R.menu.dicts_menu );
|
||||
m_activity = activity;
|
||||
init( savedInstanceState );
|
||||
}
|
||||
|
@ -453,14 +453,6 @@ public class DictsDelegate extends DelegateBase
|
|||
return handled;
|
||||
}
|
||||
|
||||
protected boolean onCreateOptionsMenu( Menu menu )
|
||||
{
|
||||
MenuInflater inflater = m_activity.getMenuInflater();
|
||||
inflater.inflate( R.menu.dicts_menu, menu );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean onPrepareOptionsMenu( Menu menu )
|
||||
{
|
||||
int nSel = m_selDicts.size();
|
||||
|
|
|
@ -123,7 +123,7 @@ public class GamesListDelegate extends DelegateBase
|
|||
|
||||
public GamesListDelegate( GamesListActivity activity, Bundle savedInstanceState )
|
||||
{
|
||||
super( activity, savedInstanceState );
|
||||
super( activity, savedInstanceState, R.menu.games_list_menu );
|
||||
m_activity = activity;
|
||||
init( savedInstanceState );
|
||||
}
|
||||
|
@ -619,15 +619,6 @@ public class GamesListDelegate extends DelegateBase
|
|||
return handled;
|
||||
}
|
||||
|
||||
protected boolean onCreateOptionsMenu( Menu menu )
|
||||
{
|
||||
MenuInflater inflater = m_activity.getMenuInflater();
|
||||
inflater.inflate( R.menu.games_list_menu, menu );
|
||||
LocUtils.xlateMenu( m_activity, menu );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean onPrepareOptionsMenu( Menu menu )
|
||||
{
|
||||
int nGamesSelected = m_selGames.size();
|
||||
|
|
|
@ -52,8 +52,7 @@ public class StudyListActivity extends ListActivity {
|
|||
@Override
|
||||
public boolean onCreateOptionsMenu( Menu menu )
|
||||
{
|
||||
getMenuInflater().inflate( R.menu.studylist, menu );
|
||||
return true;
|
||||
return m_dlgt.onCreateOptionsMenu( menu );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -66,7 +66,7 @@ public class StudyListDelegate extends DelegateBase
|
|||
|
||||
protected StudyListDelegate( ListActivity activity, Bundle savedInstanceState )
|
||||
{
|
||||
super( activity, savedInstanceState );
|
||||
super( activity, savedInstanceState, R.menu.studylist );
|
||||
m_activity = activity;
|
||||
init( savedInstanceState );
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.eehouse.android.xw4.loc;
|
|||
|
||||
import android.app.ListActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
|
||||
public class LocActivity extends ListActivity {
|
||||
|
||||
|
@ -33,6 +34,12 @@ public class LocActivity extends ListActivity {
|
|||
m_dlgt = new LocDelegate( this, savedInstanceState );
|
||||
} // onCreate
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu( Menu menu )
|
||||
{
|
||||
return m_dlgt.onCreateOptionsMenu( menu );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if ( !m_dlgt.onBackPressed() ) {
|
||||
|
|
|
@ -43,7 +43,7 @@ public class LocDelegate extends DelegateBase implements View.OnClickListener {
|
|||
|
||||
protected LocDelegate( ListActivity activity, Bundle savedInstanceState )
|
||||
{
|
||||
super( activity, savedInstanceState );
|
||||
super( activity, savedInstanceState, R.menu.loc_menu );
|
||||
m_activity = activity;
|
||||
init( savedInstanceState );
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue