1 |
|
package game.shad.tempus.hearts; |
2 |
|
|
3 |
|
import android.app.Activity; |
4 |
|
import android.os.AsyncTask; |
5 |
|
import android.os.Bundle; |
6 |
|
import android.widget.ProgressBar; |
7 |
|
import android.widget.TextView; |
8 |
|
import android.widget.ViewSwitcher; |
9 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0,6 |
|
10 |
|
public class LoadingScreenActivity extends Activity |
11 |
|
{ |
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
private ViewSwitcher viewSwitcher; |
16 |
|
|
17 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
18 |
0
|
@Override... |
19 |
|
public void onCreate(Bundle savedInstanceState) |
20 |
|
{ |
21 |
0
|
super.onCreate(savedInstanceState); |
22 |
|
|
23 |
|
|
24 |
0
|
new LoadViewTask().execute(); |
25 |
|
} |
26 |
|
|
27 |
|
|
|
|
| 0% |
Uncovered Elements: 27 (27) |
Complexity: 7 |
Complexity Density: 0,37 |
|
28 |
|
private class LoadViewTask extends AsyncTask{ |
29 |
|
|
30 |
|
private TextView tv_progress; |
31 |
|
private ProgressBar pb_progressBar; |
32 |
|
|
33 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
|
34 |
0
|
@Override... |
35 |
|
protected void onPreExecute() |
36 |
|
{ |
37 |
|
|
38 |
0
|
viewSwitcher = new ViewSwitcher(LoadingScreenActivity.this); |
39 |
|
|
40 |
|
|
41 |
0
|
viewSwitcher.addView(ViewSwitcher.inflate(LoadingScreenActivity.this, R.layout.startup, null)); |
42 |
|
|
43 |
|
|
44 |
|
|
45 |
0
|
pb_progressBar = (ProgressBar) viewSwitcher.findViewById(R.id.progressBar); |
46 |
|
|
47 |
0
|
pb_progressBar.setMax(100); |
48 |
|
|
49 |
|
|
50 |
0
|
setContentView(viewSwitcher); |
51 |
|
} |
52 |
|
|
53 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0,33 |
|
54 |
0
|
@Override... |
55 |
|
protected Object doInBackground(Object... params) { |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
0
|
try |
63 |
|
{ |
64 |
|
|
65 |
0
|
synchronized (this) |
66 |
|
{ |
67 |
|
|
68 |
0
|
int counter = 0; |
69 |
|
|
70 |
0
|
while(counter <= 20) |
71 |
|
{ |
72 |
|
|
73 |
0
|
this.wait(200); |
74 |
|
|
75 |
0
|
counter++; |
76 |
|
|
77 |
|
|
78 |
0
|
publishProgress(counter*5); |
79 |
|
} |
80 |
|
} |
81 |
|
} |
82 |
|
catch (InterruptedException e) |
83 |
|
{ |
84 |
0
|
e.printStackTrace(); |
85 |
|
} |
86 |
0
|
return null; |
87 |
|
} |
88 |
|
|
89 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0,67 |
|
90 |
0
|
@Override... |
91 |
|
protected void onProgressUpdate(Object... values) { |
92 |
|
|
93 |
0
|
if((Integer)values[0] <= 100) |
94 |
|
{ |
95 |
0
|
tv_progress.setText("Progress: " + Integer.toString((Integer)values[0]) + "%"); |
96 |
0
|
pb_progressBar.setProgress((Integer)values[0]); |
97 |
|
} |
98 |
|
} |
99 |
|
|
100 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
101 |
0
|
@Override... |
102 |
|
protected void onPostExecute(Object objects) |
103 |
|
{ |
104 |
|
|
105 |
|
|
106 |
|
|
107 |
0
|
viewSwitcher.addView(ViewSwitcher.inflate(LoadingScreenActivity.this, R.layout.main, null)); |
108 |
|
|
109 |
0
|
viewSwitcher.showNext(); |
110 |
|
} |
111 |
|
|
112 |
|
} |
113 |
|
|
114 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0,67 |
|
115 |
0
|
@Override... |
116 |
|
public void onBackPressed() |
117 |
|
{ |
118 |
|
|
119 |
|
|
120 |
0
|
if(viewSwitcher.getDisplayedChild() == 0) |
121 |
|
{ |
122 |
|
|
123 |
0
|
return; |
124 |
|
} |
125 |
|
else |
126 |
|
{ |
127 |
|
|
128 |
0
|
super.onBackPressed(); |
129 |
|
} |
130 |
|
} |
131 |
|
|
132 |
|
} |