-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgressBarActivity3.java
More file actions
66 lines (57 loc) · 2.14 KB
/
Copy pathProgressBarActivity3.java
File metadata and controls
66 lines (57 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package com.work.progressbar;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.widget.Toast;
import com.work.R;
import com.work.base.BaseActivity;
import java.lang.ref.WeakReference;
/**
* Title: ProgressBarActivity
* <p>
* Description:进度条演示页面2
* </p>
* Author Changbao
* Date 2018/10/15 11:35
*/
public class ProgressBarActivity3 extends BaseActivity {
private PlanProgressBar mCircleProgressBar;
private ProgressHandler myHandler = new ProgressHandler();
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_v_progress_bar2);
// mCircleProgressBar = findViewById(R.id.circleProgressBar);
// mCircleProgressBar.setStrokeRoundCap(true);
// //模拟业务情形,已完成 5/8 的目标
// final int hasFinished = 5;
// final int total = 8;
//
// mCircleProgressBar.setPlanProgressBarTextGenerator(new PlanProgressBar.PlanProgressBarTextGenerator() {
// @Override
// public String generateText(PlanProgressBar progressBar, int value, int maxValue) {
//// return 100 * value / maxValue + "%";
// return String.valueOf(hasFinished);
// }
// });
//
// myHandler.setProgressBar(mCircleProgressBar);
}
private class ProgressHandler extends Handler {
private WeakReference<PlanProgressBar> weakCircleProgressBar;
void setProgressBar(PlanProgressBar circleProgressBar) {
this.weakCircleProgressBar = new WeakReference<>(circleProgressBar);
}
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (!Thread.currentThread().isInterrupted()) {
if (weakCircleProgressBar.get() != null) {
Toast.makeText(ProgressBarActivity3.this, "" + msg.arg1, Toast.LENGTH_SHORT).show();
weakCircleProgressBar.get().setProgress(msg.arg1);
}
}
}
}
}