private async void DownloadLanguageCompleted(OcrLanguage language, Exception error)
        {
            if (language != null && language.Tag != null)
            {
                await Device.InvokeOnMainThreadAsync(() => (language.Tag as Label).IsEnabled = true);
            }

            if (error == null)
            {
                // Download completed successfully, then remove the downloaded language from the downloadable languages list and add it to the inactive languages list.
                await Device.InvokeOnMainThreadAsync(async() =>
                {
                    if (language != null && !language.CancellationTokenSource.IsCancellationRequested)
                    {
                        DownloadableLanguages = OcrLanguageManager.DownloadableLanguages;

                        var langs = InactiveLanguages.Where(l => l.Language.Equals(language.Language));
                        if (langs == null || langs.Count() == 0)
                        {
                            InactiveLanguages.Add(language);
                        }

                        language.IsDownloadable = false;

                        await Device.InvokeOnMainThreadAsync(() => ReloadCachedLanguagesInfo());
                    }
                });
            }
            else
            {
                // Error occurred while downloading this language
                await Device.InvokeOnMainThreadAsync(async() =>
                {
                    ReloadCachedLanguagesInfo();
                    await DisplayAlert("Error Downloading File", $"Encountered an error while trying to download the {language.LocalizedName} language: {error.Message}", "OK");
                });
            }
        }
        private void PopulateActiveInactiveLanguages()
        {
            InactiveLanguages.Clear();

            foreach (OcrLanguage localLanguage in OcrLanguageManager.LocalLanguages)
            {
                localLanguage.IsDefaultLanguage = false;
                if (!ActiveLanguages.Any(l => l.Language.Equals(localLanguage.Language)))
                {
                    InactiveLanguages.Add(localLanguage);
                }
            }

            foreach (OcrLanguage activeLanguage in ActiveLanguages)
            {
                activeLanguage.IsDefaultLanguage = ActiveLanguages[0].Equals(activeLanguage);
            }

            var inactiveLanguages = InactiveLanguages.OrderBy(firstOrder => firstOrder.CanBeDeleted).ThenBy(secondOrder => secondOrder.LocalizedName);

            InactiveLanguages = new ObservableCollection <OcrLanguage>(inactiveLanguages);

            RefreshActiveInactiveListViews();
        }