├── .gitattributes ├── .gitignore ├── Picture.png ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── org │ │ └── ninetripods │ │ └── mq │ │ └── badgeviewpro │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── org │ │ │ └── ninetripods │ │ │ └── mq │ │ │ └── badgeviewpro │ │ │ ├── DividerItemDecoration.java │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── item_recycle_img_view.xml │ │ ├── item_recycle_linearlayout.xml │ │ ├── item_recycle_relativelayout.xml │ │ └── item_recycle_text_view.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ ├── group_icon.png │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── attr.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── org │ └── ninetripods │ └── mq │ └── badgeviewpro │ └── ExampleUnitTest.java ├── badgelibrary ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── org │ │ └── ninetripods │ │ └── mq │ │ └── badgelibrary │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── org │ │ │ └── ninetripods │ │ │ └── mq │ │ │ └── badgelibrary │ │ │ ├── BadgeViewPro.java │ │ │ ├── CircleDrawable.java │ │ │ ├── ShapeUtil.java │ │ │ └── TypefaceUtil.java │ └── res │ │ └── values │ │ ├── attr.xml │ │ └── strings.xml │ └── test │ └── java │ └── org │ └── ninetripods │ └── mq │ └── badgelibrary │ └── ExampleUnitTest.java ├── build.gradle ├── 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 | 2 | # Built application files 3 | *.apk 4 | *.ap_ 5 | 6 | # Files for the ART/Dalvik VM 7 | *.dex 8 | 9 | # Java class files 10 | *.class 11 | 12 | # Generated files 13 | bin/ 14 | gen/ 15 | out/ 16 | 17 | # Gradle files 18 | .gradle/ 19 | build/ 20 | .idea/ 21 | 22 | 23 | # Local configuration file (sdk path, etc) 24 | local.properties 25 | 26 | # Proguard folder generated by Eclipse 27 | proguard/ 28 | 29 | # Log Files 30 | *.log 31 | 32 | # Android Studio Navigation editor temp files 33 | .navigation/ 34 | 35 | # Android Studio captures folder 36 | captures/ 37 | 38 | # Intellij 39 | *.iml 40 | .idea/workspace.xml 41 | 42 | # Keystore files 43 | *.jks -------------------------------------------------------------------------------- /Picture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyqiang/BadgeView/cdb47da7e14009df21f3d7fd670033121f131f84/Picture.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BagdeView 2 | ![image](https://github.com/crazyqiang/BadgeView/blob/master/Picture.png) 3 | 4 | ##How to use 5 | 6 | new BadgeViewPro(this).setStrColor(Color.parseColor("#ffffff"))//文本字体颜色 7 | .setStrSize(10)//文本字体大小 8 | .setMargin(15, 0, 15, 0)//目标View的Margin 9 | .setStrBgColor(Color.parseColor("#000000"))//文本背景颜色 10 | .setStrText("99+")//设置文本 11 | .setShape(BadgeViewPro.SHAPE_OVAL)//文本背景形状 12 | .setBgGravity(Gravity.CENTER)//文本背景位置 13 | .setTargetView(targetView); 14 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 24 5 | buildToolsVersion "24.0.1" 6 | defaultConfig { 7 | applicationId "org.ninetripods.mq.badgeviewpro" 8 | minSdkVersion 15 9 | targetSdkVersion 24 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 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 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:24.2.0' 28 | testCompile 'junit:junit:4.12' 29 | compile project(':badgelibrary') 30 | compile 'com.android.support:recyclerview-v7:24.2.0' 31 | } 32 | -------------------------------------------------------------------------------- /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\sdkN/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/org/ninetripods/mq/badgeviewpro/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package org.ninetripods.mq.badgeviewpro; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("org.ninetripods.mq.badgeviewpro", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/java/org/ninetripods/mq/badgeviewpro/DividerItemDecoration.java: -------------------------------------------------------------------------------- 1 | package org.ninetripods.mq.badgeviewpro; 2 | 3 | import android.graphics.Rect; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.View; 6 | 7 | /** 8 | * Created by MQ on 2016/11/30. 9 | */ 10 | 11 | class DividerItemDecoration extends RecyclerView.ItemDecoration { 12 | @Override 13 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { 14 | // super.getItemOffsets(outRect, view, parent, state); 15 | outRect.set(0, 0, 0, 5); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/org/ninetripods/mq/badgeviewpro/MainActivity.java: -------------------------------------------------------------------------------- 1 | package org.ninetripods.mq.badgeviewpro; 2 | 3 | import android.graphics.Color; 4 | import android.os.Handler; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.os.Bundle; 7 | import android.support.v7.widget.GridLayoutManager; 8 | import android.support.v7.widget.LinearLayoutManager; 9 | import android.support.v7.widget.RecyclerView; 10 | import android.util.Log; 11 | import android.view.Gravity; 12 | import android.view.LayoutInflater; 13 | import android.view.View; 14 | import android.view.ViewGroup; 15 | import android.view.ViewTreeObserver; 16 | import android.widget.ImageView; 17 | import android.widget.LinearLayout; 18 | import android.widget.RelativeLayout; 19 | import android.widget.TextView; 20 | 21 | import org.ninetripods.mq.badgelibrary.BadgeViewPro; 22 | 23 | public class MainActivity extends AppCompatActivity { 24 | private RecyclerView rv_recycle_view; 25 | private MyAdapter mAdatper; 26 | 27 | @Override 28 | protected void onCreate(Bundle savedInstanceState) { 29 | super.onCreate(savedInstanceState); 30 | setContentView(R.layout.activity_main); 31 | rv_recycle_view = (RecyclerView) findViewById(R.id.rv_recycle_view); 32 | rv_recycle_view.addItemDecoration(new DividerItemDecoration()); 33 | rv_recycle_view.setLayoutManager(new LinearLayoutManager(this)); 34 | mAdatper = new MyAdapter(); 35 | rv_recycle_view.setAdapter(mAdatper); 36 | // bv_view1.setStrColor(Color.parseColor("#ffffff"))//文本字体颜色 37 | // .setStrSize(10)//文本字体大小 38 | // .setMargin(15, 0, 15, 0)//目标View的Margin 39 | // .setStrBgColor(Color.parseColor("#000000"))//文本背景颜色 40 | // .setStrText("99+")//设置文本 41 | // .setShape(BadgeViewPro.SHAPE_OVAL)//文本背景形状 42 | // .setBgGravity(Gravity.CENTER)//文本背景位置 43 | // .setTargetView(iv_icon); 44 | } 45 | 46 | 47 | class MyAdapter extends RecyclerView.Adapter { 48 | @Override 49 | public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 50 | View itemView = null; 51 | switch (viewType) { 52 | case 0: 53 | //目标view是ImageView 54 | itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_recycle_img_view, parent, false); 55 | break; 56 | case 1: 57 | //目标view是TextView 58 | itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_recycle_text_view, parent, false); 59 | break; 60 | case 2: 61 | //目标view是RelativeLayout 62 | itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_recycle_relativelayout, parent, false); 63 | break; 64 | case 3: 65 | //目标view是LinearLayout 66 | itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_recycle_linearlayout, parent, false); 67 | break; 68 | } 69 | return new MyViewHolder(itemView, viewType); 70 | } 71 | 72 | @Override 73 | public void onBindViewHolder(MyViewHolder holder, int position) { 74 | 75 | } 76 | 77 | @Override 78 | public int getItemCount() { 79 | return 4; 80 | } 81 | 82 | @Override 83 | public int getItemViewType(int position) { 84 | switch (position) { 85 | case 0: 86 | //ImageView 87 | return 0; 88 | case 1: 89 | //TextView 90 | return 1; 91 | case 2: 92 | //RelativeLayout 93 | return 2; 94 | case 3: 95 | //LinearLayout 96 | return 3; 97 | default: 98 | return super.getItemViewType(position); 99 | } 100 | } 101 | 102 | class MyViewHolder extends RecyclerView.ViewHolder { 103 | ImageView iv_img1, iv_img2, iv_img3, iv_img4, iv_img5, iv_img6, iv_img7, iv_img8; 104 | TextView tv_text; 105 | RelativeLayout rl_layout; 106 | LinearLayout ll_layout; 107 | 108 | MyViewHolder(View itemView, int viewType) { 109 | super(itemView); 110 | switch (viewType) { 111 | case 0: 112 | iv_img1 = (ImageView) itemView.findViewById(R.id.iv_img1); 113 | final BadgeViewPro bv1 = new BadgeViewPro(MainActivity.this); 114 | bv1.setStrText("10").setMargin(10, 3, 10, 0).setStrSize(10).setTargetView(iv_img1); 115 | iv_img2 = (ImageView) itemView.findViewById(R.id.iv_img2); 116 | BadgeViewPro bv2 = new BadgeViewPro(MainActivity.this); 117 | bv2.setStrText("1").setTargetView(iv_img2); 118 | iv_img3 = (ImageView) itemView.findViewById(R.id.iv_img3); 119 | BadgeViewPro bv3 = new BadgeViewPro(MainActivity.this); 120 | bv3.setStrText("99+").setTargetView(iv_img3); 121 | iv_img4 = (ImageView) itemView.findViewById(R.id.iv_img4); 122 | BadgeViewPro bv4 = new BadgeViewPro(MainActivity.this); 123 | bv4.setTargetView(iv_img4); 124 | iv_img5 = (ImageView) itemView.findViewById(R.id.iv_img5); 125 | BadgeViewPro bv5 = new BadgeViewPro(MainActivity.this); 126 | bv5.setMargin(10, 3, 10, 0).setStrText("新").setShape(BadgeViewPro.SHAPE_ROUND_RECTANGLE).setTargetView(iv_img5); 127 | iv_img6 = (ImageView) itemView.findViewById(R.id.iv_img6); 128 | BadgeViewPro bv6 = new BadgeViewPro(MainActivity.this); 129 | bv6.setStrText("矩形").setShape(BadgeViewPro.SHAPE_RECTANGLE).setTargetView(iv_img6); 130 | iv_img7 = (ImageView) itemView.findViewById(R.id.iv_img7); 131 | BadgeViewPro bv7 = new BadgeViewPro(MainActivity.this); 132 | bv7.setStrText("椭圆").setBgGravity(Gravity.START | Gravity.TOP).setShape(BadgeViewPro.SHAPE_OVAL).setTargetView(iv_img7); 133 | iv_img8 = (ImageView) itemView.findViewById(R.id.iv_img8); 134 | BadgeViewPro bv8 = new BadgeViewPro(MainActivity.this); 135 | bv8.setStrText("圆").setBgGravity(Gravity.END | Gravity.TOP).setShape(BadgeViewPro.SHAPE_CIRCLE).setTargetView(iv_img8); 136 | break; 137 | case 1: 138 | tv_text = (TextView) itemView.findViewById(R.id.tv_text); 139 | BadgeViewPro bvt1 = new BadgeViewPro(MainActivity.this); 140 | bvt1.setStrText("10") 141 | .setStrBgColor(Color.parseColor("#000000")) 142 | .setShape(BadgeViewPro.SHAPE_OVAL) 143 | .setStrSize(10) 144 | .setMargin(10, 10, 10, 10) 145 | .setTargetView(tv_text); 146 | break; 147 | case 2: 148 | rl_layout = (RelativeLayout) itemView.findViewById(R.id.rl_layout); 149 | BadgeViewPro bv_r = new BadgeViewPro(MainActivity.this); 150 | bv_r.setStrText("10") 151 | .setStrBgColor(Color.parseColor("#88dc4d")) 152 | .setStrSize(10) 153 | .setBgGravity(Gravity.END | Gravity.CENTER_VERTICAL) 154 | .setTargetView(rl_layout); 155 | break; 156 | case 3: 157 | ll_layout = (LinearLayout) itemView.findViewById(R.id.ll_layout); 158 | BadgeViewPro bv_ll = new BadgeViewPro(MainActivity.this); 159 | bv_ll.setStrText("999+") 160 | .setStrBgColor(Color.parseColor("#3F51B5")) 161 | .setStrSize(10) 162 | .setBgGravity(Gravity.START | Gravity.TOP) 163 | .setTargetView(ll_layout); 164 | break; 165 | } 166 | } 167 | } 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 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 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_recycle_img_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 16 | 17 | 23 | 24 | 30 | 31 | 38 | 39 | 46 | 47 | 54 | 55 | 56 | 62 | 63 | 69 | 70 | 77 | 78 | 85 | 86 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_recycle_linearlayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_recycle_relativelayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_recycle_text_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 16 | 17 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyqiang/BadgeView/cdb47da7e14009df21f3d7fd670033121f131f84/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyqiang/BadgeView/cdb47da7e14009df21f3d7fd670033121f131f84/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/group_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyqiang/BadgeView/cdb47da7e14009df21f3d7fd670033121f131f84/app/src/main/res/mipmap-xhdpi/group_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyqiang/BadgeView/cdb47da7e14009df21f3d7fd670033121f131f84/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyqiang/BadgeView/cdb47da7e14009df21f3d7fd670033121f131f84/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyqiang/BadgeView/cdb47da7e14009df21f3d7fd670033121f131f84/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/attr.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | #FF4081 7 | 8 | #ff5b0f 9 | #a29d99 10 | #88dc4d 11 | #3f454f 12 | 13 | #ffb7babb 14 | #f0f0f0 15 | #4e3d31 16 | #381902 17 | #70000000 18 | #dddddd 19 | #f2f2f2 20 | #efefef 21 | #fafafa 22 | #f9f9f9 23 | #f5f5f5 24 | 25 | #FFFFFF 26 | #FFFFFF 27 | 28 | #e8e9eb 29 | 30 | #fffcfcfc 31 | #ffd7d7d7 32 | #ff5e5e5e 33 | 34 | 35 | #000000 36 | #ffffff 37 | #9AE96C 38 | 39 | #e5e5e5 40 | #dcdcdc 41 | #8bdf13 42 | #eeeeee 43 | #000000 44 | #ffffff 45 | #dadada 46 | #505050 47 | #9e9e9e 48 | #A2E542 49 | #6FB30D 50 | #3676bd 51 | #CACACA 52 | #ff5a00 53 | #F46C09 54 | #F46C09 55 | #791010 56 | 57 | #4ebcd3 58 | #00acff 59 | #46678d 60 | #d33f3f 61 | #DA5A4D 62 | #ffffff 63 | #00acff 64 | #2d2f31 65 | #161718 66 | #2ea7e0 67 | #fcfcfc 68 | #B6DA53 69 | #d4d4d4 70 | #00acff 71 | #F6EBE6 72 | #2D2F31 73 | #ffffff 74 | #f7f8f8 75 | #b5b5b6 76 | #A2E542 77 | #88A2E542 78 | #6FB30D 79 | #c0c0c0 80 | #88c3c3c3 81 | #b5b5b6 82 | #666667 83 | #1e90ff 84 | #0066FF 85 | #FFA500 86 | #b5b5b6 87 | #666667 88 | #1Affffff 89 | #80000000 90 | #bababa 91 | #FF000000 92 | #4ebcd3 93 | #2dafa3 94 | #00000000 95 | #666666 96 | #505050 97 | #ffececec 98 | #ff5a00 99 | #C7C7C7 100 | #a2e542 101 | #377caf 102 | #bf9e5a 103 | #282828 104 | #bbbbbb 105 | #f3f3f3 106 | #666666 107 | #6fb30d 108 | #ff464646 109 | 110 | #ea2226 111 | #ffffffff 112 | #ff3c00 113 | 114 | #ffd0d0d0 115 | #8e8e8e 116 | 117 | #FFE1E8EB 118 | 119 | #ff000000 120 | #7f000000 121 | #00000000 122 | #ff66ccff 123 | #c099cc00 124 | 125 | #ffffffff 126 | #b0000000 127 | #ffffffff 128 | #a2e542 129 | 130 | #60000000 131 | #c0ffbd21 132 | #cccccc 133 | #FFFFFB 134 | #AA1C1C1C 135 | #1C1C1C 136 | #86C166 137 | #86C166 138 | #AA86C166 139 | #FFFFFB 140 | #80000000 141 | #CECECE 142 | #505050 143 | #F49092 144 | #eceff4 145 | #EBEBEB 146 | #FAFAFA 147 | #E1E1E1 148 | 149 | 150 | #888888 151 | #dddddd 152 | #f2f2f2 153 | #2f77b8 154 | 155 | #EC5745 156 | #A6463A 157 | #4B1D17 158 | #109121 159 | 160 | 161 | #404040ff 162 | #FF0000 163 | #0ff0ff 164 | #c0c0c0ff 165 | #ff3939 166 | #ff0f81d9 167 | #ffC3C3C3 168 | #ff6699ff 169 | #66ffffff 170 | #ff000000 171 | #f0f0f0 172 | #2c2c2c 173 | #2980B9 174 | #005084 175 | #24ff00 176 | #1b5d89 177 | #2980B9 178 | #1b1c1f 179 | #fcb840 180 | #f68b2b 181 | #CC000000 182 | #7f000000 183 | #66000000 184 | #DA000000 185 | #4D000000 186 | #50000000 187 | 188 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | BadgeViewPro 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/org/ninetripods/mq/badgeviewpro/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package org.ninetripods.mq.badgeviewpro; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /badgelibrary/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /badgelibrary/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.novoda.bintray-release'//添加 3 | 4 | android { 5 | compileSdkVersion 24 6 | buildToolsVersion "24.0.1" 7 | 8 | defaultConfig { 9 | minSdkVersion 15 10 | targetSdkVersion 24 11 | versionCode 1 12 | versionName "1.0" 13 | 14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 15 | 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 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 28 | exclude group: 'com.android.support', module: 'support-annotations' 29 | }) 30 | compile 'com.android.support:appcompat-v7:24.2.0' 31 | testCompile 'junit:junit:4.12' 32 | } 33 | 34 | //添加 35 | publish { 36 | userOrg = 'crazyqiang'//bintray.com用户名 37 | groupId = 'com.crazyqiang'//jcenter上的路径 38 | artifactId = 'BagdeView'//项目名称 39 | publishVersion = '1.0.0'//版本号 40 | desc = 'Oh hi, this is a nice description for a project, right?'//描述,不重要 41 | website = 'https://github.com/crazyqiang/BadgeView'//网站,不重要;尽量模拟github上的地址,例如我这样的;当然你有地址最好了 42 | } -------------------------------------------------------------------------------- /badgelibrary/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\sdkN/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 | -------------------------------------------------------------------------------- /badgelibrary/src/androidTest/java/org/ninetripods/mq/badgelibrary/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package org.ninetripods.mq.badgelibrary; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("org.ninetripods.mq.badgelibrary.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /badgelibrary/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /badgelibrary/src/main/java/org/ninetripods/mq/badgelibrary/BadgeViewPro.java: -------------------------------------------------------------------------------- 1 | package org.ninetripods.mq.badgelibrary; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Canvas; 6 | import android.graphics.Color; 7 | import android.graphics.Paint; 8 | import android.graphics.RectF; 9 | import android.graphics.drawable.ShapeDrawable; 10 | import android.graphics.drawable.shapes.OvalShape; 11 | import android.graphics.drawable.shapes.RectShape; 12 | import android.graphics.drawable.shapes.RoundRectShape; 13 | import android.text.TextUtils; 14 | import android.util.AttributeSet; 15 | import android.util.Log; 16 | import android.view.Gravity; 17 | import android.view.View; 18 | import android.view.ViewGroup; 19 | import android.view.ViewTreeObserver; 20 | import android.widget.FrameLayout; 21 | import android.widget.TextView; 22 | 23 | /** 24 | * Created by MQ on 2016/11/28. 25 | */ 26 | 27 | public class BadgeViewPro extends TextView { 28 | //背景形状 29 | private int shape_type; 30 | public static final int SHAPE_CIRCLE = 0; 31 | public static final int SHAPE_OVAL = 1; 32 | public static final int SHAPE_RECTANGLE = 2; 33 | public static final int SHAPE_ROUND_RECTANGLE = 3; 34 | 35 | private int bgColor;//背景颜色 36 | private Context mContext; 37 | private float leftMargin, topMargin, rightMargin, bottomMargin; 38 | private int gravity; 39 | private int textColor; 40 | private int textSize; 41 | private String textStr; 42 | 43 | public BadgeViewPro(Context context) { 44 | this(context, null); 45 | } 46 | 47 | public BadgeViewPro(Context context, AttributeSet attrs) { 48 | this(context, attrs, 0); 49 | } 50 | 51 | public BadgeViewPro(Context context, AttributeSet attrs, int defStyleAttr) { 52 | super(context, attrs, defStyleAttr); 53 | init(context, attrs); 54 | } 55 | 56 | private void init(Context context, AttributeSet attrs) { 57 | gravity = Gravity.END | Gravity.TOP; 58 | this.mContext = context; 59 | //get custom attribute 60 | TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.BadgeViewPro); 61 | bgColor = ta.getColor(R.styleable.BadgeViewPro_bgColor, Color.RED); 62 | textColor = ta.getColor(R.styleable.BadgeViewPro_textColor, Color.WHITE); 63 | textSize = ta.getDimensionPixelSize(R.styleable.BadgeViewPro_textSize, 10); 64 | shape_type = ta.getInteger(R.styleable.BadgeViewPro_shape_type, SHAPE_ROUND_RECTANGLE); 65 | ta.recycle(); 66 | if (!(getLayoutParams() instanceof FrameLayout.LayoutParams)) { 67 | FrameLayout.LayoutParams layoutParams = 68 | new FrameLayout.LayoutParams( 69 | android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 70 | android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 71 | gravity); 72 | setLayoutParams(layoutParams); 73 | } 74 | //文本居中 75 | setGravity(Gravity.CENTER); 76 | setPadding(TypefaceUtil.dip2Px(context, 5) 77 | , TypefaceUtil.dip2Px(context, 1) 78 | , TypefaceUtil.dip2Px(context, 5) 79 | , TypefaceUtil.dip2Px(context, 1)); 80 | } 81 | 82 | 83 | private void setTextBgShape() { 84 | switch (shape_type) { 85 | case SHAPE_CIRCLE: 86 | ShapeUtil.setCircleBg(this, bgColor); 87 | break; 88 | case SHAPE_OVAL: 89 | ShapeUtil.setOvalBg(this, bgColor); 90 | break; 91 | case SHAPE_RECTANGLE: 92 | ShapeUtil.setRectBg(this, bgColor); 93 | break; 94 | case SHAPE_ROUND_RECTANGLE: 95 | ShapeUtil.setRoundRectBg(mContext, this, 9, bgColor); 96 | break; 97 | default: 98 | break; 99 | } 100 | } 101 | 102 | /** 103 | * 设置目标View的Margin 104 | * 105 | * @param left leftMargin 106 | * @param top topMargin 107 | * @param right rightMargin 108 | * @param bottom bottomMargin 109 | * @return BadgeViewPro 110 | */ 111 | public BadgeViewPro setMargin(float left, float top, float right, float bottom) { 112 | leftMargin = TypefaceUtil.dip2Px(mContext, left); 113 | topMargin = TypefaceUtil.dip2Px(mContext, top); 114 | rightMargin = TypefaceUtil.dip2Px(mContext, right); 115 | bottomMargin = TypefaceUtil.dip2Px(mContext, bottom); 116 | return this; 117 | } 118 | 119 | /** 120 | * 设置文本颜色 121 | * 122 | * @param textColor TextColor 123 | * @return BadgeViewPro 124 | */ 125 | public BadgeViewPro setStrColor(int textColor) { 126 | this.textColor = textColor; 127 | return this; 128 | } 129 | 130 | /** 131 | * 设置显示文本 132 | * 133 | * @param textStr StrText 134 | * @return BadgeViewPro 135 | */ 136 | public BadgeViewPro setStrText(String textStr) { 137 | this.textStr = textStr; 138 | return this; 139 | } 140 | 141 | /** 142 | * 设置文本大小 143 | * 144 | * @param textSize TextSize 145 | * @return BadgeViewPro 146 | */ 147 | public BadgeViewPro setStrSize(int textSize) { 148 | this.textSize = textSize; 149 | return this; 150 | } 151 | 152 | /** 153 | * 设置文字背景颜色 154 | * 155 | * @param bgColor Background Color 156 | * @return BadgeViewPro 157 | */ 158 | public BadgeViewPro setStrBgColor(int bgColor) { 159 | this.bgColor = bgColor; 160 | return this; 161 | } 162 | 163 | /** 164 | * 设置文本背景类型 165 | * 166 | * @param shapeType ShapeType 167 | * @return BadgeViewPro 168 | */ 169 | public BadgeViewPro setShape(int shapeType) { 170 | this.shape_type = shapeType; 171 | return this; 172 | } 173 | 174 | /** 175 | * get text background 176 | * 177 | * @param mGravity Gravity 178 | * @return BadgeViewPro 179 | */ 180 | public BadgeViewPro setBgGravity(int mGravity) { 181 | this.gravity = mGravity; 182 | FrameLayout.LayoutParams layoutParams = 183 | new FrameLayout.LayoutParams( 184 | android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 185 | android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 186 | gravity); 187 | setLayoutParams(layoutParams); 188 | return this; 189 | } 190 | 191 | 192 | /** 193 | * 绑定目标View 194 | * 195 | * @param target 目标View 196 | */ 197 | public void setTargetView(final View target) { 198 | if (target == null) { 199 | return; 200 | } 201 | //目标view不可见,直接return 202 | if (target.getVisibility() == View.GONE | target.getVisibility() == View.INVISIBLE) return; 203 | if (TextUtils.isEmpty(textStr)) { 204 | shape_type = SHAPE_CIRCLE; 205 | } else { 206 | setText(textStr); 207 | } 208 | setTextSize(textSize); 209 | setTextColor(textColor); 210 | setTextBgShape(); 211 | target.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { 212 | @Override 213 | public void onGlobalLayout() { 214 | if (getParent() != null) { 215 | ((ViewGroup) getParent()).removeView(BadgeViewPro.this); 216 | } 217 | if (target.getParent() instanceof FrameLayout) { 218 | FrameLayout parentContainer = (FrameLayout) target.getParent(); 219 | setParams(target, parentContainer); 220 | parentContainer.addView(BadgeViewPro.this); 221 | } else if (target.getParent() instanceof ViewGroup) { 222 | //find TargetView's parent and remove TargetView from parent 223 | ViewGroup parentContainer = (ViewGroup) target.getParent(); 224 | int groupIndex = parentContainer.indexOfChild(target); 225 | parentContainer.removeView(target); 226 | // new a FrameLayout that contains TargetView 227 | FrameLayout pContainer = new FrameLayout(getContext()); 228 | //set LayoutParams 229 | setParams(target, pContainer); 230 | pContainer.addView(target); 231 | pContainer.addView(BadgeViewPro.this); 232 | parentContainer.addView(pContainer, groupIndex); 233 | } else if (target.getParent() == null) { 234 | Log.e(getClass().getSimpleName(), "ParentView is needed"); 235 | } 236 | target.getViewTreeObserver().removeGlobalOnLayoutListener(this); 237 | } 238 | }); 239 | 240 | 241 | } 242 | 243 | /** 244 | * 设置targetView和父View的LayoutParams 245 | * 246 | * @param target TargetView 247 | * @param parentContainer TargetView的父View 248 | */ 249 | private void setParams(View target, FrameLayout parentContainer) { 250 | int tempWidth, tempHeight; 251 | ViewGroup.LayoutParams containerParams = target.getLayoutParams(); 252 | tempWidth = target.getWidth(); 253 | tempHeight = target.getHeight(); 254 | containerParams.width = (int) (tempWidth + leftMargin + rightMargin); 255 | containerParams.height = (int) (tempHeight + topMargin + bottomMargin); 256 | parentContainer.setLayoutParams(containerParams); 257 | parentContainer.setId(target.getId()); 258 | FrameLayout.LayoutParams targetViewMargin = new FrameLayout.LayoutParams(tempWidth, tempHeight); 259 | targetViewMargin.leftMargin = (int) leftMargin; 260 | targetViewMargin.rightMargin = (int) rightMargin; 261 | targetViewMargin.topMargin = (int) topMargin; 262 | targetViewMargin.bottomMargin = (int) bottomMargin; 263 | target.setLayoutParams(targetViewMargin); 264 | } 265 | } 266 | -------------------------------------------------------------------------------- /badgelibrary/src/main/java/org/ninetripods/mq/badgelibrary/CircleDrawable.java: -------------------------------------------------------------------------------- 1 | package org.ninetripods.mq.badgelibrary; 2 | 3 | /** 4 | * Created by MQ on 2016/11/30. 5 | */ 6 | 7 | import android.graphics.Canvas; 8 | import android.graphics.ColorFilter; 9 | import android.graphics.Paint; 10 | import android.graphics.PixelFormat; 11 | import android.graphics.Rect; 12 | import android.graphics.drawable.Drawable; 13 | 14 | public class CircleDrawable extends Drawable { 15 | 16 | 17 | private final Paint mPaint; 18 | private int mRadius = 0; 19 | 20 | public CircleDrawable(final int color) { 21 | this.mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 22 | this.mPaint.setColor(color); 23 | } 24 | 25 | @Override 26 | public void draw(final Canvas canvas) { 27 | final Rect bounds = getBounds(); 28 | canvas.drawCircle(bounds.centerX(), bounds.centerY(), mRadius, mPaint); 29 | } 30 | 31 | @Override 32 | protected void onBoundsChange(final Rect bounds) { 33 | super.onBoundsChange(bounds); 34 | mRadius = Math.min(bounds.width(), bounds.height()) / 2; 35 | } 36 | 37 | @Override 38 | public void setAlpha(final int alpha) { 39 | mPaint.setAlpha(alpha); 40 | } 41 | 42 | @Override 43 | public void setColorFilter(final ColorFilter cf) { 44 | mPaint.setColorFilter(cf); 45 | } 46 | 47 | @Override 48 | public int getOpacity() { 49 | return PixelFormat.TRANSLUCENT; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /badgelibrary/src/main/java/org/ninetripods/mq/badgelibrary/ShapeUtil.java: -------------------------------------------------------------------------------- 1 | package org.ninetripods.mq.badgelibrary; 2 | 3 | import android.content.Context; 4 | import android.graphics.Color; 5 | import android.graphics.Paint; 6 | import android.graphics.drawable.ShapeDrawable; 7 | import android.graphics.drawable.shapes.OvalShape; 8 | import android.graphics.drawable.shapes.RectShape; 9 | import android.graphics.drawable.shapes.RoundRectShape; 10 | import android.view.View; 11 | 12 | /** 13 | * Created by MQ on 2016/11/29. 14 | */ 15 | 16 | class ShapeUtil { 17 | /** 18 | * 设置圆角矩形背景 19 | * 20 | * @param mContext Context 21 | * @param view TargetView 22 | * @param dipRadius circular radius 23 | * @param badgeColor background color 24 | */ 25 | static void setRoundRectBg(Context mContext, View view, int dipRadius, int badgeColor) { 26 | int radius = TypefaceUtil.dip2Px(mContext, dipRadius); 27 | float[] radiusArray = new float[]{radius, radius, radius, radius, radius, radius, radius, radius}; 28 | RoundRectShape roundRect = new RoundRectShape(radiusArray, null, null); 29 | ShapeDrawable bgDrawable = new ShapeDrawable(roundRect); 30 | bgDrawable.getPaint().setColor(badgeColor); 31 | view.setBackgroundDrawable(bgDrawable); 32 | } 33 | 34 | /** 35 | * 设置矩形背景 36 | * 37 | * @param view TargetView 38 | * @param badgeColor background color 39 | */ 40 | static void setRectBg(View view, int badgeColor) { 41 | RectShape rectShape = new RectShape(); 42 | ShapeDrawable drawable = new ShapeDrawable(rectShape); 43 | drawable.getPaint().setColor(badgeColor); 44 | drawable.getPaint().setStyle(Paint.Style.FILL); //填充 45 | view.setBackgroundDrawable(drawable); 46 | } 47 | 48 | /** 49 | * 设置椭圆背景 50 | * 51 | * @param view TargetView 52 | * @param badgeColor background color 53 | */ 54 | static void setOvalBg(View view, int badgeColor) { 55 | OvalShape ovalShape = new OvalShape(); 56 | ShapeDrawable drawable = new ShapeDrawable(ovalShape); 57 | drawable.getPaint().setColor(badgeColor); 58 | drawable.getPaint().setStyle(Paint.Style.FILL); 59 | // drawable.getPaint().setStrokeWidth(1); 60 | // drawable.setBounds(0, 0, view.getMeasuredWidth() * 2, view.getMeasuredHeight() * 2); 61 | // drawable.getPaint().setShadowLayer(10, 15, 15, Color.GREEN);//设置阴影 62 | view.setBackgroundDrawable(drawable); 63 | } 64 | 65 | /** 66 | * 设置椭圆背景 67 | * 68 | * @param view TargetView 69 | * @param badgeColor background color 70 | */ 71 | static void setCircleBg(View view, int badgeColor) { 72 | view.setBackgroundDrawable(new CircleDrawable(badgeColor)); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /badgelibrary/src/main/java/org/ninetripods/mq/badgelibrary/TypefaceUtil.java: -------------------------------------------------------------------------------- 1 | package org.ninetripods.mq.badgelibrary; 2 | 3 | import android.content.Context; 4 | 5 | /** 6 | * Created by MQ on 2016/11/28. 7 | */ 8 | 9 | public class TypefaceUtil { 10 | /* 11 | * converts dip to px 12 | */ 13 | public static int dip2Px(Context context, float dip) { 14 | return (int) (dip * context.getResources().getDisplayMetrics().density + 0.5f); 15 | } 16 | 17 | // /** 18 | // * converts sp to px 19 | // */ 20 | // public static int sp2px(Context context, float sp) { 21 | // return (int) (sp * context.getResources().getDisplayMetrics().scaledDensity); 22 | // } 23 | 24 | public static int sp2px(Context context, float spValue) { 25 | final float fontScale = context.getResources().getDisplayMetrics().scaledDensity; 26 | return (int) (spValue * fontScale + 0.5f); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /badgelibrary/src/main/res/values/attr.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /badgelibrary/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | BadgeLibrary 3 | 4 | -------------------------------------------------------------------------------- /badgelibrary/src/test/java/org/ninetripods/mq/badgelibrary/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package org.ninetripods.mq.badgelibrary; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /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:2.2.2' 9 | classpath 'com.novoda:bintray-release:0.3.4' 10 | } 11 | } 12 | 13 | allprojects { 14 | repositories { 15 | jcenter() 16 | } 17 | tasks.withType(Javadoc) { 18 | options{ 19 | encoding "UTF-8" 20 | charSet 'UTF-8' 21 | links "http://docs.oracle.com/javase/7/docs/api" 22 | } 23 | } 24 | } 25 | 26 | task clean(type: Delete) { 27 | delete rootProject.buildDir 28 | } 29 | -------------------------------------------------------------------------------- /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 | org.gradle.jvmargs=-Xmx1336m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyqiang/BadgeView/cdb47da7e14009df21f3d7fd670033121f131f84/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 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.14.1-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 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /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', ':badgelibrary' 2 | --------------------------------------------------------------------------------