    protected void dispatchDraw(Canvas canvas) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
            scrollChanged(getFirstVisiblePosition());
        }
        boolean drawStickiedHeader = mStickiedHeader != null
                && mAreHeadersSticky
                && mStickiedHeader.getVisibility() == View.VISIBLE;
        int headerHeight = getHeaderHeight();
        int top = mHeaderBottomPosition - headerHeight;
        if (drawStickiedHeader && mMaskStickyHeaderRegion) {
            mClippingRect.left = getPaddingLeft();
            mClippingRect.right = getWidth() - getPaddingRight();
            mClippingRect.top = mHeaderBottomPosition;
            mClippingRect.bottom = getHeight();
            canvas.save();
            canvas.clipRect(mClippingRect);
        }
        super.dispatchDraw(canvas);
        List<Integer> headerPositions = new ArrayList<Integer>();
        int vi = 0;
        for (int i = getFirstVisiblePosition(); i <= getLastVisiblePosition();) {
            long id = getItemIdAtPosition(i);
            if (id == StickyGridHeadersBaseAdapterWrapper.ID_HEADER) {
                headerPositions.add(vi);
            }
            i += mNumMeasuredColumns;
            vi += mNumMeasuredColumns;
        }
        for (int i = 0; i < headerPositions.size(); i++) {
            ReferenceView frame = (ReferenceView)getChildAt(headerPositions
                    .get(i));
            View header;
            try {
                header = (View)frame.getTag();
            } catch (Exception e) {
                return;
            }
            boolean headerIsStickied = ((HeaderFillerView)frame.getChildAt(0))
                    .getHeaderId() == mCurrentHeaderId
                    && frame.getTop() <= 0
                    && mAreHeadersSticky;
            if (header.getVisibility() != View.VISIBLE || headerIsStickied) {
                continue;
            }
            int widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth(),
                    MeasureSpec.EXACTLY - getPaddingLeft() - getPaddingRight());
            int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0,
                    MeasureSpec.UNSPECIFIED);
            header.measure(widthMeasureSpec, heightMeasureSpec);
            header.layout(getLeft() + getPaddingLeft(), 0, getRight()
                    - getPaddingRight(), frame.getHeight());
            mClippingRect.left = getPaddingLeft();
            mClippingRect.right = getWidth() - getPaddingRight();
            mClippingRect.bottom = frame.getBottom();
            mClippingRect.top = frame.getTop();
            canvas.save();
            canvas.clipRect(mClippingRect);
            canvas.translate(getPaddingLeft(), frame.getTop());
            header.draw(canvas);
            canvas.restore();
        }
        if (drawStickiedHeader && mMaskStickyHeaderRegion) {
            canvas.restore();
        } else if (!drawStickiedHeader) {
            return;
        }
        if (mStickiedHeader.getWidth() != getWidth() - getPaddingLeft()
                - getPaddingRight()) {
            int widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth(),
                    MeasureSpec.EXACTLY - getPaddingLeft() - getPaddingRight());
            int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0,
                    MeasureSpec.UNSPECIFIED);
            mStickiedHeader.measure(widthMeasureSpec, heightMeasureSpec);
            mStickiedHeader.layout(getLeft() + getPaddingLeft(), 0, getRight()
                    - getPaddingRight(), mStickiedHeader.getHeight());
        }
        mClippingRect.left = getPaddingLeft();
        mClippingRect.right = getWidth() - getPaddingRight();
        mClippingRect.bottom = top + headerHeight;
        if (mClippingToPadding) {
            mClippingRect.top = getPaddingTop();
        } else {
            mClippingRect.top = 0;
        }
        canvas.save();
        canvas.clipRect(mClippingRect);
        canvas.translate(getPaddingLeft(), top);
        canvas.saveLayerAlpha(0, 0, canvas.getWidth(), canvas.getHeight(),
                (int)(0xff * (float)mHeaderBottomPosition / headerHeight),
                Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);
        mStickiedHeader.draw(canvas);
        canvas.restore();
        canvas.restore();
    }

    protected void dispatchDraw(Canvas canvas) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
            scrollChanged(getFirstVisiblePosition());
        }
        boolean drawStickiedHeader = mStickiedHeader != null
                && mAreHeadersSticky
                && mStickiedHeader.getVisibility() == View.VISIBLE;
        int headerHeight = getHeaderHeight();
        int top = mHeaderBottomPosition - headerHeight;
        if (drawStickiedHeader && mMaskStickyHeaderRegion) {
            mClippingRect.left = getPaddingLeft();
            mClippingRect.right = getWidth() - getPaddingRight();
            mClippingRect.top = mHeaderBottomPosition;
            mClippingRect.bottom = getHeight();
            canvas.save();
            canvas.clipRect(mClippingRect);
        }
        super.dispatchDraw(canvas);
        List<Integer> headerPositions = new ArrayList<Integer>();
        int vi = 0;
        for (int i = getFirstVisiblePosition(); i <= getLastVisiblePosition();) {
            long id = getItemIdAtPosition(i);
            if (id == StickyGridHeadersBaseAdapterWrapper.ID_HEADER) {
                headerPositions.add(vi);
            }
            i += mNumMeasuredColumns;
            vi += mNumMeasuredColumns;
        }
        for (int i = 0; i < headerPositions.size(); i++) {
            ReferenceView frame = (ReferenceView)getChildAt(headerPositions
                    .get(i));
            View header;
            try {
                header = (View)frame.getTag();
            } catch (Exception e) {
                return;
            }
            boolean headerIsStickied = ((HeaderFillerView)frame.getChildAt(0))
                    .getHeaderId() == mCurrentHeaderId
                    && frame.getTop() < 0
                    && mAreHeadersSticky;
            if (header.getVisibility() != View.VISIBLE || headerIsStickied) {
                continue;
            }
            int widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth(),
                    MeasureSpec.EXACTLY - getPaddingLeft() - getPaddingRight());
            int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0,
                    MeasureSpec.UNSPECIFIED);
            header.measure(widthMeasureSpec, heightMeasureSpec);
            header.layout(getLeft() + getPaddingLeft(), 0, getRight()
                    - getPaddingRight(), frame.getHeight());
            mClippingRect.left = getPaddingLeft();
            mClippingRect.right = getWidth() - getPaddingRight();
            mClippingRect.bottom = frame.getBottom();
            mClippingRect.top = frame.getTop();
            canvas.save();
            canvas.clipRect(mClippingRect);
            canvas.translate(getPaddingLeft(), frame.getTop());
            header.draw(canvas);
            canvas.restore();
        }
        if (drawStickiedHeader && mMaskStickyHeaderRegion) {
            canvas.restore();
        } else if (!drawStickiedHeader) {
            return;
        }
        if (mStickiedHeader.getWidth() != getWidth() - getPaddingLeft()
                - getPaddingRight()) {
            int widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth(),
                    MeasureSpec.EXACTLY - getPaddingLeft() - getPaddingRight());
            int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0,
                    MeasureSpec.UNSPECIFIED);
            mStickiedHeader.measure(widthMeasureSpec, heightMeasureSpec);
            mStickiedHeader.layout(getLeft() + getPaddingLeft(), 0, getRight()
                    - getPaddingRight(), mStickiedHeader.getHeight());
        }
        mClippingRect.left = getPaddingLeft();
        mClippingRect.right = getWidth() - getPaddingRight();
        mClippingRect.bottom = top + headerHeight;
        if (mClippingToPadding) {
            mClippingRect.top = getPaddingTop();
        } else {
            mClippingRect.top = 0;
        }
        canvas.save();
        canvas.clipRect(mClippingRect);
        canvas.translate(getPaddingLeft(), top);
        canvas.saveLayerAlpha(0, 0, canvas.getWidth(), canvas.getHeight(),
                (int)(0xff * (float)mHeaderBottomPosition / headerHeight),
                Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);
        mStickiedHeader.draw(canvas);
        canvas.restore();
        canvas.restore();
    }
