mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-02 20:46:15 +01:00
collapse a couple of list-specific classes into their superclasses.
This commit is contained in:
parent
87edd09ab6
commit
9d42d76ae0
22 changed files with 48 additions and 99 deletions
|
@ -62,7 +62,7 @@ public class BTInviteDelegate extends InviteDelegate {
|
||||||
activity.startActivityForResult( intent, requestCode );
|
activity.startActivityForResult( intent, requestCode );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected BTInviteDelegate( ListDelegator delegator, Bundle savedInstanceState )
|
protected BTInviteDelegate( Delegator delegator, Bundle savedInstanceState )
|
||||||
{
|
{
|
||||||
super( delegator, savedInstanceState, R.layout.btinviter );
|
super( delegator, savedInstanceState, R.layout.btinviter );
|
||||||
m_activity = delegator.getActivity();
|
m_activity = delegator.getActivity();
|
||||||
|
|
|
@ -21,9 +21,16 @@ package org.eehouse.android.xw4;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.widget.ListAdapter;
|
||||||
|
import android.widget.ListView;
|
||||||
|
|
||||||
public interface Delegator {
|
public interface Delegator {
|
||||||
Activity getActivity();
|
Activity getActivity();
|
||||||
Bundle getArguments();
|
Bundle getArguments();
|
||||||
void finish();
|
void finish();
|
||||||
|
|
||||||
|
// For activities with lists
|
||||||
|
void setListAdapter( ListAdapter adapter );
|
||||||
|
ListAdapter getListAdapter();
|
||||||
|
ListView getListView();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ package org.eehouse.android.xw4;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
public class DictBrowseActivity extends XWListActivity {
|
public class DictBrowseActivity extends XWActivity {
|
||||||
|
|
||||||
private DictBrowseDelegate m_dlgt;
|
private DictBrowseDelegate m_dlgt;
|
||||||
|
|
||||||
|
|
|
@ -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 );
|
super( delegator, savedInstanceState, R.layout.dict_browser );
|
||||||
m_activity = delegator.getActivity();
|
m_activity = delegator.getActivity();
|
||||||
|
|
|
@ -33,7 +33,7 @@ import java.util.HashMap;
|
||||||
import org.eehouse.android.xw4.DictUtils.DictAndLoc;
|
import org.eehouse.android.xw4.DictUtils.DictAndLoc;
|
||||||
import org.eehouse.android.xw4.loc.LocUtils;
|
import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
|
|
||||||
public class DictsActivity extends XWListActivity {
|
public class DictsActivity extends XWActivity {
|
||||||
|
|
||||||
private static interface SafePopup {
|
private static interface SafePopup {
|
||||||
public void doPopup( Context context, View button,
|
public void doPopup( Context context, View button,
|
||||||
|
|
|
@ -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,
|
super( delegator, savedInstanceState, R.layout.dict_browse,
|
||||||
R.menu.dicts_menu );
|
R.menu.dicts_menu );
|
||||||
|
|
|
@ -24,7 +24,7 @@ import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
|
||||||
public class DwnldActivity extends XWListActivity {
|
public class DwnldActivity extends XWActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate( Bundle savedInstanceState )
|
protected void onCreate( Bundle savedInstanceState )
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class DwnldDelegate extends ListDelegateBase {
|
||||||
void gotDictInfo( boolean success, String lc, String name );
|
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 );
|
super( delegator, savedInstanceState, R.layout.import_dict );
|
||||||
m_activity = delegator.getActivity();
|
m_activity = delegator.getActivity();
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.eehouse.android.xw4.jni.CurGameInfo;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
public class GamesListActivity extends XWListActivity {
|
public class GamesListActivity extends XWActivity {
|
||||||
private GamesListDelegate m_dlgt;
|
private GamesListDelegate m_dlgt;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -567,7 +567,7 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
|
|
||||||
private Activity m_activity;
|
private Activity m_activity;
|
||||||
private static GamesListDelegate s_self;
|
private static GamesListDelegate s_self;
|
||||||
private ListDelegator m_delegator;
|
private Delegator m_delegator;
|
||||||
private GameListAdapter m_adapter;
|
private GameListAdapter m_adapter;
|
||||||
private Handler m_handler;
|
private Handler m_handler;
|
||||||
private String m_missingDict;
|
private String m_missingDict;
|
||||||
|
@ -594,7 +594,7 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
private Intent m_rematchIntent;
|
private Intent m_rematchIntent;
|
||||||
private Object[] m_newGameParams;
|
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 );
|
super( delegator, sis, R.layout.game_list, R.menu.games_list_menu );
|
||||||
m_delegator = delegator;
|
m_delegator = delegator;
|
||||||
|
|
|
@ -23,7 +23,7 @@ package org.eehouse.android.xw4;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
|
||||||
public abstract class InviteActivity extends XWListActivity {
|
public abstract class InviteActivity extends XWActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate( Bundle savedInstanceState )
|
protected void onCreate( Bundle savedInstanceState )
|
||||||
|
|
|
@ -44,7 +44,7 @@ abstract class InviteDelegate extends ListDelegateBase
|
||||||
protected Button m_clearButton;
|
protected Button m_clearButton;
|
||||||
private Activity m_activity;
|
private Activity m_activity;
|
||||||
|
|
||||||
public InviteDelegate( ListDelegator delegator, Bundle savedInstanceState,
|
public InviteDelegate( Delegator delegator, Bundle savedInstanceState,
|
||||||
int layoutID )
|
int layoutID )
|
||||||
{
|
{
|
||||||
super( delegator, savedInstanceState, layoutID, R.menu.empty );
|
super( delegator, savedInstanceState, layoutID, R.menu.empty );
|
||||||
|
|
|
@ -28,15 +28,15 @@ import android.widget.ListView;
|
||||||
public class ListDelegateBase extends DelegateBase {
|
public class ListDelegateBase extends DelegateBase {
|
||||||
|
|
||||||
private Activity m_activity;
|
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 )
|
int layoutID )
|
||||||
{
|
{
|
||||||
this( delegator, savedInstanceState, layoutID, R.menu.empty );
|
this( delegator, savedInstanceState, layoutID, R.menu.empty );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ListDelegateBase( ListDelegator delegator, Bundle savedInstanceState,
|
protected ListDelegateBase( Delegator delegator, Bundle savedInstanceState,
|
||||||
int layoutID, int menuID )
|
int layoutID, int menuID )
|
||||||
{
|
{
|
||||||
super( delegator, savedInstanceState, layoutID, menuID );
|
super( delegator, savedInstanceState, layoutID, menuID );
|
||||||
|
|
|
@ -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();
|
|
||||||
|
|
||||||
}
|
|
|
@ -76,7 +76,7 @@ public class RelayInviteDelegate extends InviteDelegate {
|
||||||
activity.startActivityForResult( intent, requestCode );
|
activity.startActivityForResult( intent, requestCode );
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelayInviteDelegate( ListDelegator delegator, Bundle savedInstanceState )
|
public RelayInviteDelegate( Delegator delegator, Bundle savedInstanceState )
|
||||||
{
|
{
|
||||||
super( delegator, savedInstanceState, R.layout.relayinviter );
|
super( delegator, savedInstanceState, R.layout.relayinviter );
|
||||||
m_activity = delegator.getActivity();
|
m_activity = delegator.getActivity();
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class SMSInviteDelegate extends InviteDelegate {
|
||||||
activity.startActivityForResult( intent, requestCode );
|
activity.startActivityForResult( intent, requestCode );
|
||||||
}
|
}
|
||||||
|
|
||||||
public SMSInviteDelegate( ListDelegator delegator, Bundle savedInstanceState )
|
public SMSInviteDelegate( Delegator delegator, Bundle savedInstanceState )
|
||||||
{
|
{
|
||||||
super( delegator, savedInstanceState, R.layout.smsinviter );
|
super( delegator, savedInstanceState, R.layout.smsinviter );
|
||||||
m_activity = delegator.getActivity();
|
m_activity = delegator.getActivity();
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.eehouse.android.xw4;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
public class StudyListActivity extends XWListActivity {
|
public class StudyListActivity extends XWActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate( Bundle savedInstanceState )
|
protected void onCreate( Bundle savedInstanceState )
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class StudyListDelegate extends ListDelegateBase
|
||||||
private ListView m_list;
|
private ListView m_list;
|
||||||
private String m_origTitle;
|
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 );
|
super( delegator, savedInstanceState, R.layout.studylist, R.menu.studylist );
|
||||||
m_activity = delegator.getActivity();
|
m_activity = delegator.getActivity();
|
||||||
|
|
|
@ -29,6 +29,8 @@ import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.ListAdapter;
|
||||||
|
import android.widget.ListView;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
@ -193,4 +195,20 @@ public class XWActivity extends Activity implements Delegator {
|
||||||
{
|
{
|
||||||
return getIntent().getExtras();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -22,9 +22,9 @@ package org.eehouse.android.xw4.loc;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Menu;
|
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;
|
private LocDelegate m_dlgt;
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.eehouse.android.xw4.DbgUtils;
|
||||||
import org.eehouse.android.xw4.ListDelegateBase;
|
import org.eehouse.android.xw4.ListDelegateBase;
|
||||||
import org.eehouse.android.xw4.R;
|
import org.eehouse.android.xw4.R;
|
||||||
import org.eehouse.android.xw4.Utils;
|
import org.eehouse.android.xw4.Utils;
|
||||||
import org.eehouse.android.xw4.ListDelegator;
|
import org.eehouse.android.xw4.Delegator;
|
||||||
|
|
||||||
public class LocDelegate extends ListDelegateBase
|
public class LocDelegate extends ListDelegateBase
|
||||||
implements View.OnClickListener,
|
implements View.OnClickListener,
|
||||||
|
@ -50,7 +50,7 @@ public class LocDelegate extends ListDelegateBase
|
||||||
private String m_curSearch;
|
private String m_curSearch;
|
||||||
private LocListItem m_lastItem;
|
private LocListItem m_lastItem;
|
||||||
|
|
||||||
protected LocDelegate( ListDelegator delegator, Bundle savedInstanceState )
|
protected LocDelegate( Delegator delegator, Bundle savedInstanceState )
|
||||||
{
|
{
|
||||||
super( delegator, savedInstanceState, R.layout.loc_main );
|
super( delegator, savedInstanceState, R.layout.loc_main );
|
||||||
m_activity = delegator.getActivity();
|
m_activity = delegator.getActivity();
|
||||||
|
|
Loading…
Add table
Reference in a new issue