-
Notifications
You must be signed in to change notification settings - Fork 540
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2、add setBorder setBadgeBackground method
- Loading branch information
Showing
8 changed files
with
280 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<solid android:color="#ff03a9f4" /> | ||
<corners android:radius="2dp" /> | ||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,4 @@ | |
package="q.rorbin.badgeview"> | ||
|
||
<application /> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
/** | ||
* @author chqiu | ||
* Email:[email protected] | ||
* 隐藏动画,动画参考自https://github.com/tyrantgit/ExplosionField | ||
* Animation borrowed from https://github.com/tyrantgit/ExplosionField | ||
*/ | ||
|
||
public class BadgeAnimator extends ValueAnimator { | ||
|
68 changes: 68 additions & 0 deletions
68
badgeviewlib/src/main/java/q/rorbin/badgeview/MathUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package q.rorbin.badgeview; | ||
|
||
import android.graphics.PointF; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by chqiu on 2017/3/20. | ||
*/ | ||
|
||
public class MathUtil { | ||
public static final double CIRCLE_RADIAN = 2 * Math.PI; | ||
|
||
public static double getTanRadian(double atan, int quadrant) { | ||
if (atan < 0) { | ||
atan += CIRCLE_RADIAN / 4; | ||
} | ||
atan += CIRCLE_RADIAN / 4 * (quadrant - 1); | ||
return atan; | ||
} | ||
|
||
public static double radianToAngle(double radian) { | ||
return 360 * (radian / CIRCLE_RADIAN); | ||
} | ||
|
||
public static int getQuadrant(PointF p, PointF center) { | ||
if (p.x > center.x) { | ||
if (p.y > center.y) { | ||
return 4; | ||
} else if (p.y < center.y) { | ||
return 1; | ||
} | ||
} else if (p.x < center.x) { | ||
if (p.y > center.y) { | ||
return 3; | ||
} else if (p.y < center.y) { | ||
return 2; | ||
} | ||
} | ||
return -1; | ||
} | ||
|
||
public static float getPointDistance(PointF p1, PointF p2) { | ||
return (float) Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2)); | ||
} | ||
|
||
/** | ||
* this formula is designed by mabeijianxi | ||
* website : http://blog.csdn.net/mabeijianxi/article/details/50560361 | ||
* | ||
* @param circleCenter The circle center point. | ||
* @param radius The circle radius. | ||
* @param slopeLine The slope of line which cross the pMiddle. | ||
*/ | ||
public static void getInnertangentPoints(PointF circleCenter, float radius, Double slopeLine, List<PointF> points) { | ||
float radian, xOffset, yOffset; | ||
if (slopeLine != null) { | ||
radian = (float) Math.atan(slopeLine); | ||
xOffset = (float) (Math.cos(radian) * radius); | ||
yOffset = (float) (Math.sin(radian) * radius); | ||
} else { | ||
xOffset = radius; | ||
yOffset = 0; | ||
} | ||
points.add(new PointF(circleCenter.x + xOffset, circleCenter.y + yOffset)); | ||
points.add(new PointF(circleCenter.x - xOffset, circleCenter.y - yOffset)); | ||
} | ||
} |
Oops, something went wrong.