Skip to content

Instantly share code, notes, and snippets.

@dcrec1
Last active April 25, 2023 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcrec1/ba61510222b47a72af1735b4addab999 to your computer and use it in GitHub Desktop.
Save dcrec1/ba61510222b47a72af1735b4addab999 to your computer and use it in GitHub Desktop.
override fun onLoadFinished(loader: Loader<MutableList<Bitmap>>, data: MutableList<Bitmap>?) {
Log.d(Constants.PLATFORM_NAME, "Finishing PrintAsyncTask loader")
loaderManager!!.destroyLoader(LOADER_NUMBER)
val provider = findProvider()
val context: Context = this
var i = 0
val listener: Result = object : Result {
override fun success(listenerResult: Any?) {
val response = listenerResult as HashMap<*, *>
if (response["success"] as Boolean) {
i++
if (i == data!!.size) {
result!!.success(response)
} else {
provider.print(data.slice(i..i), this, context)
}
} else {
AlertDialog.Builder(context)
.setTitle("Erro na impressão")
.setMessage(response["description"] as String)
.setPositiveButton("Tentar novamente") { _, _ ->
provider.print(data!!.slice(i..i), this, context)
}
.setCancelable(false)
.show()
}
}
override fun error(errorCode: String, errorMessage: String?, errorDetails: Any?) {
}
override fun notImplemented() {
}
}
provider.print(data!!.slice(0..0), listener, this)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment