summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-10-29 23:12:13 +0000
committerThomas Martitz <kugel@rockbox.org>2010-10-29 23:12:13 +0000
commit4cbb16e86acf97ffeda9d2c873be01161ac86f59 (patch)
tree5a0c7de378e4d33cb6301959a4ab11e299c27274
parent6bb75228529382d59fda7bf455cf578766ed995e (diff)
downloadrockbox-4cbb16e86acf97ffeda9d2c873be01161ac86f59.zip
rockbox-4cbb16e86acf97ffeda9d2c873be01161ac86f59.tar.gz
rockbox-4cbb16e86acf97ffeda9d2c873be01161ac86f59.tar.bz2
rockbox-4cbb16e86acf97ffeda9d2c873be01161ac86f59.tar.xz
Android: Delay the progress dialog so it's not shown until after 0.5s are over. This way it shouldn't show in a normal launch, but only if libmisc.so needs unzipping.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28387 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--android/src/org/rockbox/RockboxActivity.java44
1 files changed, 30 insertions, 14 deletions
diff --git a/android/src/org/rockbox/RockboxActivity.java b/android/src/org/rockbox/RockboxActivity.java
index b4ca9a6..6226455 100644
--- a/android/src/org/rockbox/RockboxActivity.java
+++ b/android/src/org/rockbox/RockboxActivity.java
@@ -25,7 +25,6 @@ import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
-import android.util.Log;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
@@ -43,16 +42,18 @@ public class RockboxActivity extends Activity
,WindowManager.LayoutParams.FLAG_FULLSCREEN);
final Intent intent = new Intent(this,
RockboxService.class);
+ /* prepare a please wait dialog in case we need
+ * to wait for unzipping libmisc.so
+ */
loadingdialog = new ProgressDialog(this);
- loadingdialog.setMessage("Rockbox Loading. Please wait...");
+ loadingdialog.setMessage("Rockbox is loading. Please wait...");
loadingdialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
loadingdialog.setCancelable(false);
- loadingdialog.show();
startService(intent);
/* Now it gets a bit tricky:
* The service is started in the same thread as we are now,
* but the service also initializes the framebuffer
- * Unfortunately, this happens *after* any of the default
+ * Unfortunately, this happens *after* any of the default
* startup methods of an activity, so we need to poll for it
*
* In order to get the fb, we need to let the Service start up
@@ -62,18 +63,37 @@ public class RockboxActivity extends Activity
{
public void run()
{
+ int i = 0;
try {
- while (RockboxService.fb == null)
+ while (true)
+ {
Thread.sleep(250);
+ if (RockboxService.fb != null)
+ break;
+ /* if it's still null show the please wait dialog
+ * but not before 0.5s are over */
+ if (!loadingdialog.isShowing() && i > 0)
+ {
+ runOnUiThread(new Runnable()
+ {
+ public void run()
+ {
+ loadingdialog.show();
+ }
+ });
+ }
+ else
+ i++ ;
+ }
} catch (InterruptedException e) {
- } catch (Exception e) {
- LOG(e.toString());
}
/* drawing needs to happen in ui thread */
runOnUiThread(new Runnable()
- {
+ {
public void run() {
loadingdialog.dismiss();
+ if (RockboxService.fb == null)
+ throw new IllegalStateException("FB NULL");
setContentView(RockboxService.fb);
RockboxService.fb.invalidate();
}
@@ -96,8 +116,9 @@ public class RockboxActivity extends Activity
ViewGroup g = (ViewGroup)RockboxService.fb.getParent();
g.removeView(RockboxService.fb);
setContentView(RockboxService.fb);
+ } finally {
+ RockboxService.fb.resume();
}
- RockboxService.fb.resume();
}
}
@@ -124,9 +145,4 @@ public class RockboxActivity extends Activity
super.onDestroy();
RockboxService.fb.suspend();
}
-
- private void LOG(CharSequence text)
- {
- Log.d("Rockbox", (String) text);
- }
} \ No newline at end of file