1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-29 14:35:45 +00:00

Début de gestion de cache avec Akavache

This commit is contained in:
Yan Maniez 2018-04-25 11:20:14 +02:00
parent aea9b24493
commit f741c229a2
6 changed files with 36 additions and 8 deletions

View file

@ -26,6 +26,7 @@ namespace AideDeJeu.Droid
public static void UpdateIdValues()
{
global::Splat.Resource.String.library_name = global::AideDeJeu.Droid.Resource.String.library_name;
global::Xamarin.Forms.Platform.Android.Resource.Attribute.actionBarSize = global::AideDeJeu.Droid.Resource.Attribute.actionBarSize;
}
@ -3730,6 +3731,9 @@ namespace AideDeJeu.Droid
// aapt resource value: 0x7f090038
public const int character_counter_pattern = 2131296312;
// aapt resource value: 0x7f09003e
public const int library_name = 2131296318;
// aapt resource value: 0x7f090000
public const int mr_button_content_description = 2131296256;

View file

@ -12,7 +12,6 @@ namespace AideDeJeu
{
InitializeComponent();
MainPage = new NavigationPage(new MainPage());
}

View file

@ -65,7 +65,7 @@ namespace AideDeJeu.Services
{
var scrapper = new Scrappers();
var spells = await scrapper.GetSpells(await scrapper.GetSpellIds("c"));
items = spells.Select(spell => new Item() { Text = spell.Title, Description = spell.Description }).ToList();
items = spells.Select(spell => new Item() { Text = spell.Title, Description = spell.DescriptionText }).ToList();
return await Task.FromResult(items);
}
}

View file

@ -5,7 +5,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.8.0" />
<PackageReference Include="akavache.core" Version="5.0.0" />
<PackageReference Include="AkavacheLite" Version="0.3.0" />
<PackageReference Include="HtmlAgilityPack" Version="1.8.1" />
</ItemGroup>
</Project>

View file

@ -1,4 +1,5 @@
using HtmlAgilityPack;
using Akavache;
using HtmlAgilityPack;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@ -9,6 +10,7 @@ using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Reactive.Linq;
namespace AideDeJeuLib
{
@ -77,7 +79,7 @@ namespace AideDeJeuLib
return spells;
}
public async Task<Spell> GetSpell(string id)
public async Task<Spell> GetSpellFromSource(string id)
{
string html = null;
using (var client = GetHttpClient())
@ -93,10 +95,17 @@ namespace AideDeJeuLib
var newSpells = new List<Spell>();
var divSpell = pack.DocumentNode.SelectNodes("//div[contains(@class,'bloc')]").FirstOrDefault();
var newSpell = HtmlDivToSpell(divSpell);
return newSpell;
}
public async Task<Spell> GetSpell(string id)
{
BlobCache.ApplicationName = "AkavacheExperiment";
//await BlobCache.UserAccount.InsertObject(id, newSpell);
var truc = await BlobCache.UserAccount.GetOrFetchObject<Spell>(id, () => GetSpellFromSource(id));
return truc;
}
public Spell HtmlDivToSpell(HtmlNode divSpell)
{
var newSpell = new Spell();

View file

@ -1,6 +1,7 @@
using HtmlAgilityPack;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;
using System.Text.RegularExpressions;
@ -20,8 +21,20 @@ namespace AideDeJeuLib
public string Range { get; set; }
public string Components { get; set; }
public string Duration { get; set; }
public string DescriptionHtml { get { return DescriptionDiv?.InnerHtml; } }
public string Description
public string DescriptionHtml
{
get
{
return DescriptionDiv?.InnerHtml;
}
set
{
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(value);
DescriptionDiv = doc.DocumentNode;
}
}
public string DescriptionText
{
get
{
@ -41,6 +54,7 @@ namespace AideDeJeuLib
return html;
}
}
[IgnoreDataMember]
public HtmlNode DescriptionDiv { get; set; }
public string Overflow { get; set; }
public string NoOverflow { get; set; }