I have an Activity Indicator that becomes visible when a button is pushed.
This button makes several asynchronous calls to a web API before finally navigating to a new content page.
When the asynchronous calls to the API are made the Activity Indicator freezes and lags to the point where it almost seems as if the entire app has crashed. This behavior is only present on Android and doesn't happen on iOS.
Here is the code which runs when the button is pressed:
public async void OnRecord(object o, EventArgs e)
{
//Fetch projects from the webservice and put them in the database
WebServiceController web = new WebServiceController();
RecordActivity.IsVisible = true;
RecordActivityHolder.IsVisible = true;
//if (await gbrViewHelper.CheckConnectivity(this)) return;
GlobalResources.availableProjects = await web.GetProjectsFromApi();
//Check for no projects available
if (GlobalResources.availableProjects.Count == 0)
{
await DisplayAlert("No Projects", "There are currently no projects available to particpate in. Please check back later.", "OK");
RecordActivity.IsVisible = false;
RecordActivityHolder.IsVisible = false;
return;
}
if (GlobalResources.availableProjects.Count == 1)
{
//This function leads to more calls to the API.
await gbrProjectPickerHelper.PickProjectForRecording(this, GlobalResources.availableProjects[0]);
}
else
{
//multiple projects
await Navigation.PushAsync(new gbrRecordProjectPicker());
}
RecordActivity.IsVisible = false;
RecordActivityHolder.IsVisible = false;
}
I was wondering if there was any way to get the Activity Indicator to perform smoothly on Android and have these API calls occur at the same time.