mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2025-06-05 21:59:19 +02:00
catch out of memory errors at setting wallpaper
This commit is contained in:
@ -32,7 +32,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
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.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
|
||||||
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0'
|
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0'
|
||||||
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
|
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
|
||||||
|
@ -94,8 +94,13 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete
|
|||||||
val wantedHeight = wallpaperManager.desiredMinimumHeight
|
val wantedHeight = wallpaperManager.desiredMinimumHeight
|
||||||
val ratio = wantedHeight / bitmap.height.toFloat()
|
val ratio = wantedHeight / bitmap.height.toFloat()
|
||||||
val wantedWidth = (bitmap.width * ratio).toInt()
|
val wantedWidth = (bitmap.width * ratio).toInt()
|
||||||
wallpaperManager.setBitmap(Bitmap.createScaledBitmap(bitmap, wantedWidth, wantedHeight, true))
|
try {
|
||||||
setResult(Activity.RESULT_OK)
|
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()
|
finish()
|
||||||
}).start()
|
}).start()
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user