@Override
 public void didReceivedNotification(int id, final Object... args) {
   if (id == NotificationCenter.FileDidUpload) {
     String location = (String) args[0];
     if (uploadingAvatar != null && location.equals(uploadingAvatar)) {
       NotificationCenter.getInstance()
           .removeObserver(AvatarUpdater.this, NotificationCenter.FileDidUpload);
       NotificationCenter.getInstance()
           .removeObserver(AvatarUpdater.this, NotificationCenter.FileDidFailUpload);
       if (delegate != null) {
         delegate.didUploadedPhoto((TLRPC.InputFile) args[1], smallPhoto, bigPhoto);
       }
       uploadingAvatar = null;
       if (clearAfterUpdate) {
         parentFragment = null;
         delegate = null;
       }
     }
   } else if (id == NotificationCenter.FileDidFailUpload) {
     String location = (String) args[0];
     if (uploadingAvatar != null && location.equals(uploadingAvatar)) {
       NotificationCenter.getInstance()
           .removeObserver(AvatarUpdater.this, NotificationCenter.FileDidUpload);
       NotificationCenter.getInstance()
           .removeObserver(AvatarUpdater.this, NotificationCenter.FileDidFailUpload);
       uploadingAvatar = null;
       if (clearAfterUpdate) {
         parentFragment = null;
         delegate = null;
       }
     }
   }
 }
 private void processBitmap(Bitmap bitmap) {
   if (bitmap == null) {
     return;
   }
   smallPhoto = ImageLoader.scaleAndSaveImage(bitmap, 100, 100, 80, false);
   bigPhoto = ImageLoader.scaleAndSaveImage(bitmap, 800, 800, 80, false, 320, 320);
   if (bigPhoto != null && smallPhoto != null) {
     if (returnOnly) {
       if (delegate != null) {
         delegate.didUploadedPhoto(null, smallPhoto, bigPhoto);
       }
     } else {
       UserConfig.saveConfig(false);
       uploadingAvatar =
           FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE)
               + "/"
               + bigPhoto.location.volume_id
               + "_"
               + bigPhoto.location.local_id
               + ".jpg";
       NotificationCenter.getInstance()
           .addObserver(AvatarUpdater.this, NotificationCenter.FileDidUpload);
       NotificationCenter.getInstance()
           .addObserver(AvatarUpdater.this, NotificationCenter.FileDidFailUpload);
       FileLoader.getInstance().uploadFile(uploadingAvatar, false, true);
     }
   }
 }