Exemplo n.º 1
0
        public async Task getDataFromServer()
        {
            IList <Lesson> lessons = null;

            try {
                lessons = await LessonUtil.GetLessonsByModuleAsync(module_id);
            } catch (Exception ex) {
                DialogFactory.ToastDialog(this, "Data Error", "Error Connecting to Server,please try again later!", Constants.LESSON_ERROR);
            }
            if (lessons != null)
            {
                sourceDateList = new List <SortModel> ();
                foreach (var lesson in lessons)
                {
                    string name = lesson.Title;
                    if (name.Length > 0)
                    {
                        string    firstAlpha = name.Substring(0, 1).ToUpper();
                        SortModel temp       = new SortModel();
                        temp.SortLetters = firstAlpha;
                        temp.Name        = name;
                        temp.LessonId    = lesson.Id;
                        temp.ScreenCount = lesson.ScreenCount;
                        sourceDateList.Add(temp);
                    }
                    else
                    {
                        continue;
                    }
                }
                sourceDateList.Sort();
            }
        }
Exemplo n.º 2
0
        public async override void RowSelected(UITableView tableView, Foundation.NSIndexPath indexPath)
        {
            // Loading indicator
            var loadingOverlay = new LoadingOverlay(Container.View.Bounds);

            Container.View.Add(loadingOverlay);

            IList <Lesson> lessons = null;

            try
            {
                lessons = await LessonUtil.GetLessonsByModuleAsync(Items[indexPath.Row].Id);
            }
            catch (Exception e)
            {
                var alert = UIAlertController.Create("Something goes wrong", e.Message, UIAlertControllerStyle.Alert);
                alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                Container.PresentViewController(alert, true, null);
            }
            loadingOverlay.HideThenRemove();

            if ((lessons != null) && (lessons.Count > 0))
            {
                Container.NavigationController.PushViewController(new LessonsViewController(lessons, Items[indexPath.Row].Name), true);
            }
            else
            {
                var alert = UIAlertController.Create("Oops!", "There is nothing in this module", UIAlertControllerStyle.Alert);
                alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                Container.PresentViewController(alert, true, null);
            }

            tableView.DeselectRow(indexPath, true);
        }
Exemplo n.º 3
0
        public async void getLessonsFromServer()
        {
            try {
                var lessons = await LessonUtil.GetLessonsByModuleAsync(module_id);

                lessonList = new List <Lesson> (lessons);
            } catch (Exception ex) {
                DialogFactory.ToastDialog(this, "Server busy", "Server is busy,please drag down to refresh later", 0);
                tv_pull_list_header_title.Text = "Server busy!";
                tv_pull_list_header_title.SetTextColor(Color.Red);
            }
            if (lessonList != null)
            {
                lv_list.onRefreshComplete();
                lv_list.Adapter = new MyListViewAdapter(this, lessonList);
                lv_list.setOnRefreshListener(new MyRefreshListener(this));
                lv_list.Visibility = ViewStates.Visible;
                ll_load.Visibility = ViewStates.Invisible;
            }
        }