mirror of
https://github.com/SimpleMobileTools/Simple-Draw.git
synced 2025-03-26 08:30:05 +01:00
use a helper function for creating a thread
This commit is contained in:
parent
833fbca958
commit
584a90026a
@ -12,6 +12,7 @@ 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.toast
|
import com.simplemobiletools.commons.extensions.toast
|
||||||
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.draw.pro.R
|
import com.simplemobiletools.draw.pro.R
|
||||||
import com.simplemobiletools.draw.pro.interfaces.CanvasListener
|
import com.simplemobiletools.draw.pro.interfaces.CanvasListener
|
||||||
import com.simplemobiletools.draw.pro.models.MyParcelable
|
import com.simplemobiletools.draw.pro.models.MyParcelable
|
||||||
@ -138,7 +139,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun drawBitmap(activity: Activity, path: Any) {
|
fun drawBitmap(activity: Activity, path: Any) {
|
||||||
Thread {
|
ensureBackgroundThread {
|
||||||
val size = Point()
|
val size = Point()
|
||||||
activity.windowManager.defaultDisplay.getSize(size)
|
activity.windowManager.defaultDisplay.getSize(size)
|
||||||
val options = RequestOptions()
|
val options = RequestOptions()
|
||||||
@ -161,7 +162,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
|||||||
val errorMsg = String.format(activity.getString(R.string.failed_to_load_image), path)
|
val errorMsg = String.format(activity.getString(R.string.failed_to_load_image), path)
|
||||||
activity.toast(errorMsg)
|
activity.toast(errorMsg)
|
||||||
}
|
}
|
||||||
}.start()
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addPath(path: MyPath, options: PaintOptions) {
|
fun addPath(path: MyPath, options: PaintOptions) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user