@@ -416,6 +416,11 @@ public class ProtocolAdapter extends BaseAdapter implements SpinnerAdapter {
416416 private List <Port > mOpenPorts = null ;
417417 private ArrayList <String > mProtocols = null ;
418418
419+ private class Holder {
420+ public TextView textView ;
421+ public String protocol ;
422+ }
423+
419424 public ProtocolAdapter () {
420425 mOpenPorts = System .getCurrentTarget ().getOpenPorts ();
421426 mProtocols = new ArrayList <String >(Arrays .asList (PROTOCOLS ));
@@ -500,24 +505,36 @@ public long getItemId(int position) {
500505 }
501506
502507 public View getView (int position , View convertView , ViewGroup parent ) {
503- LayoutInflater inflater = ( LayoutInflater ) LoginCracker . this
504- . getSystemService ( Context . LAYOUT_INFLATER_SERVICE ) ;
508+ View spinView = convertView ;
509+ Holder holder ;
505510
506- View spinView = inflater .inflate (
507- android .R .layout .simple_spinner_item , null );
508- TextView textView = (TextView ) (spinView != null ? spinView
509- .findViewById (android .R .id .text1 ) : null );
511+ if (spinView == null ) {
512+ LayoutInflater inflater = (LayoutInflater ) LoginCracker .this
513+ .getSystemService (Context .LAYOUT_INFLATER_SERVICE );
510514
511- String sProtocol = mProtocols . get ( position );
515+ holder = new Holder ( );
512516
513- if ( textView != null )
514- textView . setText ( sProtocol );
517+ spinView = inflater . inflate (
518+ android . R . layout . simple_spinner_item , parent , false );
515519
516- if (hasProtocolOpenPort (sProtocol )) {
517- if (textView != null ) {
518- textView .setTextColor (Color .GREEN );
519- textView .setTypeface (null , Typeface .BOLD );
520- }
520+ holder .textView = (TextView ) (spinView != null ? spinView
521+ .findViewById (android .R .id .text1 ) : null );
522+
523+ holder .protocol = mProtocols .get (position );
524+
525+ if (holder .textView != null )
526+ holder .textView .setText (holder .protocol );
527+
528+ if (spinView != null )
529+ spinView .setTag (holder );
530+
531+ } else {
532+ holder = (Holder ) spinView .getTag ();
533+ }
534+
535+ if (hasProtocolOpenPort (holder .protocol ) && holder .textView != null ) {
536+ holder .textView .setTextColor (Color .GREEN );
537+ holder .textView .setTypeface (null , Typeface .BOLD );
521538 }
522539
523540 return spinView ;
0 commit comments