refresh list view on (some) changes; get rid of unused button.

This commit is contained in:
ehouse 2010-01-12 13:32:19 +00:00
parent 47d29d8d4d
commit 839e707069
3 changed files with 38 additions and 60 deletions

View file

@ -114,8 +114,8 @@ public class GameConfig extends Activity implements View.OnClickListener {
setContentView(R.layout.game_config);
mOpenB = (Button)findViewById(R.id.game_config_open);
mOpenB.setOnClickListener( this );
// mOpenB = (Button)findViewById(R.id.game_config_open);
// mOpenB.setOnClickListener( this );
mDoneB = (Button)findViewById(R.id.game_config_done);
mDoneB.setOnClickListener( this );
@ -170,6 +170,8 @@ public class GameConfig extends Activity implements View.OnClickListener {
Utils.logf( "got FileNotFoundException: " + ex.toString() );
}
}
setResult( 1 );
finish();
} else if ( mOpenB == view ) {
// finish but after posting an intent that'll cause the

View file

@ -15,14 +15,12 @@ import java.nio.CharBuffer;
public class GameListAdapter implements ListAdapter {
Context m_context;
String[] m_files;
public GameListAdapter( Context context ) {
m_context = context;
m_files = context.fileList();
}
public boolean areAllItemsEnabled() {
public boolean areAllItemsEnabled() {
return true;
}
@ -31,13 +29,19 @@ public class GameListAdapter implements ListAdapter {
}
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 ) {
TextView view = new TextView(m_context);
view.setText( "one game" );
view.setText( "game " + position );
return view;
}

View file

@ -42,35 +42,16 @@ import org.eehouse.android.xw4.XWords4.Games; // for constants
public class GamesList extends ListActivity implements View.OnClickListener {
private static final String TAG = "GamesList";
// private InputStream m_dict;
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
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.game_list);
// 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() );
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);
}
// Inform the list we provide context menus for items
// getListView().setOnCreateContextMenuListener(this);
// 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);
m_adapter = new GameListAdapter( this );
setListAdapter( m_adapter );
}
// @Override
@ -203,15 +172,9 @@ public class GamesList extends ListActivity implements View.OnClickListener {
}
@Override
public boolean onContextItemSelected( MenuItem item ) {
public boolean onContextItemSelected( MenuItem item )
{
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()) {
case R.id.list_item_open:
@ -219,16 +182,16 @@ public class GamesList extends ListActivity implements View.OnClickListener {
handled = true;
break;
case R.id.list_item_view:
Utils.logf( "view" );
handled = true;
break;
case R.id.list_item_hide:
Utils.logf( "hide" );
handled = true;
break;
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;
Utils.notImpl( this );
break;
}
return handled;
@ -254,16 +217,25 @@ public class GamesList extends ListActivity implements View.OnClickListener {
setListAdapter( m_adapter );
handled = true;
break;
case R.id.gamel_menu_view_hidden:
Utils.notImpl( this );
break;
}
return handled;
}
protected void onActivityResult( int requestCode, int resultCode,
Intent result )
{
if ( requestCode == 0 && resultCode == 1 ) {
onContentChanged();
}
}
public void onClick( View v ) {
Intent intent = new Intent();
intent.setClassName( "org.eehouse.android.xw4",
"org.eehouse.android.xw4.GameConfig");
Intent intent = new Intent( GamesList.this, GameConfig.class );
intent.setAction( Intent.ACTION_INSERT );
startActivity( intent );
startActivityForResult( intent, 0 );
}
@Override