@@ -355,7 +355,7 @@ public void onClick(View v) {
355
355
onTextChangeOfPeopleSearchEditText ();
356
356
mNotificationManager = (NotificationManager ) getSystemService (Context .NOTIFICATION_SERVICE );
357
357
mBuilder = (NotificationCompat .Builder ) new NotificationCompat .Builder (this )
358
- .setColor (getColor (R .color .notif_background ));
358
+ .setColor (ContextCompat . getColor (this , R .color .notif_background ));
359
359
ivSearchPeopleCancel .setOnClickListener (new View .OnClickListener () {
360
360
@ Override
361
361
public void onClick (View v ) {
@@ -899,7 +899,7 @@ protected void onNewIntent(Intent intent) {
899
899
if (mBuilder == null ) {
900
900
mBuilder = (NotificationCompat .Builder ) new NotificationCompat .Builder (this )
901
901
.setContentTitle (getString (R .string .notif_title ))
902
- .setColor (getColor (R .color .notif_background ));
902
+ .setColor (ContextCompat . getColor (this , R .color .notif_background ));
903
903
}
904
904
905
905
// Get action and MIME type of intent
@@ -941,8 +941,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
941
941
942
942
// activity transition animation
943
943
ActivityTransitionAnim .transition (ZulipActivity .this );
944
- }
945
- else if (requestCode == REQUEST_PICK_FILE && resultCode == RESULT_OK ) {
944
+ } else if (requestCode == REQUEST_PICK_FILE && resultCode == RESULT_OK ) {
946
945
List <Uri > fileUris = new ArrayList <>();
947
946
if (data .getData () != null ) {
948
947
fileUris .add (data .getData ());
@@ -1214,8 +1213,6 @@ private void uploadFile(final File file) {
1214
1213
// MultipartBody.Part is used to send also the actual file name
1215
1214
MultipartBody .Part body = prepareFilePart ("file" , file , notifId );
1216
1215
1217
- final String loadingMsg = getResources ().getString (R .string .uploading_message );
1218
-
1219
1216
// start notification
1220
1217
setNotification (notifId , getString (R .string .init_notif_title ));
1221
1218
@@ -1225,40 +1222,44 @@ private void uploadFile(final File file) {
1225
1222
call .enqueue (new DefaultCallback <UploadResponse >() {
1226
1223
@ Override
1227
1224
public void onSuccess (Call <UploadResponse > call , Response <UploadResponse > response ) {
1228
- if (!isDestroyed ()) {
1229
- String filePathOnServer = "" ;
1230
- UploadResponse uploadResponse = response .body ();
1231
- filePathOnServer = uploadResponse .getUri ();
1232
- if (!filePathOnServer .equals ("" )) {
1233
- endNotification (notifId , getString (R .string .finish_notif_title ));
1234
-
1235
- // add uploaded file url on server to composed message
1236
- messageEt .append ("\n [" + file .getName () + "](" +
1237
- UrlHelper .addHost (filePathOnServer ) + ")" );
1238
- displayFAB (false );
1239
- displayChatBox (true );
1240
- } else {
1241
- endNotification (notifId , getString (R .string .failed_to_upload ));
1242
- }
1243
- mNotificationManager .cancel (notifId );
1225
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .JELLY_BEAN_MR1 && isDestroyed ()) {
1226
+ return ;
1244
1227
}
1228
+ String filePathOnServer = "" ;
1229
+ UploadResponse uploadResponse = response .body ();
1230
+ filePathOnServer = uploadResponse .getUri ();
1231
+ if (!filePathOnServer .equals ("" )) {
1232
+ endNotification (notifId , getString (R .string .finish_notif_title ));
1233
+
1234
+ // add uploaded file url on server to composed message
1235
+ messageEt .append ("\n [" + file .getName () + "](" +
1236
+ UrlHelper .addHost (filePathOnServer ) + ")" );
1237
+ displayFAB (false );
1238
+ displayChatBox (true );
1239
+ } else {
1240
+ endNotification (notifId , getString (R .string .failed_to_upload ));
1241
+ }
1242
+ mNotificationManager .cancel (notifId );
1243
+
1245
1244
}
1246
1245
1247
1246
@ Override
1248
1247
public void onError (Call <UploadResponse > call , Response <UploadResponse > response ) {
1249
- if (!isDestroyed ()) {
1250
- endNotification (notifId , getString (R .string .failed_to_upload ));
1251
- mNotificationManager .cancel (notifId );
1248
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .JELLY_BEAN_MR1 && isDestroyed ()) {
1249
+ return ;
1252
1250
}
1251
+ endNotification (notifId , getString (R .string .failed_to_upload ));
1252
+ mNotificationManager .cancel (notifId );
1253
1253
}
1254
1254
1255
1255
@ Override
1256
1256
public void onFailure (Call <UploadResponse > call , Throwable t ) {
1257
- if (!isDestroyed ()) {
1258
- endNotification (notifId , getString (R .string .failed_to_upload ));
1259
- mNotificationManager .cancel (notifId );
1260
- ZLog .logException (t );
1257
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .JELLY_BEAN_MR1 && isDestroyed ()) {
1258
+ return ;
1261
1259
}
1260
+ endNotification (notifId , getString (R .string .failed_to_upload ));
1261
+ mNotificationManager .cancel (notifId );
1262
+ ZLog .logException (t );
1262
1263
}
1263
1264
});
1264
1265
}
0 commit comments