* Remove asynctask code * add job test example * Fix testing * Fix a couple of imports
39 lines
762 B
Plaintext
39 lines
762 B
Plaintext
import "pkg:/source/QrCode/QrImage.bs"
|
|
import "pkg:/source/QrCode/QrMode.bs"
|
|
import "pkg:/source/utils/StringUtils.bs"
|
|
|
|
@job("GenerateQrCodeJob")
|
|
function ExecuteJob() as void
|
|
input = JobGetInput()
|
|
|
|
poster = input.poster
|
|
mode = input.mode
|
|
text = input.text
|
|
size = input.size
|
|
padding = input.padding
|
|
|
|
if mode = invalid
|
|
mode = QrCode.QRMode.Byte
|
|
end if
|
|
|
|
if size = invalid
|
|
size = 200
|
|
end if
|
|
|
|
if padding = invalid
|
|
padding = 0
|
|
end if
|
|
|
|
qr = new QrCode.QRImage()
|
|
imagePath = qr.Generate(text, size, padding, mode)
|
|
|
|
if JobIsCancelled()
|
|
JobCancel()
|
|
return
|
|
end if
|
|
|
|
if not StringUtils.IsNullOrEmpty(imagePath)
|
|
poster.uri = imagePath
|
|
end if
|
|
end function
|