├── .gitattributes
├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── BadgedView.iml
├── BadgedView
├── .gitattributes
├── .gitignore
├── BadgedView-BadgedView.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── github
│ │ └── chaossss
│ │ └── widget
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── github
│ │ │ └── chaossss
│ │ │ └── widget
│ │ │ ├── badge
│ │ │ ├── BaseBadge.java
│ │ │ ├── CircleBadge.java
│ │ │ ├── RecBadge.java
│ │ │ └── TriBadge.java
│ │ │ └── view
│ │ │ ├── BadgedView.java
│ │ │ ├── CircleBadgedView.java
│ │ │ ├── RecBadgedView.java
│ │ │ └── TriBadgedView.java
│ └── res
│ │ └── values
│ │ ├── attrs_badged_view.xml
│ │ ├── attrs_circlebadged_view.xml
│ │ ├── attrs_recbadged_view.xml
│ │ ├── attrs_tribadged_view.xml
│ │ ├── colors.xml
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── github
│ └── chaossss
│ └── widget
│ └── ExampleUnitTest.java
├── README.md
├── README_ENGLISH.md
├── app
├── .gitignore
├── app.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── github
│ │ └── chaossss
│ │ └── badgedview
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── github
│ │ │ └── chaossss
│ │ │ └── badgedview
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ ├── gem.png
│ │ ├── hebe.png
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-v21
│ │ └── styles.xml
│ │ ├── values-w820dp
│ │ ├── colors.xml
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── github
│ └── chaossss
│ └── badgedview
│ └── ExampleUnitTest.java
├── build.gradle
├── example.png
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 | /captures
8 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | BadgedView
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/BadgedView.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/BadgedView/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/BadgedView/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/BadgedView/BadgedView-BadgedView.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/BadgedView/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 | apply plugin: 'com.jfrog.bintray'
4 |
5 | version = "1.1.0"
6 |
7 | android {
8 | compileSdkVersion 23
9 | buildToolsVersion "23.0.2"
10 |
11 | defaultConfig {
12 | minSdkVersion 12
13 | targetSdkVersion 23
14 | versionCode 1
15 | versionName "1.1.0"
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | compile fileTree(dir: 'libs', include: ['*.jar'])
27 | testCompile 'junit:junit:4.12'
28 | compile 'com.android.support:appcompat-v7:23.1.0'
29 | }
30 |
31 | def siteUrl = 'https://github.com/chaossss/BadgedView'
32 | def gitUrl = 'https://github.com/chaossss/BadgedView'
33 | group = "com.github.chaossss"
34 |
35 | install {
36 | repositories.mavenInstaller {
37 | // This generates POM.xml with proper parameters
38 | pom {
39 | project {
40 | packaging 'aar'
41 | // Add your description here
42 | name 'BadgedView allows you show a badge into any View'
43 | url siteUrl
44 | // Set your license
45 | licenses {
46 | license {
47 | name 'The Apache Software License, Version 2.0'
48 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
49 | }
50 | }
51 | developers {
52 | developer {
53 | id 'chaossss'
54 | name 'chaossss'
55 | email '437700255@qq.com'
56 | }
57 | }
58 | scm {
59 | connection gitUrl
60 | developerConnection gitUrl
61 | url siteUrl
62 | }
63 | }
64 | }
65 | }
66 | }
67 |
68 | task sourcesJar(type: Jar) {
69 | from android.sourceSets.main.java.srcDirs
70 | classifier = 'sources'
71 | }
72 | task javadoc(type: Javadoc) {
73 | source = android.sourceSets.main.java.srcDirs
74 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
75 | }
76 | task javadocJar(type: Jar, dependsOn: javadoc) {
77 | classifier = 'javadoc'
78 | from javadoc.destinationDir
79 | }
80 | artifacts {
81 | archives javadocJar
82 | archives sourcesJar
83 | }
84 |
85 | Properties properties = new Properties()
86 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
87 | bintray {
88 | user = properties.getProperty("bintray.user")
89 | key = properties.getProperty("bintray.apikey")
90 | configurations = ['archives']
91 | pkg {
92 | repo = "maven"
93 | name = "BadgedView"
94 | websiteUrl = siteUrl
95 | vcsUrl = gitUrl
96 | licenses = ["Apache-2.0"]
97 | publish = true
98 | }
99 | }
--------------------------------------------------------------------------------
/BadgedView/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\Android\ADT\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/BadgedView/src/androidTest/java/com/github/chaossss/widget/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.github.chaossss.widget;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/BadgedView/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/BadgedView/src/main/java/com/github/chaossss/widget/badge/BaseBadge.java:
--------------------------------------------------------------------------------
1 | package com.github.chaossss.widget.badge;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.Canvas;
6 | import android.graphics.ColorFilter;
7 | import android.graphics.Paint;
8 | import android.graphics.Rect;
9 | import android.graphics.Typeface;
10 | import android.graphics.drawable.Drawable;
11 |
12 | /**
13 | * Class defines what attr Badge owns, and how badge finish its drawing
14 | * Created by chaos on 2015/11/26.
15 | */
16 | public class BaseBadge extends Drawable {
17 | protected static final String TYPEFACE = "sans-serif-black";
18 | protected static final int TYPEFACE_STYLE = Typeface.NORMAL;
19 |
20 | protected int badgePadding;
21 | protected int badgeCornerRadius;
22 |
23 | protected int textSize;
24 | protected int badgeColor;
25 | protected int badgeTextColor;
26 |
27 | protected String badgeText;
28 |
29 | protected Paint paint;
30 | protected Bitmap badge;
31 | protected Context context;
32 |
33 | public BaseBadge(Context context, String badgeText, int badgeColor, int badgeTextColor) {
34 | this.badgeText = badgeText;
35 |
36 | this.badgeColor = badgeColor;
37 | this.badgeTextColor = badgeTextColor;
38 |
39 | paint = new Paint();
40 | this.context = context;
41 | }
42 |
43 | public void setText(String text) {
44 | this.badgeText = text;
45 | }
46 |
47 | public void setCornerRadius(int corner_radius) {
48 | this.badgeCornerRadius = corner_radius;
49 | }
50 |
51 | public void setTextSize(int textSize) {
52 | this.textSize = textSize;
53 | }
54 |
55 | public void setPadding(int padding) {
56 | this.badgePadding = padding;
57 | }
58 |
59 | @Override
60 | public void draw(Canvas canvas) {
61 | }
62 |
63 | public void initBadge(){
64 |
65 | }
66 |
67 | public void reset() {
68 | if(badge != null) {
69 | badge.recycle();
70 | badge = null;
71 | }
72 | }
73 |
74 | @Override
75 | public void setAlpha(int alpha) {
76 | }
77 |
78 | @Override
79 | public void setColorFilter(ColorFilter colorFilter) {
80 | }
81 |
82 | @Override
83 | public int getOpacity() {
84 | return 0;
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/BadgedView/src/main/java/com/github/chaossss/widget/badge/CircleBadge.java:
--------------------------------------------------------------------------------
1 | package com.github.chaossss.widget.badge;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.Canvas;
6 | import android.graphics.Paint;
7 | import android.graphics.Rect;
8 | import android.graphics.Typeface;
9 | import android.text.TextPaint;
10 | import android.util.DisplayMetrics;
11 |
12 | /**
13 | * Created by chaos on 2016/1/6.
14 | */
15 | public class CircleBadge extends BaseBadge {
16 | private static final double MAGIC = 1.732;
17 |
18 | private int radius;
19 | private int center;
20 |
21 | public CircleBadge(Context context, String badgeText, int badgeColor, int badgeTextColor) {
22 | super(context, badgeText, badgeColor, badgeTextColor);
23 | }
24 |
25 | @Override
26 | public void initBadge() {
27 | Paint backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
28 | backgroundPaint.setColor(badgeColor);
29 | backgroundPaint.setStyle(Paint.Style.FILL);
30 |
31 | DisplayMetrics dm = context.getResources().getDisplayMetrics();
32 | float scaledDensity = dm.scaledDensity;
33 |
34 | TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint
35 | .SUBPIXEL_TEXT_FLAG);
36 | textPaint.setTypeface(Typeface.create(TYPEFACE, TYPEFACE_STYLE));
37 | textPaint.setTextSize(textSize * scaledDensity);
38 | textPaint.setTextAlign(Paint.Align.CENTER);
39 | textPaint.setColor(badgeTextColor);
40 |
41 | Rect textBounds = new Rect();
42 | textPaint.getTextBounds(badgeText, 0, badgeText.length(), textBounds);
43 |
44 | if(textBounds.height() > textBounds.width()){
45 | radius = (int)(textBounds.height() / 2 * MAGIC);
46 | } else {
47 | radius = (int)(textBounds.width() / 2 * MAGIC);
48 | }
49 |
50 | badge = Bitmap.createBitmap(radius * 2, radius * 2, Bitmap.Config.ARGB_8888);
51 | badge.setHasAlpha(true);
52 |
53 | Canvas canvas = new Canvas(badge);
54 | canvas.drawCircle(radius, radius, radius, backgroundPaint);
55 | canvas.drawText(badgeText, radius, radius + textBounds.height() / 2, textPaint);
56 | }
57 |
58 | @Override
59 | public void draw(Canvas canvas) {
60 | if(badge == null) {
61 | initBadge();
62 | }
63 | canvas.drawBitmap(badge, getBounds().left, getBounds().top, paint);
64 | }
65 |
66 | @Override
67 | public int getIntrinsicWidth() {
68 | return radius * 2;
69 | }
70 |
71 | @Override
72 | public int getIntrinsicHeight() {
73 | return radius * 2;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/BadgedView/src/main/java/com/github/chaossss/widget/badge/RecBadge.java:
--------------------------------------------------------------------------------
1 | package com.github.chaossss.widget.badge;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.Canvas;
6 | import android.graphics.Paint;
7 | import android.graphics.PorterDuff;
8 | import android.graphics.PorterDuffXfermode;
9 | import android.graphics.Rect;
10 | import android.graphics.Typeface;
11 | import android.os.Build;
12 | import android.text.TextPaint;
13 | import android.util.DisplayMetrics;
14 |
15 | /**
16 | * Badge that draws a rectangle
17 | * Created by chaos on 2015/11/26.
18 | */
19 | public class RecBadge extends BaseBadge {
20 | private int width;
21 | private int height;
22 |
23 | public RecBadge(Context context, String badgeText, int badgeColor, int badgeTextColor) {
24 | super(context, badgeText, badgeColor, badgeTextColor);
25 | }
26 |
27 | @Override
28 | public void initBadge(){
29 | DisplayMetrics dm = context.getResources().getDisplayMetrics();
30 | float density = dm.density;
31 | float scaledDensity = dm.scaledDensity;
32 |
33 | TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint
34 | .SUBPIXEL_TEXT_FLAG);
35 | textPaint.setTypeface(Typeface.create(TYPEFACE, TYPEFACE_STYLE));
36 | textPaint.setTextSize(textSize * scaledDensity);
37 | textPaint.setColor(badgeTextColor);
38 |
39 | float padding = badgePadding * density;
40 | float cornerRadius = badgeCornerRadius * density;
41 |
42 | Rect textBounds = new Rect();
43 | textPaint.getTextBounds(badgeText, 0, badgeText.length(), textBounds);
44 | height = (int) (padding + textBounds.height() + padding);
45 | width = (int) (padding + textBounds.width() + padding);
46 |
47 | badge = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
48 | badge.setHasAlpha(true);
49 |
50 | Canvas canvas = new Canvas(badge);
51 | Paint backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
52 | backgroundPaint.setColor(badgeColor);
53 |
54 | if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP) {
55 | canvas.drawRoundRect(0, 0, width, height, cornerRadius, cornerRadius, backgroundPaint);
56 | }else {
57 | // TODO: 11/21/15 support cornerRadius for api < 21
58 | canvas.drawRect(0, 0, width, height, backgroundPaint);
59 | }
60 |
61 | // punch out the word ,leaving transparency
62 | textPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
63 | canvas.drawText(badgeText, padding, height - padding, textPaint);
64 | }
65 |
66 | @Override
67 | public void draw(Canvas canvas) {
68 | if(badge == null) {
69 | initBadge();
70 | }
71 | canvas.drawBitmap(badge, getBounds().left, getBounds().top, paint);
72 | }
73 |
74 | @Override
75 | public int getIntrinsicWidth() {
76 | return width;
77 | }
78 |
79 | @Override
80 | public int getIntrinsicHeight() {
81 | return height;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/BadgedView/src/main/java/com/github/chaossss/widget/badge/TriBadge.java:
--------------------------------------------------------------------------------
1 | package com.github.chaossss.widget.badge;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.Canvas;
6 | import android.graphics.Paint;
7 | import android.graphics.Path;
8 | import android.graphics.Rect;
9 | import android.graphics.Typeface;
10 | import android.text.TextPaint;
11 | import android.util.DisplayMetrics;
12 |
13 | /**
14 | * Badge that draws a triangle
15 | * Created by chaos on 2015/11/27.
16 | */
17 | public class TriBadge extends BaseBadge {
18 | private static final double SQUARE2 = 1.414;
19 | private static final double SQUARE5 = 2.236;
20 |
21 | public static final int TOPLEFT = 0x00;
22 | public static final int TOPRIGHT = 0x01;
23 | public static final int BOTTMLEFT = 0x10;
24 | public static final int BOTTOMRIGHT = 0x11;
25 |
26 | private int triLength;
27 | private int rootViewWidth;
28 | private int rootViewHeight;
29 | private int tribadgeGravity;
30 |
31 | public TriBadge(Context context, String badgeText, int badgeColor, int badgeTextColor) {
32 | super(context, badgeText, badgeColor, badgeTextColor);
33 | }
34 |
35 | public void setTribadgeGravity(int tribadgeGravity) {
36 | this.tribadgeGravity = tribadgeGravity;
37 | }
38 |
39 | public void setRootViewParam(int rootViewWidth, int rootViewHeight){
40 | this.rootViewWidth = rootViewWidth;
41 | this.rootViewHeight = rootViewHeight;
42 | }
43 |
44 | @Override
45 | public void initBadge() {
46 | Paint backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
47 | backgroundPaint.setColor(badgeColor);
48 | backgroundPaint.setStyle(Paint.Style.FILL);
49 |
50 | DisplayMetrics dm = context.getResources().getDisplayMetrics();
51 | float scaledDensity = dm.scaledDensity;
52 |
53 | TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint
54 | .SUBPIXEL_TEXT_FLAG);
55 | textPaint.setTypeface(Typeface.create(TYPEFACE, TYPEFACE_STYLE));
56 | textPaint.setTextSize(textSize * scaledDensity);
57 | textPaint.setColor(badgeTextColor);
58 |
59 | badge = Bitmap.createBitmap(rootViewWidth, rootViewHeight, Bitmap.Config.ARGB_8888);
60 | badge.setHasAlpha(true);
61 |
62 | Canvas canvas = new Canvas(badge);
63 |
64 | Path path = new Path();
65 | Rect textBounds = new Rect();
66 | textPaint.getTextBounds(badgeText, 0, badgeText.length(), textBounds);
67 |
68 | //Calculates triangle badges's length by the input badgeText's length
69 | triLength = (int)((textBounds.height() / 4 * 7 + textBounds.width() / 2) * SQUARE2);
70 |
71 | drawTribadgePath(canvas, path, backgroundPaint);
72 |
73 | float textYOffset = textBounds.height() / 8 * 11;
74 | //Keep the offset distance
75 | if(tribadgeGravity >> 1 == 0){
76 | textYOffset = -textYOffset / 2;
77 | }
78 | float textXOffset = (float)(triLength * SQUARE2 - textBounds.width()) / 2;
79 |
80 | canvas.drawTextOnPath(badgeText, path, textXOffset, textYOffset, textPaint);
81 | }
82 |
83 | private void drawTribadgePath(Canvas canvas, Path path, Paint backgroundPaint){
84 | switch (tribadgeGravity){
85 | case TOPLEFT:
86 | path.moveTo(0, triLength);
87 | path.lineTo(triLength, 0);
88 | path.lineTo(0, 0);
89 | path.close();
90 | break;
91 |
92 | case TOPRIGHT:
93 | path.moveTo(rootViewWidth - triLength, 0);
94 | path.lineTo(rootViewWidth, triLength);
95 | path.lineTo(rootViewWidth, 0);
96 | path.close();
97 | break;
98 |
99 | case BOTTMLEFT:
100 | path.moveTo(0, rootViewHeight - triLength);
101 | path.lineTo(triLength, rootViewHeight);
102 | path.lineTo(0, rootViewHeight);
103 | path.close();
104 | break;
105 |
106 | case BOTTOMRIGHT:
107 | path.moveTo(rootViewWidth - triLength, rootViewHeight);
108 | path.lineTo(rootViewWidth, rootViewHeight - triLength);
109 | path.lineTo(rootViewWidth, rootViewHeight);
110 | path.close();
111 | break;
112 | }
113 |
114 | canvas.drawPath(path, backgroundPaint);
115 | }
116 |
117 | @Override
118 | public void draw(Canvas canvas) {
119 | if(badge == null) {
120 | initBadge();
121 | }
122 | canvas.drawBitmap(badge, 0, 0, paint);
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/BadgedView/src/main/java/com/github/chaossss/widget/view/BadgedView.java:
--------------------------------------------------------------------------------
1 | package com.github.chaossss.widget.view;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.os.Build;
7 | import android.support.v4.content.ContextCompat;
8 | import android.util.AttributeSet;
9 | import android.view.MotionEvent;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.view.ViewOutlineProvider;
13 |
14 | import com.github.chaossss.widget.R;
15 | import com.github.chaossss.widget.badge.BaseBadge;
16 |
17 | /**
18 | * An extension to {@link ViewGroup} which has a Badge.
19 | * Created by chaos on 2015/11/27.
20 | */
21 | public class BadgedView extends ViewGroup {
22 | protected BaseBadge badge;
23 |
24 | protected boolean drawBadge = false;
25 |
26 | protected int badgeColor;
27 | protected int widthRatio;
28 | protected int heightRatio;
29 | protected int badgePadding;
30 |
31 | protected int badgeTextSize;
32 | protected int badgeTextColor;
33 | protected int badgeCornerRadius;
34 |
35 | protected String badgeText;
36 |
37 | public BadgedView(Context context, AttributeSet attrs) {
38 | super(context, attrs);
39 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BadgedImageView, 0, 0);
40 |
41 | badgePadding = a.getDimensionPixelSize(R.styleable.BadgedImageView_badgePadding, 4);
42 | badgeTextSize = a.getDimensionPixelSize(R.styleable.BadgedImageView_badgeTextSize, 12);
43 | badgeCornerRadius = a.getDimensionPixelSize(R.styleable.BadgedImageView_badgeCornerRadius, 2);
44 |
45 | badgeText = a.getString(R.styleable.BadgedImageView_badgeText);
46 |
47 | badgeColor = a.getColor(R.styleable.BadgedImageView_badgeColor, ContextCompat.getColor(context, R.color.default_badge_color));
48 | badgeTextColor = a.getColor(R.styleable.BadgedImageView_badgeTextColor, ContextCompat.getColor(context, R.color.default_badge_text_color));
49 |
50 | widthRatio = a.getInt(R.styleable.BadgedImageView_badgeWidthRatio, 1);
51 | heightRatio = a.getInt(R.styleable.BadgedImageView_badgeHeightRatio, 1);
52 |
53 | initBadge(context);
54 |
55 | a.recycle();
56 | setWillNotDraw(false);
57 | if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP)
58 | setOutlineProvider(ViewOutlineProvider.BOUNDS);
59 | }
60 |
61 | public void initBadge(Context context) {
62 | badge = new BaseBadge(context, badgeText, badgeColor, badgeTextColor);
63 | badge.setPadding(badgePadding);
64 | badge.setTextSize(badgeTextSize);
65 | badge.setCornerRadius(badgeCornerRadius);
66 | }
67 |
68 | @Override
69 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
70 | int width = getScaleWidth(widthMeasureSpec);
71 | int height = getScaleHeight(heightMeasureSpec);
72 | super.onMeasure(width, height);
73 | measureChildren(width, height);
74 | }
75 |
76 | @Override
77 | protected void onLayout(boolean changed, int l, int t, int r, int b) {
78 | for(int i = 0; i < getChildCount(); i++) {
79 | View child = getChildAt(i);
80 | LayoutParams lp = child.getLayoutParams();
81 | child.layout(lp.width, lp.height, lp.width + child.getMeasuredWidth(), lp.height + child.getMeasuredHeight());
82 | }
83 | }
84 |
85 | private int getScaleWidth(int widthMeasureSpec){
86 | return !isScaleWidth() ? widthMeasureSpec : MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec) * widthRatio / heightRatio,
87 | MeasureSpec.EXACTLY);
88 | }
89 |
90 | private int getScaleHeight(int heightMeasureSpec){
91 | return isScaleWidth() ? heightMeasureSpec : MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec) * heightRatio / widthRatio,
92 | MeasureSpec.EXACTLY);
93 | }
94 |
95 | private boolean isScaleWidth() {
96 | return widthRatio / heightRatio < 1;
97 | }
98 |
99 | public void showBadge(boolean show) {
100 | drawBadge = show;
101 | invalidate();
102 | }
103 |
104 | public void setBadgeText(String newText) {
105 | badge.setText(newText);
106 | badge.reset();
107 | invalidate();
108 | }
109 |
110 | public boolean isBadgeVisible() {
111 | return drawBadge;
112 | }
113 |
114 | @Override
115 | public void draw(Canvas canvas) {
116 | super.draw(canvas);
117 | if (drawBadge) {
118 | badge.draw(canvas);
119 | }
120 | }
121 |
122 | @Override
123 | public boolean onInterceptTouchEvent(MotionEvent ev) {
124 | return true;
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/BadgedView/src/main/java/com/github/chaossss/widget/view/CircleBadgedView.java:
--------------------------------------------------------------------------------
1 | package com.github.chaossss.widget.view;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.Rect;
7 | import android.util.AttributeSet;
8 | import android.view.Gravity;
9 |
10 | import com.github.chaossss.widget.R;
11 | import com.github.chaossss.widget.badge.CircleBadge;
12 |
13 | /**
14 | * Created by chaos on 2016/1/6.
15 | */
16 | public class CircleBadgedView extends BadgedView {
17 | private int circlebadgeGravity;
18 | private boolean badgeBoundsSet = false;
19 |
20 | public CircleBadgedView(Context context, AttributeSet attrs) {
21 | super(context, attrs);
22 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RecBadgedView, 0, 0);
23 | circlebadgeGravity = a.getInt(R.styleable.CircleBadgedView_circlebadgeGravity, Gravity.TOP | Gravity
24 | .RIGHT);
25 | a.recycle();
26 | }
27 |
28 | @Override
29 | public void initBadge(Context context) {
30 | badge = new CircleBadge(context, badgeText, badgeColor, badgeTextColor);
31 | badge.setTextSize(badgeTextSize);
32 | }
33 |
34 | @Override
35 | public void draw(Canvas canvas) {
36 | super.draw(canvas);
37 | if (drawBadge) {
38 | badge.draw(canvas);
39 |
40 | if (!badgeBoundsSet) {
41 | layoutBadge();
42 | }
43 | }
44 | }
45 |
46 | private void layoutBadge() {
47 | Rect badgeBounds = badge.getBounds();
48 |
49 | Gravity.apply(circlebadgeGravity,
50 | badge.getIntrinsicWidth(),
51 | badge.getIntrinsicHeight(),
52 | new Rect(0, 0, getWidth(), getHeight()),
53 | badgeBounds);
54 | badge.setBounds(badgeBounds);
55 | badgeBoundsSet = true;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/BadgedView/src/main/java/com/github/chaossss/widget/view/RecBadgedView.java:
--------------------------------------------------------------------------------
1 | package com.github.chaossss.widget.view;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.Rect;
7 | import android.util.AttributeSet;
8 | import android.view.Gravity;
9 |
10 | import com.github.chaossss.widget.R;
11 | import com.github.chaossss.widget.badge.RecBadge;
12 |
13 | /**
14 | * An extension to {@link BadgedView} which has a Rectangle Badge.
15 | * Created by chaos on 2015/11/25.
16 | */
17 |
18 | public class RecBadgedView extends BadgedView {
19 | private int recbadgeGravity;
20 | private boolean badgeBoundsSet = false;
21 |
22 | public RecBadgedView(Context context, AttributeSet attrs) {
23 | super(context, attrs);
24 |
25 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RecBadgedView, 0, 0);
26 | recbadgeGravity = a.getInt(R.styleable.RecBadgedView_recbadgeGravity, Gravity.TOP | Gravity
27 | .LEFT);
28 | a.recycle();
29 | }
30 |
31 | @Override
32 | public void initBadge(Context context) {
33 | badge = new RecBadge(context, badgeText, badgeColor, badgeTextColor);
34 | badge.setPadding(badgePadding);
35 | badge.setTextSize(badgeTextSize);
36 | badge.setCornerRadius(badgeCornerRadius);
37 | }
38 |
39 | @Override
40 | public void draw(Canvas canvas) {
41 | super.draw(canvas);
42 | if (drawBadge) {
43 | badge.draw(canvas);
44 |
45 | if (!badgeBoundsSet) {
46 | layoutBadge();
47 | }
48 | }
49 | }
50 |
51 | private void layoutBadge() {
52 | Rect badgeBounds = badge.getBounds();
53 |
54 | Gravity.apply(recbadgeGravity,
55 | badge.getIntrinsicWidth(),
56 | badge.getIntrinsicHeight(),
57 | new Rect(0, 0, getWidth(), getHeight()),
58 | badgePadding,
59 | badgePadding,
60 | badgeBounds);
61 | badge.setBounds(badgeBounds);
62 | badgeBoundsSet = true;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/BadgedView/src/main/java/com/github/chaossss/widget/view/TriBadgedView.java:
--------------------------------------------------------------------------------
1 | package com.github.chaossss.widget.view;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.util.AttributeSet;
7 |
8 | import com.github.chaossss.widget.R;
9 | import com.github.chaossss.widget.badge.TriBadge;
10 |
11 | /**
12 | * An extension to {@link BadgedView} which has a Triangle Badge.
13 | * Created by chaos on 2015/11/27.
14 | */
15 | public class TriBadgedView extends BadgedView {
16 | private int tribadgeGravity;
17 |
18 | public TriBadgedView(Context context, AttributeSet attrs) {
19 | super(context, attrs);
20 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TriBadgedView, 0, 0);
21 | tribadgeGravity = a.getInt(R.styleable.TriBadgedView_TribadgeGravity, TriBadge.BOTTOMRIGHT);
22 | a.recycle();
23 | }
24 |
25 | @Override
26 | public void initBadge(Context context) {
27 | badge = new TriBadge(context, badgeText, badgeColor, badgeTextColor);
28 | badge.setPadding(badgePadding);
29 | badge.setTextSize(badgeTextSize);
30 | badge.setCornerRadius(badgeCornerRadius);
31 | }
32 |
33 | @Override
34 | public void draw(Canvas canvas) {
35 | ((TriBadge)badge).setTribadgeGravity(tribadgeGravity);
36 | ((TriBadge)badge).setRootViewParam(getWidth(), getHeight());
37 | super.draw(canvas);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/BadgedView/src/main/res/values/attrs_badged_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/BadgedView/src/main/res/values/attrs_circlebadged_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/BadgedView/src/main/res/values/attrs_recbadged_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/BadgedView/src/main/res/values/attrs_tribadged_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/BadgedView/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FF4081
4 | #50000000
5 |
6 |
--------------------------------------------------------------------------------
/BadgedView/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | BadgeView
3 |
4 |
--------------------------------------------------------------------------------
/BadgedView/src/test/java/com/github/chaossss/widget/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.github.chaossss.widget;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # BadgedView
2 |
3 | [English Version](README_ENGLISH.md)
4 |
5 | BadgedView 能够为任意一个 View 添加矩形或三角形标签。
6 |
7 | BadgedImageView 就是 [Plaid](https://github.com/nickbutcher/plaid) 和 [虎扑体育](http://mobile.hupu.com/?_r=globalNav) 用来给图片添加标签的控件。原作者的实现里,只能为 ImageView 添加 Badge,我看了看他的代码([开源](https://github.com/yesidlazaro/BadgedImageview))发现这个控件其实蛮简单的,想法挺好,但是代码写的不是特别好。而且我觉得应该能将这个控件应用到任意一个 View 上边,所以我根据我的想法实现了 BadgedView。
8 |
9 | 效果图:
10 |
11 | 
12 |
13 | #Feature
14 |
15 | ## Implemented
16 |
17 | - 设置标签内的文字
18 | - 设置标签背景颜色
19 | - 自定义标签形状、文字
20 | - 将标签应用于任意 View
21 | - 可在标签所在布局设置长宽比例
22 | - 设置矩形标签或三角形标签在视图中的位置
23 | - 为任意 View 添加矩形、三角形、圆形标签
24 |
25 | ## Processing
26 |
27 | - 添加其他样式的标签
28 | - 不需要实现子类就能为每一个 View 添加任意多的标签
29 |
30 | #Usage
31 |
32 | ##Dependency
33 |
34 | ###Min SDK:2.3.3
35 |
36 | ###Add Dependency
37 |
38 | 在项目的 build.gradle 里添加:
39 |
40 | ```
41 | dependencies {
42 | ...
43 | compile 'com.github.chaossss:BadgedView:1.1.1'
44 | }
45 | ```
46 |
47 | ##Attr
48 |
49 | | Attr | usage |
50 | |---------|--------|
51 | | app:badgeText | 设置标签中显示的文字 |
52 | | app:badgeTextSize | 设置标签中显示的文字大小 |
53 | | app:badgeTextColor | 设置标签中显示的文字颜色 |
54 | | app:badgePadding | 设置标签中文字和标签边界的间距 |
55 | | app:badgeWidthRatio | 设置标签布局的长宽比 |
56 | | app:badgeHeightRatio | 设置标签布局的长宽比 |
57 | | app:badgeCornerRadius | 设置矩形标签圆角的半径 |
58 | | app:recbadgeGravity(RecBadgedView) | 设置矩形标签的位置 |
59 | | app:tribadgeGravity(TriBadgedView) | 设置三角标签的位置 |
60 |
61 | ##API
62 |
63 | | API | usage |
64 | |---------|--------|
65 | | showBadge(boolean show) | 显示标签 |
66 | | setBadgeText(String newText) | 设置标签显示文字 |
67 |
68 | ##Customize BadgedView
69 |
70 | 1. 继承 BadgedView,父类 BadgedView 已经有了标签常用的属性
71 | 2. 在子类添加你所需要的特定的属性域
72 | 3. 重写 initBadge(Context context) 和 draw(Canvas canvas) 方法以实现你的需求
73 |
74 | 如果需要自定义标签:
75 |
76 | 4. 继承 BaseBadge
77 | 5. 在子类添加你所需要的特定的属性域
78 | 6. 重写 initBadge(),在其中对 badge 完成你所需要的标签的绘制工作
79 |
80 | ##Activity
81 |
82 | ```java
83 | public class MainActivity extends AppCompatActivity implements View.OnClickListener {
84 | private RecBadgedView anyView;
85 | private RecBadgedView scaleView;
86 | private RecBadgedView regularView;
87 |
88 | private TriBadgedView triView;
89 |
90 | @Override
91 | protected void onCreate(Bundle savedInstanceState) {
92 | super.onCreate(savedInstanceState);
93 | setContentView(R.layout.activity_main);
94 |
95 | anyView = (RecBadgedView) findViewById(R.id.badge_any_view);
96 | scaleView = (RecBadgedView) findViewById(R.id.badge_scale_view);
97 | regularView = (RecBadgedView) findViewById(R.id.badge_regular_view);
98 |
99 | triView = (TriBadgedView) findViewById(R.id.badge_tri_view);
100 |
101 | anyView.setBadgeText("I'm badge");
102 | anyView.setOnClickListener(this);
103 | anyView.showBadge(true);
104 |
105 | scaleView.showBadge(true);
106 | regularView.showBadge(true);
107 |
108 | triView.showBadge(true);
109 | }
110 |
111 | @Override
112 | public void onClick(View v) {
113 | if(anyView.isBadgeVisible()){
114 | anyView.showBadge(false);
115 | } else {
116 | anyView.showBadge(true);
117 | }
118 | }
119 | }
120 | ```
121 |
122 | ##XML
123 |
124 | ```xml
125 |
126 |
131 |
135 |
145 |
150 |
151 |
152 |
160 |
165 |
166 |
167 |
174 |
178 |
179 |
180 |
185 |
190 |
191 |
192 |
193 | ```
194 |
--------------------------------------------------------------------------------
/README_ENGLISH.md:
--------------------------------------------------------------------------------
1 | # BadgedView
2 |
3 | BadgedView is what [Plaid](https://github.com/nickbutcher/plaid) and [HuPu Sports](http://mobile.hupu.com/?_r=globalNav) uses to show a badge in an ImageView.
4 |
5 | BadgedView allows you show a badge into any View. The idea of this widget is from [BadgedImageview](https://github.com/yesidlazaro/BadgedImageview). I think the origin project has good idea but doesn't implement with good code. Therefor, for adding new feature and implementing it in a better way, I implement my own version of BadgedView, and it seems better than yesidlazaro's.
6 |
7 | PreView:
8 |
9 | 
10 |
11 | #Feature
12 |
13 | ## Implemented
14 |
15 | - set badge's text
16 | - set badge's gravity
17 | - set badge's background color
18 | - set BadgedView's length-width ratio
19 | - customize you own badge and BadgedView
20 | - show badges into any View u want
21 | - set recbadge or tribadge's gravity
22 |
23 | ## Processing
24 |
25 | - add other style of badge
26 | - add any number of badges u want without implementing a subclass of BadgedView
27 |
28 | #Usage
29 |
30 | ##Dependency
31 |
32 | ###Min SDK:2.3.3
33 |
34 | ###Add dependency
35 |
36 | Open you Project's build.gradle, and add line like this:
37 |
38 | ```
39 | dependencies {
40 | ...
41 | compile 'com.github.chaossss:BadgedView:1.1.1'
42 | }
43 | ```
44 |
45 | ##Attr
46 |
47 | | Attr | usage |
48 | |---------|--------|
49 | | app:badgeText | set badges's text |
50 | | app:badgeTextSize | set badge's text size |
51 | | app:badgeTextColor | set badge's text color |
52 | | app:badgePadding | set badge's padding |
53 | | app:badgeWidthRatio | set layout's width ratio |
54 | | app:badgeHeightRatio | set layout's height ratio |
55 | | app:badgeCornerRadius | set corner radius |
56 | | app:recbadgeGravity(RecBadgedView) | set rectangle badge's position |
57 | | app:tribadgeGravity(TriBadgedView) | set triangle badge's position |
58 |
59 | ##API
60 |
61 | | API | usage |
62 | |---------|--------|
63 | | showBadge(boolean show) | show the badge |
64 | | setBadgeText(String newText) | set badge's text |
65 |
66 | ##Customize BadgedView
67 |
68 | 1. Creates a subclass which extends from BadgedView,BadgedView completes attrs' initialize
69 | 2. Adds your specified attr scope in subclass
70 | 3. Overrides initBadge(Context context) and draw(Canvas canvas) to implement what u want
71 |
72 | If customized badge needed:
73 |
74 | 4. Creates a subclass of BaseBadge
75 | 5. Adds your specified attr scope in subclass
76 | 6. Overrides initBadge() to finish drawing the badge you wanted. Please remember, u should draw your badge in the `Bitmap instance -> badge`, or u may meet some trouble
77 |
78 | ##Activity
79 |
80 | ```java
81 | public class MainActivity extends AppCompatActivity implements View.OnClickListener {
82 | private RecBadgedView anyView;
83 | private RecBadgedView scaleView;
84 | private RecBadgedView regularView;
85 |
86 | private TriBadgedView triView;
87 |
88 | @Override
89 | protected void onCreate(Bundle savedInstanceState) {
90 | super.onCreate(savedInstanceState);
91 | setContentView(R.layout.activity_main);
92 |
93 | anyView = (RecBadgedView) findViewById(R.id.badge_any_view);
94 | scaleView = (RecBadgedView) findViewById(R.id.badge_scale_view);
95 | regularView = (RecBadgedView) findViewById(R.id.badge_regular_view);
96 |
97 | triView = (TriBadgedView) findViewById(R.id.badge_tri_view);
98 |
99 | anyView.setBadgeText("I'm badge");
100 | anyView.setOnClickListener(this);
101 | anyView.showBadge(true);
102 |
103 | scaleView.showBadge(true);
104 | regularView.showBadge(true);
105 |
106 | triView.showBadge(true);
107 | }
108 |
109 | @Override
110 | public void onClick(View v) {
111 | if(anyView.isBadgeVisible()){
112 | anyView.showBadge(false);
113 | } else {
114 | anyView.showBadge(true);
115 | }
116 | }
117 | }
118 | ```
119 |
120 | ```xml
121 |
122 |
127 |
131 |
141 |
146 |
147 |
148 |
156 |
161 |
162 |
163 |
170 |
174 |
175 |
176 |
181 |
186 |
187 |
188 |
189 | ```
190 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | applicationId "com.github.chaossss.badgedview"
9 | minSdkVersion 14
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.1.0'
26 | compile 'com.android.support:design:23.1.0'
27 | compile project(':BadgedView')
28 | }
29 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\Android\ADT\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/github/chaossss/badgedview/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.github.chaossss.badgedview;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/chaossss/badgedview/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.github.chaossss.badgedview;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.view.View;
6 |
7 | import com.github.chaossss.widget.view.CircleBadgedView;
8 | import com.github.chaossss.widget.view.RecBadgedView;
9 | import com.github.chaossss.widget.view.TriBadgedView;
10 |
11 |
12 | public class MainActivity extends AppCompatActivity implements View.OnClickListener {
13 | private RecBadgedView anyView;
14 | private RecBadgedView scaleView;
15 | private RecBadgedView regularView;
16 |
17 | private TriBadgedView triView;
18 |
19 | private CircleBadgedView circleBadgedView;
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_main);
25 |
26 | anyView = (RecBadgedView) findViewById(R.id.badge_any_view);
27 | scaleView = (RecBadgedView) findViewById(R.id.badge_scale_view);
28 | regularView = (RecBadgedView) findViewById(R.id.badge_regular_view);
29 | circleBadgedView = (CircleBadgedView) findViewById(R.id.badge_circle_view);
30 |
31 | triView = (TriBadgedView) findViewById(R.id.badge_tri_view);
32 |
33 | anyView.setBadgeText("I'm badge");
34 | anyView.setOnClickListener(this);
35 | anyView.showBadge(true);
36 |
37 | scaleView.showBadge(true);
38 | regularView.showBadge(true);
39 |
40 | triView.showBadge(true);
41 | circleBadgedView.showBadge(true);
42 | }
43 |
44 | @Override
45 | public void onClick(View v) {
46 | if(anyView.isBadgeVisible()){
47 | anyView.showBadge(false);
48 | } else {
49 | anyView.showBadge(true);
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
19 |
24 |
25 |
26 |
36 |
41 |
42 |
43 |
51 |
56 |
57 |
58 |
65 |
69 |
70 |
71 |
77 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chaossss/BadgedView/abbdd29ee0c8ea8be1bfe02b072db4de8b5b10f9/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chaossss/BadgedView/abbdd29ee0c8ea8be1bfe02b072db4de8b5b10f9/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chaossss/BadgedView/abbdd29ee0c8ea8be1bfe02b072db4de8b5b10f9/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/gem.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chaossss/BadgedView/abbdd29ee0c8ea8be1bfe02b072db4de8b5b10f9/app/src/main/res/mipmap-xxhdpi/gem.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/hebe.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chaossss/BadgedView/abbdd29ee0c8ea8be1bfe02b072db4de8b5b10f9/app/src/main/res/mipmap-xxhdpi/hebe.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chaossss/BadgedView/abbdd29ee0c8ea8be1bfe02b072db4de8b5b10f9/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chaossss/BadgedView/abbdd29ee0c8ea8be1bfe02b072db4de8b5b10f9/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 | >
2 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #50000000
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #50000000
7 | #ffffff
8 | #FF0000
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 1
3 | BadgedView
4 | GIF
5 | VIDEO
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/test/java/com/github/chaossss/badgedview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.github.chaossss.badgedview;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.3.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
13 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | jcenter()
20 | }
21 | }
22 |
23 | task clean(type: Delete) {
24 | delete rootProject.buildDir
25 | }
26 |
--------------------------------------------------------------------------------
/example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chaossss/BadgedView/abbdd29ee0c8ea8be1bfe02b072db4de8b5b10f9/example.png
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chaossss/BadgedView/abbdd29ee0c8ea8be1bfe02b072db4de8b5b10f9/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Nov 30 19:00:00 CST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':BadgedView'
2 |
--------------------------------------------------------------------------------