Make the list of Hybrid App packages searchable.
The comment tag associated with making the list of Hybrid App packages searchable is ANDROID_CUSTOMIZATION_POINT_HYBRIDAPPSEARCH.
<EditText
android:hint="@string/SEARCH_HINT"
android:id="@+id/EditTextSearchHybridAppList"
android:layout_width="match_parent"
android:layout_height="47dp" />
<string name="SEARCH_HINT">search</string>
import android.widget.EditText; import android.text.Editable; import android.text.TextWatcher;
final EditText edittext = (EditText) findViewById(R.id.EditTextSearchHybridAppList);
edittext.addTextChangedListener( new TextWatcher()
{
public void afterTextChanged( Editable s)
{
String sSearchFor = s.toString();
m_adapter.setSearch( sSearchFor );
m_adapter.notifyDataSetChanged();
}
// stubs; have to implement the abstract methods
public void beforeTextChanged( CharSequence s, int start, int count, int after ) {}
public void onTextChanged( CharSequence s, int start, int before, int count) {}
});
String m_sToSearchFor;
m_sToSearchFor = "";
public View getView(int position, View convertView, ViewGroup parent)
{
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = vi.inflate(R.layout.hybridapps, null);
HybridApp oHybridApp = getItem( position );
if( oHybridApp != null )
{
if( m_abDisplayThisApp == null || position >= m_abDisplayThisApp.length || m_abDisplayThisApp[position])
{
ImageView ic = (ImageView) v.findViewById( R.id.hybridApp_icon );
ic.setImageResource( UiIconIndexLookup.getNormalIconIdForIndex( oHybridApp.getIconIndex() ));
TextView tt = (TextView) v.findViewById(R.id.hybridApp_title);
if (tt != null)
{
tt.setText( oHybridApp.getDisplayName());
}
}
else
{
v = vi.inflate(R.layout.emptyview, null);
}
}
return v;
}
public void search()
{
m_abDisplayThisApp = new boolean[m_adapter.getCount()];
for(int index = 0; index < m_adapter.getCount(); index++)
{
int iIndexOfResult = m_adapter.getItem( index ).getDisplayName().indexOf( m_sToSearchFor );
if( iIndexOfResult >= 0 )
{
m_abDisplayThisApp[index] = true;
}
}
}
public void notifyDataSetChanged()
{
search();
super.notifyDataSetChanged();
}
public void setSearch( String sSearchFor )
{
m_sToSearchFor = sSearchFor;
}
private boolean[] m_abDisplayThisApp;