Started table layout and web request

This commit is contained in:
Norbi Peti 2017-02-08 22:21:11 +01:00
parent ec1188de66
commit 96229e0b76
5 changed files with 126 additions and 9 deletions

View file

@ -1,15 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
namespace Orarend
{
public static class API
{
public static IEnumerable<Óra> Órák(string csoportok)
/// <summary>
/// Visszatér az adott nap óráival.
/// </summary>
/// <param name="osztályid">Az osztály azonosítója, ld. <see cref="Osztályok"/></param>
/// <param name="csoportok">A csoportok, amiknek az óráit kérjük, szóközökkel elválasztva</param>
/// <param name="nap">A nap egy betűs formában</param>
/// <returns></returns>
public static IEnumerable<Óra> Órák(string osztályid, string csoportok, string nap)
{
return null;
return new Óra[] { new Óra { Azonosító = "test", Név = "Test", Tanár = new Tanár { Név = "A B" }, Terem = "222" }, new Óra { Azonosító = "asd", Név = "Asd", Tanár = new Tanár { Név = "B A" }, Terem = "216" } };
}
public static async Task<IEnumerable<string>> Osztályok()
{ //TODO: Tárolja el az adatokat, és csak külön hívásra frissítse; csak a frissítés legyen async, ezek nem
var req = WebRequest.CreateHttp("http://deri.enaplo.net/ajax/orarend/orarendoszt.php");
var resp = await req.GetResponseAsync();
var doc = XDocument.Parse(new StreamReader(resp.GetResponseStream()).ReadToEnd());
return new string[] { doc.Element(XName.Get("select")).Value };
}
}
}

View file

@ -7,6 +7,8 @@ using Android.Widget;
using Android.OS;
using Android.Support.V4.View;
using Orarend;
using System.Linq;
using Android.Graphics;
namespace OrarendAndroidApp
{
@ -16,9 +18,22 @@ namespace OrarendAndroidApp
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
ViewPager viewPager = FindViewById<ViewPager>(Resource.Id.viewpager);
API.Órák("");
SetContentView(Resource.Layout.MainLayout);
//ViewPager viewPager = FindViewById<ViewPager>(Resource.Id.viewpager);
var table = FindViewById<TableLayout>(Resource.Id.tableLayout1);
Action<string, Color, TableRow> addCell = (text, color, tr1) =>
{
TextView textview = new TextView(this);
textview.SetText(text, TextView.BufferType.Normal);
textview.SetTextColor(color);
tr1.AddView(textview);
};
foreach (var óra in API.Órák(""))
{
TableRow tr1 = new TableRow(this);
addCell(óra.Név + "\n" + óra.Tanár.Név + "\n" + óra.Terem, Color.White, tr1);
table.AddView(tr1);
}
}
}
}

View file

@ -63,6 +63,9 @@
<None Include="packages.config" />
<None Include="Resources\AboutResources.txt" />
<None Include="Assets\AboutAssets.txt" />
<AndroidResource Include="Resources\layout\MainLayout.axml">
<SubType>AndroidResource</SubType>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\layout\Main.axml" />

View file

@ -60,6 +60,9 @@ namespace OrarendAndroidApp
public partial class Id
{
// aapt resource value: 0x7f050001
public const int tableLayout1 = 2131034113;
// aapt resource value: 0x7f050000
public const int viewpager = 2131034112;
@ -79,6 +82,9 @@ namespace OrarendAndroidApp
// aapt resource value: 0x7f030000
public const int Main = 2130903040;
// aapt resource value: 0x7f030001
public const int MainLayout = 2130903041;
static Layout()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();

View file

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="25px"
android:minHeight="25px">
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1">
<TableRow>
<TextView
android:layout_column="1"
android:text="Open..."
android:padding="3dip" />
<TextView
android:text="Ctrl-O"
android:gravity="right"
android:padding="3dip" />
</TableRow>
<TableRow>
<TextView
android:layout_column="1"
android:text="Save..."
android:padding="3dip" />
<TextView
android:text="Ctrl-S"
android:gravity="right"
android:padding="3dip" />
</TableRow>
<TableRow>
<TextView
android:layout_column="1"
android:text="Save As..."
android:padding="3dip" />
<TextView
android:text="Ctrl-Shift-S"
android:gravity="right"
android:padding="3dip" />
</TableRow>
<View
android:layout_height="2dip"
android:background="#FF909090" />
<TableRow>
<TextView
android:text="X"
android:padding="3dip" />
<TextView
android:text="Import..."
android:padding="3dip" />
</TableRow>
<TableRow>
<TextView
android:text="X"
android:padding="3dip" />
<TextView
android:text="Export..."
android:padding="3dip" />
<TextView
android:text="Ctrl-E"
android:gravity="right"
android:padding="3dip" />
</TableRow>
<View
android:layout_height="2dip"
android:background="#FF909090" />
<TableRow>
<TextView
android:layout_column="1"
android:text="Quit"
android:padding="3dip" />
</TableRow>
</TableLayout>
</LinearLayout>