mirror of
https://github.com/rebelonion/Dantotsu.git
synced 2026-01-18 19:53:56 +00:00
error catch for saving image
This commit is contained in:
@@ -625,13 +625,16 @@ fun shareImage(title: String, bitmap: Bitmap, context: Context) {
|
||||
|
||||
fun saveImage(image: Bitmap, path: String, imageFileName: String): File? {
|
||||
val imageFile = File(path, "$imageFileName.png")
|
||||
return tryWith {
|
||||
return try {
|
||||
val fOut: OutputStream = FileOutputStream(imageFile)
|
||||
image.compress(Bitmap.CompressFormat.PNG, 0, fOut)
|
||||
fOut.close()
|
||||
scanFile(imageFile.absolutePath, currContext()!!)
|
||||
toast(String.format(currContext()!!.getString(R.string.saved_to_path, path)))
|
||||
imageFile
|
||||
} catch (e: Exception) {
|
||||
snackString("Failed to save image: ${e.localizedMessage}")
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user