Don't display error message if user cancels picking an image (#3427)

* Don't display error message if user cancels picking an image

* Update app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt
This commit is contained in:
Nik Clayton 2023-03-13 10:17:41 +01:00 committed by GitHub
parent 9ec9d35100
commit 70dced795c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 7 deletions

View File

@ -34,6 +34,7 @@ import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.bitmap.FitCenter import com.bumptech.glide.load.resource.bitmap.FitCenter
import com.bumptech.glide.load.resource.bitmap.RoundedCorners import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.canhub.cropper.CropImage
import com.canhub.cropper.CropImageContract import com.canhub.cropper.CropImageContract
import com.canhub.cropper.options import com.canhub.cropper.options
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
@ -80,15 +81,19 @@ class EditProfileActivity : BaseActivity(), Injectable {
} }
private val cropImage = registerForActivityResult(CropImageContract()) { result -> private val cropImage = registerForActivityResult(CropImageContract()) { result ->
if (result.isSuccessful) { if (result is CropImage.CancelledResult) {
return@registerForActivityResult
}
if (!result.isSuccessful) {
return@registerForActivityResult onPickFailure(result.error)
}
if (result.uriContent == viewModel.getAvatarUri()) { if (result.uriContent == viewModel.getAvatarUri()) {
viewModel.newAvatarPicked() viewModel.newAvatarPicked()
} else { } else {
viewModel.newHeaderPicked() viewModel.newHeaderPicked()
} }
} else {
onPickFailure(result.error)
}
} }
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {