mirror of
https://github.com/SimpleMobileTools/Simple-Draw.git
synced 2025-04-05 14:21:19 +02:00
catch exceptions thrown at loading bitmap
This commit is contained in:
parent
11cd55bc53
commit
6d24714030
@ -12,7 +12,9 @@ import com.bumptech.glide.Glide
|
|||||||
import com.bumptech.glide.load.DecodeFormat
|
import com.bumptech.glide.load.DecodeFormat
|
||||||
import com.bumptech.glide.request.RequestOptions
|
import com.bumptech.glide.request.RequestOptions
|
||||||
import com.simplemobiletools.commons.extensions.getContrastColor
|
import com.simplemobiletools.commons.extensions.getContrastColor
|
||||||
|
import com.simplemobiletools.commons.extensions.toast
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import java.util.concurrent.ExecutionException
|
||||||
|
|
||||||
class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
||||||
var mPaths = LinkedHashMap<MyPath, PaintOptions>()
|
var mPaths = LinkedHashMap<MyPath, PaintOptions>()
|
||||||
@ -94,6 +96,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
|||||||
.format(DecodeFormat.PREFER_ARGB_8888)
|
.format(DecodeFormat.PREFER_ARGB_8888)
|
||||||
.fitCenter()
|
.fitCenter()
|
||||||
|
|
||||||
|
try {
|
||||||
val builder = Glide.with(context)
|
val builder = Glide.with(context)
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.load(path)
|
.load(path)
|
||||||
@ -104,6 +107,10 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
|||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
invalidate()
|
invalidate()
|
||||||
}
|
}
|
||||||
|
} catch (e: ExecutionException) {
|
||||||
|
val errorMsg = String.format(activity.getString(R.string.failed_to_load_image), path)
|
||||||
|
activity.toast(errorMsg)
|
||||||
|
}
|
||||||
}).start()
|
}).start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<string name="app_launcher_name">Zeichenblock</string>
|
<string name="app_launcher_name">Zeichenblock</string>
|
||||||
<string name="open_file">Open file</string>
|
<string name="open_file">Open file</string>
|
||||||
<string name="eraser">Eraser</string>
|
<string name="eraser">Eraser</string>
|
||||||
|
<string name="failed_to_load_image">Failed to load image %s</string>
|
||||||
|
|
||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
<string name="show_brush_size">Show brush size tool</string>
|
<string name="show_brush_size">Show brush size tool</string>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<string name="app_launcher_name">Draw</string>
|
<string name="app_launcher_name">Draw</string>
|
||||||
<string name="open_file">Open file</string>
|
<string name="open_file">Open file</string>
|
||||||
<string name="eraser">Eraser</string>
|
<string name="eraser">Eraser</string>
|
||||||
|
<string name="failed_to_load_image">Failed to load image %s</string>
|
||||||
|
|
||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
<string name="show_brush_size">Show brush size tool</string>
|
<string name="show_brush_size">Show brush size tool</string>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<string name="app_launcher_name">Dessiner</string>
|
<string name="app_launcher_name">Dessiner</string>
|
||||||
<string name="open_file">Open file</string>
|
<string name="open_file">Open file</string>
|
||||||
<string name="eraser">Eraser</string>
|
<string name="eraser">Eraser</string>
|
||||||
|
<string name="failed_to_load_image">Failed to load image %s</string>
|
||||||
|
|
||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
<string name="show_brush_size">Show brush size tool</string>
|
<string name="show_brush_size">Show brush size tool</string>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<string name="app_launcher_name">Draw</string>
|
<string name="app_launcher_name">Draw</string>
|
||||||
<string name="open_file">Open file</string>
|
<string name="open_file">Open file</string>
|
||||||
<string name="eraser">Eraser</string>
|
<string name="eraser">Eraser</string>
|
||||||
|
<string name="failed_to_load_image">Failed to load image %s</string>
|
||||||
|
|
||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
<string name="show_brush_size">Show brush size tool</string>
|
<string name="show_brush_size">Show brush size tool</string>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<string name="app_launcher_name">ドロー</string>
|
<string name="app_launcher_name">ドロー</string>
|
||||||
<string name="open_file">Open file</string>
|
<string name="open_file">Open file</string>
|
||||||
<string name="eraser">Eraser</string>
|
<string name="eraser">Eraser</string>
|
||||||
|
<string name="failed_to_load_image">Failed to load image %s</string>
|
||||||
|
|
||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
<string name="show_brush_size">Show brush size tool</string>
|
<string name="show_brush_size">Show brush size tool</string>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<string name="app_launcher_name">Simple Draw</string>
|
<string name="app_launcher_name">Simple Draw</string>
|
||||||
<string name="open_file">Otwórz plik</string>
|
<string name="open_file">Otwórz plik</string>
|
||||||
<string name="eraser">Gumka</string>
|
<string name="eraser">Gumka</string>
|
||||||
|
<string name="failed_to_load_image">Failed to load image %s</string>
|
||||||
|
|
||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
<string name="show_brush_size">Pokaż narzędzie rozmiaru pędzla</string>
|
<string name="show_brush_size">Pokaż narzędzie rozmiaru pędzla</string>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<string name="app_launcher_name">Desenho</string>
|
<string name="app_launcher_name">Desenho</string>
|
||||||
<string name="open_file">Abrir ficheiro</string>
|
<string name="open_file">Abrir ficheiro</string>
|
||||||
<string name="eraser">Borracha</string>
|
<string name="eraser">Borracha</string>
|
||||||
|
<string name="failed_to_load_image">Failed to load image %s</string>
|
||||||
|
|
||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
<string name="show_brush_size">Mostrar ferramenta Tamanho do pincel</string>
|
<string name="show_brush_size">Mostrar ferramenta Tamanho do pincel</string>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<string name="app_launcher_name">Рисунки</string>
|
<string name="app_launcher_name">Рисунки</string>
|
||||||
<string name="open_file">Открыть файл</string>
|
<string name="open_file">Открыть файл</string>
|
||||||
<string name="eraser">Eraser</string>
|
<string name="eraser">Eraser</string>
|
||||||
|
<string name="failed_to_load_image">Failed to load image %s</string>
|
||||||
|
|
||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
<string name="show_brush_size">Позволить изменять размер кисти</string>
|
<string name="show_brush_size">Позволить изменять размер кисти</string>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<string name="app_launcher_name">Rita</string>
|
<string name="app_launcher_name">Rita</string>
|
||||||
<string name="open_file">Öppna fil</string>
|
<string name="open_file">Öppna fil</string>
|
||||||
<string name="eraser">Radergummi</string>
|
<string name="eraser">Radergummi</string>
|
||||||
|
<string name="failed_to_load_image">Failed to load image %s</string>
|
||||||
|
|
||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
<string name="show_brush_size">Visa penselstorleksverktyg</string>
|
<string name="show_brush_size">Visa penselstorleksverktyg</string>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<string name="app_launcher_name">Draw</string>
|
<string name="app_launcher_name">Draw</string>
|
||||||
<string name="open_file">Open file</string>
|
<string name="open_file">Open file</string>
|
||||||
<string name="eraser">Eraser</string>
|
<string name="eraser">Eraser</string>
|
||||||
|
<string name="failed_to_load_image">Failed to load image %s</string>
|
||||||
|
|
||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
<string name="show_brush_size">Show brush size tool</string>
|
<string name="show_brush_size">Show brush size tool</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user