Órarend szerkesztés/hozzáadás működőképes!
Bár a hozzáadást nem teszteltem.
This commit is contained in:
parent
96fdf7db6b
commit
6c9f953789
7 changed files with 203 additions and 58 deletions
|
@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
|||
namespace Orarend
|
||||
{
|
||||
[DataContract]
|
||||
public class Osztály
|
||||
public class Osztály : IEquatable<Osztály>
|
||||
{
|
||||
[DataMember]
|
||||
public string Azonosító { get; internal set; }
|
||||
|
@ -22,5 +22,10 @@ namespace Orarend
|
|||
{
|
||||
return Név;
|
||||
}
|
||||
|
||||
public bool Equals(Osztály other)
|
||||
{
|
||||
return Azonosító == other.Azonosító;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,9 +33,9 @@ namespace Orarend
|
|||
/// Egy 16 elemű tömb az órák kezdő időpontjaival
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public TimeSpan[] Órakezdetek { get; private set; } = new TimeSpan[16];
|
||||
public TimeSpan[] Órakezdetek { get; private set; } = new TimeSpan[16]; //A private set kell a serialization miatt
|
||||
[DataMember]
|
||||
public List<string> Csoportok { get; private set; } = new List<string>(); //A private set kell a serialization miatt
|
||||
public string[] Csoportok { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Létrehoz egy új órarendet
|
||||
|
@ -47,7 +47,7 @@ namespace Orarend
|
|||
{
|
||||
Név = név;
|
||||
Osztály = osztály;
|
||||
Csoportok.AddRange(csoportok.Replace("Egész osztály", "").Trim().Split(' '));
|
||||
Csoportok = csoportok.Replace("Egész osztály", "").Trim().Split(' ');
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
|
|
@ -9,17 +9,53 @@ using Android.OS;
|
|||
using Android.Runtime;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using Orarend;
|
||||
|
||||
namespace OrarendAndroidApp
|
||||
{
|
||||
[Activity(Label = "AddActivity", Theme = "@android:style/Theme.Holo.Light")]
|
||||
public class EditActivity : Activity
|
||||
{
|
||||
private bool add;
|
||||
private int index;
|
||||
protected override void OnCreate(Bundle savedInstanceState)
|
||||
{
|
||||
base.OnCreate(savedInstanceState);
|
||||
SetContentView(Resource.Layout.EditLayout);
|
||||
Title = (add = Intent.Extras.GetBoolean("add")) ? "Hozzáadás" : "Szerkesztés";
|
||||
index = Intent.Extras.GetInt("index");
|
||||
var osztálySpinner = FindViewById<Spinner>(Resource.Id.osztálySpinner);
|
||||
osztálySpinner.Adapter = new ArrayAdapter(this, Resource.Layout.simple_list_item_1, API.Osztályok);
|
||||
if (!add)
|
||||
{
|
||||
var órarend = API.Órarendek[index];
|
||||
FindViewById<EditText>(Resource.Id.névEditText).Text = órarend.Név;
|
||||
int ix = Array.IndexOf(API.Osztályok, órarend.Osztály);
|
||||
/*for (int i = 0; i < API.Osztályok.Length; i++)
|
||||
{
|
||||
var o = API.Osztályok[i];
|
||||
}*/
|
||||
osztálySpinner.SetSelection(ix);
|
||||
FindViewById<EditText>(Resource.Id.csoportokEditText).Text = órarend.Csoportok.Aggregate((a, b) => a + " " + b);
|
||||
}
|
||||
FindViewById<Button>(Resource.Id.saveButton).Click += SaveButtonClick;
|
||||
}
|
||||
|
||||
// Create your application here
|
||||
private void SaveButtonClick(object sender, EventArgs e)
|
||||
{
|
||||
var név = FindViewById<EditText>(Resource.Id.névEditText).Text;
|
||||
var osztály = API.Osztályok[FindViewById<Spinner>(Resource.Id.osztálySpinner).SelectedItemPosition];
|
||||
var csoportok = FindViewById<EditText>(Resource.Id.csoportokEditText).Text;
|
||||
if (!add)
|
||||
{
|
||||
var órarend = API.Órarendek[index];
|
||||
órarend.Név = név;
|
||||
órarend.Osztály = osztály;
|
||||
órarend.Csoportok = csoportok.Split(' ');
|
||||
}
|
||||
else
|
||||
API.Órarendek.Add(new Órarend(név, osztály, csoportok)); //TODO: Órarend törlése
|
||||
Finish();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -46,19 +46,23 @@ namespace OrarendAndroidApp
|
|||
}
|
||||
}
|
||||
|
||||
private void osztálylistafrissítés()
|
||||
private void órarendlistafrissítés()
|
||||
{
|
||||
handler.Post(() =>
|
||||
{
|
||||
var list = FindViewById<Spinner>(Resource.Id.spinner);
|
||||
list.Adapter = new ArrayAdapter(this, Resource.Layout.simple_list_item_1, API.Órarendek);
|
||||
var adapter = (ArrayAdapter)list.Adapter ?? new ArrayAdapter(this, Resource.Layout.simple_list_item_1, API.Órarendek);
|
||||
list.Adapter = adapter;
|
||||
adapter.NotifyDataSetChanged(); //TODO: Teszt
|
||||
list.ItemSelected += ÓrarendClick;
|
||||
//list.SetSelection(list.SelectedItemPosition); //Szöveg frissítése - TODO: Teszt
|
||||
});
|
||||
}
|
||||
|
||||
private void ÓrarendClick(object sender, AdapterView.ItemSelectedEventArgs e)
|
||||
{
|
||||
órarend = API.Órarendek[e.Position];
|
||||
órarendfrissítés();
|
||||
}
|
||||
|
||||
private void addCell(string text, Color color, TableRow tr1, bool clickable = false, int[] tag = null)
|
||||
|
@ -99,7 +103,7 @@ namespace OrarendAndroidApp
|
|||
if (TaskHiba(t) && órarend != null && (ór == null || ór == órarend))
|
||||
órarendfrissítés();
|
||||
bar.Visibility = ViewStates.Gone;
|
||||
osztálylistafrissítés();
|
||||
órarendlistafrissítés();
|
||||
Toast.MakeText(this, "Órarend és osztálylista frissítve", ToastLength.Long).Show();
|
||||
});
|
||||
});
|
||||
|
@ -174,7 +178,7 @@ namespace OrarendAndroidApp
|
|||
if (API.Osztályok == null || API.Osztályok.Length == 0)
|
||||
ÓrarendFrissítés();
|
||||
else
|
||||
osztálylistafrissítés();
|
||||
órarendlistafrissítés();
|
||||
return base.OnCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
|
@ -190,14 +194,15 @@ namespace OrarendAndroidApp
|
|||
case Resource.Id.menu_add:
|
||||
{
|
||||
var intent = new Intent(this, typeof(EditActivity));
|
||||
intent.PutExtra("mode", "add");
|
||||
intent.PutExtra("add", true);
|
||||
StartActivity(intent);
|
||||
break;
|
||||
}
|
||||
case Resource.Id.menu_edit:
|
||||
{
|
||||
var intent = new Intent(this, typeof(EditActivity));
|
||||
intent.PutExtra("mode", "edit"); //Az aktuális órarend elérhető
|
||||
intent.PutExtra("add", false);
|
||||
intent.PutExtra("index", API.Órarendek.IndexOf(órarend));
|
||||
StartActivity(intent);
|
||||
break;
|
||||
}
|
||||
|
@ -293,5 +298,15 @@ namespace OrarendAndroidApp
|
|||
}
|
||||
}); //TODO: Az egészet függőlegesen görgethetővé tenni
|
||||
}
|
||||
|
||||
public override void FinishFromChild(Activity child)
|
||||
{
|
||||
base.FinishFromChild(child);
|
||||
if (child is EditActivity)
|
||||
{
|
||||
ÓrarendFrissítés(child.Intent.Extras.GetBoolean("add") ? API.Órarendek.Last() : API.Órarendek[child.Intent.Extras.GetInt("index")]);
|
||||
órarendlistafrissítés();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,6 +62,9 @@
|
|||
<AndroidResource Include="Resources\layout\simple_list_item_1.axml">
|
||||
<SubType>AndroidResource</SubType>
|
||||
</AndroidResource>
|
||||
<AndroidResource Include="Resources\layout\EditLayout.axml">
|
||||
<SubType>AndroidResource</SubType>
|
||||
</AndroidResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\values\Strings.xml" />
|
||||
|
|
121
OrarendAndroidApp/Resources/Resource.Designer.cs
generated
121
OrarendAndroidApp/Resources/Resource.Designer.cs
generated
|
@ -84,62 +84,86 @@ namespace OrarendAndroidApp
|
|||
public partial class Id
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7f060000
|
||||
public const int ScrollView01 = 2131099648;
|
||||
|
||||
// aapt resource value: 0x7f060004
|
||||
public const int actionMenuView1 = 2131099652;
|
||||
|
||||
// aapt resource value: 0x7f060001
|
||||
public const int horizontalView = 2131099649;
|
||||
|
||||
// aapt resource value: 0x7f060009
|
||||
public const int idoTV = 2131099657;
|
||||
|
||||
// aapt resource value: 0x7f06000a
|
||||
public const int kezdvegTV = 2131099658;
|
||||
|
||||
// aapt resource value: 0x7f06000b
|
||||
public const int kovoraTV = 2131099659;
|
||||
|
||||
// aapt resource value: 0x7f06000f
|
||||
public const int menu_add = 2131099663;
|
||||
|
||||
// aapt resource value: 0x7f060010
|
||||
public const int menu_edit = 2131099664;
|
||||
|
||||
// aapt resource value: 0x7f060012
|
||||
public const int menu_fullrefresh = 2131099666;
|
||||
|
||||
// aapt resource value: 0x7f060011
|
||||
public const int menu_preferences = 2131099665;
|
||||
|
||||
// aapt resource value: 0x7f06000e
|
||||
public const int menu_refresh = 2131099662;
|
||||
|
||||
// aapt resource value: 0x7f060006
|
||||
public const int nevTV = 2131099654;
|
||||
// aapt resource value: 0x7f060008
|
||||
public const int ScrollView01 = 2131099656;
|
||||
|
||||
// aapt resource value: 0x7f06000c
|
||||
public const int osztalylistaTV = 2131099660;
|
||||
public const int actionMenuView1 = 2131099660;
|
||||
|
||||
// aapt resource value: 0x7f060005
|
||||
public const int pozTV = 2131099653;
|
||||
public const int csoportokEditText = 2131099653;
|
||||
|
||||
// aapt resource value: 0x7f060009
|
||||
public const int horizontalView = 2131099657;
|
||||
|
||||
// aapt resource value: 0x7f060011
|
||||
public const int idoTV = 2131099665;
|
||||
|
||||
// aapt resource value: 0x7f060012
|
||||
public const int kezdvegTV = 2131099666;
|
||||
|
||||
// aapt resource value: 0x7f060013
|
||||
public const int kovoraTV = 2131099667;
|
||||
|
||||
// aapt resource value: 0x7f060017
|
||||
public const int menu_add = 2131099671;
|
||||
|
||||
// aapt resource value: 0x7f060018
|
||||
public const int menu_edit = 2131099672;
|
||||
|
||||
// aapt resource value: 0x7f06001a
|
||||
public const int menu_fullrefresh = 2131099674;
|
||||
|
||||
// aapt resource value: 0x7f060019
|
||||
public const int menu_preferences = 2131099673;
|
||||
|
||||
// aapt resource value: 0x7f060016
|
||||
public const int menu_refresh = 2131099670;
|
||||
|
||||
// aapt resource value: 0x7f06000e
|
||||
public const int nevTV = 2131099662;
|
||||
|
||||
// aapt resource value: 0x7f060001
|
||||
public const int névEditText = 2131099649;
|
||||
|
||||
// aapt resource value: 0x7f060014
|
||||
public const int osztalylistaTV = 2131099668;
|
||||
|
||||
// aapt resource value: 0x7f060003
|
||||
public const int progressBar1 = 2131099651;
|
||||
public const int osztálySpinner = 2131099651;
|
||||
|
||||
// aapt resource value: 0x7f06000d
|
||||
public const int spinner = 2131099661;
|
||||
public const int pozTV = 2131099661;
|
||||
|
||||
// aapt resource value: 0x7f060002
|
||||
public const int tableLayout1 = 2131099650;
|
||||
|
||||
// aapt resource value: 0x7f060008
|
||||
public const int tanarTV = 2131099656;
|
||||
// aapt resource value: 0x7f06000b
|
||||
public const int progressBar1 = 2131099659;
|
||||
|
||||
// aapt resource value: 0x7f060007
|
||||
public const int teremTV = 2131099655;
|
||||
public const int saveButton = 2131099655;
|
||||
|
||||
// aapt resource value: 0x7f060015
|
||||
public const int spinner = 2131099669;
|
||||
|
||||
// aapt resource value: 0x7f06000a
|
||||
public const int tableLayout1 = 2131099658;
|
||||
|
||||
// aapt resource value: 0x7f060010
|
||||
public const int tanarTV = 2131099664;
|
||||
|
||||
// aapt resource value: 0x7f06000f
|
||||
public const int teremTV = 2131099663;
|
||||
|
||||
// aapt resource value: 0x7f060000
|
||||
public const int textView1 = 2131099648;
|
||||
|
||||
// aapt resource value: 0x7f060002
|
||||
public const int textView2 = 2131099650;
|
||||
|
||||
// aapt resource value: 0x7f060004
|
||||
public const int textView3 = 2131099652;
|
||||
|
||||
// aapt resource value: 0x7f060006
|
||||
public const int textView4 = 2131099654;
|
||||
|
||||
static Id()
|
||||
{
|
||||
|
@ -155,10 +179,13 @@ namespace OrarendAndroidApp
|
|||
{
|
||||
|
||||
// aapt resource value: 0x7f030000
|
||||
public const int MainLayout = 2130903040;
|
||||
public const int EditLayout = 2130903040;
|
||||
|
||||
// aapt resource value: 0x7f030001
|
||||
public const int simple_list_item_1 = 2130903041;
|
||||
public const int MainLayout = 2130903041;
|
||||
|
||||
// aapt resource value: 0x7f030002
|
||||
public const int simple_list_item_1 = 2130903042;
|
||||
|
||||
static Layout()
|
||||
{
|
||||
|
|
59
OrarendAndroidApp/Resources/layout/EditLayout.axml
Normal file
59
OrarendAndroidApp/Resources/layout/EditLayout.axml
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TableLayout 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"
|
||||
android:stretchColumns="*">
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:text="Név:"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/textView1"
|
||||
android:textSize="20dp"
|
||||
android:layout_column="0" />
|
||||
<EditText
|
||||
android:id="@+id/névEditText"
|
||||
android:layout_column="1"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="44.0dp" />
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:text="Osztály:"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/textView2"
|
||||
android:textSize="20dp"
|
||||
android:layout_column="0" />
|
||||
<Spinner
|
||||
android:layout_column="1"
|
||||
android:id="@+id/osztálySpinner"
|
||||
android:layout_width="fill_parent" />
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:text="Csoportok:"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/textView3"
|
||||
android:textSize="20dp"
|
||||
android:layout_column="0" />
|
||||
<EditText
|
||||
android:id="@+id/csoportokEditText "
|
||||
android:layout_column="1"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="44.0dp" />
|
||||
</TableRow>
|
||||
<TextView
|
||||
android:text="A csoportok megtalálhatók az E-napló osztályzatainál. Pl.: 'Egész osztály a1 pgy1'"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/textView4"
|
||||
android:textSize="16dp" />
|
||||
<Button
|
||||
android:text="Mentés"
|
||||
android:id="@+id/saveButton" />
|
||||
</TableLayout>
|
Loading…
Reference in a new issue