FileDocCategorySizeDatePackage
TaskViewThumbnail.javaAPI DocAndroid 5.1 API9569Thu Mar 12 22:22:42 GMT 2015com.android.systemui.recents.views

TaskViewThumbnail

public class TaskViewThumbnail extends android.view.View
The task thumbnail view. It implements an image view that allows for animating the dim and alpha of the thumbnail image.

Fields Summary
com.android.systemui.recents.RecentsConfiguration
mConfig
float
mDimAlpha
android.graphics.Matrix
mScaleMatrix
android.graphics.Paint
mDrawPaint
android.graphics.RectF
mBitmapRect
android.graphics.RectF
mLayoutRect
android.graphics.BitmapShader
mBitmapShader
android.graphics.LightingColorFilter
mLightingColorFilter
float
mThumbnailAlpha
android.animation.ValueAnimator
mThumbnailAlphaAnimator
ValueAnimator.AnimatorUpdateListener
mThumbnailAlphaUpdateListener
android.view.View
mTaskBar
android.graphics.Rect
mClipRect
boolean
mInvisible
Constructors Summary
public TaskViewThumbnail(android.content.Context context)


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

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

        this(context, attrs, defStyleAttr, 0);
    
public TaskViewThumbnail(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr, int defStyleRes)

        super(context, attrs, defStyleAttr, defStyleRes);
        mConfig = RecentsConfiguration.getInstance();
        mDrawPaint.setColorFilter(mLightingColorFilter);
        mDrawPaint.setFilterBitmap(true);
        mDrawPaint.setAntiAlias(true);
    
Methods Summary
protected voidonDraw(android.graphics.Canvas canvas)

        if (mInvisible) {
            return;
        }
        // Draw the thumbnail with the rounded corners
        canvas.drawRoundRect(0, 0, getWidth(), getHeight(),
                mConfig.taskViewRoundedCornerRadiusPx,
                mConfig.taskViewRoundedCornerRadiusPx, mDrawPaint);
    
protected voidonFinishInflate()

        mThumbnailAlpha = mConfig.taskViewThumbnailAlpha;
        updateThumbnailPaintFilter();
    
voidonFocusChanged(boolean focused)
Handles focus changes.

        if (focused) {
            if (Float.compare(getAlpha(), 1f) != 0) {
                startFadeAnimation(1f, 0, 150, null);
            }
        } else {
            if (Float.compare(getAlpha(), mConfig.taskViewThumbnailAlpha) != 0) {
                startFadeAnimation(mConfig.taskViewThumbnailAlpha, 0, 150, null);
            }
        }
    
protected voidonLayout(boolean changed, int left, int top, int right, int bottom)

        super.onLayout(changed, left, top, right, bottom);
        if (changed) {
            mLayoutRect.set(0, 0, getWidth(), getHeight());
            updateThumbnailScale();
        }
    
voidprepareEnterRecentsAnimation(boolean isTaskViewLaunchTargetTask)
Prepares for the enter recents animation, this gets called before the the view is first visible and will be followed by a startEnterRecentsAnimation() call.

        if (isTaskViewLaunchTargetTask) {
            mThumbnailAlpha = 1f;
        } else {
            mThumbnailAlpha = mConfig.taskViewThumbnailAlpha;
        }
        updateThumbnailPaintFilter();
    
voidrebindToTask(com.android.systemui.recents.model.Task t)
Binds the thumbnail view to the task

        if (t.thumbnail != null) {
            setThumbnail(t.thumbnail);
        } else {
            setThumbnail(null);
        }
    
public voidsetDimAlpha(float dimAlpha)
Sets the dim alpha, only used when we are not using hardware layers. (see RecentsConfiguration.useHardwareLayers)

        mDimAlpha = dimAlpha;
        updateThumbnailPaintFilter();
    
voidsetThumbnail(android.graphics.Bitmap bm)
Sets the thumbnail to a given bitmap.

        if (bm != null) {
            mBitmapShader = new BitmapShader(bm, Shader.TileMode.CLAMP,
                    Shader.TileMode.CLAMP);
            mDrawPaint.setShader(mBitmapShader);
            mBitmapRect.set(0, 0, bm.getWidth(), bm.getHeight());
            updateThumbnailScale();
        } else {
            mBitmapShader = null;
            mDrawPaint.setShader(null);
        }
        updateThumbnailPaintFilter();
    
voidstartEnterRecentsAnimation(int delay, java.lang.Runnable postAnimRunnable)
Animates this task thumbnail as it enters Recents.

        startFadeAnimation(mConfig.taskViewThumbnailAlpha, delay,
                mConfig.taskViewEnterFromAppDuration, postAnimRunnable);
    
voidstartFadeAnimation(float finalAlpha, int delay, int duration, java.lang.Runnable postAnimRunnable)
Starts a new thumbnail alpha animation.

        Utilities.cancelAnimationWithoutCallbacks(mThumbnailAlphaAnimator);
        mThumbnailAlphaAnimator = ValueAnimator.ofFloat(mThumbnailAlpha, finalAlpha);
        mThumbnailAlphaAnimator.setStartDelay(delay);
        mThumbnailAlphaAnimator.setDuration(duration);
        mThumbnailAlphaAnimator.setInterpolator(mConfig.fastOutSlowInInterpolator);
        mThumbnailAlphaAnimator.addUpdateListener(mThumbnailAlphaUpdateListener);
        if (postAnimRunnable != null) {
            mThumbnailAlphaAnimator.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    postAnimRunnable.run();
                }
            });
        }
        mThumbnailAlphaAnimator.start();
    
voidstartLaunchTaskAnimation(java.lang.Runnable postAnimRunnable)
Animates this task thumbnail as it exits Recents.

        startFadeAnimation(1f, 0, mConfig.taskViewExitToAppDuration, postAnimRunnable);
    
voidunbindFromTask()
Unbinds the thumbnail view from the task

        setThumbnail(null);
    
voidupdateClipToTaskBar(android.view.View taskBar)
Updates the clip rect based on the given task bar.

        mTaskBar = taskBar;
        int top = (int) Math.max(0, taskBar.getTranslationY() +
                taskBar.getMeasuredHeight() - 1);
        mClipRect.set(0, top, getMeasuredWidth(), getMeasuredHeight());
        setClipBounds(mClipRect);
    
voidupdateThumbnailPaintFilter()
Updates the paint to draw the thumbnail.

        if (mInvisible) {
            return;
        }
        int mul = (int) ((1.0f - mDimAlpha) * mThumbnailAlpha * 255);
        int add = (int) ((1.0f - mDimAlpha) * (1 - mThumbnailAlpha) * 255);
        if (mBitmapShader != null) {
            mLightingColorFilter.setColorMultiply(Color.argb(255, mul, mul, mul));
            mLightingColorFilter.setColorAdd(Color.argb(0, add, add, add));
            mDrawPaint.setColorFilter(mLightingColorFilter);
            mDrawPaint.setColor(0xffffffff);
        } else {
            int grey = mul + add;
            mDrawPaint.setColorFilter(null);
            mDrawPaint.setColor(Color.argb(255, grey, grey, grey));
        }
        invalidate();
    
voidupdateThumbnailScale()
Updates the thumbnail shader's scale transform.

        if (mBitmapShader != null) {
            mScaleMatrix.setRectToRect(mBitmapRect, mLayoutRect, Matrix.ScaleToFit.FILL);
            mBitmapShader.setLocalMatrix(mScaleMatrix);
        }
    
voidupdateThumbnailVisibility(int clipBottom)
Updates the visibility of the the thumbnail.

        boolean invisible = mTaskBar != null && (getHeight() - clipBottom) <= mTaskBar.getHeight();
        if (invisible != mInvisible) {
            mInvisible = invisible;
            if (!mInvisible) {
                updateThumbnailPaintFilter();
            }
            invalidate();
        }