Skip to content

Commit 1c55be1

Browse files
committed
优化
1 parent 93e1a92 commit 1c55be1

28 files changed

+1631
-574
lines changed

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ android {
55
buildToolsVersion "24.0.2"
66
defaultConfig {
77
applicationId "com.allen.androidcustomview"
8-
minSdkVersion 14
8+
minSdkVersion 19
99
targetSdkVersion 24
1010
versionCode 1
1111
versionName "1.0"
@@ -17,10 +17,12 @@ android {
1717
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
1818
}
1919
}
20+
productFlavors {
21+
}
2022
}
2123

2224
dependencies {
23-
compile fileTree(dir: 'libs', include: ['*.jar'])
25+
compile fileTree(include: ['*.jar'], dir: 'libs')
2426
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
2527
exclude group: 'com.android.support', module: 'support-annotations'
2628
})

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
<category android:name="android.intent.category.LAUNCHER" />
1616
</intent-filter>
1717
</activity>
18+
<activity android:name=".BubbleViewActivity" />
19+
<activity android:name=".WaveByBezierActivity" />
20+
<activity android:name=".WaveBySinCosActivity"></activity>
1821
</application>
1922

2023
</manifest>
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
package com.allen.androidcustomview;
2+
3+
import android.graphics.PointF;
4+
import android.os.Bundle;
5+
import android.support.v7.app.AppCompatActivity;
6+
import android.util.Log;
7+
import android.view.View;
8+
import android.widget.Button;
9+
import android.widget.ImageView;
10+
import android.widget.TextView;
11+
12+
import com.allen.androidcustomview.bean.CircleBean;
13+
import com.allen.androidcustomview.utils.DisplayUtils;
14+
import com.allen.androidcustomview.widget.BubbleView;
15+
import com.allen.androidcustomview.widget.WaveViewByBezier;
16+
17+
import java.util.ArrayList;
18+
import java.util.List;
19+
20+
public class BubbleViewActivity extends AppCompatActivity {
21+
22+
private static final String TAG = "allen";
23+
private ImageView hxbIv;
24+
private TextView hxbTv;
25+
private Button button;
26+
private BubbleView bezierView;
27+
28+
private List<CircleBean> circleBeanList = new ArrayList<>();
29+
30+
private WaveViewByBezier waveView;
31+
@Override
32+
protected void onCreate(Bundle savedInstanceState) {
33+
super.onCreate(savedInstanceState);
34+
setContentView(R.layout.activity_bubble_view);
35+
waveView = (WaveViewByBezier) findViewById(R.id.wave);
36+
hxbIv = (ImageView) findViewById(R.id.hxb_iv);
37+
hxbTv = (TextView) findViewById(R.id.center_tv);
38+
bezierView = (BubbleView) findViewById(R.id.circle_view);
39+
button = (Button) findViewById(R.id.start_btn);
40+
button.setOnClickListener(new View.OnClickListener() {
41+
@Override
42+
public void onClick(View v) {
43+
bezierView.setCenterImg(hxbTv);
44+
bezierView.openAnimation();
45+
46+
}
47+
});
48+
49+
50+
initPoint();
51+
52+
bezierView.setCircleBeen(circleBeanList);
53+
// bezierView.createInAnimation();
54+
}
55+
56+
private void initPoint() {
57+
58+
int height = DisplayUtils.getDisplayHight(this);
59+
int width = DisplayUtils.getDisplayWidth(this);
60+
61+
int centerX = width / 2;
62+
int centerY = height / 2;
63+
64+
65+
Log.d(TAG, "initPoint: " + centerX + "----" + centerY);
66+
67+
68+
CircleBean circleBean = new CircleBean(
69+
new PointF((float) (-width / 5.1), (float) (height / 1.5)),
70+
new PointF(centerX - 30, height * 2 / 3),
71+
new PointF((float) (width / 2.4), (float) (height / 3.4)),
72+
new PointF(width / 6, centerY - 120),
73+
new PointF((float) (width / 7.2), -height / 128),
74+
(float) (width / 14.4), 60);
75+
CircleBean circleBean2 = new CircleBean(
76+
new PointF(-width / 4, (float) (height / 1.3)),
77+
new PointF(centerX - 20, height * 3 / 5),
78+
new PointF((float) (width / 2.1), (float) (height / 2.5)),
79+
new PointF(width / 3, centerY - 10),
80+
new PointF(width / 4, (float) (-height / 5.3)),
81+
width / 4, 60);
82+
CircleBean circleBean3 = new CircleBean(
83+
new PointF(-width / 12, (float) (height / 1.1)),
84+
new PointF(centerX - 100, height * 2 / 3),
85+
new PointF((float) (width / 3.4), height / 2),
86+
new PointF(0, centerY + 100),
87+
new PointF(0, 0),
88+
width / 24, 60);
89+
90+
CircleBean circleBean4 = new CircleBean(
91+
new PointF(-width / 9, (float) (height / 0.9)),
92+
new PointF(centerX, height * 3 / 4),
93+
new PointF((float) (width / 2.1), (float) (height / 2.3)),
94+
new PointF(width / 2, centerY),
95+
new PointF((float) (width / 1.5), (float) (-height / 5.6)),
96+
width / 4, 60);
97+
98+
CircleBean circleBean5 = new CircleBean(
99+
new PointF((float) (width / 1.4), (float) (height / 0.9)),
100+
new PointF(centerX, height * 3 / 4),
101+
new PointF(width / 2, (float) (height / 2.37)),
102+
new PointF(width * 10 / 13, centerY - 20),
103+
new PointF(width / 2, (float) (-height / 7.1)),
104+
width / 4, 60);
105+
CircleBean circleBean6 = new CircleBean(
106+
new PointF((float) (width / 0.8), height),
107+
new PointF(centerX + 20, height * 2 / 3),
108+
new PointF((float) (width / 1.9), (float) (height / 2.3)),
109+
new PointF(width * 11 / 14, centerY + 10),
110+
111+
new PointF((float) (width / 1.1), (float) (-height / 6.4)),
112+
(float) (width / 4), 60);
113+
CircleBean circleBean7 = new CircleBean(
114+
new PointF((float) (width / 0.9), (float) (height / 1.2)),
115+
new PointF(centerX + 20, height * 4 / 7),
116+
new PointF((float) (width / 1.6), (float) (height / 1.9)),
117+
new PointF(width, centerY + 10),
118+
119+
new PointF(width, 0),
120+
(float) (width / 9.6), 60);
121+
122+
circleBeanList.add(circleBean);
123+
circleBeanList.add(circleBean2);
124+
circleBeanList.add(circleBean3);
125+
circleBeanList.add(circleBean4);
126+
circleBeanList.add(circleBean5);
127+
circleBeanList.add(circleBean6);
128+
circleBeanList.add(circleBean7);
129+
130+
}
131+
132+
/**
133+
* 获取状态栏高度
134+
*
135+
* @return
136+
*/
137+
public int getStatusBarHeight() {
138+
int result = 0;
139+
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
140+
if (resourceId > 0) {
141+
result = getResources().getDimensionPixelSize(resourceId);
142+
}
143+
return result;
144+
}
145+
146+
147+
@Override
148+
protected void onResume() {
149+
super.onResume();
150+
Log.d(TAG, "onResume: ");
151+
waveView.startAnimation();
152+
}
153+
154+
@Override
155+
protected void onPause() {
156+
super.onPause();
157+
Log.d(TAG, "onPause: ");
158+
waveView.stopAnimation();
159+
}
160+
}
Lines changed: 25 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,48 @@
11
package com.allen.androidcustomview;
22

3+
import android.content.Intent;
34
import android.os.Bundle;
45
import android.support.v7.app.AppCompatActivity;
5-
import android.util.Log;
66
import android.view.View;
77
import android.widget.Button;
88

9-
import com.allen.androidcustomview.bean.CircleBean;
10-
import com.allen.androidcustomview.bean.Point;
11-
import com.allen.androidcustomview.utils.DisplayUtils;
12-
import com.allen.androidcustomview.widget.BezierView;
9+
import com.allen.androidcustomview.widget.WaveViewByBezier;
1310

14-
import java.util.ArrayList;
15-
import java.util.List;
1611

1712
public class MainActivity extends AppCompatActivity {
1813

19-
private static final String TAG = "allen";
20-
private Button button;
21-
private BezierView bezierView;
22-
23-
private List<CircleBean> circleBeanList = new ArrayList<>();
14+
private Button button_bubble;
15+
private Button button_wave_bezier;
16+
private Button button_wave_sin_cos;
2417

2518
@Override
2619
protected void onCreate(Bundle savedInstanceState) {
2720
super.onCreate(savedInstanceState);
2821
setContentView(R.layout.activity_main);
29-
bezierView = (BezierView) findViewById(R.id.circle_view);
30-
button = (Button) findViewById(R.id.start_btn);
31-
button.setOnClickListener(new View.OnClickListener() {
22+
23+
button_bubble = (Button) findViewById(R.id.bubble_view_btn);
24+
button_wave_bezier = (Button) findViewById(R.id.wave_view_by_bezier_btn);
25+
button_wave_sin_cos = (Button) findViewById(R.id.wave_view_by_sin_cos_btn);
26+
27+
button_bubble.setOnClickListener(new View.OnClickListener() {
3228
@Override
33-
public void onClick(View v) {
34-
bezierView.createInAnimation();
29+
public void onClick(View view) {
30+
startActivity(new Intent(MainActivity.this, BubbleViewActivity.class));
31+
}
32+
});
33+
button_wave_bezier.setOnClickListener(new View.OnClickListener() {
34+
@Override
35+
public void onClick(View view) {
36+
startActivity(new Intent(MainActivity.this, WaveByBezierActivity.class));
37+
}
38+
});
39+
button_wave_sin_cos.setOnClickListener(new View.OnClickListener() {
40+
@Override
41+
public void onClick(View view) {
42+
startActivity(new Intent(MainActivity.this, WaveBySinCosActivity.class));
3543
}
3644
});
3745

38-
initPoint();
39-
40-
bezierView.setCircleBeen(circleBeanList);
41-
// bezierView.createInAnimation();
4246
}
4347

44-
private void initPoint() {
45-
46-
int hight = DisplayUtils.getDisplayHight(this);
47-
int width = DisplayUtils.getDisplayWidth(this);
48-
49-
int centerX = width / 2;
50-
int centerY = hight / 3;
51-
52-
Log.d(TAG, "initPoint: " + centerX + "----" + centerY);
53-
54-
CircleBean circleBean = new CircleBean(
55-
new Point(-width / 4, hight * 3 / 5),
56-
new Point(centerX - 30, hight * 3 / 5),
57-
new Point(centerX - 30, centerY - 120),
58-
new Point(width / 6, centerY - 120),
59-
new Point(width / 6, 0),
60-
100, 60);
61-
CircleBean circleBean2 = new CircleBean(
62-
new Point(-width / 4, hight * 4 / 6),
63-
new Point(centerX - 20, hight * 4 / 6),
64-
new Point(centerX - 20, centerY - 10),
65-
new Point(width / 3, centerY - 10),
66-
new Point(width / 3, -hight * 5 / 27),
67-
130, 60);
68-
CircleBean circleBean3 = new CircleBean(
69-
new Point(-width / 12, hight * 5 / 7),
70-
new Point(centerX - 100, hight * 5 / 7),
71-
new Point(centerX - 100, centerY + 100),
72-
new Point(0, centerY + 100),
73-
new Point(0, 0),
74-
80, 60);
75-
76-
CircleBean circleBean4 = new CircleBean(
77-
new Point(-width / 12, hight * 4 / 5),
78-
new Point(centerX, hight * 4 / 5),
79-
new Point(centerX, centerY),
80-
new Point(width / 2, centerY),
81-
new Point(width / 2, -hight / 7),
82-
200, 60);
83-
84-
CircleBean circleBean5 = new CircleBean(
85-
new Point(width * 5 / 7, hight * 4 / 5),
86-
new Point(centerX, hight * 4 / 5),
87-
new Point(centerX, centerY - 20),
88-
new Point(width * 10 / 13, centerY - 20),
89-
new Point(width * 10 / 13, -hight * 2 / 13),
90-
260, 60);
91-
CircleBean circleBean6 = new CircleBean(
92-
new Point(width + width / 5, hight * 3 / 4),
93-
new Point(centerX + 20, hight * 3 / 4),
94-
new Point(centerX + 20, centerY + 10),
95-
new Point(width * 11 / 14, centerY + 10),
96-
97-
new Point(width * 11 / 14, -hight * 5 / 27),
98-
70, 60);
99-
CircleBean circleBean7 = new CircleBean(
100-
new Point(width + width / 7, hight * 5 / 8),
101-
new Point(centerX + 20, hight * 5 / 8),
102-
new Point(centerX + 20, centerY + 10),
103-
new Point(width, centerY + 10),
104-
105-
new Point(width, 0),
106-
100, 60);
107-
108-
circleBeanList.add(circleBean);
109-
circleBeanList.add(circleBean2);
110-
circleBeanList.add(circleBean3);
111-
circleBeanList.add(circleBean4);
112-
circleBeanList.add(circleBean5);
113-
circleBeanList.add(circleBean6);
114-
circleBeanList.add(circleBean7);
115-
}
11648
}

0 commit comments

Comments
 (0)