Voice Downloading
In this guide you will learn how to list all navigation instruction voices available on the server, indicating which are already downloaded, and download a voice.
Getting the list
To get the voices list a ContentStore
must be instantiated. Normally in Android's MVVM, stores are retained in the Repository layer, injected via dependency injection, and ultimately consumed by ViewModels but for the scope of this example we will use it inside an activity.
To request the list there also needs to be an established internet connection. In the code below is shown how to make a request for the voice list.
If retrieving the list is succesfull the ProgressListener.onCompleted
callback is triggered with no error. Download is started on the first succesfull retrieved item of the list. The
voiceItem.asyncDownload(..)
also receives progress callbacks that will update the UI.
Finally, the list is displayed using a RecyclerView.Adapter
.
The example also uses a CustomAdapter
to display a scrollable list of country names, flags and voice names with the displayList()
function.