Last active
April 25, 2023 11:27
-
-
Save dcrec1/ba61510222b47a72af1735b4addab999 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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