Ejemplo n.º 1
0
        protected override void OnAppearing()
        {
            base.OnAppearing();

            ctsMain = new CancellationTokenSource();

            viewModel = new ProfileViewModel();
            viewModel.IsDataLoaded = false;
            BindingContext         = viewModel;

            profileApi.Get(profileId).Subscribe(SetModel, ctsMain.Token);
        }
Ejemplo n.º 2
0
        protected override void OnAppearing()
        {
            base.OnAppearing();
            cts = new CancellationTokenSource();

            foreach (string profileId in bookmarkController.ProfileIds)
            {
                BookmarkViewModel viewModel = null;

                if (!_bookmarks.TryGetValue(profileId, out viewModel))
                {
                    viewModel       = new BookmarkViewModel(profileId);
                    viewModel.Label = profileId;
                    _bookmarks.Add(profileId, viewModel);
                    Bookmarks.Add(viewModel);
                }

                profileApi.Get(profileId).Subscribe(model =>
                {
                    viewModel.Label = model.Name;

                    void setImage(ImageModel image)
                    {
                        viewModel.Image = ImageSource.FromStream(() => new MemoryStream(image.Bytes));
                    };
                    imageApi.Get(model.ImageId).Subscribe(setImage, cts.Token);
                }, cts.Token);
            }
        }