mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 04:13:53 +01:00
Upload progressbar works properly!
This commit is contained in:
parent
887d5e7894
commit
018c565f3b
2 changed files with 6 additions and 4 deletions
|
|
@ -28,7 +28,9 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:indeterminate="false"
|
||||
>
|
||||
android:indeterminateOnly="false"
|
||||
android:progressDrawable="@android:drawable/progress_horizontal" >
|
||||
|
||||
</ProgressBar>
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public class UploadService extends IntentService {
|
|||
}
|
||||
@Override
|
||||
public void onProgress(long transferred, long total) {
|
||||
double percent = transferred/total * 100;
|
||||
double percent = (double)transferred / (double)total * 100;
|
||||
Log.d("Commons", "Uploaded " + percent + "% (" + transferred + " of " + total + ")");
|
||||
curNotification.contentView.setProgressBar(R.id.uploadNotificationProgress, 100, (int)percent, false);
|
||||
notificationManager.notify(NOTIFICATION_DOWNLOAD_IN_PROGRESS, curNotification);
|
||||
|
|
@ -98,6 +98,7 @@ public class UploadService extends IntentService {
|
|||
|
||||
notificationView = new RemoteViews(getPackageName(), R.layout.layout_upload_progress);
|
||||
notificationView.setTextViewText(R.id.uploadNotificationTitle, "Uploading " + filename);
|
||||
notificationView.setProgressBar(R.id.uploadNotificationProgress, 100, 0, false);
|
||||
|
||||
Log.d("Commons", "Before execution!");
|
||||
Notification curNotification = new NotificationCompat.Builder(this).setAutoCancel(true)
|
||||
|
|
@ -105,12 +106,11 @@ public class UploadService extends IntentService {
|
|||
.setAutoCancel(true)
|
||||
.setContent(notificationView)
|
||||
.setContentIntent(PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), 0))
|
||||
.setOngoing(true)
|
||||
.getNotification();
|
||||
|
||||
notificationManager.notify(NOTIFICATION_DOWNLOAD_IN_PROGRESS, curNotification);
|
||||
|
||||
Toast startingToast = Toast.makeText(this, R.string.uploading_started, Toast.LENGTH_LONG);
|
||||
startingToast.show();
|
||||
Log.d("Commons", "Just before");
|
||||
try {
|
||||
result = api.upload(filename, file, length, pageContents, editSummary, new NotificationUpdateProgressListener(curNotification));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue