FileDocCategorySizeDatePackage
Ticker.javaAPI DocAndroid 1.5 API7919Wed May 06 22:42:00 BST 2009com.android.server.status

Ticker

public abstract class Ticker extends Object

Fields Summary
private static final int
TICKER_SEGMENT_DELAY
private android.os.Handler
mHandler
private ArrayList
mSegments
private android.text.TextPaint
mPaint
private android.view.View
mTickerView
private android.widget.ImageSwitcher
mIconSwitcher
private android.widget.TextSwitcher
mTextSwitcher
private Runnable
mAdvanceTicker
Constructors Summary
Ticker(android.content.Context context, StatusBarView sb)


        
        mTickerView = sb.findViewById(R.id.ticker);

        mIconSwitcher = (ImageSwitcher)sb.findViewById(R.id.tickerIcon);
        mIconSwitcher.setInAnimation(
                    AnimationUtils.loadAnimation(context, com.android.internal.R.anim.push_up_in));
        mIconSwitcher.setOutAnimation(
                    AnimationUtils.loadAnimation(context, com.android.internal.R.anim.push_up_out));

        mTextSwitcher = (TextSwitcher)sb.findViewById(R.id.tickerText);
        mTextSwitcher.setInAnimation(
                    AnimationUtils.loadAnimation(context, com.android.internal.R.anim.push_up_in));
        mTextSwitcher.setOutAnimation(
                    AnimationUtils.loadAnimation(context, com.android.internal.R.anim.push_up_out));

        // Copy the paint style of one of the TextSwitchers children to use later for measuring
        TextView text = (TextView)mTextSwitcher.getChildAt(0);
        mPaint = text.getPaint();
    
Methods Summary
voidaddEntry(NotificationData n, android.graphics.drawable.Drawable icon, java.lang.CharSequence text)

        int initialCount = mSegments.size();

        Segment newSegment = new Segment(n, icon, text);

        // prune out any preexisting ones for this notification, but not the current one.
        // let that finish, even if it's the same id
        for (int i=1; i<initialCount; i++) {
            Segment seg = mSegments.get(i);
            if (n.id == seg.notificationData.id && n.pkg.equals(seg.notificationData.pkg)) {
                // just update that one to use this new data instead
                mSegments.set(i, newSegment);
                // and since we know initialCount != 0, just return
                return ;
            }
        }

        mSegments.add(newSegment);

        if (initialCount == 0 && mSegments.size() > 0) {
            Segment seg = mSegments.get(0);
            seg.first = false;
            
            mIconSwitcher.setAnimateFirstView(false);
            mIconSwitcher.reset();
            mIconSwitcher.setImageDrawable(seg.icon);
            
            mTextSwitcher.setAnimateFirstView(false);
            mTextSwitcher.reset();
            mTextSwitcher.setText(seg.getText());
            
            tickerStarting();
            scheduleAdvance();
        }
    
voidhalt()

        mHandler.removeCallbacks(mAdvanceTicker);
        mSegments.clear();
        tickerHalting();
    
voidreflowText()

        if (mSegments.size() > 0) {
            Segment seg = mSegments.get(0);
            CharSequence text = seg.getText();
            mTextSwitcher.setCurrentText(text);
        }
    
private voidscheduleAdvance()


       
        mHandler.postDelayed(mAdvanceTicker, TICKER_SEGMENT_DELAY);
    
abstract voidtickerDone()

abstract voidtickerHalting()

abstract voidtickerStarting()