cleanup; refresh view on regaining focus rather than using

startActivityForResult
This commit is contained in:
ehouse 2010-01-13 13:31:23 +00:00
parent c04c6974ba
commit a3a313fdb4
2 changed files with 15 additions and 103 deletions

View file

@ -170,7 +170,6 @@ 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

@ -70,107 +70,22 @@ public class GamesList extends ListActivity implements View.OnClickListener {
setListAdapter( m_adapter );
}
// @Override
// public boolean onCreateOptionsMenu(Menu menu) {
// super.onCreateOptionsMenu(menu);
// // This is our one standard application action -- inserting a
// // new note into the list.
// menu.add(0, MENU_ITEM_INSERT, 0, R.string.menu_insert)
// .setShortcut('3', 'a')
// .setIcon(android.R.drawable.ic_menu_add);
// // Generate any additional actions that can be performed on the
// // overall list. In a normal install, there are no additional
// // actions found here, but this allows other applications to extend
// // our menu with their own actions.
// Intent intent = new Intent(null, getIntent().getData());
// intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
// menu.addIntentOptions(Menu.CATEGORY_ALTERNATIVE, 0, 0,
// new ComponentName(this, GamesList.class), null, intent, 0, null);
// return true;
// }
// @Override
// public boolean onPrepareOptionsMenu(Menu menu) {
// super.onPrepareOptionsMenu(menu);
// final boolean haveItems = getListAdapter().getCount() > 0;
// // If there are any notes in the list (which implies that one of
// // them is selected), then we need to generate the actions that
// // can be performed on the current selection. This will be a combination
// // of our own specific actions along with any extensions that can be
// // found.
// if (haveItems) {
// // This is the selected item.
// Uri uri = ContentUris.withAppendedId(getIntent().getData(), getSelectedItemId());
// // Build menu... always starts with the EDIT action...
// Intent[] specifics = new Intent[1];
// specifics[0] = new Intent(Intent.ACTION_EDIT, uri);
// MenuItem[] items = new MenuItem[1];
// // ... is followed by whatever other actions are available...
// Intent intent = new Intent(null, uri);
// intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
// menu.addIntentOptions(Menu.CATEGORY_ALTERNATIVE, 0, 0, null, specifics, intent, 0,
// items);
// // Give a shortcut to the edit action.
// if (items[0] != null) {
// items[0].setShortcut('1', 'e');
// }
// } else {
// menu.removeGroup(Menu.CATEGORY_ALTERNATIVE);
// }
// return true;
// }
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// switch (item.getItemId()) {
// case MENU_ITEM_INSERT:
// // Launch activity to insert a new item
// startActivity(new Intent(Intent.ACTION_INSERT, getIntent().getData()));
// return true;
// }
// return super.onOptionsItemSelected(item);
// }
@Override
public void onWindowFocusChanged( boolean hasFocus )
{
super.onWindowFocusChanged( hasFocus );
if ( hasFocus ) {
onContentChanged();
}
}
@Override
public void onCreateContextMenu( ContextMenu menu, View view,
ContextMenuInfo menuInfo ) {
// AdapterView.AdapterContextMenuInfo info;
// try {
// info = (AdapterView.AdapterContextMenuInfo) menuInfo;
// } catch (ClassCastException e) {
// Log.e(TAG, "bad menuInfo", e);
// return;
// }
Utils.logf( "onCreateContextMenu called" );
MenuInflater inflater = getMenuInflater();
inflater.inflate( R.menu.games_list_item_menu, menu );
// Cursor cursor = (Cursor) getListAdapter().getItem(info.position);
// if (cursor == null) {
// // For some reason the requested item isn't available, do nothing
// return;
// }
// Setup the menu header
// menu.setHeaderTitle(cursor.getString(COLUMN_INDEX_TITLE));
}
private void doOpen() {
Intent intent = new Intent( Intent.ACTION_EDIT );
intent.setClassName( "org.eehouse.android.xw4",
"org.eehouse.android.xw4.BoardActivity");
startActivity( intent );
}
@Override
public boolean onContextItemSelected( MenuItem item )
{
@ -224,18 +139,10 @@ public class GamesList extends ListActivity implements View.OnClickListener {
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( GamesList.this, GameConfig.class );
intent.setAction( Intent.ACTION_INSERT );
startActivityForResult( intent, 0 );
startActivity( intent );
}
@Override
@ -243,6 +150,12 @@ public class GamesList extends ListActivity implements View.OnClickListener {
doOpen();
}
private void doOpen() {
Intent intent = new Intent( Intent.ACTION_EDIT );
intent.setClassName( "org.eehouse.android.xw4",
"org.eehouse.android.xw4.BoardActivity");
startActivity( intent );
}
static {
System.loadLibrary("xwjni");