1
0
Fork 0
forked from len0rd/rockbox

Android: only display progress dialog when extraction happens

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28514 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Maurus Cuelenaere 2010-11-06 01:27:01 +00:00
parent c31a2f3bbb
commit 93640fc228

View file

@ -37,7 +37,6 @@ import android.widget.Toast;
public class RockboxActivity extends Activity public class RockboxActivity extends Activity
{ {
private ProgressDialog loadingdialog;
private RockboxService rbservice; private RockboxService rbservice;
/** Called when the activity is first created. */ /** Called when the activity is first created. */
@ -49,38 +48,41 @@ public class RockboxActivity extends Activity
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN); WindowManager.LayoutParams.FLAG_FULLSCREEN);
/* Do not try starting the service if it's already running */
if (isRockboxRunning())
return;
/* prepare a please wait dialog in case we need
* to wait for unzipping libmisc.so
*/
loadingdialog = new ProgressDialog(this);
loadingdialog.setMessage("Rockbox is loading. Please wait...");
loadingdialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
loadingdialog.setIndeterminate(true);
loadingdialog.setCancelable(false);
loadingdialog.show();
Intent intent = new Intent(this, RockboxService.class); Intent intent = new Intent(this, RockboxService.class);
intent.putExtra("callback", new ResultReceiver(new Handler(getMainLooper())) { intent.putExtra("callback", new ResultReceiver(new Handler(getMainLooper())) {
private ProgressDialog loadingdialog;
private void createProgressDialog()
{
loadingdialog = new ProgressDialog(RockboxActivity.this);
loadingdialog.setMessage("Rockbox is loading. Please wait...");
loadingdialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
loadingdialog.setIndeterminate(true);
loadingdialog.setCancelable(false);
loadingdialog.show();
}
@Override @Override
protected void onReceiveResult(final int resultCode, final Bundle resultData) protected void onReceiveResult(final int resultCode, final Bundle resultData)
{ {
switch (resultCode) { switch (resultCode) {
case RockboxService.RESULT_LIB_LOADED: case RockboxService.RESULT_LIB_LOADED:
rbservice = RockboxService.get_instance(); rbservice = RockboxService.get_instance();
loadingdialog.setIndeterminate(true); if (loadingdialog != null)
loadingdialog.setIndeterminate(true);
break; break;
case RockboxService.RESULT_LIB_LOAD_PROGRESS: case RockboxService.RESULT_LIB_LOAD_PROGRESS:
if (loadingdialog == null)
createProgressDialog();
loadingdialog.setIndeterminate(false); loadingdialog.setIndeterminate(false);
loadingdialog.setMax(resultData.getInt("max", 100)); loadingdialog.setMax(resultData.getInt("max", 100));
loadingdialog.setProgress(resultData.getInt("value", 0)); loadingdialog.setProgress(resultData.getInt("value", 0));
break; break;
case RockboxService.RESULT_FB_INITIALIZED: case RockboxService.RESULT_FB_INITIALIZED:
attachFramebuffer(); attachFramebuffer();
loadingdialog.dismiss(); if (loadingdialog != null)
loadingdialog.dismiss();
break; break;
case RockboxService.RESULT_ERROR_OCCURED: case RockboxService.RESULT_ERROR_OCCURED:
Toast.makeText(RockboxActivity.this, resultData.getString("error"), Toast.LENGTH_LONG); Toast.makeText(RockboxActivity.this, resultData.getString("error"), Toast.LENGTH_LONG);