mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2025-06-05 21:59:19 +02:00
move the wallpaper handling in a background thread
This commit is contained in:
@ -63,13 +63,16 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete
|
||||
|
||||
override fun onCropImageComplete(view: CropImageView?, result: CropImageView.CropResult) {
|
||||
if (result.error == null) {
|
||||
val bitmap = result.bitmap
|
||||
val wantedHeight = wallpaperManager.desiredMinimumHeight
|
||||
val ratio = wantedHeight / bitmap.height.toFloat()
|
||||
val wantedWidth = (bitmap.width * ratio).toInt()
|
||||
wallpaperManager.setBitmap(Bitmap.createScaledBitmap(bitmap, wantedWidth, wantedHeight, false))
|
||||
setResult(Activity.RESULT_OK)
|
||||
finish()
|
||||
toast(R.string.setting_wallpaper)
|
||||
Thread({
|
||||
val bitmap = result.bitmap
|
||||
val wantedHeight = wallpaperManager.desiredMinimumHeight
|
||||
val ratio = wantedHeight / bitmap.height.toFloat()
|
||||
val wantedWidth = (bitmap.width * ratio).toInt()
|
||||
wallpaperManager.setBitmap(Bitmap.createScaledBitmap(bitmap, wantedWidth, wantedHeight, false))
|
||||
setResult(Activity.RESULT_OK)
|
||||
finish()
|
||||
}).start()
|
||||
} else {
|
||||
toast("${getString(R.string.image_editing_failed)}: ${result.error.message}")
|
||||
}
|
||||
|
Reference in New Issue
Block a user