@@ -21,18 +21,18 @@ private final class AsyncInit
21
21
extends AsyncTask <String , Integer , String >
22
22
implements Game .InitProgressListener
23
23
{
24
- private final View dots ;
24
+ private final View root ;
25
25
private final Game game ;
26
26
private final TextView message ;
27
27
private final Drawable bg ;
28
28
29
29
public AsyncInit (
30
- View dots ,
30
+ View root ,
31
31
Drawable bg ,
32
32
Game game ,
33
33
TextView msg )
34
34
{
35
- this .dots = dots ;
35
+ this .root = root ;
36
36
this .bg = bg ;
37
37
this .game = game ;
38
38
this .message = msg ;
@@ -41,16 +41,16 @@ public AsyncInit(
41
41
// runs on the UI thread
42
42
@ Override protected void onPreExecute () {
43
43
if (0 >= mInFlight ++) {
44
- dots .setBackgroundResource (R .anim .dots );
45
- ((AnimationDrawable ) dots .getBackground ()).start ();
44
+ root .setBackgroundResource (R .anim .dots );
45
+ ((AnimationDrawable ) root .getBackground ()).start ();
46
46
}
47
47
}
48
48
49
49
// runs on the UI thread
50
50
@ Override protected void onPostExecute (String msg ) {
51
51
if (0 >= --mInFlight ) {
52
- ((AnimationDrawable ) dots .getBackground ()).stop ();
53
- dots .setBackgroundDrawable (bg );
52
+ ((AnimationDrawable ) root .getBackground ()).stop ();
53
+ root .setBackgroundDrawable (bg );
54
54
}
55
55
56
56
message .setText (msg );
@@ -63,10 +63,12 @@ public AsyncInit(
63
63
: game .initialize (args [0 ], this );
64
64
}
65
65
66
+ // runs on the UI thread
66
67
@ Override protected void onProgressUpdate (Integer ... vals ) {
67
68
updateProgressBar (vals [0 ].intValue ());
68
69
}
69
70
71
+ // runs on its own thread
70
72
@ Override public void onInitProgress (int pctComplete ) {
71
73
publishProgress (Integer .valueOf (pctComplete ));
72
74
}
0 commit comments