Skip to content

Commit 11d96ee

Browse files
committed
更新版本和文案
1 parent 19d81f8 commit 11d96ee

23 files changed

+648
-57
lines changed

.DS_Store

0 Bytes
Binary file not shown.

MaterialProgressView-master/.idea/modules.xml

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
206 KB
Loading

MaterialProgressView-master/library/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ publish {
3838
userOrg = 'moosphon'//bintray.com用户名
3939
groupId = 'com.moos'//jcenter上的路径
4040
artifactId = 'Material-ProgressView'//项目名称
41-
publishVersion = '1.0.0'//版本号
41+
publishVersion = '1.0.1'//版本号
4242
desc = 'This is a pretty and simple used library for progress views on android'
4343
website = 'https://github.com/Moosphan/Material-ProgressView'//网站
4444
}

MaterialProgressView-master/library/src/main/java/com/moos/library/CircleProgressView.java

+30-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.moos.library;
22

3+
import android.animation.Animator;
34
import android.animation.ObjectAnimator;
45
import android.animation.ValueAnimator;
56
import android.content.Context;
@@ -488,11 +489,36 @@ public void startProgressAnimation(){
488489
public void onAnimationUpdate(ValueAnimator animation) {
489490
float progress = (float) animation.getAnimatedValue("progress");
490491
if(updateListener != null){
491-
updateListener.onProgressUpdate(progress);
492+
updateListener.onCircleProgressUpdate(CircleProgressView.this, progress);
492493
}
493494

494495
}
495496
});
497+
progressAnimator.addListener(new Animator.AnimatorListener() {
498+
@Override
499+
public void onAnimationStart(Animator animator) {
500+
if(updateListener != null){
501+
updateListener.onCircleProgressStart(CircleProgressView.this);
502+
}
503+
}
504+
505+
@Override
506+
public void onAnimationEnd(Animator animator) {
507+
if(updateListener != null){
508+
updateListener.onCircleProgressFinished(CircleProgressView.this);
509+
}
510+
}
511+
512+
@Override
513+
public void onAnimationCancel(Animator animator) {
514+
515+
}
516+
517+
@Override
518+
public void onAnimationRepeat(Animator animator) {
519+
520+
}
521+
});
496522
progressAnimator.start();
497523
}
498524

@@ -545,7 +571,9 @@ private void initProgressDrawing(Canvas canvas, boolean isFilled){
545571
* the interface to help get the value of progress moving
546572
*/
547573
public interface CircleProgressUpdateListener{
548-
void onProgressUpdate(float progress);
574+
void onCircleProgressStart(View view);
575+
void onCircleProgressUpdate(View view, float progress);
576+
void onCircleProgressFinished(View view);
549577
}
550578

551579
/**

MaterialProgressView-master/library/src/main/java/com/moos/library/HorizontalProgressView.java

+32-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.moos.library;
22

3+
import android.animation.Animator;
34
import android.animation.ObjectAnimator;
45
import android.animation.ValueAnimator;
56
import android.content.Context;
@@ -440,10 +441,36 @@ public void startProgressAnimation(){
440441
public void onAnimationUpdate(ValueAnimator animation) {
441442
float progress = (float) animation.getAnimatedValue("progress");
442443
if(animatorUpdateListener != null){
443-
animatorUpdateListener.onProgressUpdate(progress);
444+
animatorUpdateListener.onHorizontalProgressUpdate(HorizontalProgressView.this,progress);
444445
}
445446

446447
}
448+
449+
});
450+
progressAnimator.addListener(new Animator.AnimatorListener() {
451+
@Override
452+
public void onAnimationStart(Animator animator) {
453+
if(animatorUpdateListener != null){
454+
animatorUpdateListener.onHorizontalProgressStart(HorizontalProgressView.this);
455+
}
456+
}
457+
458+
@Override
459+
public void onAnimationEnd(Animator animator) {
460+
if(animatorUpdateListener != null){
461+
animatorUpdateListener.onHorizontalProgressFinished(HorizontalProgressView.this);
462+
}
463+
}
464+
465+
@Override
466+
public void onAnimationCancel(Animator animator) {
467+
468+
}
469+
470+
@Override
471+
public void onAnimationRepeat(Animator animator) {
472+
473+
}
447474
});
448475
progressAnimator.start();
449476
}
@@ -501,7 +528,10 @@ private void updateTheTrack() {
501528
* the interface to help get the value of progress moving
502529
*/
503530
public interface HorizontalProgressUpdateListener{
504-
void onProgressUpdate(float progress);
531+
void onHorizontalProgressStart(View view);
532+
void onHorizontalProgressUpdate(View view, float progress);
533+
void onHorizontalProgressFinished(View view);
534+
505535
}
506536

507537
/**

MaterialProgressView-master/library/src/main/res/values/strings.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<resources>
2-
<string name="app_name">MaterialProgressView</string>
2+
<string name="app_name">Material-ProgressView</string>
33

44
<!-- TODO: Remove or change this placeholder text -->
55
<string name="hello_blank_fragment">Hello blank fragment</string>

MaterialProgressView-master/sample/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ dependencies {
2323
implementation fileTree(include: ['*.jar'], dir: 'libs')
2424
implementation 'com.android.support:appcompat-v7:25.4.0'
2525
implementation 'com.android.support:support-v4:25.4.0'
26+
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
2627
testCompile 'junit:junit:4.12'
2728
}

MaterialProgressView-master/sample/src/main/AndroidManifest.xml

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@
99
android:roundIcon="@mipmap/ic_launcher_round"
1010
android:supportsRtl="true"
1111
android:theme="@style/AppTheme">
12-
<activity android:name=".MainActivity">
12+
<activity android:name=".MainActivity"
13+
android:screenOrientation="portrait">
1314
<intent-filter>
1415
<action android:name="android.intent.action.MAIN" />
1516

1617
<category android:name="android.intent.category.LAUNCHER" />
1718
</intent-filter>
1819
</activity>
20+
<activity
21+
android:name=".DetailsActivity"
22+
android:screenOrientation="portrait"/>
1923
</application>
2024

2125
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package com.moos.progress;
2+
3+
import android.support.v4.app.Fragment;
4+
import android.support.v4.app.FragmentManager;
5+
import android.support.v4.app.FragmentTransaction;
6+
import android.support.v7.app.AppCompatActivity;
7+
import android.os.Bundle;
8+
import android.support.v7.widget.SwitchCompat;
9+
import android.widget.CompoundButton;
10+
import android.widget.FrameLayout;
11+
import android.widget.TextView;
12+
13+
import com.moos.progress.fragment.CircleProgressFragment;
14+
import com.moos.progress.fragment.HorizontalProgressFragment;
15+
16+
/**
17+
* created by Moos on 2018/03/23
18+
* desc: some details of two styles of material-progressView
19+
*/
20+
public class DetailsActivity extends AppCompatActivity {
21+
22+
private SwitchCompat switcher;
23+
private FrameLayout container;
24+
private TextView title;
25+
26+
@Override
27+
protected void onCreate(Bundle savedInstanceState) {
28+
super.onCreate(savedInstanceState);
29+
setContentView(R.layout.activity_details);
30+
31+
switcher = (SwitchCompat) findViewById(R.id.fragment_switch);
32+
container = (FrameLayout) findViewById(R.id.fragment_container);
33+
title = (TextView) findViewById(R.id.fragment_title);
34+
replaceFragment(new CircleProgressFragment());
35+
switcher.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
36+
@Override
37+
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
38+
if(isChecked){
39+
title.setText(getString(R.string.fragment_name_horizontal_progress));
40+
replaceFragment(new HorizontalProgressFragment());
41+
}else {
42+
title.setText(getString(R.string.fragment_name_circle_progress));
43+
replaceFragment(new CircleProgressFragment());
44+
}
45+
}
46+
});
47+
48+
}
49+
50+
private void replaceFragment(Fragment fragment){
51+
FragmentManager manager = getSupportFragmentManager();
52+
FragmentTransaction transaction = manager.beginTransaction();
53+
transaction.replace(R.id.fragment_container, fragment);
54+
transaction.commit();
55+
}
56+
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.moos.progress;
22

3+
import android.content.Intent;
34
import android.support.v4.app.Fragment;
45
import android.support.v4.app.FragmentManager;
56
import android.support.v4.app.FragmentTransaction;
@@ -11,53 +12,135 @@
1112
import android.widget.Button;
1213
import android.widget.CompoundButton;
1314
import android.widget.FrameLayout;
15+
import android.widget.ImageView;
1416
import android.widget.TextView;
1517
import android.widget.Toast;
1618

1719
import com.moos.library.CircleProgressView;
20+
import com.moos.library.HorizontalProgressView;
1821
import com.moos.progress.fragment.CircleProgressFragment;
1922
import com.moos.progress.fragment.HorizontalProgressFragment;
2023

2124
/**
2225
* by Moos on 2018/03/21
23-
* just a example to use it
26+
* just a design example to use it
2427
*/
25-
public class MainActivity extends AppCompatActivity {
28+
public class MainActivity extends AppCompatActivity implements View.OnClickListener, HorizontalProgressView.HorizontalProgressUpdateListener, CircleProgressView.CircleProgressUpdateListener {
2629
private static final String TAG = "MainActivity";
27-
private SwitchCompat switcher;
28-
private FrameLayout container;
29-
private TextView title;
30+
private CircleProgressView cpv_main, cpv_small;
31+
private HorizontalProgressView hpv_language, hpv_math, hpv_history, hpv_english;
32+
private TextView tv_language, tv_math, tv_history, tv_english, tv_main;
33+
private Button button;
34+
private ImageView bt_detail;
3035

3136
@Override
3237
protected void onCreate(Bundle savedInstanceState) {
3338
super.onCreate(savedInstanceState);
3439
setContentView(R.layout.activity_main);
40+
initView();
41+
42+
}
43+
44+
private void initView() {
45+
cpv_main = (CircleProgressView) findViewById(R.id.progressView_circle_main);
46+
cpv_small = (CircleProgressView) findViewById(R.id.progressView_circle_small);
47+
hpv_language = (HorizontalProgressView) findViewById(R.id.hpv_language);
48+
hpv_math = (HorizontalProgressView) findViewById(R.id.hpv_math);
49+
hpv_history = (HorizontalProgressView) findViewById(R.id.hpv_history);
50+
hpv_english = (HorizontalProgressView) findViewById(R.id.hpv_english);
51+
tv_language = (TextView) findViewById(R.id.progress_text_language);
52+
tv_english = (TextView) findViewById(R.id.progress_text_english);
53+
tv_history = (TextView) findViewById(R.id.progress_text_history);
54+
tv_math = (TextView) findViewById(R.id.progress_text_math);
55+
tv_main = (TextView) findViewById(R.id.progress_text_main);
56+
button = (Button) findViewById(R.id.btn_start);
57+
bt_detail = (ImageView) findViewById(R.id.btn_details);
58+
button.setOnClickListener(this);
59+
bt_detail.setOnClickListener(this);
60+
initProgressViews();
61+
}
62+
63+
private void initProgressViews(){
64+
hpv_language.setProgressViewUpdateListener(this);
65+
hpv_english.setProgressViewUpdateListener(this);
66+
hpv_history.setProgressViewUpdateListener(this);
67+
hpv_math.setProgressViewUpdateListener(this);
68+
cpv_small.setProgressViewUpdateListener(this);
69+
cpv_main.setProgressViewUpdateListener(this);
70+
}
3571

36-
switcher = (SwitchCompat) findViewById(R.id.fragment_switch);
37-
container = (FrameLayout) findViewById(R.id.fragment_container);
38-
title = (TextView) findViewById(R.id.fragment_title);
39-
replaceFragment(new CircleProgressFragment());
40-
switcher.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
41-
@Override
42-
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
43-
if(isChecked){
44-
title.setText(getString(R.string.fragment_name_horizontal_progress));
45-
replaceFragment(new HorizontalProgressFragment());
46-
}else {
47-
title.setText(getString(R.string.fragment_name_circle_progress));
48-
replaceFragment(new CircleProgressFragment());
49-
}
50-
}
51-
});
5272

73+
@Override
74+
public void onClick(View v) {
75+
if(v.getId() == R.id.btn_start){
76+
//cpv_small.startProgressAnimation();
77+
//cpv_main.startProgressAnimation();
78+
hpv_language.startProgressAnimation();
79+
hpv_math.startProgressAnimation();
80+
hpv_history.startProgressAnimation();
81+
hpv_english.startProgressAnimation();
82+
}else if(v.getId() == R.id.btn_details){
83+
Intent intent = new Intent(MainActivity.this, DetailsActivity.class);
84+
startActivity(intent);
85+
}
5386
}
5487

55-
private void replaceFragment(Fragment fragment){
56-
FragmentManager manager = getSupportFragmentManager();
57-
FragmentTransaction transaction = manager.beginTransaction();
58-
transaction.replace(R.id.fragment_container, fragment);
59-
transaction.commit();
88+
@Override
89+
public void onHorizontalProgressStart(View view) {
90+
6091
}
6192

93+
@Override
94+
public void onHorizontalProgressUpdate(View view, float progress) {
95+
int progressInt = (int) progress;
96+
switch (view.getId()){
97+
case R.id.hpv_language:
98+
tv_language.setText(progressInt + "%");
99+
break;
100+
101+
case R.id.hpv_english:
102+
tv_english.setText(progressInt + "%");
103+
break;
104+
105+
case R.id.hpv_history:
106+
tv_history.setText(progressInt + "%");
107+
break;
62108

109+
case R.id.hpv_math:
110+
tv_math.setText(progressInt + "%");
111+
break;
112+
113+
}
114+
}
115+
116+
@Override
117+
public void onHorizontalProgressFinished(View view) {
118+
119+
if(view.getId() == R.id.hpv_language){
120+
cpv_small.startProgressAnimation();
121+
}
122+
}
123+
124+
@Override
125+
public void onCircleProgressStart(View view) {
126+
127+
}
128+
129+
@Override
130+
public void onCircleProgressUpdate(View view, float progress) {
131+
132+
int progressInt = (int) progress;
133+
if(view.getId() == R.id.progressView_circle_main){
134+
tv_main.setText(progressInt+"");
135+
}
136+
}
137+
138+
@Override
139+
public void onCircleProgressFinished(View view) {
140+
141+
if(view.getId() == R.id.progressView_circle_small){
142+
cpv_main.startProgressAnimation();
143+
}
144+
145+
}
63146
}

0 commit comments

Comments
 (0)