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);
     }
   }
 }
 private void startCrop(String path, Uri uri) {
   try {
     LaunchActivity activity = (LaunchActivity) parentFragment.getParentActivity();
     if (activity == null) {
       return;
     }
     Bundle args = new Bundle();
     if (path != null) {
       args.putString("photoPath", path);
     } else if (uri != null) {
       args.putParcelable("photoUri", uri);
     }
     PhotoCropActivity photoCropActivity = new PhotoCropActivity(args);
     photoCropActivity.setDelegate(this);
     activity.presentFragment(photoCropActivity);
   } catch (Exception e) {
     FileLog.e("tmessages", e);
     Bitmap bitmap = ImageLoader.loadBitmap(path, uri, 800, 800, true);
     processBitmap(bitmap);
   }
 }