public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.StudySessionScreen, container, false);
            view.FindViewById<EditText>(Resource.Id.date).Click += (object sender, EventArgs e) =>
            {
                var dialog = new DatePickerFrag(Activity,DateTime.Now,this);
                dialog.Show(FragmentManager,null);
            };
            view.FindViewById<EditText>(Resource.Id.time).Click += (object sender, EventArgs e) =>
            {
                var dialog = new timePicker(Activity,this,DateTime.Now.Hour,DateTime.Now.Minute,false);
                dialog.Show(FragmentManager,null);
            };

            Button CreateButton = view.FindViewById<Button>(Resource.Id.createSessionButton);
            Button DeleteButton = view.FindViewById<Button> (Resource.Id.delete);
            Button EditButton = view.FindViewById<Button> (Resource.Id.Edit);

             course = view.FindViewById<TextView> (Resource.Id.courseStudy);
             topic = view.FindViewById<TextView> (Resource.Id.SessionTopic);
             date = view.FindViewById<TextView> (Resource.Id.date);
             time = view.FindViewById<TextView> (Resource.Id.time);
             member1 = view.FindViewById<TextView> (Resource.Id.Member1);
             member2 = view.FindViewById<TextView> (Resource.Id.Member2);
             member3 = view.FindViewById<TextView> (Resource.Id.Member3);
             member4 = view.FindViewById<TextView> (Resource.Id.Member4);
             member5 = view.FindViewById<TextView> (Resource.Id.Member5);
            if (!create) {
                course.Text = sg.course;
                date.Text = sg.date;
                time.Text = sg.time;
                topic.Text = sg.topic;
                member1.Text = sg.members [0];
                member2.Text = sg.members [1];
                member3.Text = sg.members [2];
                member4.Text = sg.members [3];
                //member5.Text = sg.members [4];
                CreateButton.Visibility = ViewStates.Invisible;
            } else {
                DeleteButton.Visibility = ViewStates.Invisible;
                EditButton.Visibility = ViewStates.Invisible;
            }

            course.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                sg.course = e.Text.ToString();
            };
            topic.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                sg.topic = e.Text.ToString();
            };
            date.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                sg.date = e.Text.ToString();
            };
            time.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                sg.time = e.Text.ToString();
            };
            member1.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                sg.members[0] = e.Text.ToString();

            };
            member2.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                sg.members[1] = e.Text.ToString();

            };
            member3.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                sg.members[2] = e.Text.ToString();

            };
            member4.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                sg.members[3] = e.Text.ToString();

            };
            member5.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                sg.members[4] = e.Text.ToString();

            };
            CreateButton.Click += async (sender, e) => {

                StudyUtility createStudySession = new StudyUtility();

                Task<StudyResponse> stuff = createStudySession.StudyAsync(LoginInfo.username, LoginInfo.KEY, sg.course, sg.topic, sg.date, sg.time, sg.members);
                StudyResponse result = await stuff;
                var ft = FragmentManager.BeginTransaction ();
                ft.Replace (Resource.Id.FragmentLayout, new StudyCardFrag ());
                ft.AddToBackStack (null);
                ft.Commit ();
                Toast.MakeText (Activity,"Study Group Created", ToastLength.Short).Show ();
            };

            DeleteButton.Click += async (sender, e) => {
                DeleteUtility deleteStudySession = new DeleteUtility();
                Task<DeleteResponse> dResponse = deleteStudySession.DeleteAsync(LoginInfo.username, LoginInfo.KEY, sg._id);
                DeleteResponse deleteResult = await dResponse;
                var ft = FragmentManager.BeginTransaction ();
                ft.Replace (Resource.Id.FragmentLayout, new StudyCardFrag ());
                ft.AddToBackStack (null);
                ft.Commit ();
                Toast.MakeText (Activity,"Study Group Deleted", ToastLength.Short).Show ();
            };

            EditButton.Click += async (sender, e) => {
                EditStudyUtility editStudySession = new EditStudyUtility();
                Task<StudyResponse> eResponse = editStudySession.EditStudyAsync(LoginInfo.username, LoginInfo.KEY,sg._id, sg.course, sg.topic, sg.date, sg.time, sg.members);
                StudyResponse result = await eResponse;
                var ft = FragmentManager.BeginTransaction ();
                ft.Replace (Resource.Id.FragmentLayout, new StudyCardFrag ());
                ft.AddToBackStack (null);
                ft.Commit ();
                Toast.MakeText (Activity,"Study Group Edited", ToastLength.Short).Show ();
            };
            return view;
        }
Esempio n. 2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.StudySessionScreen, container, false);

            view.FindViewById <EditText>(Resource.Id.date).Click += (object sender, EventArgs e) =>
            {
                var dialog = new DatePickerFrag(Activity, DateTime.Now, this);
                dialog.Show(FragmentManager, null);
            };
            view.FindViewById <EditText>(Resource.Id.time).Click += (object sender, EventArgs e) =>
            {
                var dialog = new timePicker(Activity, this, DateTime.Now.Hour, DateTime.Now.Minute, false);
                dialog.Show(FragmentManager, null);
            };

            Button CreateButton = view.FindViewById <Button>(Resource.Id.createSessionButton);
            Button DeleteButton = view.FindViewById <Button> (Resource.Id.delete);
            Button EditButton   = view.FindViewById <Button> (Resource.Id.Edit);

            course  = view.FindViewById <TextView> (Resource.Id.courseStudy);
            topic   = view.FindViewById <TextView> (Resource.Id.SessionTopic);
            date    = view.FindViewById <TextView> (Resource.Id.date);
            time    = view.FindViewById <TextView> (Resource.Id.time);
            member1 = view.FindViewById <TextView> (Resource.Id.Member1);
            member2 = view.FindViewById <TextView> (Resource.Id.Member2);
            member3 = view.FindViewById <TextView> (Resource.Id.Member3);
            member4 = view.FindViewById <TextView> (Resource.Id.Member4);
            member5 = view.FindViewById <TextView> (Resource.Id.Member5);
            if (!create)
            {
                course.Text  = sg.course;
                date.Text    = sg.date;
                time.Text    = sg.time;
                topic.Text   = sg.topic;
                member1.Text = sg.members [0];
                member2.Text = sg.members [1];
                member3.Text = sg.members [2];
                member4.Text = sg.members [3];
                //member5.Text = sg.members [4];
                CreateButton.Visibility = ViewStates.Invisible;
            }
            else
            {
                DeleteButton.Visibility = ViewStates.Invisible;
                EditButton.Visibility   = ViewStates.Invisible;
            }

            course.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                sg.course = e.Text.ToString();
            };
            topic.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                sg.topic = e.Text.ToString();
            };
            date.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                sg.date = e.Text.ToString();
            };
            time.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                sg.time = e.Text.ToString();
            };
            member1.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                sg.members[0] = e.Text.ToString();
            };
            member2.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                sg.members[1] = e.Text.ToString();
            };
            member3.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                sg.members[2] = e.Text.ToString();
            };
            member4.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                sg.members[3] = e.Text.ToString();
            };
            member5.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                sg.members[4] = e.Text.ToString();
            };
            CreateButton.Click += async(sender, e) => {
                StudyUtility createStudySession = new StudyUtility();

                Task <StudyResponse> stuff  = createStudySession.StudyAsync(LoginInfo.username, LoginInfo.KEY, sg.course, sg.topic, sg.date, sg.time, sg.members);
                StudyResponse        result = await stuff;
                var ft = FragmentManager.BeginTransaction();
                ft.Replace(Resource.Id.FragmentLayout, new StudyCardFrag());
                ft.AddToBackStack(null);
                ft.Commit();
                Toast.MakeText(Activity, "Study Group Created", ToastLength.Short).Show();
            };

            DeleteButton.Click += async(sender, e) => {
                DeleteUtility         deleteStudySession = new DeleteUtility();
                Task <DeleteResponse> dResponse          = deleteStudySession.DeleteAsync(LoginInfo.username, LoginInfo.KEY, sg._id);
                DeleteResponse        deleteResult       = await dResponse;
                var ft = FragmentManager.BeginTransaction();
                ft.Replace(Resource.Id.FragmentLayout, new StudyCardFrag());
                ft.AddToBackStack(null);
                ft.Commit();
                Toast.MakeText(Activity, "Study Group Deleted", ToastLength.Short).Show();
            };

            EditButton.Click += async(sender, e) => {
                EditStudyUtility     editStudySession = new EditStudyUtility();
                Task <StudyResponse> eResponse        = editStudySession.EditStudyAsync(LoginInfo.username, LoginInfo.KEY, sg._id, sg.course, sg.topic, sg.date, sg.time, sg.members);
                StudyResponse        result           = await eResponse;
                var ft = FragmentManager.BeginTransaction();
                ft.Replace(Resource.Id.FragmentLayout, new StudyCardFrag());
                ft.AddToBackStack(null);
                ft.Commit();
                Toast.MakeText(Activity, "Study Group Edited", ToastLength.Short).Show();
            };
            return(view);
        }