Thanks Mark,
I knew it had to be simpler. I've turfed all the Spannable stuff ...almost
flawless now. Only one slight stutter on fast fling. Next stop is addressing
nested layout in the row xml ...
if( w.state.equalsIgnoreCase( Tasks.STATE_READ ))
{
w.getStepName().setTypeface( Typeface.DEFAULT );
w.getInstructions().setTypeface( Typeface.DEFAULT );
....
}
else
{
w.getStepName().setTypeface( Typeface.DEFAULT_BOLD );
w.getInstructions().setTypeface( Typeface.DEFAULT_BOLD );
....
}
On Wed, Jun 30, 2010 at 10:47 AM, Mark Murphy <[email protected]>wrote:
> 1. w.getInstructions().setTextColor( 0xFFBDBEBD ); appears to be the
> same in both branches of your if(), meaning it probably does not need
> to be called every time.
>
> 2. Create private data members for new StyleSpan( Typeface.NORMAL )
> and new StyleSpan( Typeface.BOLD ) and reference those data members,
> rather than creating new instances every time.
>
> 3. If s and i are TextViews, skip the Spannable stuff and just call
> setTypeface() (using cached normal and bold Typeface objects)
>
> On Wed, Jun 30, 2010 at 10:29 AM, Connick <[email protected]> wrote:
> > Ever since I added conditional text formatting on my list items I've
> noticed
> > a performance drop. It's still usable but I'm somewhat obsessive about
> > performance/experience so I would really like to tweak my approach as
> best I
> > can. The following snippet is how I'm achieving my conditional
> formatting.
> > Is this the only way? (Perf drop appears to be related to making
> TextViews
> > spannable)
> >
> > if( w.state.equalsIgnoreCase( Tasks.STATE_READ ))
> > {
> > s.setSpan( new StyleSpan( Typeface.NORMAL ), 0, s.length(),
> > Spannable.SPAN_EXCLUSIVE_EXCLUSIVE );
> > i.setSpan( new StyleSpan( Typeface.NORMAL ), 0, i.length(),
> > Spannable.SPAN_EXCLUSIVE_EXCLUSIVE );
> >
> > w.getInstructions().setTextColor( 0xFFBDBEBD );
> > w.getDeadline().setTextColor( 0xFFBDBEBD );
> > }
> > else
> > {
> > s.setSpan( new StyleSpan( Typeface.BOLD ), 0, s.length(),
> > Spannable.SPAN_EXCLUSIVE_EXCLUSIVE );
> > i.setSpan( new StyleSpan( Typeface.BOLD ), 0, i.length(),
> > Spannable.SPAN_EXCLUSIVE_EXCLUSIVE );
> >
> > w.getInstructions().setTextColor( 0xFFBDBEBD );
> > w.getDeadline().setTextColor( 0xFFFFFFFF );
> > }
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://github.com/commonsguy
> http://commonsware.com/blog | http://twitter.com/commonsguy
>
> Android Training...At Your Office: http://commonsware.com/training
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en