From 9d42d76ae0864ce48b1b5f473e294d6cd65b9b40 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 24 Nov 2015 08:15:27 -0800 Subject: [PATCH] collapse a couple of list-specific classes into their superclasses. --- .../eehouse/android/xw4/BTInviteDelegate.java | 2 +- .../org/eehouse/android/xw4/Delegator.java | 7 +++ .../android/xw4/DictBrowseActivity.java | 2 +- .../android/xw4/DictBrowseDelegate.java | 2 +- .../eehouse/android/xw4/DictsActivity.java | 2 +- .../eehouse/android/xw4/DictsDelegate.java | 2 +- .../eehouse/android/xw4/DwnldActivity.java | 2 +- .../eehouse/android/xw4/DwnldDelegate.java | 2 +- .../android/xw4/GamesListActivity.java | 2 +- .../android/xw4/GamesListDelegate.java | 4 +- .../eehouse/android/xw4/InviteActivity.java | 2 +- .../eehouse/android/xw4/InviteDelegate.java | 2 +- .../eehouse/android/xw4/ListDelegateBase.java | 6 +-- .../eehouse/android/xw4/ListDelegator.java | 30 ------------ .../android/xw4/RelayInviteDelegate.java | 2 +- .../android/xw4/SMSInviteDelegate.java | 2 +- .../android/xw4/StudyListActivity.java | 2 +- .../android/xw4/StudyListDelegate.java | 2 +- .../org/eehouse/android/xw4/XWActivity.java | 18 ++++++++ .../eehouse/android/xw4/XWListActivity.java | 46 ------------------- .../eehouse/android/xw4/loc/LocActivity.java | 4 +- .../eehouse/android/xw4/loc/LocDelegate.java | 4 +- 22 files changed, 48 insertions(+), 99 deletions(-) delete mode 100644 xwords4/android/XWords4/src/org/eehouse/android/xw4/ListDelegator.java delete mode 100644 xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListActivity.java diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTInviteDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTInviteDelegate.java index 1ddfc7c2e..916d4d015 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTInviteDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTInviteDelegate.java @@ -62,7 +62,7 @@ public class BTInviteDelegate extends InviteDelegate { activity.startActivityForResult( intent, requestCode ); } - protected BTInviteDelegate( ListDelegator delegator, Bundle savedInstanceState ) + protected BTInviteDelegate( Delegator delegator, Bundle savedInstanceState ) { super( delegator, savedInstanceState, R.layout.btinviter ); m_activity = delegator.getActivity(); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Delegator.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Delegator.java index cc705e8c4..c9b506175 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Delegator.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Delegator.java @@ -21,9 +21,16 @@ package org.eehouse.android.xw4; import android.app.Activity; import android.os.Bundle; +import android.widget.ListAdapter; +import android.widget.ListView; public interface Delegator { Activity getActivity(); Bundle getArguments(); void finish(); + + // For activities with lists + void setListAdapter( ListAdapter adapter ); + ListAdapter getListAdapter(); + ListView getListView(); } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseActivity.java index 8dacfc986..7019977d1 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseActivity.java @@ -22,7 +22,7 @@ package org.eehouse.android.xw4; import android.os.Bundle; -public class DictBrowseActivity extends XWListActivity { +public class DictBrowseActivity extends XWActivity { private DictBrowseDelegate m_dlgt; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseDelegate.java index 2b6a1caf0..e0eceacb6 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseDelegate.java @@ -155,7 +155,7 @@ public class DictBrowseDelegate extends ListDelegateBase } } - protected DictBrowseDelegate( ListDelegator delegator, Bundle savedInstanceState ) + protected DictBrowseDelegate( Delegator delegator, Bundle savedInstanceState ) { super( delegator, savedInstanceState, R.layout.dict_browser ); m_activity = delegator.getActivity(); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java index a19be63d6..58fb4e824 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java @@ -33,7 +33,7 @@ import java.util.HashMap; import org.eehouse.android.xw4.DictUtils.DictAndLoc; import org.eehouse.android.xw4.loc.LocUtils; -public class DictsActivity extends XWListActivity { +public class DictsActivity extends XWActivity { private static interface SafePopup { public void doPopup( Context context, View button, diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsDelegate.java index 7c6963de7..60a0bae80 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsDelegate.java @@ -299,7 +299,7 @@ public class DictsDelegate extends ListDelegateBase } } - protected DictsDelegate( ListDelegator delegator, Bundle savedInstanceState ) + protected DictsDelegate( Delegator delegator, Bundle savedInstanceState ) { super( delegator, savedInstanceState, R.layout.dict_browse, R.menu.dicts_menu ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DwnldActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DwnldActivity.java index aa184b294..9f4d17731 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DwnldActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DwnldActivity.java @@ -24,7 +24,7 @@ import android.app.Activity; import android.os.Bundle; import android.view.Window; -public class DwnldActivity extends XWListActivity { +public class DwnldActivity extends XWActivity { @Override protected void onCreate( Bundle savedInstanceState ) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DwnldDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DwnldDelegate.java index 542d31168..c9603482b 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DwnldDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DwnldDelegate.java @@ -68,7 +68,7 @@ public class DwnldDelegate extends ListDelegateBase { void gotDictInfo( boolean success, String lc, String name ); } - public DwnldDelegate( ListDelegator delegator, Bundle savedInstanceState ) + public DwnldDelegate( Delegator delegator, Bundle savedInstanceState ) { super( delegator, savedInstanceState, R.layout.import_dict ); m_activity = delegator.getActivity(); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListActivity.java index 414e53409..e4f5d6163 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListActivity.java @@ -29,7 +29,7 @@ import org.eehouse.android.xw4.jni.CurGameInfo; import junit.framework.Assert; -public class GamesListActivity extends XWListActivity { +public class GamesListActivity extends XWActivity { private GamesListDelegate m_dlgt; @Override diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java index 88f7c9cff..952cd4f1d 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java @@ -567,7 +567,7 @@ public class GamesListDelegate extends ListDelegateBase private Activity m_activity; private static GamesListDelegate s_self; - private ListDelegator m_delegator; + private Delegator m_delegator; private GameListAdapter m_adapter; private Handler m_handler; private String m_missingDict; @@ -594,7 +594,7 @@ public class GamesListDelegate extends ListDelegateBase private Intent m_rematchIntent; private Object[] m_newGameParams; - public GamesListDelegate( ListDelegator delegator, Bundle sis ) + public GamesListDelegate( Delegator delegator, Bundle sis ) { super( delegator, sis, R.layout.game_list, R.menu.games_list_menu ); m_delegator = delegator; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/InviteActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/InviteActivity.java index d6c7a070b..44e7250fb 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/InviteActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/InviteActivity.java @@ -23,7 +23,7 @@ package org.eehouse.android.xw4; import android.os.Bundle; import android.view.Window; -public abstract class InviteActivity extends XWListActivity { +public abstract class InviteActivity extends XWActivity { @Override protected void onCreate( Bundle savedInstanceState ) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/InviteDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/InviteDelegate.java index d53b6de0b..251118d3c 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/InviteDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/InviteDelegate.java @@ -44,7 +44,7 @@ abstract class InviteDelegate extends ListDelegateBase protected Button m_clearButton; private Activity m_activity; - public InviteDelegate( ListDelegator delegator, Bundle savedInstanceState, + public InviteDelegate( Delegator delegator, Bundle savedInstanceState, int layoutID ) { super( delegator, savedInstanceState, layoutID, R.menu.empty ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ListDelegateBase.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ListDelegateBase.java index 5c322f40f..cc170c1bc 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ListDelegateBase.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ListDelegateBase.java @@ -28,15 +28,15 @@ import android.widget.ListView; public class ListDelegateBase extends DelegateBase { private Activity m_activity; - private ListDelegator m_delegator; + private Delegator m_delegator; - protected ListDelegateBase( ListDelegator delegator, Bundle savedInstanceState, + protected ListDelegateBase( Delegator delegator, Bundle savedInstanceState, int layoutID ) { this( delegator, savedInstanceState, layoutID, R.menu.empty ); } - protected ListDelegateBase( ListDelegator delegator, Bundle savedInstanceState, + protected ListDelegateBase( Delegator delegator, Bundle savedInstanceState, int layoutID, int menuID ) { super( delegator, savedInstanceState, layoutID, menuID ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ListDelegator.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ListDelegator.java deleted file mode 100644 index 02a85ab8f..000000000 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ListDelegator.java +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- compile-command: "find-and-ant.sh debug install"; -*- */ -/* - * Copyright 2014 by Eric House (xwords@eehouse.org). All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package org.eehouse.android.xw4; - -import android.widget.ListAdapter; -import android.widget.ListView; - -public interface ListDelegator extends Delegator { - void setListAdapter( ListAdapter adapter ); - ListAdapter getListAdapter(); - ListView getListView(); - -} diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayInviteDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayInviteDelegate.java index 99f6aedc2..09f077907 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayInviteDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayInviteDelegate.java @@ -76,7 +76,7 @@ public class RelayInviteDelegate extends InviteDelegate { activity.startActivityForResult( intent, requestCode ); } - public RelayInviteDelegate( ListDelegator delegator, Bundle savedInstanceState ) + public RelayInviteDelegate( Delegator delegator, Bundle savedInstanceState ) { super( delegator, savedInstanceState, R.layout.relayinviter ); m_activity = delegator.getActivity(); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSInviteDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSInviteDelegate.java index f2773e691..b7179ac20 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSInviteDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSInviteDelegate.java @@ -72,7 +72,7 @@ public class SMSInviteDelegate extends InviteDelegate { activity.startActivityForResult( intent, requestCode ); } - public SMSInviteDelegate( ListDelegator delegator, Bundle savedInstanceState ) + public SMSInviteDelegate( Delegator delegator, Bundle savedInstanceState ) { super( delegator, savedInstanceState, R.layout.smsinviter ); m_activity = delegator.getActivity(); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListActivity.java index 742d720a9..bb2c46433 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListActivity.java @@ -21,7 +21,7 @@ package org.eehouse.android.xw4; import android.os.Bundle; -public class StudyListActivity extends XWListActivity { +public class StudyListActivity extends XWActivity { @Override protected void onCreate( Bundle savedInstanceState ) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListDelegate.java index d403bccd9..83e033632 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListDelegate.java @@ -65,7 +65,7 @@ public class StudyListDelegate extends ListDelegateBase private ListView m_list; private String m_origTitle; - protected StudyListDelegate( ListDelegator delegator, Bundle savedInstanceState ) + protected StudyListDelegate( Delegator delegator, Bundle savedInstanceState ) { super( delegator, savedInstanceState, R.layout.studylist, R.menu.studylist ); m_activity = delegator.getActivity(); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java index 1bf367315..d700b8264 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java @@ -29,6 +29,8 @@ import android.view.Menu; import android.view.MenuItem; import android.view.MenuItem; import android.view.View; +import android.widget.ListAdapter; +import android.widget.ListView; import junit.framework.Assert; @@ -193,4 +195,20 @@ public class XWActivity extends Activity implements Delegator { { return getIntent().getExtras(); } + + public ListView getListView() + { + ListView view = (ListView)findViewById( android.R.id.list ); + return view; + } + + public void setListAdapter( ListAdapter adapter ) + { + getListView().setAdapter( adapter ); + } + + public ListAdapter getListAdapter() + { + return getListView().getAdapter(); + } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListActivity.java deleted file mode 100644 index 8827745ff..000000000 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListActivity.java +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- compile-command: "find-and-ant.sh debug install"; -*- */ -/* - * Copyright 2014 by Eric House (xwords@eehouse.org). All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package org.eehouse.android.xw4; - -import android.os.Bundle; -import android.widget.ListAdapter; -import android.widget.ListView; - -public class XWListActivity extends XWActivity implements ListDelegator { - - ////////////////////////////////////////////////////////////////////// - // ListDelegator interface - ////////////////////////////////////////////////////////////////////// - public ListView getListView() - { - ListView view = (ListView)findViewById( android.R.id.list ); - return view; - } - - public void setListAdapter( ListAdapter adapter ) - { - getListView().setAdapter( adapter ); - } - - public ListAdapter getListAdapter() - { - return getListView().getAdapter(); - } -} diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocActivity.java index edc742c02..9ee4bb1df 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocActivity.java @@ -22,9 +22,9 @@ package org.eehouse.android.xw4.loc; import android.os.Bundle; import android.view.Menu; -import org.eehouse.android.xw4.XWListActivity; +import org.eehouse.android.xw4.XWActivity; -public class LocActivity extends XWListActivity { +public class LocActivity extends XWActivity { private LocDelegate m_dlgt; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocDelegate.java index 3738b09ad..2cb07f04c 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocDelegate.java @@ -35,7 +35,7 @@ import org.eehouse.android.xw4.DbgUtils; import org.eehouse.android.xw4.ListDelegateBase; import org.eehouse.android.xw4.R; import org.eehouse.android.xw4.Utils; -import org.eehouse.android.xw4.ListDelegator; +import org.eehouse.android.xw4.Delegator; public class LocDelegate extends ListDelegateBase implements View.OnClickListener, @@ -50,7 +50,7 @@ public class LocDelegate extends ListDelegateBase private String m_curSearch; private LocListItem m_lastItem; - protected LocDelegate( ListDelegator delegator, Bundle savedInstanceState ) + protected LocDelegate( Delegator delegator, Bundle savedInstanceState ) { super( delegator, savedInstanceState, R.layout.loc_main ); m_activity = delegator.getActivity();