Cleanup: get rid of ListActivity. Eventually all Activities need to

inherit from FragmentActivity since there's no List-aware equivalent,
so XWListActivity now extends XWActivity and nearly all its methods go
away. getListView() and friends are all I needed to implement --
apparently.
This commit is contained in:
Eric House 2015-11-24 07:32:53 -08:00
parent e3e4ebd7de
commit 87edd09ab6
13 changed files with 33 additions and 171 deletions

View file

@ -13,7 +13,6 @@
ant_out.txt
bin
gen
libs
local.properties
obj
proguard.cfg

View file

@ -0,0 +1,2 @@
/armeabi
/x86

View file

@ -21,7 +21,6 @@
package org.eehouse.android.xw4;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.database.DataSetObserver;

View file

@ -23,7 +23,6 @@ package org.eehouse.android.xw4;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ListActivity;
import android.content.Context;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnClickListener;

View file

@ -21,7 +21,6 @@
package org.eehouse.android.xw4;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;

View file

@ -20,7 +20,6 @@
package org.eehouse.android.xw4;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.Window;

View file

@ -22,7 +22,6 @@ package org.eehouse.android.xw4;
import android.app.Activity;
import android.app.Dialog;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

View file

@ -23,7 +23,6 @@ package org.eehouse.android.xw4;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ListActivity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;

View file

@ -23,7 +23,6 @@ package org.eehouse.android.xw4;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ListActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;

View file

@ -23,8 +23,12 @@ import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MenuItem;
import android.view.View;
import junit.framework.Assert;
@ -139,6 +143,19 @@ public class XWActivity extends Activity implements Delegator {
|| super.onOptionsItemSelected( item );
}
@Override
public void onCreateContextMenu( ContextMenu menu, View view,
ContextMenuInfo menuInfo )
{
m_dlgt.onCreateContextMenu( menu, view, menuInfo );
}
@Override
public boolean onContextItemSelected( MenuItem item )
{
return m_dlgt.onContextItemSelected( item );
}
@Override
protected Dialog onCreateDialog( int id )
{

View file

@ -19,175 +19,28 @@
package org.eehouse.android.xw4;
import android.app.Activity;
import android.app.Dialog;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListAdapter;
import android.widget.ListView;
public class XWListActivity extends ListActivity implements ListDelegator {
private DelegateBase m_dlgt;
protected void onCreate( Bundle savedInstanceState, DelegateBase dlgt )
{
if ( XWApp.LOG_LIFECYLE ) {
DbgUtils.logf( "%s.onCreate(this=%H)", getClass().getName(), this );
}
super.onCreate( savedInstanceState );
m_dlgt = dlgt;
int layoutID = dlgt.getLayoutID();
if ( 0 < layoutID ) {
dlgt.setContentView( layoutID );
}
dlgt.init( savedInstanceState );
}
@Override
protected void onSaveInstanceState( Bundle outState )
{
super.onSaveInstanceState( outState );
m_dlgt.onSaveInstanceState( outState );
}
@Override
protected void onPause()
{
if ( XWApp.LOG_LIFECYLE ) {
DbgUtils.logf( "%s.onPause(this=%H)", getClass().getName(), this );
}
m_dlgt.onPause();
super.onPause();
}
@Override
protected void onResume()
{
if ( XWApp.LOG_LIFECYLE ) {
DbgUtils.logf( "%s.onResume(this=%H)", getClass().getName(), this );
}
super.onResume();
m_dlgt.onResume();
}
@Override
protected void onStart()
{
if ( XWApp.LOG_LIFECYLE ) {
DbgUtils.logf( "%s.onStart(this=%H)", getClass().getName(), this );
}
super.onStart();
m_dlgt.onStart();
}
@Override
protected void onStop()
{
if ( XWApp.LOG_LIFECYLE ) {
DbgUtils.logf( "%s.onStop(this=%H)", getClass().getName(), this );
}
m_dlgt.onStop();
super.onStop();
}
@Override
protected void onDestroy()
{
if ( XWApp.LOG_LIFECYLE ) {
DbgUtils.logf( "%s.onDestroy(this=%H)", getClass().getName(), this );
}
m_dlgt.onDestroy();
super.onDestroy();
}
@Override
public void onWindowFocusChanged( boolean hasFocus )
{
super.onWindowFocusChanged( hasFocus );
m_dlgt.onWindowFocusChanged( hasFocus );
}
@Override
public void onBackPressed() {
if ( !m_dlgt.onBackPressed() ) {
super.onBackPressed();
}
}
@Override
public boolean onCreateOptionsMenu( Menu menu )
{
return m_dlgt.onCreateOptionsMenu( menu );
}
@Override
public void onCreateContextMenu( ContextMenu menu, View view,
ContextMenuInfo menuInfo )
{
m_dlgt.onCreateContextMenu( menu, view, menuInfo );
}
@Override
public boolean onContextItemSelected( MenuItem item )
{
return m_dlgt.onContextItemSelected( item );
}
@Override
public boolean onPrepareOptionsMenu( Menu menu )
{
return m_dlgt.onPrepareOptionsMenu( menu )
|| super.onPrepareOptionsMenu( menu );
} // onPrepareOptionsMenu
@Override
public boolean onOptionsItemSelected( MenuItem item )
{
return m_dlgt.onOptionsItemSelected( item )
|| super.onOptionsItemSelected( item );
}
@Override
protected Dialog onCreateDialog( int id )
{
Dialog dialog = super.onCreateDialog( id );
if ( null == dialog ) {
dialog = m_dlgt.onCreateDialog( id );
}
return dialog;
} // onCreateDialog
@Override
public void onPrepareDialog( int id, Dialog dialog )
{
super.onPrepareDialog( id, dialog );
m_dlgt.prepareDialog( DlgID.values()[id], dialog );
}
@Override
protected void onActivityResult( int requestCode, int resultCode,
Intent data )
{
m_dlgt.onActivityResult( requestCode, resultCode, data );
}
public class XWListActivity extends XWActivity implements ListDelegator {
//////////////////////////////////////////////////////////////////////
// Delegator interface
// ListDelegator interface
//////////////////////////////////////////////////////////////////////
public Activity getActivity()
public ListView getListView()
{
return this;
ListView view = (ListView)findViewById( android.R.id.list );
return view;
}
public Bundle getArguments()
public void setListAdapter( ListAdapter adapter )
{
getListView().setAdapter( adapter );
}
public ListAdapter getListAdapter()
{
return getIntent().getExtras();
return getListView().getAdapter();
}
}

View file

@ -20,7 +20,6 @@
package org.eehouse.android.xw4;
import android.app.ListActivity;
import android.widget.ListAdapter;
import android.content.Context;
import android.database.DataSetObserver;

View file

@ -20,7 +20,6 @@
package org.eehouse.android.xw4.loc;
import android.app.Activity;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;