mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
modify item text after the db backing it is modified by covering edit
activity.
This commit is contained in:
parent
dfbb1bae71
commit
018424e6e8
5 changed files with 47 additions and 21 deletions
|
@ -427,7 +427,7 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
}
|
||||
}
|
||||
|
||||
public void onWindowFocusChanged( boolean hasFocus )
|
||||
protected void onWindowFocusChanged( boolean hasFocus )
|
||||
{
|
||||
// super.onWindowFocusChanged( hasFocus );
|
||||
if ( hasFocus ) {
|
||||
|
|
|
@ -47,4 +47,11 @@ public class LocActivity extends XWListActivity {
|
|||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged( boolean hasFocus )
|
||||
{
|
||||
m_dlgt.onWindowFocusChanged( hasFocus );
|
||||
super.onWindowFocusChanged( hasFocus );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ public class LocDelegate extends ListDelegateBase
|
|||
private ImageButton m_searchButton;
|
||||
private LocSearcher m_searcher;
|
||||
private String m_curSearch;
|
||||
private LocListItem m_lastItem;
|
||||
|
||||
protected LocDelegate( ListActivity activity, Bundle savedInstanceState )
|
||||
{
|
||||
|
@ -63,18 +64,32 @@ public class LocDelegate extends ListDelegateBase
|
|||
@Override
|
||||
public void onClick( View view )
|
||||
{
|
||||
String newText = m_searchField.getText().toString();
|
||||
if ( null == m_curSearch || ! m_curSearch.equals( newText ) ) {
|
||||
m_curSearch = newText;
|
||||
m_searcher.start( newText ); // synchronous for now
|
||||
makeNewAdapter();
|
||||
if ( view instanceof LocListItem ) {
|
||||
m_lastItem = (LocListItem)view;
|
||||
LocItemEditDelegate.launch( m_activity, m_lastItem.getPair() );
|
||||
} else if ( view == m_searchButton ) {
|
||||
String newText = m_searchField.getText().toString();
|
||||
if ( null == m_curSearch || ! m_curSearch.equals( newText ) ) {
|
||||
m_curSearch = newText;
|
||||
m_searcher.start( newText ); // synchronous for now
|
||||
makeNewAdapter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void onWindowFocusChanged( boolean hasFocus )
|
||||
{
|
||||
if ( hasFocus && null != m_lastItem ) {
|
||||
DbgUtils.logf( "updating LocListItem instance %H", m_lastItem );
|
||||
m_lastItem.update();
|
||||
m_lastItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void makeNewAdapter()
|
||||
{
|
||||
ListView listview = getListView();
|
||||
m_adapter = new LocListAdapter( m_activity, listview, m_searcher );
|
||||
m_adapter = new LocListAdapter( m_activity, listview, m_searcher, this );
|
||||
m_activity.setListAdapter( m_adapter );
|
||||
}
|
||||
|
||||
|
|
|
@ -33,13 +33,16 @@ public class LocListAdapter extends XWListAdapter {
|
|||
private Context m_context;
|
||||
private ListView m_listView;
|
||||
private LocSearcher m_searcher;
|
||||
private View.OnClickListener m_listener;
|
||||
|
||||
protected LocListAdapter( Context context, ListView listView,
|
||||
LocSearcher searcher )
|
||||
LocSearcher searcher,
|
||||
View.OnClickListener listener )
|
||||
{
|
||||
m_context = context;
|
||||
m_listView = listView;
|
||||
m_searcher = searcher;
|
||||
m_listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,6 +57,8 @@ public class LocListAdapter extends XWListAdapter {
|
|||
{
|
||||
// DbgUtils.logf( "LocListAdapter.getView(position=%d)", position );
|
||||
LocSearcher.Pair pair = m_searcher.getNthMatch( position );
|
||||
return LocListItem.create( m_context, pair, position );
|
||||
View view = LocListItem.create( m_context, pair, position );
|
||||
view.setOnClickListener( m_listener );
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,8 +35,7 @@ import org.eehouse.android.xw4.R;
|
|||
import org.eehouse.android.xw4.Utils;
|
||||
import org.eehouse.android.xw4.DbgUtils;
|
||||
|
||||
public class LocListItem extends LinearLayout
|
||||
implements View.OnClickListener {
|
||||
public class LocListItem extends LinearLayout {
|
||||
|
||||
private static final int LOCAL_COLOR = Color.argb( 0xFF, 0x7f, 0x00, 0x00 );
|
||||
|
||||
|
@ -55,7 +54,16 @@ public class LocListItem extends LinearLayout
|
|||
{
|
||||
super.onFinishInflate();
|
||||
m_xlated = (TextView)findViewById( R.id.xlated_view );
|
||||
setOnClickListener( this );
|
||||
}
|
||||
|
||||
protected void update()
|
||||
{
|
||||
setXlated();
|
||||
}
|
||||
|
||||
protected LocSearcher.Pair getPair()
|
||||
{
|
||||
return m_pair;
|
||||
}
|
||||
|
||||
private void setEnglish()
|
||||
|
@ -84,15 +92,6 @@ public class LocListItem extends LinearLayout
|
|||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// View.OnClickListener interface
|
||||
//////////////////////////////////////////////////
|
||||
@Override
|
||||
public void onClick( View view )
|
||||
{
|
||||
LocItemEditDelegate.launch( getContext(), m_pair );
|
||||
}
|
||||
|
||||
protected static LocListItem create( Context context,
|
||||
LocSearcher.Pair pair,
|
||||
int position )
|
||||
|
|
Loading…
Reference in a new issue