mirror of
https://github.com/love2d/love-android.git
synced 2026-08-12 08:31:04 +02:00
download and progress bar somewhat work
This commit is contained in:
+2
-3
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user