mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-08 05:24:39 +01:00
add and use fragment for dict browser. Works except for the relaunch
logic around changing the parameters (e.g. word length filters.)
This commit is contained in:
parent
117752d965
commit
9e9d9a740c
3 changed files with 61 additions and 13 deletions
|
@ -20,13 +20,10 @@
|
|||
package org.eehouse.android.xw4;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.eehouse.android.xw4.loc.LocUtils;
|
||||
|
||||
public class BoardFrag extends XWFragment implements Delegator {
|
||||
public class BoardFrag extends XWFragment {
|
||||
private BoardDelegate m_dlgt;
|
||||
|
||||
@Override
|
||||
|
|
|
@ -163,14 +163,15 @@ public class DictBrowseDelegate extends ListDelegateBase
|
|||
|
||||
protected void init( Bundle savedInstanceState )
|
||||
{
|
||||
Intent intent = getIntent();
|
||||
String name = null == intent? null:intent.getStringExtra( DICT_NAME );
|
||||
Bundle args = getArguments();
|
||||
String name = null == args? null : args.getString( DICT_NAME );
|
||||
Assert.assertNotNull( name );
|
||||
if ( null == name ) {
|
||||
finish();
|
||||
} else {
|
||||
m_name = name;
|
||||
m_loc =
|
||||
DictUtils.DictLoc.values()[intent.getIntExtra( DICT_LOC, 0 )];
|
||||
DictUtils.DictLoc.values()[args.getInt( DICT_LOC, 0 )];
|
||||
m_lang = DictLangCache.getDictLangCode( m_activity, name );
|
||||
|
||||
String[] names = { name };
|
||||
|
@ -363,9 +364,9 @@ public class DictBrowseDelegate extends ListDelegateBase
|
|||
DBUtils.dictsSetOffset( m_activity, m_name, m_loc, m_browseState );
|
||||
m_browseState = null;
|
||||
|
||||
startActivity( getIntent() );
|
||||
finish(); // pop fragment stack before adding new (only it doesn't work)
|
||||
|
||||
finish();
|
||||
launch( m_activity, getArguments() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -421,14 +422,24 @@ public class DictBrowseDelegate extends ListDelegateBase
|
|||
m_maxSpinner.setOnItemSelectedListener( this );
|
||||
}
|
||||
|
||||
private static void launch( Context context, Bundle bundle )
|
||||
{
|
||||
if ( context instanceof FragActivity ) {
|
||||
FragActivity.addFragment( new DictBrowseFrag(), bundle );
|
||||
} else {
|
||||
Intent intent = new Intent( context, DictBrowseActivity.class );
|
||||
intent.putExtras( bundle );
|
||||
context.startActivity( intent );
|
||||
}
|
||||
}
|
||||
|
||||
public static void launch( Context caller, String name,
|
||||
DictUtils.DictLoc loc )
|
||||
{
|
||||
Intent intent = new Intent( caller, DictBrowseActivity.class );
|
||||
intent.putExtra( DICT_NAME, name );
|
||||
intent.putExtra( DICT_LOC, loc.ordinal() );
|
||||
caller.startActivity( intent );
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString( DICT_NAME, name );
|
||||
bundle.putInt( DICT_LOC, loc.ordinal() );
|
||||
launch( caller, bundle );
|
||||
}
|
||||
|
||||
public static void launch( Context caller, String name )
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/* -*- 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 DictBrowseFrag extends XWFragment {
|
||||
private DictBrowseDelegate m_dlgt;
|
||||
|
||||
@Override
|
||||
public void onCreate( Bundle savedInstanceState )
|
||||
{
|
||||
m_dlgt = new DictBrowseDelegate( this, savedInstanceState );
|
||||
super.onCreate( m_dlgt, savedInstanceState );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated( Bundle savedInstanceState )
|
||||
{
|
||||
super.onActivityCreated( savedInstanceState );
|
||||
setHasOptionsMenu( true );
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue