mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
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
This commit is contained in:
parent
6bb7522852
commit
4cbb16e86a
1 changed files with 30 additions and 14 deletions
|
@ -25,7 +25,6 @@ import android.app.Activity;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
@ -43,11 +42,13 @@ public class RockboxActivity extends Activity
|
||||||
,WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
,WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
final Intent intent = new Intent(this,
|
final Intent intent = new Intent(this,
|
||||||
RockboxService.class);
|
RockboxService.class);
|
||||||
|
/* prepare a please wait dialog in case we need
|
||||||
|
* to wait for unzipping libmisc.so
|
||||||
|
*/
|
||||||
loadingdialog = new ProgressDialog(this);
|
loadingdialog = new ProgressDialog(this);
|
||||||
loadingdialog.setMessage("Rockbox Loading. Please wait...");
|
loadingdialog.setMessage("Rockbox is loading. Please wait...");
|
||||||
loadingdialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
loadingdialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
||||||
loadingdialog.setCancelable(false);
|
loadingdialog.setCancelable(false);
|
||||||
loadingdialog.show();
|
|
||||||
startService(intent);
|
startService(intent);
|
||||||
/* Now it gets a bit tricky:
|
/* Now it gets a bit tricky:
|
||||||
* The service is started in the same thread as we are now,
|
* The service is started in the same thread as we are now,
|
||||||
|
@ -62,18 +63,37 @@ public class RockboxActivity extends Activity
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
|
int i = 0;
|
||||||
try {
|
try {
|
||||||
while (RockboxService.fb == null)
|
while (true)
|
||||||
|
{
|
||||||
Thread.sleep(250);
|
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 (InterruptedException e) {
|
||||||
} catch (Exception e) {
|
|
||||||
LOG(e.toString());
|
|
||||||
}
|
}
|
||||||
/* drawing needs to happen in ui thread */
|
/* drawing needs to happen in ui thread */
|
||||||
runOnUiThread(new Runnable()
|
runOnUiThread(new Runnable()
|
||||||
{
|
{
|
||||||
public void run() {
|
public void run() {
|
||||||
loadingdialog.dismiss();
|
loadingdialog.dismiss();
|
||||||
|
if (RockboxService.fb == null)
|
||||||
|
throw new IllegalStateException("FB NULL");
|
||||||
setContentView(RockboxService.fb);
|
setContentView(RockboxService.fb);
|
||||||
RockboxService.fb.invalidate();
|
RockboxService.fb.invalidate();
|
||||||
}
|
}
|
||||||
|
@ -96,10 +116,11 @@ public class RockboxActivity extends Activity
|
||||||
ViewGroup g = (ViewGroup)RockboxService.fb.getParent();
|
ViewGroup g = (ViewGroup)RockboxService.fb.getParent();
|
||||||
g.removeView(RockboxService.fb);
|
g.removeView(RockboxService.fb);
|
||||||
setContentView(RockboxService.fb);
|
setContentView(RockboxService.fb);
|
||||||
}
|
} finally {
|
||||||
RockboxService.fb.resume();
|
RockboxService.fb.resume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* this is also called when the backlight goes off,
|
/* this is also called when the backlight goes off,
|
||||||
* which is nice
|
* which is nice
|
||||||
|
@ -124,9 +145,4 @@ public class RockboxActivity extends Activity
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
RockboxService.fb.suspend();
|
RockboxService.fb.suspend();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LOG(CharSequence text)
|
|
||||||
{
|
|
||||||
Log.d("Rockbox", (String) text);
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue