mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
wrap the wallpaper setter in a try-catch block
This commit is contained in:
parent
25b31eb5a7
commit
277ded39ab
1 changed files with 8 additions and 4 deletions
|
@ -72,11 +72,15 @@ fun Activity.shareMedia(media: List<Medium>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Activity.trySetAsWallpaper(file: File) {
|
fun Activity.trySetAsWallpaper(file: File) {
|
||||||
|
try {
|
||||||
var uri = Uri.fromFile(file)
|
var uri = Uri.fromFile(file)
|
||||||
if (!setAsWallpaper(uri, file)) {
|
if (!setAsWallpaper(uri, file)) {
|
||||||
uri = getFileContentUri(file)
|
uri = getFileContentUri(file)
|
||||||
setAsWallpaper(uri, file, false)
|
setAsWallpaper(uri, file, false)
|
||||||
}
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
toast(R.string.unknown_error_occurred)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Activity.setAsWallpaper(uri: Uri, file: File, showToast: Boolean = true): Boolean {
|
fun Activity.setAsWallpaper(uri: Uri, file: File, showToast: Boolean = true): Boolean {
|
||||||
|
|
Loading…
Reference in a new issue