download and progress bar somewhat work

This commit is contained in:
fysx
2014-02-19 20:57:09 +01:00
parent cb2c852f58
commit 4c2846f4bb
3 changed files with 8 additions and 7 deletions
+2 -3
View File
@@ -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"
@@ -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
View File
@@ -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) {