use of android.graphics.PathEffect in project UltimateAndroid by cymcsg.
the class DiscrollvablePathLayout method onDraw.
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
makeAndMeasurePath();
if (!isInEditMode()) {
// Apply the dash effect
float length = mPathMeasure.getLength();
PathEffect effect = new DashPathEffect(new float[] { length, length }, length * (1 - mRatio));
mPaint.setPathEffect(effect);
}
canvas.drawPath(mPath, mPaint);
}
use of android.graphics.PathEffect in project assertj-android by square.
the class AbstractPaintAssert method hasPathEffect.
public S hasPathEffect(PathEffect effect) {
isNotNull();
PathEffect actualEffect = actual.getPathEffect();
//
assertThat(actualEffect).overridingErrorMessage("Expected path effect <%s> but was <%s>.", effect, //
actualEffect).isSameAs(effect);
return myself;
}
use of android.graphics.PathEffect in project RecyclerViewDecoration by arjinmc.
the class RecyclerViewItemDecoration method drawVertical.
/**
* draw vertival decoration
*
* @param c
* @param parent
*/
private void drawVertical(Canvas c, RecyclerView parent) {
int childrenCount = parent.getChildCount();
if (mDrawableRid != 0) {
if (mFirstLineVisible) {
View childView = parent.getChildAt(0);
if (!isIgnoreType(parent.getAdapter().getItemViewType(parent.getChildLayoutPosition(childView)))) {
int myX = childView.getLeft();
if (hasNinePatch) {
Rect rect = new Rect(myX - mCurrentThickness, mPaddingStart, myX, parent.getHeight() - mPaddingEnd);
mNinePatch.draw(c, rect);
} else {
c.drawBitmap(mBmp, myX - mCurrentThickness, mPaddingStart, mPaint);
}
}
}
for (int i = 0; i < childrenCount; i++) {
if (!mLastLineVisible && i == childrenCount - 1)
break;
View childView = parent.getChildAt(i);
if (!isIgnoreType(parent.getAdapter().getItemViewType(parent.getChildLayoutPosition(childView)))) {
int myX = childView.getRight();
if (hasNinePatch) {
Rect rect = new Rect(myX, mPaddingStart, myX + mCurrentThickness, parent.getHeight() - mPaddingEnd);
mNinePatch.draw(c, rect);
} else {
c.drawBitmap(mBmp, myX, mPaddingStart, mPaint);
}
}
}
} else {
boolean isPureLine = isPureLine();
if (!isPureLine) {
PathEffect effects = new DashPathEffect(new float[] { 0, 0, mDashWidth, mThickness }, mDashGap);
mPaint.setPathEffect(effects);
}
if (mFirstLineVisible) {
View childView = parent.getChildAt(0);
if (!isIgnoreType(parent.getAdapter().getItemViewType(parent.getChildLayoutPosition(childView)))) {
int myX = childView.getLeft() - mThickness / 2;
Path path = new Path();
path.moveTo(myX, mPaddingStart);
path.lineTo(myX, parent.getHeight() - mPaddingEnd);
c.drawPath(path, mPaint);
}
}
for (int i = 0; i < childrenCount; i++) {
if (!mLastLineVisible && i == childrenCount - 1)
break;
View childView = parent.getChildAt(i);
if (!isIgnoreType(parent.getAdapter().getItemViewType(parent.getChildLayoutPosition(childView)))) {
int myX = childView.getRight() + mThickness / 2;
Path path = new Path();
path.moveTo(myX, mPaddingStart);
path.lineTo(myX, parent.getHeight() - mPaddingEnd);
c.drawPath(path, mPaint);
}
}
}
}
use of android.graphics.PathEffect in project RecyclerViewDecoration by arjinmc.
the class RecyclerViewItemDecoration method drawHorizontal.
/**
* draw horizontal decoration
*
* @param c
* @param parent
*/
private void drawHorizontal(Canvas c, RecyclerView parent) {
int childrenCount = parent.getChildCount();
if (mDrawableRid != 0) {
if (mFirstLineVisible) {
View childView = parent.getChildAt(0);
int myY = childView.getTop();
if (!isIgnoreType(parent.getAdapter().getItemViewType(parent.getChildLayoutPosition(childView)))) {
if (hasNinePatch) {
Rect rect = new Rect(mPaddingStart, myY - mCurrentThickness, parent.getWidth() - mPaddingEnd, myY);
mNinePatch.draw(c, rect);
} else {
c.drawBitmap(mBmp, mPaddingStart, myY - mCurrentThickness, mPaint);
}
}
}
for (int i = 0; i < childrenCount; i++) {
if (!mLastLineVisible && i == childrenCount - 1)
break;
View childView = parent.getChildAt(i);
if (!isIgnoreType(parent.getAdapter().getItemViewType(parent.getChildLayoutPosition(childView)))) {
int myY = childView.getBottom();
if (hasNinePatch) {
Rect rect = new Rect(mPaddingStart, myY, parent.getWidth() - mPaddingEnd, myY + mCurrentThickness);
mNinePatch.draw(c, rect);
} else {
c.drawBitmap(mBmp, mPaddingStart, myY, mPaint);
}
}
}
} else {
boolean isPureLine = isPureLine();
if (!isPureLine) {
PathEffect effects = new DashPathEffect(new float[] { 0, 0, mDashWidth, mThickness }, mDashGap);
mPaint.setPathEffect(effects);
}
if (mFirstLineVisible) {
View childView = parent.getChildAt(0);
if (!isIgnoreType(parent.getAdapter().getItemViewType(parent.getChildLayoutPosition(childView)))) {
int myY = childView.getTop() - mThickness / 2;
Path path = new Path();
path.moveTo(mPaddingStart, myY);
path.lineTo(parent.getWidth() - mPaddingEnd, myY);
c.drawPath(path, mPaint);
}
}
for (int i = 0; i < childrenCount; i++) {
if (!mLastLineVisible && i == childrenCount - 1)
break;
View childView = parent.getChildAt(i);
if (!isIgnoreType(parent.getAdapter().getItemViewType(parent.getChildLayoutPosition(childView)))) {
int myY = childView.getBottom() + mThickness / 2;
Path path = new Path();
path.moveTo(mPaddingStart, myY);
path.lineTo(parent.getWidth() - mPaddingEnd, myY);
c.drawPath(path, mPaint);
}
}
}
}
use of android.graphics.PathEffect in project YhLibraryForAndroid by android-coco.
the class LineChartView method setAnim.
// 设置动画
private void setAnim(Canvas canvas) {
PathMeasure measure = new PathMeasure(mPath, false);
float pathLength = measure.getLength();
PathEffect effect = new DashPathEffect(new float[] { pathLength, pathLength }, pathLength - pathLength * mProgress);
mPaintLine.setPathEffect(effect);
canvas.drawPath(mPath, mPaintLine);
}
Aggregations