From ab06ac11ec20949be31d8e3348444fa18debcd13 Mon Sep 17 00:00:00 2001 From: 09370458 Date: Thu, 19 Mar 2020 15:34:37 +0300 Subject: [PATCH] -Added fourth of shape, name is GLASS. --- .idea/gradle.xml | 4 + .idea/modules.xml | 2 +- build.gradle | 4 +- gradle/wrapper/gradle-wrapper.properties | 4 +- .../waveloadingview/WaveLoadingView.java | 75 ++++++++++++++++++- 5 files changed, 84 insertions(+), 5 deletions(-) diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 903e3d4..74c96df 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -3,6 +3,9 @@ diff --git a/.idea/modules.xml b/.idea/modules.xml index e157815..ec827b2 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,7 @@ - + diff --git a/build.gradle b/build.gradle index 834079b..8daba25 100644 --- a/build.gradle +++ b/build.gradle @@ -3,9 +3,10 @@ buildscript { repositories { jcenter() + google() } dependencies { - classpath 'com.android.tools.build:gradle:3.0.0' + classpath 'com.android.tools.build:gradle:3.5.0' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' // NOTE: Do not place your application dependencies here; they belong @@ -16,6 +17,7 @@ buildscript { allprojects { repositories { jcenter() + google() } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f671e45..6eb6b86 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Nov 20 15:20:33 CST 2017 +#Thu Mar 19 15:26:18 EET 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/library/src/main/java/me/itangqi/waveloadingview/WaveLoadingView.java b/library/src/main/java/me/itangqi/waveloadingview/WaveLoadingView.java index eb00138..fafdcc3 100755 --- a/library/src/main/java/me/itangqi/waveloadingview/WaveLoadingView.java +++ b/library/src/main/java/me/itangqi/waveloadingview/WaveLoadingView.java @@ -65,7 +65,8 @@ public enum ShapeType { TRIANGLE, CIRCLE, SQUARE, - RECTANGLE + RECTANGLE, + GLASS } public enum TriangleDirection { @@ -324,6 +325,26 @@ public void onDraw(Canvas canvas) { } } break; + case 4: + if (mIsRoundRectangle) { + if (borderWidth > 0) { + canvas.drawPath(roundedRect(borderWidth / 2f,0,getWidth() - borderWidth / 2f - 0.5f,getHeight() - borderWidth / 2f - 0.5f,mRoundRectangleXY,mRoundRectangleXY,false,false,true,true), mBorderPaint); + canvas.drawPath(roundedRect(borderWidth + 10,0,getWidth()-(borderWidth + 10),getHeight()-(borderWidth + 10),mRoundRectangleXY,mRoundRectangleXY,false,false,true,true), mWaveBgPaint); + canvas.drawPath(roundedRect(borderWidth + 10,0,getWidth()-(borderWidth + 10),getHeight()-(borderWidth + 10),mRoundRectangleXY,mRoundRectangleXY,false,false,true,true), mWavePaint); + } else { + canvas.drawPath(roundedRect(0,0,getWidth(),getHeight(),mRoundRectangleXY,mRoundRectangleXY,false,false,true,true), mWaveBgPaint); + canvas.drawPath(roundedRect(0,0,getWidth(),getHeight(),mRoundRectangleXY,mRoundRectangleXY,false,false,true,true), mWavePaint); + } + } else { + if (borderWidth > 0) { + canvas.drawRect(borderWidth / 2f, borderWidth / 2f, getWidth() - borderWidth / 2f - 0.5f, getHeight() - borderWidth / 2f - 0.5f, mWaveBgPaint); + canvas.drawRect(borderWidth / 2f, borderWidth / 2f, getWidth() - borderWidth / 2f - 0.5f, getHeight() - borderWidth / 2f - 0.5f, mWavePaint); + } else { + canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), mWaveBgPaint); + canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), mWavePaint); + } + } + break; default: break; } @@ -836,4 +857,56 @@ else if (direction == 3) { return path; } + + public static Path roundedRect( + float left, float top, float right, float bottom, float rx, float ry, + boolean tl, boolean tr, boolean br, boolean bl + ){ + Path path = new Path(); + if (rx < 0) rx = 0; + if (ry < 0) ry = 0; + float width = right - left; + float height = bottom - top; + if (rx > width / 2) rx = width / 2; + if (ry > height / 2) ry = height / 2; + float widthMinusCorners = (width - (2 * rx)); + float heightMinusCorners = (height - (2 * ry)); + + path.moveTo(right, top + ry); + if (tr) + path.rQuadTo(0, -ry, -rx, -ry);//top-right corner + else{ + path.rLineTo(0, -ry); + path.rLineTo(-rx,0); + } + path.rLineTo(-widthMinusCorners, 0); + if (tl) + path.rQuadTo(-rx, 0, -rx, ry); //top-left corner + else{ + path.rLineTo(-rx, 0); + path.rLineTo(0,ry); + } + path.rLineTo(0, heightMinusCorners); + + if (bl) + path.rQuadTo(0, ry, rx, ry);//bottom-left corner + else{ + path.rLineTo(0, ry); + path.rLineTo(rx,0); + } + + path.rLineTo(widthMinusCorners, 0); + if (br) + path.rQuadTo(rx, 0, rx, -ry); //bottom-right corner + else{ + path.rLineTo(rx,0); + path.rLineTo(0, -ry); + } + + path.rLineTo(0, -heightMinusCorners); + + path.close();//Given close, last lineto can be removed. + + return path; + } }