protected void ReloadList(string gameGuidToStart = "") { ((POPpicApplication)Application).GetGameRepository(this).ContinueWith(r => { this.viewModel = new MyGamesViewModel(r.Result); viewModel.InitializeAsync().ContinueWith(t => { RunOnUiThread(() => { if (!t.IsFaulted && t.Result) { this.myTurnAdapter = new AndroidGameListAdapter(this, this.viewModel, MyGamesViewModel.ListType.MY_TURN); this.theirTurnAdapter = new AndroidGameListAdapter(this, this.viewModel, MyGamesViewModel.ListType.THEIR_TURN); this.completedAdapter = new AndroidGameListAdapter(this, this.viewModel, MyGamesViewModel.ListType.COMPLETED); this.myTurnFragment.ListAdapter = this.myTurnAdapter; this.theirTurnFragment.ListAdapter = this.theirTurnAdapter; this.completedFragment.ListAdapter = this.completedAdapter; this.myTurnAdapter.GameSelected += this.OnGameSelected; this.theirTurnAdapter.GameSelected += this.OnGameSelected; this.completedAdapter.GameSelected += this.OnGameSelected; } else { // TODO Show error } SetProgressBarVisibility(false); }); }); }); }
protected void ReloadList(string gameGuidToStart = "") { loadingRelativeLayout.Visibility = ViewStates.Visible; var rootView = FindViewById <LinearLayout> (Resource.Id.rootLinearLayout); rootView.Visibility = ViewStates.Invisible; if (myMoveList == null) { // we need to create the lists myMoveList = Utility.CreateListView("My Turn", rootView, Resources, LayoutInflater); theirMoveList = Utility.CreateListView("Their Turn", rootView, Resources, LayoutInflater); completedList = Utility.CreateListView("Completed", rootView, Resources, LayoutInflater); } RunOnUiThread(() => { // AndHUD.Shared.Show (this, "Loading Your Games", -1, MaskType.Black, null); ((POPpicApplication)Application).GetGameRepository(this).ContinueWith(r => { this.viewModel = new MyGamesViewModel(r.Result); viewModel.InitializeAsync().ContinueWith(t => { if (!t.IsFaulted && t.Result) { myGamesAdapter = new AndroidGameListAdapter(this, this.viewModel, MyGamesViewModel.ListType.MY_TURN); //, this); theirGamesAdapter = new AndroidGameListAdapter(this, this.viewModel, MyGamesViewModel.ListType.THEIR_TURN); //, this); completedAdapter = new AndroidGameListAdapter(this, this.viewModel, MyGamesViewModel.ListType.COMPLETED); //, this); myGamesAdapter.GameSelected += OnGameSelected; theirGamesAdapter.GameSelected += OnGameSelected; theirGamesAdapter.SeeAllClicked += OnSeeAllSelected; completedAdapter.GameSelected += OnGameSelected; completedAdapter.SeeAllClicked += OnSeeAllSelected; myGamesAdapter.CreateNewGameSelected += (object sender, bool e) => { StartCreateGameActivity(); }; myMoveList.Adapter = myGamesAdapter; theirMoveList.Adapter = theirGamesAdapter; completedList.Adapter = completedAdapter; Utility.SetListViewHeightBasedOnChildren2(myMoveList); Utility.SetListViewHeightBasedOnChildren2(theirMoveList); Utility.SetListViewHeightBasedOnChildren2(completedList); } else { AndroidUtilities.ShowAlert(this, "Loading Games Failed", "Sorry, loading your games failed. Please try again later."); } if (!string.IsNullOrEmpty(gameGuidToStart)) { var gameToStart = this.viewModel.GetGameById(gameGuidToStart); if (gameToStart != null) { OnGameSelected(this, gameToStart); } } loadingRelativeLayout.Visibility = ViewStates.Gone; rootView.Visibility = ViewStates.Visible; }, TaskScheduler.FromCurrentSynchronizationContext()); }, TaskScheduler.FromCurrentSynchronizationContext()); }); }