Browse Source

download and progress bar somewhat work

fysx 11 years ago
parent
commit
4c2846f4bb

+ 2 - 3
AndroidManifest.xml

@@ -8,13 +8,12 @@
     <!-- Allow writing to external storage -->
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
 
-		<service android:name="DownloadService" />
-
     <application
         android:allowBackup="true"
         android:icon="@drawable/ic_launcher"
         android:label="LÖVE for Android"
-        android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
+				android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
+				<service android:name=".DownloadService" />
         <activity
             android:name="GameActivity"
             android:configChanges="orientation|screenSize"

+ 0 - 2
src/org/love2d/android/DownloadService.java

@@ -45,8 +45,6 @@ public class DownloadService extends IntentService {
                 resultData.putInt("progress" ,(int) (total * 100 / fileLength));
                 receiver.send(UPDATE_PROGRESS, resultData);
                 output.write(data, 0, count);
-                
-                Log.d ("GameActivity", "Downloading...");
             }
 
             output.flush();

+ 6 - 2
src/org/love2d/android/GameActivity.java

@@ -82,8 +82,10 @@ public class GameActivity extends SDLActivity {
     	  mProgressDialog.setIndeterminate(true);
     	  mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
     	  mProgressDialog.setCancelable(true);
+    	  mProgressDialog.setProgress (0);
+    	  mProgressDialog.setMax (100);
     	  
-    	// this is how you fire the downloader
+    	  // this is how you fire the downloader
     	  mProgressDialog.show();
     	  Intent intent = new Intent(this, DownloadService.class);
     	  intent.putExtra("url", url);
@@ -126,8 +128,10 @@ public class GameActivity extends SDLActivity {
 
         @Override
         protected void onReceiveResult(int resultCode, Bundle resultData) {
-            super.onReceiveResult(resultCode, resultData);
+        	super.onReceiveResult(resultCode, resultData);
+
             if (resultCode == DownloadService.UPDATE_PROGRESS) {
+          	    mProgressDialog.setIndeterminate(false);
                 int progress = resultData.getInt("progress");
                 mProgressDialog.setProgress(progress);
                 if (progress == 100) {