Java Code Examples for android.graphics.Outline#setConvexPath()
The following examples show how to use
android.graphics.Outline#setConvexPath() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShapeOfView.java From ShapeOfView with Apache License 2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public ViewOutlineProvider getOutlineProvider() { return new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { if (clipManager != null && !isInEditMode()) { final Path shadowConvexPath = clipManager.getShadowConvexPath(); if (shadowConvexPath != null) { try { outline.setConvexPath(shadowConvexPath); } catch (Exception e) { e.printStackTrace(); } } } } }; }
Example 2
Source File: JellyLayout.java From JellyRefreshLayout with MIT License | 6 votes |
private void init() { setWillNotDraw(false); mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setStyle(Paint.Style.FILL); mPath = new Path(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mViewOutlineProvider = new ViewOutlineProvider() { @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @Override public void getOutline(View view, Outline outline) { if (mPath.isConvex()) outline.setConvexPath(mPath); } }; } }
Example 3
Source File: ObliqueView.java From Oblique with Apache License 2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public ViewOutlineProvider getOutlineProvider() { shadowpath = new Path(); if (config.getRadius() == 0) { shadowpath = path; } else { rect = new Rect(0, 0, (int) width, (int) height); RectF r = new RectF(rect); shadowpath.addRoundRect(r, config.getRadius(), config.getRadius(), Path.Direction.CCW); shadowpath.op(path, shadowpath, Path.Op.INTERSECT); } return new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { if (path.isConvex()) { outline.setConvexPath(shadowpath); } } }; }
Example 4
Source File: ShapeOfView.java From ArcLayout with Apache License 2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public ViewOutlineProvider getOutlineProvider() { return new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { if (clipManager != null) { final Path shadowConvexPath = clipManager.getShadowConvexPath(); if (shadowConvexPath != null) { try { outline.setConvexPath(shadowConvexPath); } catch (Exception e) { e.printStackTrace(); } } } } }; }
Example 5
Source File: ShapeOfView.java From DiagonalLayout with Apache License 2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public ViewOutlineProvider getOutlineProvider() { return new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { if (clipManager != null) { final Path shadowConvexPath = clipManager.getShadowConvexPath(); if (shadowConvexPath != null) { try { outline.setConvexPath(shadowConvexPath); } catch (Exception e) { e.printStackTrace(); } } } } }; }
Example 6
Source File: MaterialShapeDrawable.java From material-components-android with Apache License 2.0 | 6 votes |
@TargetApi(VERSION_CODES.LOLLIPOP) @Override public void getOutline(@NonNull Outline outline) { if (drawableState.shadowCompatMode == SHADOW_COMPAT_MODE_ALWAYS) { // Don't draw the native shadow if we're always rendering with compat shadow. return; } if (isRoundRect()) { float radius = getTopLeftCornerResolvedSize() * drawableState.interpolation; outline.setRoundRect(getBounds(), radius); return; } calculatePath(getBoundsAsRectF(), path); if (path.isConvex() || Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { try { outline.setConvexPath(path); } catch (IllegalArgumentException ignored) { // The change to support concave paths was done late in the release cycle. People // using pre-releases of Q would experience a crash here. } } }
Example 7
Source File: BorderDrawable.java From material-components-android with Apache License 2.0 | 6 votes |
@TargetApi(VERSION_CODES.LOLLIPOP) @Override public void getOutline(@NonNull Outline outline) { if (shapeAppearanceModel.isRoundRect(getBoundsAsRectF())) { float radius = shapeAppearanceModel.getTopLeftCornerSize().getCornerSize(getBoundsAsRectF()); outline.setRoundRect(getBounds(), radius); return; } copyBounds(rect); rectF.set(rect); pathProvider.calculatePath(shapeAppearanceModel, 1f, rectF, shapePath); if (shapePath.isConvex()) { outline.setConvexPath(shapePath); } }
Example 8
Source File: ClipDrawable.java From ProjectX with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void getOutline(@SuppressWarnings("NullableProblems") Outline outline) { if (mProvider == null || mOutlinePath.isEmpty() || !mOutlinePath.isConvex()) { super.getOutline(outline); return; } outline.setConvexPath(mOutlinePath); outline.setAlpha(1); }
Example 9
Source File: Md2PopupBackground.java From AndroidFastScroll with Apache License 2.0 | 5 votes |
@Override public void getOutline(@NonNull Outline outline) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q && !mPath.isConvex()) { // The outline path must be convex before Q, but we may run into floating point error // caused by calculation involving sqrt(2) or OEM implementation difference, so in this // case we just omit the shadow instead of crashing. super.getOutline(outline); return; } outline.setConvexPath(mPath); }
Example 10
Source File: CornerDrawable.java From ProjectX with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void getOutline(Outline outline) { if (mPath.isEmpty() || !mPath.isConvex()) { super.getOutline(outline); return; } final int[] state = getState(); final int fillColor = DrawableHelper.getColor(mFillColor, state, mAlpha); final int strokeColor = DrawableHelper.getColor(mStrokeColor, state, mAlpha); final int alpha = Math.max(Color.alpha(fillColor), Color.alpha(strokeColor)); outline.setConvexPath(mPath); outline.setAlpha(alpha / 255f); }
Example 11
Source File: CustomRoundRectDrawable.java From Slice with Apache License 2.0 | 5 votes |
@Override public void getOutline(Outline outline) { if (buildConvexPath().isConvex()) { outline.setConvexPath(buildConvexPath()); } else { super.getOutline(outline); } }
Example 12
Source File: ArcDrawable.java From ArcLayout with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void getOutline(Outline outline) { if (arcPath == null || !arcPath.isConvex()) { super.getOutline(outline); } else { outline.setConvexPath(arcPath); } }
Example 13
Source File: DiagonalLayout.java From Blackbulb with GNU General Public License v3.0 | 5 votes |
@Override public ViewOutlineProvider getOutlineProvider() { return new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { outline.setConvexPath(outlinePath); } }; }
Example 14
Source File: WXBackgroundDrawable.java From weex with Apache License 2.0 | 5 votes |
@Override public void getOutline(@NonNull Outline outline) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { super.getOutline(outline); } else { if ((!CSSConstants.isUndefined(mBorderRadius) && mBorderRadius > 0) || mBorderCornerRadii != null) { updatePath(); outline.setConvexPath(mPathForBorderRadiusOutline); } else { outline.setRect(getBounds()); } } }
Example 15
Source File: CustomRoundRectDrawable.java From Slice with Apache License 2.0 | 5 votes |
@Override public void getOutline(Outline outline) { if (buildConvexPath().isConvex()) { outline.setConvexPath(buildConvexPath()); } else { super.getOutline(outline); } }
Example 16
Source File: OptRoundRectDrawable.java From OptionRoundCardview with Apache License 2.0 | 5 votes |
@Override public void getOutline(Outline outline) { if (buildConvexPath().isConvex()) { outline.setConvexPath(buildConvexPath()); } else { super.getOutline(outline); } }
Example 17
Source File: BorderDrawable.java From weex-uikit with MIT License | 5 votes |
@Override public void getOutline(@NonNull Outline outline) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (mPathForBorderOutline == null) { mNeedUpdatePath = true; } updateBorderOutline(); outline.setConvexPath(mPathForBorderOutline); } }
Example 18
Source File: BorderDrawable.java From ucar-weex-core with Apache License 2.0 | 5 votes |
@Override public void getOutline(@NonNull Outline outline) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (mPathForBorderOutline == null) { mNeedUpdatePath = true; } updateBorderOutline(); outline.setConvexPath(mPathForBorderOutline); } }
Example 19
Source File: ReactViewBackgroundDrawable.java From react-native-GPay with MIT License | 5 votes |
@Override public void getOutline(Outline outline) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { super.getOutline(outline); return; } if ((!YogaConstants.isUndefined(mBorderRadius) && mBorderRadius > 0) || mBorderCornerRadii != null) { updatePath(); outline.setConvexPath(mPathForBorderRadiusOutline); } else { outline.setRect(getBounds()); } }
Example 20
Source File: TriangleShape.java From LaunchEnr with GNU General Public License v3.0 | 4 votes |
@Override public void getOutline(@NonNull Outline outline) { outline.setConvexPath(mTriangularPath); }