Search in sources :

Example 1 with FolderRingAnimator

use of org.fairphone.launcher.FolderIcon.FolderRingAnimator in project Fairphone by Kwamecorp.

the class CellLayout method onDraw.

@Override
protected void onDraw(Canvas canvas) {
    // backgrounds
    if (mBackgroundAlpha > 0.0f) {
        Drawable bg;
        if (mIsDragOverlapping) {
            // In the mini case, we draw the active_glow bg *over* the active background
            bg = mActiveGlowBackground;
        } else {
            bg = mNormalBackground;
        }
        bg.setAlpha((int) (mBackgroundAlpha * mBackgroundAlphaMultiplier * 255));
        bg.setBounds(mBackgroundRect);
        bg.draw(canvas);
    }
    final Paint paint = mDragOutlinePaint;
    for (int i = 0; i < mDragOutlines.length; i++) {
        final float alpha = mDragOutlineAlphas[i];
        if (alpha > 0) {
            final Rect r = mDragOutlines[i];
            scaleRectAboutCenter(r, temp, getChildrenScale());
            final Bitmap b = (Bitmap) mDragOutlineAnims[i].getTag();
            paint.setAlpha((int) (alpha + .5f));
            canvas.drawBitmap(b, null, temp, paint);
        }
    }
    // requires an expanded clip rect (due to the glow's blur radius)
    if (mPressedOrFocusedIcon != null) {
        final int padding = mPressedOrFocusedIcon.getPressedOrFocusedBackgroundPadding();
        final Bitmap b = mPressedOrFocusedIcon.getPressedOrFocusedBackground();
        if (b != null) {
            canvas.drawBitmap(b, mPressedOrFocusedIcon.getLeft() + getPaddingLeft() - padding, mPressedOrFocusedIcon.getTop() + getPaddingTop() - padding, null);
        }
    }
    if (DEBUG_VISUALIZE_OCCUPIED) {
        int[] pt = new int[2];
        ColorDrawable cd = new ColorDrawable(Color.RED);
        cd.setBounds(0, 0, mCellWidth, mCellHeight);
        for (int i = 0; i < mCountX; i++) {
            for (int j = 0; j < mCountY; j++) {
                if (mOccupied[i][j]) {
                    cellToPoint(i, j, pt);
                    canvas.save();
                    canvas.translate(pt[0], pt[1]);
                    cd.draw(canvas);
                    canvas.restore();
                }
            }
        }
    }
    int previewOffset = FolderRingAnimator.sPreviewSize;
    // The folder outer / inner ring image(s)
    for (int i = 0; i < mFolderOuterRings.size(); i++) {
        FolderRingAnimator fra = mFolderOuterRings.get(i);
        // Draw outer ring
        Drawable d = FolderRingAnimator.sSharedOuterRingDrawable;
        int width = (int) fra.getOuterRingSize();
        int height = width;
        cellToPoint(fra.mCellX, fra.mCellY, mTempLocation);
        int centerX = mTempLocation[0] + mCellWidth / 2;
        int centerY = mTempLocation[1] + previewOffset / 2;
        canvas.save();
        canvas.translate(centerX - width / 2, centerY - height / 2);
        d.setBounds(0, 0, width, height);
        d.draw(canvas);
        canvas.restore();
        // Draw inner ring
        d = FolderRingAnimator.sSharedInnerRingDrawable;
        width = (int) fra.getInnerRingSize();
        height = width;
        cellToPoint(fra.mCellX, fra.mCellY, mTempLocation);
        centerX = mTempLocation[0] + mCellWidth / 2;
        centerY = mTempLocation[1] + previewOffset / 2;
        canvas.save();
        canvas.translate(centerX - width / 2, centerY - width / 2);
        d.setBounds(0, 0, width, height);
        d.draw(canvas);
        canvas.restore();
    }
    if (mFolderLeaveBehindCell[0] >= 0 && mFolderLeaveBehindCell[1] >= 0) {
        Drawable d = FolderIcon.sSharedFolderLeaveBehind;
        int width = d.getIntrinsicWidth();
        int height = d.getIntrinsicHeight();
        cellToPoint(mFolderLeaveBehindCell[0], mFolderLeaveBehindCell[1], mTempLocation);
        int centerX = mTempLocation[0] + mCellWidth / 2;
        int centerY = mTempLocation[1] + previewOffset / 2;
        canvas.save();
        canvas.translate(centerX - width / 2, centerY - width / 2);
        d.setBounds(0, 0, width, height);
        d.draw(canvas);
        canvas.restore();
    }
}
Also used : Rect(android.graphics.Rect) Bitmap(android.graphics.Bitmap) ColorDrawable(android.graphics.drawable.ColorDrawable) FolderRingAnimator(org.fairphone.launcher.FolderIcon.FolderRingAnimator) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable) Paint(android.graphics.Paint) Point(android.graphics.Point) Paint(android.graphics.Paint)

Aggregations

Bitmap (android.graphics.Bitmap)1 Paint (android.graphics.Paint)1 Point (android.graphics.Point)1 Rect (android.graphics.Rect)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1 NinePatchDrawable (android.graphics.drawable.NinePatchDrawable)1 FolderRingAnimator (org.fairphone.launcher.FolderIcon.FolderRingAnimator)1