public async override void ViewDidLoad() { base.ViewDidLoad(); View.BackgroundColor = UIColor.White; var modulesTable = new UITableView(); View.AddSubview(modulesTable); View.ConstrainLayout(() => modulesTable.Frame.Top == View.Frame.Top && modulesTable.Frame.Left == View.Frame.Left && modulesTable.Frame.Right == View.Frame.Right && modulesTable.Frame.Bottom == View.Frame.Bottom ); // Loading indicator var loadingOverlay = new LoadingOverlay(View.Bounds); View.AddSubview(loadingOverlay); try { Modules = await LessonUtil.GetModulesAsync(); } catch (Exception e) { var alert = UIAlertController.Create("Something goes wrong", e.Message, UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); PresentViewController(alert, true, null); } if (Modules != null) { modulesTable.Source = new ModulesTableSource(this, Modules); modulesTable.ReloadData(); } loadingOverlay.HideThenRemove(); }
public async void getModulesFromServer() { try { var modules = await LessonUtil.GetModulesAsync(); Constants.currentUser = await UserUtil.GetCurrentUserAsync(); moduleList = new List <Module> (modules); } catch (Exception ex) { DialogFactory.ToastDialog(activity, "Server busy", "Server is busy,please login later", Constants.LOGIN_TIMEOUT); } if (Constants.currentUser == null) { //illegal login DialogFactory.ToastDialog(activity, "Login timeout", "Timeout,please login again", Constants.LOGIN_TIMEOUT); } else { lv_list.Adapter = new MyModuleListAdapter(moduleList, this.activity); lv_list.Visibility = ViewStates.Visible; ll_load.Visibility = ViewStates.Invisible; } }