/// <summary> /// Pulls today's featured wikipedia article /// </summary> private async void LoadWikiInfo() { ProgressDialog dialog = new ProgressDialog(this); dialog.SetTitle("Please Wait..."); dialog.SetMessage("Downloading today's content!"); dialog.SetCancelable(false); dialog.Show(); wiki = await AndroidUtils.GetTodaysWiki(this); if (wikiImage != null && wiki.imageURL != null) { if (!File.Exists(wiki.imageURL)) { // Force update, file has been deleted somehow wiki = await ServerData.FetchWikiData(AndroidUtils.DecodeHTML); } wikiImage.SetImageURI(Android.Net.Uri.FromFile(new Java.IO.File(wiki.imageURL))); wikiImage.Visibility = ViewStates.Visible; } else if(wikiImage != null) { wikiImage.Visibility = ViewStates.Gone; } string[] sentences = wiki.content.Split(new[] {". "}, StringSplitOptions.RemoveEmptyEntries); string finalText = ""; int charTarget = 400; foreach (string sentence in sentences) { if (finalText.Length < charTarget && finalText.Length + sentence.Length < 570) { finalText += sentence + ". "; } else { break; } } wikiText.Text = finalText; // If it's longer than expected, reduce the text size! if (finalText.Length > 520) { if ((Resources.Configuration.ScreenLayout & Android.Content.Res.ScreenLayout.SizeMask) <= Android.Content.Res.ScreenLayout.SizeNormal) { wikiText.SetTextSize(Android.Util.ComplexUnitType.Sp, 15); } else { wikiText.SetTextSize(Android.Util.ComplexUnitType.Sp, 19); } } SwitchMode(ServerData.TaskType.Loudness); dialog.Hide(); }