diff options
-rw-r--r-- | android/src/org/rockbox/RockboxActivity.java | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/android/src/org/rockbox/RockboxActivity.java b/android/src/org/rockbox/RockboxActivity.java index b4ca9a6d2a..6226455deb 100644 --- a/android/src/org/rockbox/RockboxActivity.java +++ b/android/src/org/rockbox/RockboxActivity.java | |||
@@ -25,7 +25,6 @@ import android.app.Activity; | |||
25 | import android.app.ProgressDialog; | 25 | import android.app.ProgressDialog; |
26 | import android.content.Intent; | 26 | import android.content.Intent; |
27 | import android.os.Bundle; | 27 | import android.os.Bundle; |
28 | import android.util.Log; | ||
29 | import android.view.ViewGroup; | 28 | import android.view.ViewGroup; |
30 | import android.view.Window; | 29 | import android.view.Window; |
31 | import android.view.WindowManager; | 30 | import android.view.WindowManager; |
@@ -43,16 +42,18 @@ public class RockboxActivity extends Activity | |||
43 | ,WindowManager.LayoutParams.FLAG_FULLSCREEN); | 42 | ,WindowManager.LayoutParams.FLAG_FULLSCREEN); |
44 | final Intent intent = new Intent(this, | 43 | final Intent intent = new Intent(this, |
45 | RockboxService.class); | 44 | RockboxService.class); |
45 | /* prepare a please wait dialog in case we need | ||
46 | * to wait for unzipping libmisc.so | ||
47 | */ | ||
46 | loadingdialog = new ProgressDialog(this); | 48 | loadingdialog = new ProgressDialog(this); |
47 | loadingdialog.setMessage("Rockbox Loading. Please wait..."); | 49 | loadingdialog.setMessage("Rockbox is loading. Please wait..."); |
48 | loadingdialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); | 50 | loadingdialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); |
49 | loadingdialog.setCancelable(false); | 51 | loadingdialog.setCancelable(false); |
50 | loadingdialog.show(); | ||
51 | startService(intent); | 52 | startService(intent); |
52 | /* Now it gets a bit tricky: | 53 | /* Now it gets a bit tricky: |
53 | * The service is started in the same thread as we are now, | 54 | * The service is started in the same thread as we are now, |
54 | * but the service also initializes the framebuffer | 55 | * but the service also initializes the framebuffer |
55 | * Unfortunately, this happens *after* any of the default | 56 | * Unfortunately, this happens *after* any of the default |
56 | * startup methods of an activity, so we need to poll for it | 57 | * startup methods of an activity, so we need to poll for it |
57 | * | 58 | * |
58 | * In order to get the fb, we need to let the Service start up | 59 | * In order to get the fb, we need to let the Service start up |
@@ -62,18 +63,37 @@ public class RockboxActivity extends Activity | |||
62 | { | 63 | { |
63 | public void run() | 64 | public void run() |
64 | { | 65 | { |
66 | int i = 0; | ||
65 | try { | 67 | try { |
66 | while (RockboxService.fb == null) | 68 | while (true) |
69 | { | ||
67 | Thread.sleep(250); | 70 | Thread.sleep(250); |
71 | if (RockboxService.fb != null) | ||
72 | break; | ||
73 | /* if it's still null show the please wait dialog | ||
74 | * but not before 0.5s are over */ | ||
75 | if (!loadingdialog.isShowing() && i > 0) | ||
76 | { | ||
77 | runOnUiThread(new Runnable() | ||
78 | { | ||
79 | public void run() | ||
80 | { | ||
81 | loadingdialog.show(); | ||
82 | } | ||
83 | }); | ||
84 | } | ||
85 | else | ||
86 | i++ ; | ||
87 | } | ||
68 | } catch (InterruptedException e) { | 88 | } catch (InterruptedException e) { |
69 | } catch (Exception e) { | ||
70 | LOG(e.toString()); | ||
71 | } | 89 | } |
72 | /* drawing needs to happen in ui thread */ | 90 | /* drawing needs to happen in ui thread */ |
73 | runOnUiThread(new Runnable() | 91 | runOnUiThread(new Runnable() |
74 | { | 92 | { |
75 | public void run() { | 93 | public void run() { |
76 | loadingdialog.dismiss(); | 94 | loadingdialog.dismiss(); |
95 | if (RockboxService.fb == null) | ||
96 | throw new IllegalStateException("FB NULL"); | ||
77 | setContentView(RockboxService.fb); | 97 | setContentView(RockboxService.fb); |
78 | RockboxService.fb.invalidate(); | 98 | RockboxService.fb.invalidate(); |
79 | } | 99 | } |
@@ -96,8 +116,9 @@ public class RockboxActivity extends Activity | |||
96 | ViewGroup g = (ViewGroup)RockboxService.fb.getParent(); | 116 | ViewGroup g = (ViewGroup)RockboxService.fb.getParent(); |
97 | g.removeView(RockboxService.fb); | 117 | g.removeView(RockboxService.fb); |
98 | setContentView(RockboxService.fb); | 118 | setContentView(RockboxService.fb); |
119 | } finally { | ||
120 | RockboxService.fb.resume(); | ||
99 | } | 121 | } |
100 | RockboxService.fb.resume(); | ||
101 | } | 122 | } |
102 | } | 123 | } |
103 | 124 | ||
@@ -124,9 +145,4 @@ public class RockboxActivity extends Activity | |||
124 | super.onDestroy(); | 145 | super.onDestroy(); |
125 | RockboxService.fb.suspend(); | 146 | RockboxService.fb.suspend(); |
126 | } | 147 | } |
127 | |||
128 | private void LOG(CharSequence text) | ||
129 | { | ||
130 | Log.d("Rockbox", (String) text); | ||
131 | } | ||
132 | } \ No newline at end of file | 148 | } \ No newline at end of file |