public async Task <Dictionary <string, List <MalProfileHistoryEntry> > > GetProfileHistory() { var output = new Dictionary <string, List <MalProfileHistoryEntry> >(); try { var client = await ResourceLocator.MalHttpContextProvider.GetHttpContextAsync(); var raw = await(await client.GetAsync( Uri.EscapeUriString($"https://myanimelist.net/history/{_source}"))).Content.ReadAsStringAsync(); if (string.IsNullOrEmpty(raw)) { return(null); } var doc = new HtmlDocument(); doc.LoadHtml(raw); foreach (var historyRow in doc.DocumentNode.Descendants("tr")) { try { //so this is one big table if it contains only on chld it means that it's day/week header so if (historyRow.ChildNodes.Count == 3) { if (historyRow.InnerText.Trim() == " ") { continue; } output.Add(historyRow.InnerText.Trim(), new List <MalProfileHistoryEntry>()); } else { var current = new MalProfileHistoryEntry(); var link = historyRow.Descendants("a").First(); current.Id = int.Parse(link.Attributes["href"].Value.Split('=').Last()); current.IsAnime = link.Attributes["href"].Value.Contains("/anime"); current.WatchedEpisode = int.Parse(historyRow.Descendants("strong").First().InnerText); current.Date = historyRow.Descendants("td").Last().InnerText; //skip "Edit" button output.Last().Value.Add(current); } } catch (Exception e) { //html } } } catch (Exception e) { //malsth } return(output); }
private View GetTemplateDelegate(int i, MalProfileHistoryEntry malProfileHistoryEntry, View arg3) { ViewGroup view; var txt1params = new FrameLayout.LayoutParams(-2, -2); var txt2params = new FrameLayout.LayoutParams(-2, -2); if (Context.Resources.Configuration.Orientation == Orientation.Landscape) { view = new FrameLayout(Context) { LayoutParameters = new ViewGroup.LayoutParams(-1, -2) }; txt1params.Gravity = GravityFlags.Start; txt2params.Gravity = GravityFlags.End; } else { view = new LinearLayout(Context) { LayoutParameters = new ViewGroup.LayoutParams(-1, -2) }; ((LinearLayout)view).Orientation = global::Android.Widget.Orientation.Vertical; ((LinearLayout)view).SetGravity(GravityFlags.CenterHorizontal); } var txt1 = new TextView(Activity) { LayoutParameters = txt1params, Text = $"{malProfileHistoryEntry.ShowUnit} {malProfileHistoryEntry.WatchedEpisode}" }; txt1.SetTextColor(new Color(ResourceExtension.BrushText)); var txt2 = new TextView(Activity) { LayoutParameters = txt2params, Text = malProfileHistoryEntry.Date }; txt2.SetTextColor(new Color(ResourceExtension.BrushText)); txt2.Typeface = Typeface.Create(ResourceExtension.FontSizeLight, TypefaceStyle.Normal); view.AddView(txt1); view.AddView(txt2); return(view); }