mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-17 09:34:08 +01:00
refresh list view on (some) changes; get rid of unused button.
This commit is contained in:
parent
47d29d8d4d
commit
839e707069
3 changed files with 38 additions and 60 deletions
xwords4/android/XWords4/src/org/eehouse/android/xw4
|
@ -114,8 +114,8 @@ public class GameConfig extends Activity implements View.OnClickListener {
|
||||||
|
|
||||||
setContentView(R.layout.game_config);
|
setContentView(R.layout.game_config);
|
||||||
|
|
||||||
mOpenB = (Button)findViewById(R.id.game_config_open);
|
// mOpenB = (Button)findViewById(R.id.game_config_open);
|
||||||
mOpenB.setOnClickListener( this );
|
// mOpenB.setOnClickListener( this );
|
||||||
mDoneB = (Button)findViewById(R.id.game_config_done);
|
mDoneB = (Button)findViewById(R.id.game_config_done);
|
||||||
mDoneB.setOnClickListener( this );
|
mDoneB.setOnClickListener( this );
|
||||||
|
|
||||||
|
@ -170,6 +170,8 @@ public class GameConfig extends Activity implements View.OnClickListener {
|
||||||
Utils.logf( "got FileNotFoundException: " + ex.toString() );
|
Utils.logf( "got FileNotFoundException: " + ex.toString() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setResult( 1 );
|
||||||
finish();
|
finish();
|
||||||
} else if ( mOpenB == view ) {
|
} else if ( mOpenB == view ) {
|
||||||
// finish but after posting an intent that'll cause the
|
// finish but after posting an intent that'll cause the
|
||||||
|
|
|
@ -15,14 +15,12 @@ import java.nio.CharBuffer;
|
||||||
|
|
||||||
public class GameListAdapter implements ListAdapter {
|
public class GameListAdapter implements ListAdapter {
|
||||||
Context m_context;
|
Context m_context;
|
||||||
String[] m_files;
|
|
||||||
|
|
||||||
public GameListAdapter( Context context ) {
|
public GameListAdapter( Context context ) {
|
||||||
m_context = context;
|
m_context = context;
|
||||||
m_files = context.fileList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean areAllItemsEnabled() {
|
public boolean areAllItemsEnabled() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,13 +29,19 @@ public class GameListAdapter implements ListAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return m_files.length;
|
int count = 0;
|
||||||
}
|
for ( String file : m_context.fileList() ) {
|
||||||
|
//if ( file.endsWith(XWConstants.GAME_EXTN) ) {
|
||||||
|
++count;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
public Object getItem( int position ) {
|
public Object getItem( int position ) {
|
||||||
TextView view = new TextView(m_context);
|
TextView view = new TextView(m_context);
|
||||||
view.setText( "one game" );
|
view.setText( "game " + position );
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,35 +42,16 @@ import org.eehouse.android.xw4.XWords4.Games; // for constants
|
||||||
|
|
||||||
public class GamesList extends ListActivity implements View.OnClickListener {
|
public class GamesList extends ListActivity implements View.OnClickListener {
|
||||||
private static final String TAG = "GamesList";
|
private static final String TAG = "GamesList";
|
||||||
// private InputStream m_dict;
|
|
||||||
private GameListAdapter m_adapter;
|
private GameListAdapter m_adapter;
|
||||||
|
|
||||||
// Menu item ids
|
|
||||||
public static final int MENU_ITEM_DELETE = Menu.FIRST;
|
|
||||||
public static final int MENU_ITEM_INSERT = Menu.FIRST + 1;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
|
||||||
setContentView(R.layout.game_list);
|
setContentView(R.layout.game_list);
|
||||||
|
|
||||||
// setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);
|
// setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);
|
||||||
|
|
||||||
// AssetManager am = getAssets();
|
|
||||||
// try {
|
|
||||||
// m_dict = am.open( "BasEnglish2to8.xwd",
|
|
||||||
// android.content.res.AssetManager.ACCESS_RANDOM );
|
|
||||||
// Utils.logf( "opened" );
|
|
||||||
// } catch ( java.io.IOException ee ){
|
|
||||||
// m_dict = null;
|
|
||||||
// Utils.logf( "failed to open" );
|
|
||||||
// }
|
|
||||||
|
|
||||||
m_adapter = new GameListAdapter( this );
|
|
||||||
setListAdapter( m_adapter );
|
|
||||||
|
|
||||||
registerForContextMenu( getListView() );
|
registerForContextMenu( getListView() );
|
||||||
|
|
||||||
Button newGameB = (Button)findViewById(R.id.new_game);
|
Button newGameB = (Button)findViewById(R.id.new_game);
|
||||||
|
@ -85,20 +66,8 @@ public class GamesList extends ListActivity implements View.OnClickListener {
|
||||||
intent.setData(Games.CONTENT_URI);
|
intent.setData(Games.CONTENT_URI);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inform the list we provide context menus for items
|
m_adapter = new GameListAdapter( this );
|
||||||
// getListView().setOnCreateContextMenuListener(this);
|
setListAdapter( m_adapter );
|
||||||
|
|
||||||
// Perform a managed query. The Activity will handle closing
|
|
||||||
// and requerying the cursor when needed.
|
|
||||||
// Cursor cursor = managedQuery(getIntent().getData(), PROJECTION, null, null,
|
|
||||||
// Notes.DEFAULT_SORT_ORDER);
|
|
||||||
|
|
||||||
// Used to map notes entries from the database to views
|
|
||||||
// SimpleCursorAdapter adapter =
|
|
||||||
// new SimpleCursorAdapter(this, R.layout.noteslist_item, cursor,
|
|
||||||
// new String[] { Notes.TITLE },
|
|
||||||
// new int[] { android.R.id.text1 });
|
|
||||||
// setListAdapter(adapter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
|
@ -203,15 +172,9 @@ public class GamesList extends ListActivity implements View.OnClickListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextItemSelected( MenuItem item ) {
|
public boolean onContextItemSelected( MenuItem item )
|
||||||
|
{
|
||||||
boolean handled = false;
|
boolean handled = false;
|
||||||
AdapterView.AdapterContextMenuInfo info;
|
|
||||||
try {
|
|
||||||
info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
|
|
||||||
} catch (ClassCastException e) {
|
|
||||||
Log.e(TAG, "bad menuInfo", e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.list_item_open:
|
case R.id.list_item_open:
|
||||||
|
@ -219,16 +182,16 @@ public class GamesList extends ListActivity implements View.OnClickListener {
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
case R.id.list_item_view:
|
case R.id.list_item_view:
|
||||||
Utils.logf( "view" );
|
|
||||||
handled = true;
|
|
||||||
break;
|
|
||||||
case R.id.list_item_hide:
|
case R.id.list_item_hide:
|
||||||
Utils.logf( "hide" );
|
|
||||||
handled = true;
|
|
||||||
break;
|
|
||||||
case R.id.list_item_delete:
|
case R.id.list_item_delete:
|
||||||
Utils.logf( "delete" );
|
case R.id.list_item_copy:
|
||||||
|
case R.id.list_item_new_from:
|
||||||
|
case R.id.list_item_move_up:
|
||||||
|
case R.id.list_item_move_down:
|
||||||
|
case R.id.list_item_move_to_top:
|
||||||
|
case R.id.list_item_move_to_bottom:
|
||||||
handled = true;
|
handled = true;
|
||||||
|
Utils.notImpl( this );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return handled;
|
return handled;
|
||||||
|
@ -254,16 +217,25 @@ public class GamesList extends ListActivity implements View.OnClickListener {
|
||||||
setListAdapter( m_adapter );
|
setListAdapter( m_adapter );
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
|
case R.id.gamel_menu_view_hidden:
|
||||||
|
Utils.notImpl( this );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void onActivityResult( int requestCode, int resultCode,
|
||||||
|
Intent result )
|
||||||
|
{
|
||||||
|
if ( requestCode == 0 && resultCode == 1 ) {
|
||||||
|
onContentChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void onClick( View v ) {
|
public void onClick( View v ) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent( GamesList.this, GameConfig.class );
|
||||||
intent.setClassName( "org.eehouse.android.xw4",
|
|
||||||
"org.eehouse.android.xw4.GameConfig");
|
|
||||||
intent.setAction( Intent.ACTION_INSERT );
|
intent.setAction( Intent.ACTION_INSERT );
|
||||||
startActivity( intent );
|
startActivityForResult( intent, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Reference in a new issue