Search in sources :

Example 1 with PathEffect

use of android.graphics.PathEffect in project UltimateAndroid by cymcsg.

the class HomeDiagram method drawBrokenLine.

/**
	 * 绘制折线
	 * 
	 * @param c
	 */
public void drawBrokenLine(Canvas c) {
    int index = 0;
    float temp_x = 0;
    float temp_y = 0;
    float base = (getHeight() - tb * 3.0f) / (Collections.max(milliliter) - Collections.min(milliliter));
    Shader mShader = new LinearGradient(0, 0, 0, getHeight(), new int[] { Color.argb(100, 0, 255, 255), Color.argb(45, 0, 255, 255), Color.argb(10, 0, 255, 255) }, null, Shader.TileMode.CLAMP);
    framPanint.setShader(mShader);
    for (int i = 0; i < milliliter.size() - 1; i++) {
        float x1 = interval_left_right * i;
        float y1 = getHeight() - tb * 1.5f - (base * milliliter.get(i));
        float x2 = interval_left_right * (i + 1);
        float y2 = getHeight() - tb * 1.5f - (base * milliliter.get(i + 1));
        if ((int) (base * milliliter.get(i + 1)) == 0 && index == 0) {
            index++;
            temp_x = x1;
            temp_y = y1;
        }
        if ((int) (base * milliliter.get(i + 1)) != 0 && index != 0) {
            index = 0;
            x1 = temp_x;
            y1 = temp_y;
        }
        if (index == 0) {
            c.drawLine(x1, y1, x2, y2, paint_brokenLine);
            path.lineTo(x1, y1);
            if (i != 0)
                c.drawBitmap(bitmap_point, x1 - bitmap_point.getWidth() / 2, y1 - bitmap_point.getHeight() / 2, null);
            if (i == milliliter.size() - 2) {
                path.lineTo(x2, y2);
                path.lineTo(x2, getHeight());
                path.lineTo(0, getHeight());
                path.close();
                c.drawPath(path, framPanint);
                c.drawBitmap(bitmap_point, x2 - bitmap_point.getWidth() / 2, y2 - bitmap_point.getHeight() / 2, null);
            }
        }
    }
    paint_dottedline.setColor(orangeLineColor);
    Path path = new Path();
    path.moveTo(0, getHeight() - tb * 6.5f);
    path.lineTo(getWidth(), getHeight() - tb * 6.5f);
    PathEffect effects = new DashPathEffect(new float[] { tb * 0.3f, tb * 0.3f, tb * 0.3f, tb * 0.3f }, tb * 0.1f);
    paint_dottedline.setPathEffect(effects);
    c.drawPath(path, paint_dottedline);
}
Also used : Path(android.graphics.Path) LinearGradient(android.graphics.LinearGradient) DashPathEffect(android.graphics.DashPathEffect) PathEffect(android.graphics.PathEffect) DashPathEffect(android.graphics.DashPathEffect) Shader(android.graphics.Shader) Paint(android.graphics.Paint)

Example 2 with PathEffect

use of android.graphics.PathEffect in project Osmand by osmandapp.

the class OsmandRenderer method getOneWayPaints.

public Paint[] getOneWayPaints(RenderingContext rc) {
    if (rc.oneWay == null) {
        float rmin = rc.getDensityValue(1);
        if (rmin > 1) {
            rmin = rmin * 2 / 3;
        }
        PathEffect arrowDashEffect1 = new DashPathEffect(new float[] { 0, 12, 10 * rmin, 152 }, 0);
        PathEffect arrowDashEffect2 = new DashPathEffect(new float[] { 0, 12, 9 * rmin, 152 + rmin }, 1);
        PathEffect arrowDashEffect3 = new DashPathEffect(new float[] { 0, 12 + 6 * rmin, 2 * rmin, 152 + 2 * rmin }, 1);
        PathEffect arrowDashEffect4 = new DashPathEffect(new float[] { 0, 12 + 6 * rmin, 1 * rmin, 152 + 3 * rmin }, 1);
        rc.oneWay = new Paint[4];
        rc.oneWay[0] = oneWayPaint();
        rc.oneWay[0].setStrokeWidth(rmin);
        rc.oneWay[0].setPathEffect(arrowDashEffect1);
        rc.oneWay[1] = oneWayPaint();
        rc.oneWay[1].setStrokeWidth(rmin * 2);
        rc.oneWay[1].setPathEffect(arrowDashEffect2);
        rc.oneWay[2] = oneWayPaint();
        rc.oneWay[2].setStrokeWidth(rmin * 3);
        rc.oneWay[2].setPathEffect(arrowDashEffect3);
        rc.oneWay[3] = oneWayPaint();
        rc.oneWay[3].setStrokeWidth(rmin * 4);
        rc.oneWay[3].setPathEffect(arrowDashEffect4);
    }
    return rc.oneWay;
}
Also used : DashPathEffect(android.graphics.DashPathEffect) PathEffect(android.graphics.PathEffect) DashPathEffect(android.graphics.DashPathEffect)

Example 3 with PathEffect

use of android.graphics.PathEffect in project Osmand by osmandapp.

the class OsmandRenderer method getReverseOneWayPaints.

public Paint[] getReverseOneWayPaints(RenderingContext rc) {
    if (rc.reverseOneWay == null) {
        int rmin = (int) rc.getDensityValue(1);
        if (rmin > 2) {
            rmin = rmin / 2;
        }
        PathEffect arrowDashEffect1 = new DashPathEffect(new float[] { 0, 12, 10 * rmin, 152 }, 0);
        PathEffect arrowDashEffect2 = new DashPathEffect(new float[] { 0, 12 + rmin, 9 * rmin, 152 }, 1);
        PathEffect arrowDashEffect3 = new DashPathEffect(new float[] { 0, 12 + 2 * rmin, 2 * rmin, 152 + 6 * rmin }, 1);
        PathEffect arrowDashEffect4 = new DashPathEffect(new float[] { 0, 12 + 3 * rmin, 1 * rmin, 152 + 6 * rmin }, 1);
        rc.reverseOneWay = new Paint[4];
        rc.reverseOneWay[0] = oneWayPaint();
        rc.reverseOneWay[0].setStrokeWidth(rmin * 2);
        rc.reverseOneWay[0].setPathEffect(arrowDashEffect1);
        rc.reverseOneWay[1] = oneWayPaint();
        rc.reverseOneWay[1].setStrokeWidth(rmin);
        rc.reverseOneWay[1].setPathEffect(arrowDashEffect2);
        rc.reverseOneWay[2] = oneWayPaint();
        rc.reverseOneWay[2].setStrokeWidth(rmin * 3);
        rc.reverseOneWay[2].setPathEffect(arrowDashEffect3);
        rc.reverseOneWay[3] = oneWayPaint();
        rc.reverseOneWay[3].setStrokeWidth(rmin * 4);
        rc.reverseOneWay[3].setPathEffect(arrowDashEffect4);
    }
    return rc.reverseOneWay;
}
Also used : DashPathEffect(android.graphics.DashPathEffect) PathEffect(android.graphics.PathEffect) DashPathEffect(android.graphics.DashPathEffect) Paint(android.graphics.Paint)

Example 4 with PathEffect

use of android.graphics.PathEffect in project Virtualview-Android by alibaba.

the class VirtualLine method onParseValueFinished.

@Override
public void onParseValueFinished() {
    super.onParseValueFinished();
    mPaint.setStrokeWidth(mLineWidth);
    mPaint.setColor(mLineColor);
    switch(mStyle) {
        case LineBaseCommon.STYLE_DASH:
            if (mPath == null) {
                mPath = new Path();
            }
            mPath.reset();
            mPaint.setStyle(Paint.Style.STROKE);
            PathEffect effects = new DashPathEffect(mDashEffect, 1);
            mPaint.setPathEffect(effects);
            break;
        case LineBaseCommon.STYLE_SOLID:
            mPaint.setStyle(Paint.Style.FILL);
            break;
        default:
            break;
    }
}
Also used : Path(android.graphics.Path) DashPathEffect(android.graphics.DashPathEffect) PathEffect(android.graphics.PathEffect) DashPathEffect(android.graphics.DashPathEffect)

Example 5 with PathEffect

use of android.graphics.PathEffect in project RecyclerViewDecoration by arjinmc.

the class RecyclerViewItemDecoration method drawGrid.

/**
 * draw grid decoration
 *
 * @param c
 * @param parent
 */
private void drawGrid(Canvas c, RecyclerView parent) {
    int childrenCount = parent.getChildCount();
    int columnSize = ((GridLayoutManager) parent.getLayoutManager()).getSpanCount();
    int itemSize = parent.getAdapter().getItemCount();
    if (mDrawableRid != 0) {
        mPaint.setStrokeWidth(mThickness);
        for (int i = 0; i < childrenCount; i++) {
            View childView = parent.getChildAt(i);
            int myT = childView.getTop();
            int myB = childView.getBottom();
            int myL = childView.getLeft();
            int myR = childView.getRight();
            int viewPosition = parent.getChildLayoutPosition(childView);
            // when columnSize/spanCount is One
            if (columnSize == 1) {
                if (isFirstGridRow(viewPosition, columnSize)) {
                    if (mGridLeftVisible) {
                        if (hasNinePatch) {
                            Rect rect = new Rect(myL - mThickness, myT, myL, myB);
                            mNinePatch.draw(c, rect);
                        } else {
                            c.drawBitmap(mBmp, myL - mThickness, myT, mPaint);
                        }
                    }
                    if (mGridTopVisible) {
                        if (hasNinePatch) {
                            Rect rect = new Rect(myL - mThickness, myT - mThickness, myR + mThickness, myT);
                            mNinePatch.draw(c, rect);
                        } else {
                            c.drawBitmap(mBmp, myL - mThickness, myT - mThickness, mPaint);
                        }
                    }
                    if (mGridRightVisible) {
                        if (hasNinePatch) {
                            Rect rect = new Rect(myR, myT, myR + mThickness, myB);
                            mNinePatch.draw(c, rect);
                        } else {
                            c.drawBitmap(mBmp, myR, myT, mPaint);
                        }
                    }
                // not first row
                } else {
                    if (mGridLeftVisible) {
                        if (hasNinePatch) {
                            Rect rect = new Rect(myL - mThickness, myT - mThickness, myL, myB);
                            mNinePatch.draw(c, rect);
                        } else {
                            c.drawBitmap(mBmp, myL - mThickness, myT - mThickness, mPaint);
                        }
                    }
                    if (mGridRightVisible) {
                        if (hasNinePatch) {
                            Rect rect = new Rect(myR, myT - mThickness, myR + mThickness, myB);
                            mNinePatch.draw(c, rect);
                        } else {
                            c.drawBitmap(mBmp, myR, myT - mThickness, mPaint);
                        }
                    }
                }
                if (isLastGridRow(viewPosition, itemSize, columnSize)) {
                    if (mGridBottomVisible) {
                        if (hasNinePatch) {
                            Rect rect = new Rect(myL - mThickness, myB, myR + mThickness, myB + mThickness);
                            mNinePatch.draw(c, rect);
                        } else {
                            c.drawBitmap(mBmp, myL - mThickness, myB, mPaint);
                        }
                    }
                } else {
                    if (hasNinePatch) {
                        Rect rect = new Rect(myL, myB, myR + mThickness, myB + mThickness);
                        mNinePatch.draw(c, rect);
                    } else {
                        c.drawBitmap(mBmp, myL, myB, mPaint);
                    }
                }
            // when columnSize/spanCount is Not One
            } else {
                if (isFirstGridColumn(viewPosition, columnSize) && isFirstGridRow(viewPosition, columnSize)) {
                    if (mGridLeftVisible) {
                        if (hasNinePatch) {
                            Rect rect = new Rect(myL - mThickness, myT - mThickness, myL, myB);
                            mNinePatch.draw(c, rect);
                        } else {
                            c.drawBitmap(mBmp, myL - mThickness, myT - mThickness, mPaint);
                        }
                    }
                    if (mGridTopVisible) {
                        if (hasNinePatch) {
                            Rect rect = new Rect(myL, myT - mThickness, myR, myT);
                            mNinePatch.draw(c, rect);
                        } else {
                            c.drawBitmap(mBmp, myL, myT - mThickness, mPaint);
                        }
                    }
                    if (itemSize == 1) {
                        if (mGridRightVisible) {
                            if (hasNinePatch) {
                                Rect rect = new Rect(myR, myT - mThickness, myR + mThickness, myB);
                                mNinePatch.draw(c, rect);
                            } else {
                                c.drawBitmap(mBmp, myR, myT - mThickness, mPaint);
                            }
                        }
                    } else {
                        if (hasNinePatch) {
                            Rect rect = new Rect(myR, myT - mThickness, myR + mThickness, myB);
                            mNinePatch.draw(c, rect);
                        } else {
                            c.drawBitmap(mBmp, myR, myT - mThickness, mPaint);
                        }
                    }
                } else if (isFirstGridRow(viewPosition, columnSize)) {
                    if (mGridTopVisible) {
                        if (hasNinePatch) {
                            Rect rect = new Rect(myL, myT - mThickness, myR, myT);
                            mNinePatch.draw(c, rect);
                        } else {
                            c.drawBitmap(mBmp, myL, myT - mThickness, mPaint);
                        }
                    }
                    if (isLastGridColumn(viewPosition, itemSize, columnSize)) {
                        if (mGridRightVisible) {
                            if (hasNinePatch) {
                                Rect rect = new Rect(myR, myT - mThickness, myR + mThickness, myB);
                                mNinePatch.draw(c, rect);
                            } else {
                                c.drawBitmap(mBmp, myR, myT - mThickness, mPaint);
                            }
                        }
                    } else {
                        if (hasNinePatch) {
                            Rect rect = new Rect(myR, myT - mThickness, myR + mThickness, myB);
                            mNinePatch.draw(c, rect);
                        } else {
                            c.drawBitmap(mBmp, myR, myT - mBmp.getHeight(), mPaint);
                        }
                    }
                } else if (isFirstGridColumn(viewPosition, columnSize)) {
                    if (mGridLeftVisible) {
                        if (hasNinePatch) {
                            Rect rect = new Rect(myL - mThickness, myT, myL, myB);
                            mNinePatch.draw(c, rect);
                        } else {
                            c.drawBitmap(mBmp, myL - mThickness, myT, mPaint);
                        }
                    }
                    if (hasNinePatch) {
                        Rect rect = new Rect(myR, myT, myR + mThickness, myB);
                        mNinePatch.draw(c, rect);
                    } else {
                        c.drawBitmap(mBmp, myR, myT, mPaint);
                    }
                } else {
                    if (isLastGridColumn(viewPosition, itemSize, columnSize)) {
                        if (mGridRightVisible) {
                            if (hasNinePatch) {
                                Rect rect = new Rect(myR, myT - mThickness, myR + mThickness, myB);
                                mNinePatch.draw(c, rect);
                            } else {
                                c.drawBitmap(mBmp, myR, myT - mBmp.getHeight(), mPaint);
                            }
                        }
                    } else {
                        if (hasNinePatch) {
                            Rect rect = new Rect(myR, myT, myR + mThickness, myB);
                            mNinePatch.draw(c, rect);
                        } else {
                            c.drawBitmap(mBmp, myR, myT, mPaint);
                        }
                    }
                }
                // bottom line
                if (isLastGridRow(viewPosition, itemSize, columnSize)) {
                    if (mGridBottomVisible) {
                        if (itemSize == 1) {
                            if (hasNinePatch) {
                                Rect rect = new Rect(myL - mThickness, myB, myR + mThickness, myB + mThickness);
                                mNinePatch.draw(c, rect);
                            } else {
                                c.drawBitmap(mBmp, myL - mThickness, myB, mPaint);
                            }
                        } else if (isLastGridColumn(viewPosition, itemSize, columnSize)) {
                            if (hasNinePatch) {
                                Rect rect = new Rect(myL - mThickness, myB, myR + mThickness, myB + mThickness);
                                mNinePatch.draw(c, rect);
                            } else {
                                c.drawBitmap(mBmp, myL - mThickness, myB + mThickness / 2, mPaint);
                            }
                        } else {
                            if (hasNinePatch) {
                                Rect rect = new Rect(myL - mThickness, myB, myR + (mGridHorizontalSpacing == 0 ? mThickness : mGridHorizontalSpacing), myB + mThickness);
                                mNinePatch.draw(c, rect);
                            } else {
                                c.drawBitmap(mBmp, myL - mThickness, myB, mPaint);
                            }
                        }
                    }
                } else {
                    if (hasNinePatch) {
                        Rect rect = new Rect(myL - mThickness, myB, myR, myB + (mGridVerticalSpacing == 0 ? mThickness : mGridVerticalSpacing));
                        mNinePatch.draw(c, rect);
                    } else {
                        c.drawBitmap(mBmp, myL - mBmp.getWidth(), myB, mPaint);
                    }
                }
            }
        }
    } else {
        if (!isPureLine()) {
            PathEffect effects = new DashPathEffect(new float[] { 0, 0, mDashWidth, mThickness }, mDashGap);
            mPaint.setPathEffect(effects);
        }
        for (int i = 0; i < childrenCount; i++) {
            View childView = parent.getChildAt(i);
            int myT = childView.getTop();
            int myB = childView.getBottom();
            int myL = childView.getLeft();
            int myR = childView.getRight();
            int viewPosition = parent.getChildLayoutPosition(childView);
            // when columnSize/spanCount is One
            if (columnSize == 1) {
                if (isFirstGridRow(viewPosition, columnSize)) {
                    if (mGridLeftVisible) {
                        mPaint.setStrokeWidth(mThickness);
                        Path path = new Path();
                        path.moveTo(myL - mThickness / 2, myT);
                        path.lineTo(myL - mThickness / 2, myB);
                        c.drawPath(path, mPaint);
                    }
                    if (mGridTopVisible) {
                        mPaint.setStrokeWidth(mThickness);
                        Path path = new Path();
                        path.moveTo(myL - mThickness, myT - mThickness / 2);
                        path.lineTo(myR + mThickness, myT - mThickness / 2);
                        c.drawPath(path, mPaint);
                    }
                    if (mGridRightVisible) {
                        mPaint.setStrokeWidth(mThickness);
                        Path path = new Path();
                        path.moveTo(myR + mThickness / 2, myT);
                        path.lineTo(myR + mThickness / 2, myB);
                        c.drawPath(path, mPaint);
                    }
                // not first row
                } else {
                    if (mGridLeftVisible) {
                        mPaint.setStrokeWidth(mThickness);
                        Path path = new Path();
                        path.moveTo(myL - mThickness / 2, myT - (mGridVerticalSpacing == 0 ? mThickness : mGridVerticalSpacing));
                        path.lineTo(myL - mThickness / 2, myB);
                        c.drawPath(path, mPaint);
                    }
                    if (mGridRightVisible) {
                        Path path = new Path();
                        mPaint.setStrokeWidth(mThickness);
                        path.moveTo(myR + mThickness / 2, myT);
                        path.lineTo(myR + mThickness / 2, myB);
                        c.drawPath(path, mPaint);
                    }
                }
                if (isLastGridRow(viewPosition, itemSize, columnSize)) {
                    if (mGridBottomVisible) {
                        mPaint.setStrokeWidth(mThickness);
                        Path path = new Path();
                        path.moveTo(myL - mThickness, myB + mThickness / 2);
                        path.lineTo(myR + mThickness, myB + mThickness / 2);
                        c.drawPath(path, mPaint);
                    }
                } else {
                    mPaint.setStrokeWidth(mThickness);
                    if (mGridVerticalSpacing != 0) {
                        mPaint.setStrokeWidth(mGridVerticalSpacing);
                    }
                    Path path = new Path();
                    path.moveTo(myL, myB + (mGridVerticalSpacing == 0 ? mThickness : mGridVerticalSpacing) / 2);
                    path.lineTo(myR + mThickness, myB + (mGridVerticalSpacing == 0 ? mThickness : mGridVerticalSpacing) / 2);
                    c.drawPath(path, mPaint);
                }
            // when columnSize/spanCount is Not One
            } else {
                if (isFirstGridColumn(viewPosition, columnSize) && isFirstGridRow(viewPosition, columnSize)) {
                    if (mGridLeftVisible) {
                        mPaint.setStrokeWidth(mThickness);
                        Path path = new Path();
                        path.moveTo(myL - mThickness / 2, myT - mThickness);
                        path.lineTo(myL - mThickness / 2, myB);
                        c.drawPath(path, mPaint);
                    }
                    if (mGridTopVisible) {
                        mPaint.setStrokeWidth(mThickness);
                        Path path = new Path();
                        path.moveTo(myL, myT - mThickness / 2);
                        path.lineTo(myR, myT - mThickness / 2);
                        c.drawPath(path, mPaint);
                    }
                    if (itemSize == 1) {
                        if (mGridRightVisible) {
                            mPaint.setStrokeWidth(mThickness);
                            Path path = new Path();
                            path.moveTo(myR + mThickness / 2, myT - mThickness);
                            path.lineTo(myR + mThickness / 2, myB);
                            c.drawPath(path, mPaint);
                        }
                    } else {
                        mPaint.setStrokeWidth(mThickness);
                        if (mGridHorizontalSpacing != 0) {
                            mPaint.setStrokeWidth(mGridHorizontalSpacing);
                        }
                        Path path = new Path();
                        path.moveTo(myR + (mGridHorizontalSpacing == 0 ? mThickness : mGridHorizontalSpacing) / 2, myT - mThickness);
                        path.lineTo(myR + (mGridHorizontalSpacing == 0 ? mThickness : mGridHorizontalSpacing) / 2, myB);
                        c.drawPath(path, mPaint);
                    }
                } else if (isFirstGridRow(viewPosition, columnSize)) {
                    if (mGridTopVisible) {
                        mPaint.setStrokeWidth(mThickness);
                        Path path = new Path();
                        path.moveTo(myL, myT - mThickness / 2);
                        path.lineTo(myR, myT - mThickness / 2);
                        c.drawPath(path, mPaint);
                    }
                    if (isLastGridColumn(viewPosition, itemSize, columnSize)) {
                        mPaint.setStrokeWidth(mThickness);
                        if (mGridRightVisible) {
                            int alterY = 0;
                            if (isLastSecondGridRowNotDivided(viewPosition, itemSize, columnSize)) {
                                alterY = (mGridVerticalSpacing == 0 ? mThickness : mGridVerticalSpacing);
                            }
                            Path path = new Path();
                            path.moveTo(myR + mThickness / 2, myT - mThickness);
                            path.lineTo(myR + mThickness / 2, myB + alterY);
                            c.drawPath(path, mPaint);
                        }
                    } else {
                        if (mGridHorizontalSpacing != 0) {
                            mPaint.setStrokeWidth(mGridHorizontalSpacing);
                        }
                        Path path = new Path();
                        path.moveTo(myR + (mGridHorizontalSpacing == 0 ? mThickness : mGridHorizontalSpacing) / 2, myT - mThickness);
                        path.lineTo(myR + (mGridHorizontalSpacing == 0 ? mThickness : mGridHorizontalSpacing) / 2, myB);
                        c.drawPath(path, mPaint);
                    }
                } else if (isFirstGridColumn(viewPosition, columnSize)) {
                    if (mGridLeftVisible) {
                        mPaint.setStrokeWidth(mThickness);
                        Path path = new Path();
                        path.moveTo(myL - mThickness / 2, myT);
                        path.lineTo(myL - mThickness / 2, myB);
                        c.drawPath(path, mPaint);
                    }
                    mPaint.setStrokeWidth(mThickness);
                    if (mGridHorizontalSpacing != 0) {
                        mPaint.setStrokeWidth(mGridHorizontalSpacing);
                    }
                    Path path = new Path();
                    path.moveTo(myR + (mGridHorizontalSpacing == 0 ? mThickness : mGridHorizontalSpacing) / 2, myT);
                    path.lineTo(myR + (mGridHorizontalSpacing == 0 ? mThickness : mGridHorizontalSpacing) / 2, myB);
                    c.drawPath(path, mPaint);
                } else {
                    mPaint.setStrokeWidth(mThickness);
                    if (isLastGridColumn(viewPosition, itemSize, columnSize)) {
                        if (mGridRightVisible) {
                            int alterY = 0;
                            if (isLastSecondGridRowNotDivided(viewPosition, itemSize, columnSize)) {
                                alterY = (mGridVerticalSpacing == 0 ? mThickness : mGridVerticalSpacing);
                            }
                            Path path = new Path();
                            path.moveTo(myR + mThickness / 2, myT - (mGridVerticalSpacing == 0 ? mThickness : mGridVerticalSpacing));
                            path.lineTo(myR + mThickness / 2, myB + alterY);
                            c.drawPath(path, mPaint);
                        }
                    } else {
                        if (mGridHorizontalSpacing != 0) {
                            mPaint.setStrokeWidth(mGridHorizontalSpacing);
                        }
                        Path path = new Path();
                        path.moveTo(myR + (mGridHorizontalSpacing == 0 ? mThickness : mGridHorizontalSpacing) / 2, myT);
                        path.lineTo(myR + (mGridHorizontalSpacing == 0 ? mThickness : mGridHorizontalSpacing) / 2, myB);
                        c.drawPath(path, mPaint);
                    }
                }
                // bottom line
                if (isLastGridRow(viewPosition, itemSize, columnSize)) {
                    if (mGridBottomVisible) {
                        mPaint.setStrokeWidth(mThickness);
                        if (itemSize == 1) {
                            Path path = new Path();
                            path.moveTo(myL - mThickness, myB + mThickness / 2);
                            path.lineTo(myR + mThickness, myB + mThickness / 2);
                            c.drawPath(path, mPaint);
                        } else if (isLastGridColumn(viewPosition, itemSize, columnSize)) {
                            Path path = new Path();
                            path.moveTo(myL - (mGridHorizontalSpacing == 0 ? mThickness : mGridHorizontalSpacing), myB + mThickness / 2);
                            path.lineTo(myR + mThickness, myB + mThickness / 2);
                            c.drawPath(path, mPaint);
                        } else {
                            Path path = new Path();
                            path.moveTo(myL - (mGridHorizontalSpacing == 0 ? mThickness : mGridHorizontalSpacing), myB + mThickness / 2);
                            path.lineTo(myR + (mGridHorizontalSpacing == 0 ? mThickness : mGridHorizontalSpacing), myB + mThickness / 2);
                            c.drawPath(path, mPaint);
                        }
                    }
                } else {
                    mPaint.setStrokeWidth(mThickness);
                    if (mGridVerticalSpacing != 0) {
                        mPaint.setStrokeWidth(mGridVerticalSpacing);
                    }
                    Path path = new Path();
                    path.moveTo(myL - (mGridHorizontalSpacing == 0 ? mThickness : mGridHorizontalSpacing), myB + (mGridVerticalSpacing == 0 ? mThickness : mGridVerticalSpacing) / 2);
                    path.lineTo(myR, myB + (mGridVerticalSpacing == 0 ? mThickness : mGridVerticalSpacing) / 2);
                    c.drawPath(path, mPaint);
                }
            }
        }
    }
}
Also used : Path(android.graphics.Path) Rect(android.graphics.Rect) GridLayoutManager(android.support.v7.widget.GridLayoutManager) DashPathEffect(android.graphics.DashPathEffect) PathEffect(android.graphics.PathEffect) DashPathEffect(android.graphics.DashPathEffect) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) Paint(android.graphics.Paint)

Aggregations

PathEffect (android.graphics.PathEffect)15 DashPathEffect (android.graphics.DashPathEffect)14 Paint (android.graphics.Paint)6 Path (android.graphics.Path)6 Rect (android.graphics.Rect)3 RecyclerView (android.support.v7.widget.RecyclerView)3 View (android.view.View)3 Cap (android.graphics.Paint.Cap)2 Join (android.graphics.Paint.Join)2 Style (android.graphics.Paint.Style)2 BasicStroke (org.achartengine.renderer.BasicStroke)2 LinearGradient (android.graphics.LinearGradient)1 PathMeasure (android.graphics.PathMeasure)1 Shader (android.graphics.Shader)1 GridLayoutManager (android.support.v7.widget.GridLayoutManager)1