mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-09 22:00:39 +01:00
Make config work as a fragment, and clean up all the fragment
subclasses: only one method needs to be overridden.
This commit is contained in:
parent
8cb2cecc18
commit
b3f6e1b0a3
10 changed files with 78 additions and 102 deletions
|
@ -1,6 +1,7 @@
|
||||||
/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
|
/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
|
||||||
/*
|
/*
|
||||||
* Copyright 2014 by Eric House (xwords@eehouse.org). All rights reserved.
|
* Copyright 2014 - 2016 by Eric House (xwords@eehouse.org). All rights
|
||||||
|
* reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License as
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
@ -21,22 +22,11 @@ package org.eehouse.android.xw4;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.loc.LocUtils;
|
|
||||||
|
|
||||||
public class BoardFrag extends XWFragment {
|
public class BoardFrag extends XWFragment {
|
||||||
private BoardDelegate m_dlgt;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate( Bundle savedInstanceState )
|
public void onCreate( Bundle sis )
|
||||||
{
|
{
|
||||||
m_dlgt = new BoardDelegate( this, savedInstanceState );
|
super.onCreate( new BoardDelegate( this, sis ), sis, true );
|
||||||
super.onCreate( m_dlgt, savedInstanceState );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityCreated( Bundle savedInstanceState )
|
|
||||||
{
|
|
||||||
super.onActivityCreated( savedInstanceState );
|
|
||||||
setHasOptionsMenu( true );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,19 +22,10 @@ package org.eehouse.android.xw4;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
public class ChatFrag extends XWFragment {
|
public class ChatFrag extends XWFragment {
|
||||||
private ChatDelegate m_dlgt;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate( Bundle savedInstanceState )
|
public void onCreate( Bundle sis )
|
||||||
{
|
{
|
||||||
m_dlgt = new ChatDelegate( this, savedInstanceState );
|
super.onCreate( new ChatDelegate( this, sis ), sis, true );
|
||||||
super.onCreate( m_dlgt, savedInstanceState );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityCreated( Bundle savedInstanceState )
|
|
||||||
{
|
|
||||||
super.onActivityCreated( savedInstanceState );
|
|
||||||
setHasOptionsMenu( true );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,19 +22,10 @@ package org.eehouse.android.xw4;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
public class DictBrowseFrag extends XWFragment {
|
public class DictBrowseFrag extends XWFragment {
|
||||||
private DictBrowseDelegate m_dlgt;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate( Bundle savedInstanceState )
|
public void onCreate( Bundle sis )
|
||||||
{
|
{
|
||||||
m_dlgt = new DictBrowseDelegate( this, savedInstanceState );
|
super.onCreate( new DictBrowseDelegate( this, sis ), sis, true );
|
||||||
super.onCreate( m_dlgt, savedInstanceState );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityCreated( Bundle savedInstanceState )
|
|
||||||
{
|
|
||||||
super.onActivityCreated( savedInstanceState );
|
|
||||||
setHasOptionsMenu( true );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
|
/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
|
||||||
/*
|
/*
|
||||||
* Copyright 2009 - 2015 by Eric House (xwords@eehouse.org). All rights
|
* Copyright 2009 - 2016 by Eric House (xwords@eehouse.org). All rights
|
||||||
* reserved.
|
* reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
|
@ -462,9 +462,10 @@ public class GameConfigDelegate extends DelegateBase
|
||||||
|
|
||||||
m_cp = CommonPrefs.get( m_activity );
|
m_cp = CommonPrefs.get( m_activity );
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Bundle args = getArguments();
|
||||||
m_rowid = intent.getLongExtra( GameUtils.INTENT_KEY_ROWID, -1 );
|
m_rowid = args.getLong( GameUtils.INTENT_KEY_ROWID, DBUtils.ROWID_NOTFOUND );
|
||||||
m_forResult = intent.getBooleanExtra( INTENT_FORRESULT_ROWID, false );
|
Assert.assertTrue( DBUtils.ROWID_NOTFOUND != m_rowid );
|
||||||
|
m_forResult = args.getBoolean( INTENT_FORRESULT_ROWID, false );
|
||||||
|
|
||||||
m_connectSetRelay = findViewById( R.id.connect_set_relay );
|
m_connectSetRelay = findViewById( R.id.connect_set_relay );
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
|
||||||
|
/*
|
||||||
|
* Copyright 2016 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;
|
||||||
|
|
||||||
|
public class GameConfigFrag extends XWFragment {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate( Bundle savedInstanceState )
|
||||||
|
{
|
||||||
|
super.onCreate( new GameConfigDelegate( this, sis ), sis, true );
|
||||||
|
}
|
||||||
|
}
|
|
@ -1083,12 +1083,20 @@ public class GameUtils {
|
||||||
DBUtils.saveSummary( context, lock, summary );
|
DBUtils.saveSummary( context, lock, summary );
|
||||||
} // applyChanges
|
} // applyChanges
|
||||||
|
|
||||||
public static void doConfig( Activity activity, long rowid, Class clazz )
|
public static void doConfig( Delegator delegator, long rowid )
|
||||||
{
|
{
|
||||||
Intent intent = new Intent( activity, clazz );
|
Bundle extras = new Bundle();
|
||||||
intent.setAction( Intent.ACTION_EDIT );
|
extras.putLong( INTENT_KEY_ROWID, rowid );
|
||||||
intent.putExtra( INTENT_KEY_ROWID, rowid );
|
|
||||||
activity.startActivity( intent );
|
Activity activity = delegator.getActivity();
|
||||||
|
if ( activity instanceof FragActivity ) {
|
||||||
|
FragActivity.addFragment( new GameConfigFrag(), extras, delegator );
|
||||||
|
} else {
|
||||||
|
Intent intent = new Intent( activity, GameConfigActivity.class );
|
||||||
|
intent.setAction( Intent.ACTION_EDIT );
|
||||||
|
intent.putExtras( extras );
|
||||||
|
activity.startActivity( intent );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String formatGameID( int gameID )
|
public static String formatGameID( int gameID )
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
|
/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
|
||||||
/*
|
/*
|
||||||
* Copyright 2009 - 2015 by Eric House (xwords@eehouse.org). All
|
* Copyright 2009 - 2016 by Eric House (xwords@eehouse.org). All
|
||||||
* rights reserved.
|
* rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
|
@ -1676,7 +1676,7 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.games_game_config:
|
case R.id.games_game_config:
|
||||||
GameUtils.doConfig( m_activity, selRowIDs[0], GameConfigActivity.class );
|
GameUtils.doConfig( getDelegator(), selRowIDs[0] );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.games_game_move:
|
case R.id.games_game_move:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
|
/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
|
||||||
/*
|
/*
|
||||||
* Copyright 2014 by Eric House (xwords@eehouse.org). All rights
|
* Copyright 2014 - 2016 by Eric House (xwords@eehouse.org). All rights
|
||||||
* reserved.
|
* reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
|
@ -20,47 +20,13 @@
|
||||||
|
|
||||||
package org.eehouse.android.xw4;
|
package org.eehouse.android.xw4;
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.ListActivity;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.ListFragment;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
|
|
||||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
|
||||||
import org.eehouse.android.xw4.loc.LocUtils;
|
|
||||||
|
|
||||||
public class GamesListFrag extends XWFragment {
|
public class GamesListFrag extends XWFragment {
|
||||||
|
|
||||||
private GamesListDelegate m_dlgt;
|
|
||||||
|
|
||||||
// public GamesListFrag( FragActivity activity )
|
|
||||||
// {
|
|
||||||
// m_activity = activity;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate( Bundle savedInstanceState )
|
public void onCreate( Bundle sis )
|
||||||
{
|
{
|
||||||
DbgUtils.logf( "GamesListFrag.onCreate()" );
|
super.onCreate( new GamesListDelegate( this, sis ), sis, true );
|
||||||
m_dlgt = new GamesListDelegate( this, savedInstanceState );
|
|
||||||
super.onCreate( m_dlgt, savedInstanceState );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityCreated( Bundle savedInstanceState )
|
|
||||||
{
|
|
||||||
super.onActivityCreated( savedInstanceState );
|
|
||||||
setHasOptionsMenu( true );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
|
/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
|
||||||
/*
|
/*
|
||||||
* Copyright 2014 by Eric House (xwords@eehouse.org). All rights reserved.
|
* Copyright 2014 - 2016 by Eric House (xwords@eehouse.org). All rights
|
||||||
|
* reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License as
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
@ -20,25 +21,12 @@
|
||||||
package org.eehouse.android.xw4;
|
package org.eehouse.android.xw4;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import org.eehouse.android.xw4.loc.LocUtils;
|
public class StudyListFrag extends XWFragment {
|
||||||
|
|
||||||
public class StudyListFrag extends XWFragment implements Delegator {
|
|
||||||
private StudyListDelegate m_dlgt;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate( Bundle savedInstanceState )
|
public void onCreate( Bundle sis )
|
||||||
{
|
{
|
||||||
DbgUtils.logf( "StudyListFrag.onCreate()" );
|
super.onCreate( new StudyListDelegate( this, sis ), sis, true );
|
||||||
m_dlgt = new StudyListDelegate( this, savedInstanceState );
|
|
||||||
super.onCreate( m_dlgt, savedInstanceState );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityCreated( Bundle savedInstanceState )
|
|
||||||
{
|
|
||||||
super.onActivityCreated( savedInstanceState );
|
|
||||||
setHasOptionsMenu( true );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,15 @@ public class XWFragment extends Fragment
|
||||||
FragActivity.OrientChangeListener {
|
FragActivity.OrientChangeListener {
|
||||||
|
|
||||||
private DelegateBase m_dlgt;
|
private DelegateBase m_dlgt;
|
||||||
|
private boolean m_hasOptionsMenu = false;
|
||||||
|
|
||||||
public void onCreate( DelegateBase dlgt, Bundle sis )
|
protected void onCreate( DelegateBase dlgt, Bundle sis, boolean hasOptionsMenu )
|
||||||
|
{
|
||||||
|
m_hasOptionsMenu = hasOptionsMenu;
|
||||||
|
this.onCreate( dlgt, sis );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onCreate( DelegateBase dlgt, Bundle sis )
|
||||||
{
|
{
|
||||||
DbgUtils.logdf( "%s.onCreate() called", this.getClass().getName() );
|
DbgUtils.logdf( "%s.onCreate() called", this.getClass().getName() );
|
||||||
super.onCreate( sis );
|
super.onCreate( sis );
|
||||||
|
@ -61,6 +68,9 @@ public class XWFragment extends Fragment
|
||||||
DbgUtils.logdf( "%s.onActivityCreated() called", this.getClass().getName() );
|
DbgUtils.logdf( "%s.onActivityCreated() called", this.getClass().getName() );
|
||||||
m_dlgt.init( savedInstanceState );
|
m_dlgt.init( savedInstanceState );
|
||||||
super.onActivityCreated( savedInstanceState );
|
super.onActivityCreated( savedInstanceState );
|
||||||
|
if ( m_hasOptionsMenu ) {
|
||||||
|
setHasOptionsMenu( true );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Reference in a new issue