@@ -1094,16 +1094,15 @@ private void startFileUpload() {
1094
1094
}
1095
1095
1096
1096
@ NonNull
1097
- private MultipartBody .Part prepareFilePart (String partName , File file ) {
1097
+ private MultipartBody .Part prepareFilePart (String partName , File file , int notificationId ) {
1098
1098
// create UploadProgressRequest instance from file
1099
- // TODO: change for multiple uploads
1100
1099
UploadProgressRequest request = new UploadProgressRequest (file , new UploadProgressRequest .UploadCallbacks () {
1101
1100
@ Override
1102
1101
public void onProgressUpdate (int percentage , String progress , int notificationId ) {
1103
1102
// update notification
1104
1103
progressNotification (notificationId , percentage , progress );
1105
1104
}
1106
- }, 100 );
1105
+ }, notificationId );
1107
1106
1108
1107
// MultipartBody.Part is used to send also the actual file name
1109
1108
return MultipartBody .Part .createFormData (partName , file .getName (), request );
@@ -1175,15 +1174,15 @@ private void endNotification(int notificationId, String content) {
1175
1174
* @param file on local storage
1176
1175
*/
1177
1176
private void uploadFile (final File file ) {
1177
+ final int notifId = (int ) ((new Date ().getTime () / 1000L ) % Integer .MAX_VALUE );
1178
1178
1179
1179
// MultipartBody.Part is used to send also the actual file name
1180
- MultipartBody .Part body = prepareFilePart ("file" , file );
1180
+ MultipartBody .Part body = prepareFilePart ("file" , file , notifId );
1181
1181
1182
1182
final String loadingMsg = getResources ().getString (R .string .uploading_message );
1183
1183
1184
1184
// start notification
1185
- // TODO: handle different notif ids
1186
- setNotification (100 , getString (R .string .init_notif_title ));
1185
+ setNotification (notifId , getString (R .string .init_notif_title ));
1187
1186
1188
1187
// finally, execute the request
1189
1188
// create upload service client
@@ -1195,7 +1194,7 @@ public void onSuccess(Call<UploadResponse> call, Response<UploadResponse> respon
1195
1194
UploadResponse uploadResponse = response .body ();
1196
1195
filePathOnServer = uploadResponse .getUri ();
1197
1196
if (!filePathOnServer .equals ("" )) {
1198
- endNotification (100 , getString (R .string .finish_notif_title ));
1197
+ endNotification (notifId , getString (R .string .finish_notif_title ));
1199
1198
// remove loading message from the screen
1200
1199
sendingMessage (false , loadingMsg );
1201
1200
0 commit comments