Ejemplo n.º 1
0
        public Design()
        {
            var newsService = new DesignNewsService();
            var item = newsService.GetFeedsAsync( null, CancellationToken.None ).Result.Feeds[0].Items[0];

            FeedItem = new FeedItemViewModel( new DesignDataCache(), new DesignNewsService(), new DesignBrowserService(), item );
            Main = new MainViewModel( new DesignDataCache(), new DesignNewsService(), new DesignNavigationService() );

            FeedItem.OnNavigatedToAsync();
            Main.OnNavigatedToAsync();
        }
        private async Task <FeedItemViewModel> GetFeedItemViewModel(FeedItem feedItem)
        {
            var returnModel = new FeedItemViewModel();

            var feedItemTags = await GetTags(feedItem.EntityId);

            var comments = await GetComments(feedItem.EntityId);

            returnModel.Tags            = feedItemTags;
            returnModel.Comments        = comments;
            returnModel.NormalizedTitle = feedItem.NormalizedTitle;
            returnModel.Content         = feedItem.Content;
            returnModel.CommentsEnabled = feedItem.CommentsEnabled;
            returnModel.Id          = feedItem.EntityId;
            returnModel.Title       = feedItem.Title;
            returnModel.Description = feedItem.Description;
            returnModel.FeedId      = feedItem.FeedId;
            returnModel.Date        = feedItem.Date;
            returnModel.Modified    = feedItem.Modified;

            return(returnModel);
        }
Ejemplo n.º 3
0
        private void HandlePopupMenu(View view, FeedItemViewModel viewModel)
        {
            var menuBuilder = new MenuBuilder(Activity);

            menuBuilder.Add(0, 0, 0, AppResources.Item_Feed_AddIgnore).SetIcon(Resource.Drawable.icon_stop);

            if (!viewModel.IsWatched)
            {
                menuBuilder.Add(0, 1, 0, AppResources.Item_Feed_AddWatched).SetIcon(Resource.Drawable.icon_eye);
            }
            else
            {
                menuBuilder.Add(0, 2, 0, AppResources.Item_Feed_RemoveWatched).SetIcon(Resource.Drawable.icon_eye_off);
            }

            menuBuilder.SetCallback(new MenuCallback((sender, menuItem) =>
            {
                if (menuItem.ItemId == 0)
                {
                    viewModel.IgnoreItemCommand.Execute(null);
                }
                else if (menuItem.ItemId == 1)
                {
                    viewModel.WatchItemCommand.Execute(null);
                }
                else if (menuItem.ItemId == 2)
                {
                    viewModel.UnwatchItemCommand.Execute(null);
                }
            }));
            var menuPopupHelper = new MenuPopupHelper(Context, menuBuilder);

            menuPopupHelper.SetAnchorView(view);
            menuPopupHelper.SetForceShowIcon(true);
            menuPopupHelper.Show();
        }
        private void FeedRequestFinished(HttpResponse response)
        {
            if (response.Successful)
            {
                // process response outside UI thread

                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    // set your data to view model or control (this code is called in the UI thread)
                    var jsonResponse = response.Response;
                    JObject jsonObject = JObject.Parse(jsonResponse);
                    JArray entries = (JArray)jsonObject["data"];

                    for (int i = 0; i < entries.Count; i++)
                    {
                        if (entries[i]["message"] != null)
                        {
                            FeedItemViewModel feedItem = new FeedItemViewModel();
                            feedItem.Message = entries[i]["message"].ToString();
                            feedItem.Username = entries[i]["from"]["name"].ToString();
                            feedItem.Date = entries[i]["created_time"].ToString();

                            if (entries[i]["picture"] != null)
                            { feedItem.Thumbnail = entries[i]["picture"].ToString(); }
                            if (entries[i]["link"] != null)
                            { feedItem.Link = entries[i]["link"].ToString(); }

                            feeds.Add(feedItem);
                        }
                    }

                    if (jsonObject["paging"] != null)
                    {
                        paging = jsonObject["paging"]["next"].ToString();
                    }
                    else
                    {
                        paging = "";
                    }
                    feedBusy = false;
                    updateBusy();
                });
            }
            else
            {
                if (!response.Canceled)
                {
                    feedBusy = false;
                    updateBusy();
                    // display exception
                    MessageBox.Show("Error loading feeds - Try again");
                }
            }
        }
Ejemplo n.º 5
0
 public IViewComponentResult Invoke(FeedItemViewModel model)
 {
     return(View("TimelineItemView", model));
 }
Ejemplo n.º 6
0
 private FeedItemViewModel InitializeViewModel(FeedItemViewModel viewModel)
 {
     viewModel.LaunchBrowserCommand = launchBrowserCommand;
     viewModel.PropertyChanged     += FeedItemViewModelPropertyChanged;
     return(viewModel);
 }
Ejemplo n.º 7
0
        public async Task Post([FromBody] FeedItemViewModel feedItem)
        {
            var user = await _userService.GetCurrentUser();

            await _favoriteFeedService.Add(user, feedItem.ToEntity());
        }
Ejemplo n.º 8
0
 private void FeedItemDataTemplate(FeedItemViewModel item, FeedItemHolder holder, int position)
 {
     MerchItemHolderTemplate.DataTemplate(item, holder, position);
     holder.ClickSurface.SetOnLongClickListener(new OnLongClickListener(view => HandlePopupMenu(view, item)));
     holder.ClickSurface.SetOnClickCommand(item.NavigateItemWebsiteCommand);
 }