├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── simple │ │ └── bubbleview │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── simple │ │ │ └── bubbleview │ │ │ ├── Adapter.java │ │ │ ├── ItemModel.java │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ ├── activity_main.xml │ │ └── item_recycler.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── simple │ └── bubbleview │ └── ExampleUnitTest.java ├── bubbleviewlibrary ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── simple │ │ └── bubbleviewlibrary │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── simple │ │ │ └── bubbleviewlibrary │ │ │ ├── BubbleView.java │ │ │ ├── Circle.java │ │ │ ├── Density.java │ │ │ ├── Particle.java │ │ │ └── Point.java │ └── res │ │ └── values │ │ ├── attrs.xml │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── simple │ └── bubbleviewlibrary │ └── ExampleUnitTest.java ├── build.gradle ├── gifs └── bubbleview.gif ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /.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 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BubbleView 2 | 3 | ## 自古代码看着烦,唯有图片得人心,so特意图片整的很大😈 4 | 5 | ![](https://raw.githubusercontent.com/simplepeng/BubbleView/master/gifs/bubbleview.gif) 6 | 7 | ## 使用 8 | 9 | * maven 10 | 11 | ``` 12 | 13 | com.simplepeng.bubbleview 14 | bubbleviewlibrary 15 | 0.0.1 16 | pom 17 | 18 | ``` 19 | 20 | * gradle 21 | 22 | ``` 23 | compile 'com.simplepeng.bubbleview:bubbleviewlibrary:0.0.1' 24 | ``` 25 | 26 | * 具体使用详见demo 27 | 28 | ## 方法属性 29 | 30 | | 方法 | 属性 | 说明 | 31 | | ------------- |:-------------:| -----:| 32 | | setText | text | 设置文字 | 33 | | setTextColor| text_color | 设置文字颜色 | 34 | | setCircleColor | circle_color | 设置圆的颜色 | 35 | | setTextSize | text_size | 设置文字大小 | 36 | 37 | ## 联系我 38 | 39 | Android进阶开发 274306954 40 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 24 5 | buildToolsVersion "24.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.simple.bubbleview" 9 | minSdkVersion 15 10 | targetSdkVersion 24 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:24.2.0' 26 | compile 'com.android.support:design:24.2.0' 27 | compile 'com.simplepeng:attrbutter_library:1.0.7' 28 | compile project(':bubbleviewlibrary') 29 | // compile 'com.simplepeng:attrbutter_compiler:1.0.1' 30 | } 31 | -------------------------------------------------------------------------------- /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 /Users/simple/Library/Android/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/simple/bubbleview/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.simple.bubbleview; 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 | 5 | 6 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/simple/bubbleview/Adapter.java: -------------------------------------------------------------------------------- 1 | package com.simple.bubbleview; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.TextView; 9 | 10 | import com.simple.bubbleviewlibrary.BubbleView; 11 | 12 | import java.util.List; 13 | 14 | public class Adapter extends RecyclerView.Adapter { 15 | 16 | private Context context; 17 | private List itemModels; 18 | 19 | public Adapter(Context context, List itemModels) { 20 | this.context = context; 21 | this.itemModels = itemModels; 22 | } 23 | 24 | @Override 25 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 26 | View view = LayoutInflater.from(context) 27 | .inflate(R.layout.item_recycler, null, false); 28 | return new ViewHolder(view); 29 | } 30 | 31 | @Override 32 | public void onBindViewHolder(ViewHolder holder, int position) { 33 | final ItemModel itemModel = itemModels.get(position); 34 | holder.tv.setText(itemModel.getMsgCount()); 35 | holder.bubbleView.setVisibility(itemModel.isVisibility() ? View.VISIBLE : View.GONE); 36 | holder.bubbleView.setText(itemModel.getMsgCount()); 37 | holder.bubbleView.setTextColor(itemModel.getTextColor()); 38 | holder.bubbleView.setCircleColor(itemModel.getCircleColor()); 39 | holder.bubbleView.setOnAnimationEndListener(new BubbleView.OnAnimationEndListener() { 40 | @Override 41 | public void onEnd(BubbleView bubbleView) { 42 | itemModel.setVisibility(false); 43 | bubbleView.setVisibility(View.GONE); 44 | } 45 | }); 46 | } 47 | 48 | @Override 49 | public int getItemCount() { 50 | return itemModels.size(); 51 | } 52 | 53 | static class ViewHolder extends RecyclerView.ViewHolder { 54 | 55 | TextView tv; 56 | BubbleView bubbleView; 57 | 58 | public ViewHolder(View itemView) { 59 | super(itemView); 60 | tv = (TextView) itemView.findViewById(R.id.tv); 61 | bubbleView = (BubbleView) itemView.findViewById(R.id.bubbleView); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /app/src/main/java/com/simple/bubbleview/ItemModel.java: -------------------------------------------------------------------------------- 1 | package com.simple.bubbleview; 2 | 3 | 4 | public class ItemModel { 5 | private String msgCount; 6 | private int textColor; 7 | private int circleColor; 8 | private boolean visibility = true; 9 | 10 | public boolean isVisibility() { 11 | return visibility; 12 | } 13 | 14 | public void setVisibility(boolean visibility) { 15 | this.visibility = visibility; 16 | } 17 | 18 | public int getCircleColor() { 19 | return circleColor; 20 | } 21 | 22 | public void setCircleColor(int circleColor) { 23 | this.circleColor = circleColor; 24 | } 25 | 26 | public int getTextColor() { 27 | return textColor; 28 | } 29 | 30 | public void setTextColor(int textColor) { 31 | this.textColor = textColor; 32 | } 33 | 34 | public String getMsgCount() { 35 | return msgCount; 36 | } 37 | 38 | public void setMsgCount(String msgCount) { 39 | this.msgCount = msgCount; 40 | } 41 | } -------------------------------------------------------------------------------- /app/src/main/java/com/simple/bubbleview/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.simple.bubbleview; 2 | 3 | import android.graphics.Color; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.support.v7.widget.LinearLayoutManager; 7 | import android.support.v7.widget.RecyclerView; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | import java.util.Random; 12 | 13 | public class MainActivity extends AppCompatActivity { 14 | 15 | private RecyclerView recyclerView; 16 | private List itemModels = new ArrayList<>(); 17 | private Random random = new Random(); 18 | private int[] circleColors = {Color.RED, Color.parseColor("#98F5FF"), Color.parseColor("#87CEFF"), 19 | Color.parseColor("#8B658B"), Color.parseColor("#B22222")}; 20 | private int[] textColors = {Color.BLACK, Color.WHITE}; 21 | 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | setContentView(R.layout.activity_main); 26 | 27 | recyclerView = (RecyclerView) findViewById(R.id.recyclerView); 28 | 29 | for (int i = 0; i < 50; i++) { 30 | ItemModel itemModel = new ItemModel(); 31 | itemModel.setMsgCount(String.valueOf(i)); 32 | itemModel.setCircleColor(circleColors[random.nextInt(circleColors.length)]); 33 | itemModel.setTextColor(textColors[random.nextInt(textColors.length)]); 34 | itemModels.add(itemModel); 35 | } 36 | recyclerView.setLayoutManager(new LinearLayoutManager(this)); 37 | recyclerView.setAdapter(new Adapter(MainActivity.this, itemModels)); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_recycler.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 16 | 17 | 27 | 28 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simplepeng/BubbleView/138dc277814a38111e935b5ee5d53a49c78d4a91/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simplepeng/BubbleView/138dc277814a38111e935b5ee5d53a49c78d4a91/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simplepeng/BubbleView/138dc277814a38111e935b5ee5d53a49c78d4a91/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simplepeng/BubbleView/138dc277814a38111e935b5ee5d53a49c78d4a91/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simplepeng/BubbleView/138dc277814a38111e935b5ee5d53a49c78d4a91/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/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | @android:color/black 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | BubbleView 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/test/java/com/simple/bubbleview/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.simple.bubbleview; 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 | } -------------------------------------------------------------------------------- /bubbleviewlibrary/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /bubbleviewlibrary/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | apply plugin: 'com.jfrog.bintray' 4 | 5 | android { 6 | 7 | //resourcePrefix "cc_" //随意填写 8 | 9 | compileSdkVersion 24 10 | buildToolsVersion "24.0.2" 11 | 12 | defaultConfig { 13 | minSdkVersion 15 14 | targetSdkVersion 24 15 | versionCode 1 16 | versionName "1.0" 17 | } 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | } 25 | 26 | dependencies { 27 | compile fileTree(dir: 'libs', include: ['*.jar']) 28 | testCompile 'junit:junit:4.12' 29 | compile 'com.android.support:appcompat-v7:24.2.0' 30 | } 31 | 32 | // 这个version是区分library版本的,因此当我们需要更新library时记得修改这个version 33 | // 这个version影响后面的引用 34 | version = "0.0.1" 35 | def siteUrl = 'https://github.com/simplepeng/BubbleView' // 项目的主页 36 | def gitUrl = 'https://github.com/simplepeng/BubbleView.git' // Git仓库的url 37 | group = "com.simplepeng.bubbleview" // Maven Group ID for the artifact,一般填你唯一的包名 38 | install { 39 | repositories.mavenInstaller { 40 | // This generates POM.xml with proper parameters 41 | pom { 42 | project { 43 | packaging 'aar' 44 | // Add your description here 45 | name 'bubbleview for android' //项目的描述 你可以多写一点 46 | url siteUrl 47 | // Set your license 48 | licenses { 49 | license { 50 | name 'The Apache Software License, Version 2.0' 51 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt' 52 | } 53 | } 54 | developers { 55 | developer { 56 | id 'simplepeng' //填写的一些基本信息 57 | name 'simplepeng' 58 | email '383559698@qq.com' 59 | } 60 | } 61 | scm { 62 | connection gitUrl 63 | developerConnection gitUrl 64 | url siteUrl 65 | } 66 | } 67 | } 68 | } 69 | } 70 | task sourcesJar(type: Jar) { 71 | from android.sourceSets.main.java.srcDirs 72 | classifier = 'sources' 73 | } 74 | task javadoc(type: Javadoc) { 75 | source = android.sourceSets.main.java.srcDirs 76 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 77 | } 78 | task javadocJar(type: Jar, dependsOn: javadoc) { 79 | classifier = 'javadoc' 80 | from javadoc.destinationDir 81 | } 82 | artifacts { 83 | archives javadocJar 84 | archives sourcesJar 85 | } 86 | Properties properties = new Properties() 87 | properties.load(project.rootProject.file('local.properties').newDataInputStream()) 88 | bintray { 89 | user = properties.getProperty("bintray.user") 90 | key = properties.getProperty("bintray.apikey") 91 | configurations = ['archives'] 92 | pkg { 93 | repo = "maven" 94 | name = "bubbleview" //发布到JCenter上的项目名字 95 | websiteUrl = siteUrl 96 | vcsUrl = gitUrl 97 | licenses = ["Apache-2.0"] 98 | publish = true 99 | } 100 | } 101 | 102 | -------------------------------------------------------------------------------- /bubbleviewlibrary/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 /Users/simple/Library/Android/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 | -------------------------------------------------------------------------------- /bubbleviewlibrary/src/androidTest/java/com/simple/bubbleviewlibrary/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.simple.bubbleviewlibrary; 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 | } -------------------------------------------------------------------------------- /bubbleviewlibrary/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /bubbleviewlibrary/src/main/java/com/simple/bubbleviewlibrary/BubbleView.java: -------------------------------------------------------------------------------- 1 | package com.simple.bubbleviewlibrary; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | import android.content.Context; 6 | import android.content.res.TypedArray; 7 | import android.graphics.Bitmap; 8 | import android.graphics.Canvas; 9 | import android.graphics.Color; 10 | import android.graphics.Paint; 11 | import android.graphics.Path; 12 | import android.graphics.Rect; 13 | import android.text.TextUtils; 14 | import android.util.AttributeSet; 15 | import android.util.Log; 16 | import android.view.MotionEvent; 17 | import android.view.View; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | /** 23 | * 24 | */ 25 | public class BubbleView extends View { 26 | 27 | private static final String TAG = "BubbleView"; 28 | //贝塞尔曲线的path 29 | private Path mPath = new Path(); 30 | //圆的画笔 31 | private Paint circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG); 32 | //文字的画笔 33 | private Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 34 | //开始的圆 35 | private Circle startCircle; 36 | //结束的圆 37 | private Circle endCircle; 38 | //两个圆连接的点 39 | private Point startCircleA = new Point(); 40 | private Point startCircleB = new Point(); 41 | private Point endCircleC = new Point(); 42 | private Point endCircleD = new Point(); 43 | //控制贝塞尔曲线的点 44 | private Point quadControlE = new Point(); 45 | //圆心相距的距离 46 | private float circleCenterDistan = 0; 47 | //是否能画path 48 | private boolean canDrawPath = true; 49 | //默认的文本 50 | private String text = ""; 51 | //圆的颜色 52 | private int circle_color; 53 | //文字的颜色 54 | private int text_color; 55 | //文字的大小 56 | private float text_size; 57 | //粒子的集合 58 | private List particleList = new ArrayList<>(); 59 | //是否画粒子 60 | private boolean canDrawParticle = false; 61 | //粒子的画笔 62 | private Paint particlePaint = new Paint(Paint.ANTI_ALIAS_FLAG); 63 | //生成粒子的bitmap 64 | private Bitmap bitmap; 65 | // 66 | private float lastDistan; 67 | //动画结束的监听 68 | private OnAnimationEndListener mOnAnimationEndListener; 69 | private int mWidth; 70 | private int mHeight; 71 | 72 | public BubbleView(Context context) { 73 | this(context, null); 74 | } 75 | 76 | public BubbleView(Context context, AttributeSet attrs) { 77 | super(context, attrs); 78 | TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.BubbleView); 79 | text = ta.getString(R.styleable.BubbleView_text); 80 | circle_color = ta.getColor(R.styleable.BubbleView_circle_color, Color.RED); 81 | text_color = ta.getColor(R.styleable.BubbleView_text_color, Color.WHITE); 82 | text_size = ta.getDimension(R.styleable.BubbleView_text_size, Density.dp2px(getContext(), 15)); 83 | ta.recycle(); 84 | init(); 85 | } 86 | 87 | private void init() { 88 | circlePaint.setColor(circle_color); 89 | textPaint.setColor(text_color); 90 | textPaint.setTextSize(text_size); 91 | } 92 | 93 | @Override 94 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 95 | int width_mode = MeasureSpec.getMode(widthMeasureSpec); 96 | int width_size = MeasureSpec.getSize(widthMeasureSpec); 97 | if (width_mode == MeasureSpec.EXACTLY) { 98 | widthMeasureSpec = width_size; 99 | } else { 100 | widthMeasureSpec = Density.dp2px(getContext(), 15); 101 | } 102 | int height_mode = MeasureSpec.getMode(heightMeasureSpec); 103 | int height_size = MeasureSpec.getSize(heightMeasureSpec); 104 | if (height_mode == MeasureSpec.EXACTLY) { 105 | heightMeasureSpec = height_size; 106 | } else { 107 | heightMeasureSpec = Density.dp2px(getContext(), 15); 108 | } 109 | setMeasuredDimension(widthMeasureSpec, heightMeasureSpec); 110 | } 111 | 112 | @Override 113 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 114 | super.onSizeChanged(w, h, oldw, oldh); 115 | this.mWidth = w; 116 | this.mHeight = h; 117 | startCircle = new Circle(w / 2, w / 2, h / 2); 118 | endCircle = new Circle(w / 2, w / 2, h / 2); 119 | } 120 | 121 | @Override 122 | protected void onDraw(Canvas canvas) { 123 | if (canDrawPath) { 124 | drawPath(canvas); 125 | drawCircle(canvas, startCircle); 126 | } 127 | if (canDrawParticle) { 128 | drawParticle(canvas, particleList); 129 | return; 130 | } 131 | drawCircle(canvas, endCircle); 132 | drawText(canvas, endCircle); 133 | } 134 | 135 | @Override 136 | public boolean onTouchEvent(MotionEvent event) { 137 | switch (event.getAction()) { 138 | case MotionEvent.ACTION_DOWN: 139 | bitmap = createBitmap(); 140 | invalidate(); 141 | break; 142 | case MotionEvent.ACTION_MOVE: 143 | float x = event.getX(); 144 | float y = event.getY(); 145 | endCircle.set(x, y); 146 | computePath(); 147 | invalidate(); 148 | lastDistan = circleCenterDistan; 149 | getParent().requestDisallowInterceptTouchEvent(true); 150 | break; 151 | case MotionEvent.ACTION_UP: 152 | if (!canDrawPath) {// 153 | generateParticles(bitmap); 154 | startAnimation(); 155 | // invalidate(); 156 | } else { 157 | endCircle.set(startCircle.getX(), startCircle.getY()); 158 | startCircle.setRadius(endCircle.getRadius()); 159 | computePath(); 160 | invalidate(); 161 | } 162 | break; 163 | case MotionEvent.ACTION_CANCEL: 164 | if (canDrawPath) { 165 | endCircle.set(startCircle.getX(), startCircle.getY()); 166 | startCircle.setRadius(endCircle.getRadius()); 167 | computePath(); 168 | invalidate(); 169 | } 170 | break; 171 | } 172 | return true; 173 | } 174 | 175 | 176 | /** 177 | * 生成粒子 178 | */ 179 | private void generateParticles(Bitmap bitmap) { 180 | canDrawParticle = true; 181 | float particleRadius = endCircle.getRadius() * 2 / Particle.particleCount / 2; 182 | int bitmap_w = bitmap.getWidth(); 183 | int bitmap_h = bitmap.getHeight(); 184 | for (int i = 0; i < Particle.particleCount; i++) { 185 | for (int j = 0; j < Particle.particleCount; j++) { 186 | float width = endCircle.getX() - endCircle.getRadius() + i * particleRadius * 2; 187 | float height = endCircle.getY() - endCircle.getRadius() + j * particleRadius * 2; 188 | int color = bitmap.getPixel(bitmap_w / Particle.particleCount * i, 189 | bitmap_h / Particle.particleCount * j); 190 | Particle particle = new Particle(width, height, particleRadius, color); 191 | particleList.add(particle); 192 | } 193 | } 194 | } 195 | 196 | /** 197 | * 开始动画 198 | */ 199 | private void startAnimation() { 200 | ValueAnimator valueAnimator = ValueAnimator.ofFloat(0.0f, 1.0f); 201 | valueAnimator.setDuration(1500); 202 | valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 203 | @Override 204 | public void onAnimationUpdate(ValueAnimator animation) { 205 | for (Particle particle : particleList) { 206 | particle.broken((Float) animation.getAnimatedValue(), getMeasuredWidth(), 207 | getMeasuredHeight()); 208 | } 209 | invalidate(); 210 | } 211 | }); 212 | valueAnimator.addListener(new Animator.AnimatorListener() { 213 | @Override 214 | public void onAnimationStart(Animator animation) { 215 | 216 | } 217 | 218 | @Override 219 | public void onAnimationEnd(Animator animation) { 220 | clearStatus(); 221 | if (mOnAnimationEndListener != null) { 222 | mOnAnimationEndListener.onEnd(BubbleView.this); 223 | Log.d(TAG, "onAnimationEnd"); 224 | } 225 | } 226 | 227 | @Override 228 | public void onAnimationCancel(Animator animation) { 229 | 230 | } 231 | 232 | @Override 233 | public void onAnimationRepeat(Animator animation) { 234 | 235 | } 236 | }); 237 | valueAnimator.start(); 238 | } 239 | 240 | /** 241 | * 生成粒子需要的bitmap 242 | */ 243 | private Bitmap createBitmap() { 244 | int w_h = (int) (endCircle.getRadius() * 2); 245 | Bitmap bitmap = Bitmap.createBitmap(w_h, w_h, Bitmap.Config.ARGB_8888); 246 | if (bitmap != null) { 247 | Canvas canvas = new Canvas(bitmap); 248 | draw(canvas); 249 | invalidate(); 250 | } 251 | return bitmap; 252 | } 253 | 254 | /** 255 | * 计算path 256 | */ 257 | private void computePath() { 258 | float startX = startCircle.x; 259 | float startY = startCircle.y; 260 | float endX = endCircle.x; 261 | float endY = endCircle.y; 262 | //计算圆心的距离 263 | circleCenterDistan = (float) Math.sqrt(Math.pow(startX - endX, 2) 264 | + Math.pow(startY - endY, 2)); 265 | //如果圆心的距离大于半径的5倍或者起点圆半径小于等于原来半径的1/5 266 | if (circleCenterDistan > endCircle.getRadius() * 5 267 | || startCircle.getRadius() <= endCircle.getRadius() / 5) { 268 | canDrawPath = false; 269 | return; 270 | } 271 | // startCircle.setRadius(endCircle.getRadius() - startCircleRadius * 5 / endCircle.getRadius()); 272 | //计算起点圆的半径 273 | if (circleCenterDistan > endCircle.getRadius()) { 274 | startCircle.setRadius(startCircle.getRadius() 275 | - (circleCenterDistan - lastDistan) / 5); 276 | } 277 | float cos = (endY - startY) / circleCenterDistan; 278 | float sin = (endX - startX) / circleCenterDistan; 279 | 280 | float xA = startX - startCircle.getRadius() * cos; 281 | float yA = startY + startCircle.getRadius() * sin; 282 | startCircleA.set(xA, yA); 283 | float xB = startX + startCircle.getRadius() * cos; 284 | float yB = startY - startCircle.getRadius() * sin; 285 | startCircleB.set(xB, yB); 286 | float xC = endX + endCircle.getRadius() * cos; 287 | float yC = endY - endCircle.getRadius() * sin; 288 | endCircleC.set(xC, yC); 289 | float xD = endX - endCircle.getRadius() * cos; 290 | float yD = endY + endCircle.getRadius() * sin; 291 | endCircleD.set(xD, yD); 292 | 293 | float xE = startX - (startX - endX) / 2; 294 | float yE = startY + (endY - startY) / 2; 295 | quadControlE.set(xE, yE); 296 | } 297 | 298 | /** 299 | * 画路径 300 | * 301 | * @param canvas 302 | */ 303 | private void drawPath(Canvas canvas) { 304 | mPath.reset(); 305 | mPath.moveTo(startCircleA.x, startCircleA.y); 306 | mPath.lineTo(startCircleB.x, startCircleB.y); 307 | mPath.quadTo(quadControlE.x, quadControlE.y, endCircleC.x, endCircleC.y); 308 | mPath.lineTo(endCircleD.x, endCircleD.y); 309 | mPath.quadTo(quadControlE.x, quadControlE.y, startCircleA.x, startCircleA.y); 310 | canvas.drawPath(mPath, circlePaint); 311 | } 312 | 313 | /** 314 | * 画圆 315 | * 316 | * @param canvas 317 | * @param circle 318 | */ 319 | private void drawCircle(Canvas canvas, Circle circle) { 320 | canvas.drawCircle(circle.getX(), circle.getY(), circle.getRadius(), circlePaint); 321 | } 322 | 323 | /** 324 | * 画字 325 | * 326 | * @param canvas 327 | * @param endCircle 328 | */ 329 | private void drawText(Canvas canvas, Circle endCircle) { 330 | if (TextUtils.isEmpty(text)) { 331 | return; 332 | } 333 | Rect rect = new Rect(); 334 | textPaint.getTextBounds(text, 0, text.length(), rect); 335 | float textWidth = textPaint.measureText(text); 336 | float x = endCircle.x - textWidth / 2; 337 | float y = endCircle.y + (rect.bottom - rect.top) / 2; 338 | canvas.drawText(text, x, y, textPaint); 339 | } 340 | 341 | /** 342 | * 画粒子 343 | * 344 | * @param canvas 345 | * @param particleList 346 | */ 347 | private void drawParticle(Canvas canvas, List particleList) { 348 | for (Particle particle : particleList) { 349 | particlePaint.setColor(particle.color); 350 | canvas.drawCircle(particle.cx, particle.cy, particle.radius, particlePaint); 351 | } 352 | } 353 | 354 | /** 355 | * 设置文字 356 | * 357 | * @param text 358 | */ 359 | public void setText(String text) { 360 | this.text = text; 361 | invalidate(); 362 | } 363 | 364 | /** 365 | * 设置文字颜色 366 | * 367 | * @param textColor 368 | */ 369 | public void setTextColor(int textColor) { 370 | textPaint.setColor(textColor); 371 | invalidate(); 372 | } 373 | 374 | /** 375 | * 设置圆的颜色 376 | * 377 | * @param circleColor 378 | */ 379 | public void setCircleColor(int circleColor) { 380 | circlePaint.setColor(circleColor); 381 | invalidate(); 382 | } 383 | 384 | /** 385 | * 设置文字大小 386 | * 387 | * @param size 388 | */ 389 | public void setTextSize(float size) { 390 | textPaint.setTextSize(size); 391 | } 392 | 393 | /** 394 | * 刷新状态 395 | */ 396 | public void clearStatus() { 397 | mPath.reset(); 398 | canDrawPath = true; 399 | canDrawParticle = false; 400 | endCircle.set(mWidth / 2, mHeight / 2); 401 | startCircle.set(mWidth / 2, mHeight / 2); 402 | startCircle.setRadius(mWidth / 2); 403 | circleCenterDistan = 0; 404 | computePath(); 405 | invalidate(); 406 | } 407 | 408 | public void setOnAnimationEndListener(OnAnimationEndListener onAnimationEndListener) { 409 | this.mOnAnimationEndListener = onAnimationEndListener; 410 | } 411 | 412 | public interface OnAnimationEndListener { 413 | void onEnd(BubbleView bubbleView); 414 | } 415 | 416 | } 417 | -------------------------------------------------------------------------------- /bubbleviewlibrary/src/main/java/com/simple/bubbleviewlibrary/Circle.java: -------------------------------------------------------------------------------- 1 | package com.simple.bubbleviewlibrary; 2 | 3 | public class Circle { 4 | float radius; 5 | float x, y; 6 | 7 | public Circle(float radius, float x, float y) { 8 | this.radius = radius; 9 | this.x = x; 10 | this.y = y; 11 | } 12 | 13 | public void set(float x, float y) { 14 | this.x = x; 15 | this.y = y; 16 | } 17 | 18 | public float getRadius() { 19 | return radius; 20 | } 21 | 22 | public void setRadius(float radius) { 23 | this.radius = radius; 24 | } 25 | 26 | public float getX() { 27 | return x; 28 | } 29 | 30 | public void setX(float x) { 31 | this.x = x; 32 | } 33 | 34 | public float getY() { 35 | return y; 36 | } 37 | 38 | public void setY(float y) { 39 | this.y = y; 40 | } 41 | } -------------------------------------------------------------------------------- /bubbleviewlibrary/src/main/java/com/simple/bubbleviewlibrary/Density.java: -------------------------------------------------------------------------------- 1 | package com.simple.bubbleviewlibrary; 2 | 3 | import android.content.Context; 4 | 5 | /** 6 | * 比例密度转换工具类 7 | */ 8 | public class Density { 9 | 10 | public static int dp2px(Context context, float dipValue) { 11 | float scale = context.getResources().getDisplayMetrics().density; 12 | return (int) (dipValue * scale + 0.5f); 13 | } 14 | 15 | public static int px2dp(Context context, float pxValue) { 16 | float scale = context.getResources().getDisplayMetrics().density; 17 | return (int) (pxValue / scale + 0.5f); 18 | } 19 | 20 | public static int sp2px(Context context, float spValue) { 21 | final float fontScale = context.getResources().getDisplayMetrics().scaledDensity; 22 | return (int) (spValue * fontScale + 0.5f); 23 | } 24 | 25 | public static int px2sp(Context context, float pxValue) { 26 | final float fontScale = context.getResources().getDisplayMetrics().scaledDensity; 27 | return (int) (pxValue / fontScale + 0.5f); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /bubbleviewlibrary/src/main/java/com/simple/bubbleviewlibrary/Particle.java: -------------------------------------------------------------------------------- 1 | package com.simple.bubbleviewlibrary; 2 | 3 | import java.util.Random; 4 | 5 | /** 6 | * 颗粒类 7 | */ 8 | public class Particle { 9 | 10 | float cx; //center x of circle 11 | float cy; //center y of circle 12 | float radius; 13 | 14 | int color; 15 | float alpha; 16 | 17 | public static int particleCount = 10; 18 | 19 | Random random = new Random(); 20 | 21 | public Particle(float cx, float cy, float radius,int color) { 22 | this.cx = cx; 23 | this.cy = cy; 24 | this.radius = radius; 25 | this.color = color; 26 | } 27 | 28 | public void broken(float factor, int width, int height) { 29 | cx = cx + factor * random.nextInt(width) * (random.nextFloat() - 0.5f); 30 | cy = cy + factor * random.nextInt(height / 2); 31 | 32 | radius = radius - factor * random.nextInt(2); 33 | 34 | alpha = (1f - factor) * (1 + random.nextFloat()); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /bubbleviewlibrary/src/main/java/com/simple/bubbleviewlibrary/Point.java: -------------------------------------------------------------------------------- 1 | package com.simple.bubbleviewlibrary; 2 | 3 | public class Point { 4 | float x; 5 | float y; 6 | 7 | public Point() { 8 | } 9 | 10 | public Point(float x, float y) { 11 | this.x = x; 12 | this.y = y; 13 | } 14 | 15 | public void set(float x, float y) { 16 | this.x = x; 17 | this.y = y; 18 | } 19 | 20 | public float getX() { 21 | return x; 22 | } 23 | 24 | public void setX(float x) { 25 | this.x = x; 26 | } 27 | 28 | public float getY() { 29 | return y; 30 | } 31 | 32 | public void setY(float y) { 33 | this.y = y; 34 | } 35 | } -------------------------------------------------------------------------------- /bubbleviewlibrary/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /bubbleviewlibrary/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | BubbleViewLibrary 3 | 4 | -------------------------------------------------------------------------------- /bubbleviewlibrary/src/test/java/com/simple/bubbleviewlibrary/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.simple.bubbleviewlibrary; 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 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:2.1.3' 10 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4' 11 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4' 12 | // NOTE: Do not place your application dependencies here; they belong 13 | // in the individual module build.gradle files 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | mavenCentral() 20 | jcenter() 21 | } 22 | } 23 | 24 | task clean(type: Delete) { 25 | delete rootProject.buildDir 26 | } 27 | -------------------------------------------------------------------------------- /gifs/bubbleview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simplepeng/BubbleView/138dc277814a38111e935b5ee5d53a49c78d4a91/gifs/bubbleview.gif -------------------------------------------------------------------------------- /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/simplepeng/BubbleView/138dc277814a38111e935b5ee5d53a49c78d4a91/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Sep 30 11:24:54 CST 2016 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', ':bubbleviewlibrary' 2 | --------------------------------------------------------------------------------