FileDocCategorySizeDatePackage
SpeechOrbView.javaAPI DocAndroid 5.1 API2712Thu Mar 12 22:22:56 GMT 2015android.support.v17.leanback.widget

SpeechOrbView

public class SpeechOrbView extends SearchOrbView

Fields Summary
private final float
mSoundLevelMaxZoom
private final Colors
mListeningOrbColors
private final Colors
mNotListeningOrbColors
private int
mCurrentLevel
private boolean
mListening
Constructors Summary
public SpeechOrbView(android.content.Context context)


       
        this(context, null);
    
public SpeechOrbView(android.content.Context context, android.util.AttributeSet attrs)

        this(context, attrs, 0);
    
public SpeechOrbView(android.content.Context context, android.util.AttributeSet attrs, int defStyle)

        super(context, attrs, defStyle);

        Resources resources = context.getResources();
        mSoundLevelMaxZoom =
                resources.getFraction(R.fraction.lb_search_bar_speech_orb_max_level_zoom, 1, 1);

        mNotListeningOrbColors = new Colors(resources.getColor(R.color.lb_speech_orb_not_recording),
                resources.getColor(R.color.lb_speech_orb_not_recording_pulsed),
                resources.getColor(R.color.lb_speech_orb_not_recording_icon));
        mListeningOrbColors = new Colors(resources.getColor(R.color.lb_speech_orb_recording),
                resources.getColor(R.color.lb_speech_orb_recording),
                Color.TRANSPARENT);

        showNotListening();
    
Methods Summary
intgetLayoutResourceId()

        return R.layout.lb_speech_orb;
    
public voidsetSoundLevel(int level)

        if (!mListening) return;

        // Either ease towards the target level, or decay away from it depending on whether
        // its higher or lower than the current.
        if (level > mCurrentLevel) {
            mCurrentLevel = mCurrentLevel + ((level - mCurrentLevel) / 2);
        } else {
            mCurrentLevel = (int) (mCurrentLevel * 0.7f);
        }

        float zoom = 1f + (mSoundLevelMaxZoom - getFocusedZoom()) * mCurrentLevel / 100;

        scaleOrbViewOnly(zoom);
    
public voidshowListening()

        setOrbColors(mListeningOrbColors);
        setOrbIcon(getResources().getDrawable(R.drawable.lb_ic_search_mic));
        // Assume focused
        animateOnFocus(true);
        enableOrbColorAnimation(false);
        scaleOrbViewOnly(1f);
        mCurrentLevel = 0;
        mListening = true;
    
public voidshowNotListening()

        setOrbColors(mNotListeningOrbColors);
        setOrbIcon(getResources().getDrawable(R.drawable.lb_ic_search_mic_out));
        animateOnFocus(hasFocus());
        scaleOrbViewOnly(1f);
        mListening = false;