2017-02-18 15:17:39 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
using Android.App;
|
|
|
|
|
using Android.Content;
|
|
|
|
|
using Android.OS;
|
|
|
|
|
using Android.Runtime;
|
|
|
|
|
using Android.Views;
|
|
|
|
|
using Android.Widget;
|
2017-02-19 02:04:31 +00:00
|
|
|
|
using Orarend;
|
2017-02-20 00:14:57 +00:00
|
|
|
|
using Android.Graphics;
|
2017-02-18 15:17:39 +00:00
|
|
|
|
|
|
|
|
|
namespace OrarendAndroidApp
|
|
|
|
|
{
|
|
|
|
|
[Activity(Label = "AddActivity", Theme = "@android:style/Theme.Holo.Light")]
|
|
|
|
|
public class EditActivity : Activity
|
|
|
|
|
{
|
2017-02-19 02:04:31 +00:00
|
|
|
|
private bool add;
|
|
|
|
|
private int index;
|
2017-02-18 15:17:39 +00:00
|
|
|
|
protected override void OnCreate(Bundle savedInstanceState)
|
|
|
|
|
{
|
|
|
|
|
base.OnCreate(savedInstanceState);
|
2017-02-19 02:04:31 +00:00
|
|
|
|
SetContentView(Resource.Layout.EditLayout);
|
|
|
|
|
Title = (add = Intent.Extras.GetBoolean("add")) ? "Hozz<7A>ad<61>s" : "Szerkeszt<7A>s";
|
|
|
|
|
index = Intent.Extras.GetInt("index");
|
|
|
|
|
var oszt<EFBFBD>lySpinner = FindViewById<Spinner>(Resource.Id.oszt<EFBFBD>lySpinner);
|
2017-02-20 22:45:44 +00:00
|
|
|
|
if (API.Oszt<EFBFBD>lyok == null)
|
|
|
|
|
{
|
|
|
|
|
MainActivity.Hiba(this, "Az oszt<7A>lylista <20>res! V<>laszd a Teljes friss<73>t<EFBFBD>st a men<65>b<EFBFBD>l.");
|
|
|
|
|
Finish();
|
|
|
|
|
}
|
2017-02-19 02:04:31 +00:00
|
|
|
|
oszt<EFBFBD>lySpinner.Adapter = new ArrayAdapter(this, Resource.Layout.simple_list_item_1, API.Oszt<EFBFBD>lyok);
|
|
|
|
|
if (!add)
|
|
|
|
|
{
|
|
|
|
|
var <EFBFBD>rarend = API.<EFBFBD>rarendek[index];
|
|
|
|
|
FindViewById<EditText>(Resource.Id.n<EFBFBD>vEditText).Text = <EFBFBD>rarend.N<EFBFBD>v;
|
|
|
|
|
int ix = Array.IndexOf(API.Oszt<EFBFBD>lyok, <EFBFBD>rarend.Oszt<EFBFBD>ly);
|
|
|
|
|
/*for (int i = 0; i < API.Oszt<EFBFBD>lyok.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
var o = API.Oszt<EFBFBD>lyok[i];
|
|
|
|
|
}*/
|
|
|
|
|
oszt<EFBFBD>lySpinner.SetSelection(ix);
|
|
|
|
|
FindViewById<EditText>(Resource.Id.csoportokEditText).Text = <EFBFBD>rarend.Csoportok.Aggregate((a, b) => a + " " + b);
|
|
|
|
|
}
|
|
|
|
|
FindViewById<Button>(Resource.Id.saveButton).Click += SaveButtonClick;
|
2017-02-20 00:14:57 +00:00
|
|
|
|
var deleteButton = FindViewById<Button>(Resource.Id.deleteButton);
|
|
|
|
|
if (add)
|
|
|
|
|
deleteButton.Visibility = ViewStates.Gone;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
deleteButton.SetBackgroundColor(Color.DarkRed);
|
|
|
|
|
deleteButton.Click += DeleteButtonClick;
|
|
|
|
|
Intent.Extras.PutBoolean("deleted", false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DeleteButtonClick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
new AlertDialog.Builder(this).SetTitle("T<>rl<72>s").SetMessage("Biztosan t<>rl<72>d ezt az <20>rarendet?")
|
|
|
|
|
.SetPositiveButton("Igen", (s, ea) =>
|
|
|
|
|
{ //T<>rl<72>s
|
|
|
|
|
API.<EFBFBD>rarendek.RemoveAt(index);
|
|
|
|
|
var intent = new Intent(Intent);
|
|
|
|
|
intent.PutExtra("deleted", true);
|
|
|
|
|
((AlertDialog)s).Dismiss();
|
|
|
|
|
((AlertDialog)s).Dispose();
|
|
|
|
|
API.<EFBFBD>rarendMent<EFBFBD>s(OpenFileOutput("orarend", FileCreationMode.Private));
|
|
|
|
|
SetResult(Result.Ok, intent);
|
|
|
|
|
Finish();
|
|
|
|
|
}).SetNegativeButton("Nem", (s, ea) =>
|
|
|
|
|
{
|
|
|
|
|
((AlertDialog)s).Dismiss();
|
|
|
|
|
((AlertDialog)s).Dispose();
|
|
|
|
|
}).Show();
|
2017-02-19 02:04:31 +00:00
|
|
|
|
}
|
2017-02-18 15:17:39 +00:00
|
|
|
|
|
2017-02-19 02:04:31 +00:00
|
|
|
|
private void SaveButtonClick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var n<EFBFBD>v = FindViewById<EditText>(Resource.Id.n<EFBFBD>vEditText).Text;
|
|
|
|
|
var oszt<EFBFBD>ly = API.Oszt<EFBFBD>lyok[FindViewById<Spinner>(Resource.Id.oszt<EFBFBD>lySpinner).SelectedItemPosition];
|
|
|
|
|
var csoportok = FindViewById<EditText>(Resource.Id.csoportokEditText).Text;
|
|
|
|
|
if (!add)
|
|
|
|
|
{
|
|
|
|
|
var <EFBFBD>rarend = API.<EFBFBD>rarendek[index];
|
|
|
|
|
<EFBFBD>rarend.N<EFBFBD>v = n<EFBFBD>v;
|
|
|
|
|
<EFBFBD>rarend.Oszt<EFBFBD>ly = oszt<EFBFBD>ly;
|
|
|
|
|
<EFBFBD>rarend.Csoportok = csoportok.Split(' ');
|
|
|
|
|
}
|
|
|
|
|
else
|
2017-02-20 00:14:57 +00:00
|
|
|
|
API.<EFBFBD>rarendek.Add(new <EFBFBD>rarend(n<EFBFBD>v, oszt<EFBFBD>ly, csoportok));
|
|
|
|
|
API.<EFBFBD>rarendMent<EFBFBD>s(OpenFileOutput("orarend", FileCreationMode.Private));
|
|
|
|
|
SetResult(Result.Ok, Intent);
|
2017-02-19 02:04:31 +00:00
|
|
|
|
Finish();
|
2017-02-18 15:17:39 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|