diff --git a/app/build.gradle b/app/build.gradle index 4e185cebc..f88b686a3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,7 +32,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.19.4' + compile 'com.simplemobiletools:commons:2.19.5' compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0' compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SetWallpaperActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SetWallpaperActivity.kt index 1dd599eff..9d2fddb3c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SetWallpaperActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SetWallpaperActivity.kt @@ -94,8 +94,13 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete val wantedHeight = wallpaperManager.desiredMinimumHeight val ratio = wantedHeight / bitmap.height.toFloat() val wantedWidth = (bitmap.width * ratio).toInt() - wallpaperManager.setBitmap(Bitmap.createScaledBitmap(bitmap, wantedWidth, wantedHeight, true)) - setResult(Activity.RESULT_OK) + try { + wallpaperManager.setBitmap(Bitmap.createScaledBitmap(bitmap, wantedWidth, wantedHeight, true)) + setResult(Activity.RESULT_OK) + } catch (e: OutOfMemoryError) { + toast(R.string.out_of_memory_error) + setResult(Activity.RESULT_CANCELED) + } finish() }).start() } else {