protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Subject_list_activity);

            ListView listView = FindViewById <ListView>(Resource.Id.listView1);
            TextView textView = FindViewById <TextView>(Resource.Id.textView1);

            //GetStringFromServer



            string json = await LocalConnection.getJsonLine("/subject/");

            //Deserialize
            var list1 = Subjects.GetSubjects(json);

            StaticStore.subjects.subjects = list1;


            if (json == null || json == "" || list1 == null || list1.Count == 0)
            {
                var a = Toast.MakeText(this, "Connection Faild", ToastLength.Short);
                a.Show();
                Intent intent = new Intent(this, typeof(MainActivity));
                StartActivity(intent);
                Finish();
            }


            List <string> list = new List <string>();

            for (int i = 0; i < list1.Count; i++)
            {
                list.Add(list1[i].name);
            }

            ArrayAdapter <string> adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, list);


            if (list.Count != 0)
            {
                listView.Adapter = adapter;
            }
            else
            {
                Intent intent = new Intent(this, typeof(MainActivity));
                StartActivity(intent);
            }

            listView.ItemClick += delegate(object sender, AdapterView.ItemClickEventArgs e)
            {
                StaticStore.isFilted = false;
                Intent intent = new Intent(this, typeof(TaskListActivity));
                intent.PutExtra("Subject", e.Position);
                StartActivity(intent);
                //Finish();
            };
        }
Ejemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Login);

            Button btn = FindViewById <Button>(Resource.Id.button1);


            btn.Click += async delegate
            {
                TextView loginView    = FindViewById <TextView>(Resource.Id.editText1);
                TextView passwordView = FindViewById <TextView>(Resource.Id.editText2);


                if (await LocalConnection.Test())//LocalConnection.Connect(loginView.Text, passwordView.Text))
                {
                    Intent intent = new Intent(this, typeof(SubjectListActivity));
                    StartActivity(intent);
                    Finish();
                }
            };
        }
Ejemplo n.º 3
0
        /*
         * protected async override void OnResume()
         * {
         *  base.OnResume();
         *
         *  Intent intent = new Intent(this, typeof(TaskListActivity));
         *  StartActivity(intent);
         *  Finish();
         * }
         */

        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Task_List_Activity);

            ListView listView = FindViewById <ListView>(Resource.Id.listView1);
            Button   filter   = FindViewById <Button>(Resource.Id.button1);



            int pos = Intent.GetIntExtra("Subject", 42);


            List <Theme> list  = new List <Theme>();
            List <Task>  tasks = new List <Task>();

            if (!StaticStore.isFilted)
            {
                Theme tem; string jsonstr;
                foreach (int a in StaticStore.subjects.subjects[pos].themes)
                {
                    try
                    {
                        jsonstr = await LocalConnection.getJsonLine("/theme/" + a);

                        tem = FutureOfEducation2.Theme.GetTheme(jsonstr);
                        list.Add(tem);
                    }
                    catch
                    {
                        jsonstr = await LocalConnection.getJsonLine("/theme/" + a);

                        tem = FutureOfEducation2.Theme.GetTheme(jsonstr);
                        list.Add(tem);
                    }

                    foreach (var ex in tem.tasks)
                    {
                        try
                        {
                            jsonstr = await LocalConnection.getJsonLine("/task/" + ex);

                            tasks.Add(Task.GetTheme(jsonstr));
                        }
                        catch
                        {
                            jsonstr = await LocalConnection.getJsonLine("/task/" + ex);

                            tasks.Add(Task.GetTheme(jsonstr));
                        }
                    }
                }

                StaticStore.themes = list;
                StaticStore.tasks  = tasks;

                if (tasks == null || tasks.Count == 0)
                {
                    Toast.MakeText(this, "All tasks are done or error", ToastLength.Short).Show();
                    Finish();
                }
            }
            else
            {
                list  = StaticStore.themes;
                tasks = StaticStore.tasks;
            }



            List <string> array = new List <string>();

            StaticStore.Filtertasks = new List <Task>();

            if (StaticStore.isFilted)
            {
                foreach (var item in StaticStore.tasks)
                {
                    bool flag = false;
                    foreach (var theme in item.themes)
                    {
                        for (int i = 0; i < StaticStore.themes.Count; i++)
                        {
                            if (theme == StaticStore.themes[i].id)
                            {
                                flag = flag || StaticStore.goodThemes[i];
                                break;
                            }
                        }
                    }
                    if (flag && Math.Abs(item.difficulty - StaticStore.difficulty) <= 1)
                    {
                        array.Add(item.name);
                        StaticStore.Filtertasks.Add(item);
                    }
                }
            }
            else
            {
                for (int i = 0; i < tasks.Count; i++)
                {
                    if (tasks[i].name != null)
                    {
                        array.Add(tasks[i].name);
                    }
                    else
                    {
                        array.Add("No name task №" + tasks[i].id);
                    }
                }
                StaticStore.Filtertasks = StaticStore.tasks;
            }


            listView.Adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, array);

            listView.ItemClick += delegate(object sender, AdapterView.ItemClickEventArgs e)
            {
                Intent intent = new Intent(this, typeof(TaskActivity));
                intent.PutExtra("Task", e.Position);
                StartActivity(intent);

                //Finish();
            };

            filter.Click += delegate
            {
                Intent intent = new Intent(this, typeof(FilterActivity));
                StartActivity(intent);
            };

            StaticStore.goodThemes = new bool[StaticStore.themes.Count];
            Array.Fill(StaticStore.goodThemes, true);
        }