@ SuppressWarnings ( "PrimitiveArrayArgumentToVariableArgMethod" ) private void visualizeItem ( @ NonNull final Item item , @ NonNull final ItemViewHolder viewHolder ) { viewHolder . iconImageView . setVisibility ( iconCount > 0 ? View . VISIBLE : View . GONE ) ; viewHolder . iconImageView . setEnabled ( item . isEnabled ( ) ) ; if ( item . getIcon ( ) != null && item . getIcon ( ) instanceof StateListDrawable ) { StateListDrawable stateListDrawable = ( StateListDrawable ) item . getIcon ( ) ; try { int [ ] currentState = viewHolder . iconImageView . getDrawableState ( ) ; Method getStateDrawableIndex = StateListDrawable . class . getMethod ( "getStateDrawableIndex" , int [ ] . class ) ; Method getStateDrawable = StateListDrawable . class . getMethod ( "getStateDrawable" , int . class ) ; int index = ( int ) getStateDrawableIndex . invoke ( stateListDrawable , currentState ) ; Drawable drawable = ( Drawable ) getStateDrawable . invoke ( stateListDrawable , index ) ; viewHolder . iconImageView . setImageDrawable ( drawable ) ; } catch ( Exception e ) { viewHolder . iconImageView . setImageDrawable ( item . getIcon ( ) ) ; } } else { viewHolder . iconImageView . setImageDrawable ( item . getIcon ( ) ) ; } viewHolder . titleTextView . setText ( item . getTitle ( ) ) ; viewHolder . titleTextView . setEnabled ( item . isEnabled ( ) ) ; if ( getItemColor ( ) != - 1 ) { viewHolder . titleTextView . setTextColor ( getItemColor ( ) ) ; } }
Visualizes a specific item .