I'm using google digital ink for handwriting recognition. The models that need to get downloaded once are of 20MB size and the download requires some time. Is there any way to show the progress of the download using a progressbar?
My code is as follows:
fun download(context: Context) {
var modelIdentifier: DigitalInkRecognitionModelIdentifier? = null
try {
modelIdentifier =
DigitalInkRecognitionModelIdentifier.fromLanguageTag(lang)
} catch (e: MlKitException) {
// language tag failed to parse, handle error.
}
model = DigitalInkRecognitionModel.builder(modelIdentifier!!).build()
val remoteModelManager = RemoteModelManager.getInstance()
remoteModelManager.download(model, DownloadConditions.Builder().build())
.addOnSuccessListener {
Log.i("StrokeManager", "Model downloaded")
Toast.makeText(context, "Model Downloaded", Toast.LENGTH_SHORT).show()
}
.addOnFailureListener { e: Exception ->
Log.e("StrokeManager", "Error while downloading a model: $e")
Toast.makeText(context, "Model Download Failed", Toast.LENGTH_SHORT).show()
}
}