public async override void ViewDidLoad()
        {
            base.ViewDidLoad();
            users = new List <iOSUser>();

            //Get all the users (for better performance, convert to paginated lists)
            var userList = await UserCall.getUsers();

            if (userList == null)
            {
                var alertController = UIAlertController.Create("Warning", "Could not connect to server, please try again.", UIAlertControllerStyle.Alert);
                alertController.AddAction(UIAlertAction.Create("Try Again", UIAlertActionStyle.Default, alert => ViewDidLoad()));
                alertController.AddAction(UIAlertAction.Create("No thanks", UIAlertActionStyle.Default, alert => System.Diagnostics.Debug.Write("No thanks was selected")));
                this.PresentViewController(alertController, true, null);
            }
            else
            {
                // Get the image and reload the list when done
                foreach (var user in userList)
                {
                    UIImage image = await IOSImageUtil.FromUrl(user.imageUrl);

                    var iosUser = new iOSUser(image, user);
                    users.Add(iosUser);
                    System.Diagnostics.Debug.WriteLine("NR OF USERS IN LIST: " + users.Count);
                    playersTableView.Source = new SelectPlayerDatasource(users, this);
                    playersTableView.ReloadData();
                }
            }
        }
Esempio n. 2
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            SelectPlayerCell cell = tableView.DequeueReusableCell(cellIdentifier) as SelectPlayerCell;
            iOSUser          user = users[indexPath.Row];

            if (cell == null)
            {
                cell = new SelectPlayerCell();
            }

            UIImage image;

            if (userDict.ContainsKey(user))
            {
                image = userDict[user];
            }
            else
            {
                image = user.image;
                userDict.Add(user, image);
            }

            cell.ImgProfile.Image = image;
            IOSImageUtil.makeRoundImageView(cell.ImgProfile);
            cell.LblPlayerUsername.Text = user.username;
            cell.LblPlayerRank.Text     = "Wins: " + user.wins + "  Losses " + user.losses;

            return(cell);
        }
Esempio n. 3
0
        public User toUser(iOSUser iOSUser)
        {
            User user = new User();

            user.id       = iOSUser.id;
            user.username = iOSUser.username;
            user.imageUrl = iOSUser.imageUrl;
            user.wins     = iOSUser.wins;
            user.losses   = iOSUser.losses;
            return(user);
        }
 public void didSelectPlayer(iOSUser user, UIImage image)
 {
     user.image = null;
     parent.didSelectPlayer(thisPlayer, user, image);
     this.DismissViewController(true, null);
 }
Esempio n. 5
0
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            iOSUser selectedUser = users[indexPath.Row];

            owner.didSelectPlayer(selectedUser, userDict[selectedUser]);
        }