Exemplo n.º 1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            if (myView == null)
            {
                myView = inflater.Inflate(Resource.Layout.SelectFriendSourceLayout, container, false);
                var rootView   = myView.FindViewById <LinearLayout> (Resource.Id.linearLayout1);
                var friendList = Utility.CreateListView("Select Friend", rootView, Resources, inflater);

                ((POPpicApplication)this.Activity.Application).GetGameRepository(this.Activity).ContinueWith(r => {
                    this.viewModel = new SelectFriendViewModel(r.Result);
                    viewModel.InitializeAsync().ContinueWith(t => {
                        if (!t.IsFaulted && t.Result)
                        {
                            this.Activity.RunOnUiThread(() => {
                                listAdapter = new AndroidFriendListAdapter(this.Activity, viewModel);
                                listAdapter.FriendSelected += (object sender, FriendViewModel e) => {
                                    if (this.FriendSelected != null)
                                    {
                                        this.FriendSelected(sender, e);
                                    }
                                };
                                friendList.Adapter = listAdapter;
                            });
                        }
                    });
                });
            }

            return(myView);
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.SelectFriendLayout);

            this.ActionBar.NavigationMode = ActionBarNavigationMode.Standard;
            this.ActionBar.Title          = "Select Opponent";
            this.ActionBar.SetDisplayHomeAsUpEnabled(true);

            var listView = FindViewById <ListView> (Resource.Id.listView1);

            AndHUD.Shared.Show(this, "Loading Friends", -1, MaskType.Black, null);

            ((POPpicApplication)Application).GetGameRepository(this).ContinueWith(r => {
                this.viewModel = new SelectFriendViewModel(r.Result);
                viewModel.InitializeAsync().ContinueWith(t => {
                    if (!t.IsFaulted && t.Result)
                    {
                        var listAdapter             = new AndroidFriendListAdapter(this, viewModel);
                        listAdapter.FriendSelected += OnFriendSelected;
                        listView.Adapter            = listAdapter;
                    }

                    AndHUD.Shared.Dismiss();
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }