示例#1
0
        public override async void OnAppearing()
        {
            base.OnAppearing();

            PredAvatarGridBuilt = true;

            ErrorMessageColor = "Black";
            ErrorMessage      = $"{Strings.ProfilePictureScreenViewModel_NoError}";

            ChosenAvatarBytes = null;
            ChosenAvatarId    = null;

            AvatarPreview = ImageSource.FromFile("predefined_avatar_empty");



            if (Settings.ProfilePicture == null)
            {
                var currentAvatar = await manager.GetProfilePicture(Settings.UserId, Settings.AccessToken);

                if (currentAvatar != null)
                {
                    Settings.ProfilePicture = Convert.ToBase64String(currentAvatar.Data);
                    Avatar = ImageSource.FromStream(() => new MemoryStream(currentAvatar.Data));
                }
            }
            else
            {
                var currentAvatarBytes = Convert.FromBase64String(Settings.ProfilePicture);
                Avatar = ImageSource.FromStream(() => new MemoryStream(currentAvatarBytes));
            }

            OnPropertyChanged();

            PredAvatarList();
        }
示例#2
0
        public override async void OnAppearing()
        {
            if (Settings.ProfilePicture == null)
            {
                var currentAvatar = await manager.GetProfilePicture(Settings.UserId, Settings.AccessToken);

                if (currentAvatar != null)
                {
                    Settings.ProfilePicture = Convert.ToBase64String(currentAvatar.Data);
                    Avatar = ImageSource.FromStream(() => new MemoryStream(currentAvatar.Data));
                    return;
                }
            }
            else
            {
                var currentAvatarBytes = Convert.FromBase64String(Settings.ProfilePicture);
                Avatar = ImageSource.FromStream(() => new MemoryStream(currentAvatarBytes));
                return;
            }

            Avatar = Settings.AdventurerMode ? ImageSource.FromFile(AdventurerImage) : ImageSource.FromFile(ProfessorImage);
        }