POS-40 Dokończono erkan z linkami

This commit is contained in:
Wojciech Przybyła 2021-01-11 14:05:50 +01:00
parent fc00e94f6a
commit 2d5e43a42b
3 changed files with 30 additions and 4 deletions

View File

@ -14,6 +14,7 @@ using System.Net;
using System.Linq;
using System.IO;
using Newtonsoft.Json;
using Klient.Droid.Modules;
namespace Klient.Droid
{
@ -240,13 +241,18 @@ namespace Klient.Droid
var second_jsonString = await response.Content.ReadAsStringAsync();
dynamic second_jsonObject = JsonConvert.DeserializeObject(second_jsonString);
List<Dictionary<string, string>> fullLink = JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(second_jsonObject);
List<SearchResult> fullLink = JsonConvert.DeserializeObject<List<SearchResult>>(second_jsonObject);
// FindViewById<TextView>(Resource.Id.links).Text = fullLink[0].title
int end = 10;
if (fullLink.Count < 10) end = fullLink.Count;
for (int i = 0; i < end; i++)
{
FindViewById<TextView>(Resource.Id.links).Text = FindViewById<TextView>(Resource.Id.links).Text + fullLink[i].Title + ": " + fullLink[i].Link + "\n\n";
}
}
else
{
FindViewById<TextView>(Resource.Id.links).Text = "Coś poszło nie tak!";
}

View File

@ -0,0 +1,20 @@
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Klient.Droid.Modules
{
public class SearchResult
{
public string Title { get; set; }
public string Link { get; set; }
public string Snippet { get; set; }
}
}

View File

@ -73,6 +73,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="MainActivity.cs" />
<Compile Include="Modules\SearchResult.cs" />
<Compile Include="Resources\Resource.designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
@ -98,7 +99,6 @@
<AndroidResource Include="Resources\mipmap-xxxhdpi\launcher_foreground.png" />
</ItemGroup>
<ItemGroup>
<Folder Include="Modules\" />
<Folder Include="Resources\drawable-hdpi\" />
<Folder Include="Resources\drawable-xhdpi\" />
<Folder Include="Resources\drawable-xxhdpi\" />