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
@@ -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) {