replace empty-list-explanation functionality that went away when I

stopped inheriting from ListActivity.
This commit is contained in:
Eric House 2016-01-04 20:40:47 -08:00
parent c62c9899eb
commit eda1e89e3e

View file

@ -27,12 +27,15 @@ import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.view.ViewGroup;
import junit.framework.Assert;
abstract class InviteDelegate extends ListDelegateBase
implements View.OnClickListener {
implements View.OnClickListener,
ViewGroup.OnHierarchyChangeListener {
public static final String DEVS = "DEVS";
public static final String COUNTS = "COUNTS";
@ -43,6 +46,8 @@ abstract class InviteDelegate extends ListDelegateBase
protected Button m_rescanButton;
protected Button m_clearButton;
private Activity m_activity;
private ListView m_lv;
private View m_ev;
public InviteDelegate( Delegator delegator, Bundle savedInstanceState,
int layoutID )
@ -66,9 +71,19 @@ abstract class InviteDelegate extends ListDelegateBase
TextView descView = (TextView)findViewById( desc_id );
descView.setText( descTxt );
m_lv = (ListView)findViewById( android.R.id.list );
m_ev = findViewById( android.R.id.empty );
if ( null != m_lv && null != m_ev ) {
m_lv.setOnHierarchyChangeListener( this );
showEmptyIfEmpty();
}
tryEnable();
}
////////////////////////////////////////
// View.OnClickListener
////////////////////////////////////////
public void onClick( View view )
{
if ( m_okButton == view ) {
@ -87,6 +102,24 @@ abstract class InviteDelegate extends ListDelegateBase
}
}
////////////////////////////////////////
// ViewGroup.OnHierarchyChangeListener
////////////////////////////////////////
public void onChildViewAdded( View parent, View child )
{
showEmptyIfEmpty();
}
public void onChildViewRemoved( View parent, View child )
{
showEmptyIfEmpty();
}
private void showEmptyIfEmpty()
{
m_ev.setVisibility( 0 == m_lv.getChildCount()
? View.VISIBLE : View.GONE );
}
abstract void tryEnable() ;
abstract void listSelected( String[][] devsP, int[][] countsP );
abstract void scan();