-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathMainActivity.java
More file actions
133 lines (89 loc) · 2.72 KB
/
MainActivity.java
File metadata and controls
133 lines (89 loc) · 2.72 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package com.thbs.progressbutton;
import com.example.progressframework.R;
import android.app.Activity;
import android.graphics.Canvas;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;
public class MainActivity extends Activity {
static MasterLayout masterLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
masterLayout = (MasterLayout) findViewById(R.id.MasterLayout01);
//Onclick listener of the progress button
masterLayout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
masterLayout.animation(); //Need to call this method for animation and progression
if (masterLayout.flg_frmwrk_mode == 1) {
//Start state. Call any method that you want to execute
runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
Toast.makeText(MainActivity.this,
"Starting download", Toast.LENGTH_SHORT)
.show();
}
});
new DownLoadSigTask().execute();
}
if (masterLayout.flg_frmwrk_mode == 2) {
//Running state. Call any method that you want to execute
new DownLoadSigTask().cancel(true);
masterLayout.reset();
runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
Toast.makeText(MainActivity.this,
"Download stopped", Toast.LENGTH_SHORT)
.show();
}
});
}
if (masterLayout.flg_frmwrk_mode == 3) {
//End state. Call any method that you want to execute.
masterLayout.reset();
runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
Toast.makeText(MainActivity.this,
"Download complete", Toast.LENGTH_SHORT)
.show();
}
});
}
}
});
}
static class DownLoadSigTask extends AsyncTask<String, Integer, String> {
@Override
protected void onPreExecute() {
}
@Override
protected String doInBackground(final String... args) {
//Creating dummy task and updating progress
for (int i = 0; i <= 100; i++) {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
publishProgress(i);
}
return null;
}
@Override
protected void onProgressUpdate(Integer... progress) {
//publishing progress to progress arc
masterLayout.cusview.setupprogress(progress[0]);
}
}
}