public PollResultsByCategoryViewModel(IPollSearchResultsByCategory pollResultsByCategory , IObjectFactory <IPollSubmissionCommand> objectFactory) { this.pollSearchResultsByCategory = pollResultsByCategory; this.searchResults = new ObservableCollection <PollSearchResultViewModel>(); this.objectFactory = objectFactory; foreach (IPollSearchResult searchResult in pollResultsByCategory.SearchResults) { this.searchResults.Add(new PollSearchResultViewModel(searchResult, this.objectFactory)); } }
public PollResultsByCategoryViewModel(IPollSearchResultsByCategory pollResultsByCategory , IObjectFactory<IPollSubmissionCommand> objectFactory) { this.pollSearchResultsByCategory = pollResultsByCategory; this.searchResults = new ObservableCollection<PollSearchResultViewModel>(); this.objectFactory = objectFactory; foreach (IPollSearchResult searchResult in pollResultsByCategory.SearchResults) { this.searchResults.Add(new PollSearchResultViewModel(searchResult, this.objectFactory)); } }
/* * instanitates a horizontal scroll view then addes the specified catagories subviews to it */ private HorizontalScrollView getCatagoryHorizontalScrollViewLayout(IPollSearchResultsByCategory pollsByCatagory) { //set orientation and sizes HorizontalScrollView horizontalScrollView = new HorizontalScrollView (mActivityContext); HorizontalScrollView.LayoutParams horizontalLayoutParameters = new HorizontalScrollView.LayoutParams ( HorizontalScrollView.LayoutParams.WrapContent, HorizontalScrollView.LayoutParams.WrapContent); horizontalScrollView.LayoutParameters = horizontalLayoutParameters; LinearLayout pollLinearLayout = new LinearLayout (mActivityContext); pollLinearLayout.Orientation = Orientation.Horizontal; LinearLayout.LayoutParams linearLayoutParameters = new LinearLayout.LayoutParams ( LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent); pollLinearLayout.LayoutParameters = linearLayoutParameters; var polls = pollsByCatagory.SearchResults; foreach(IPollSearchResult poll in polls) { RelativeLayout pollLayout = (RelativeLayout)mActivityContext.LayoutInflater.Inflate (Resource.Layout.pollview_container, null); pollLayout.SetBackgroundColor (Color.Transparent); ImageView pollLayoutImage = pollLayout.FindViewById<ImageView> (Resource.Id.pollview_cellImage); if(poll.ImageLink.CompareTo("")!=0) pollLayoutImage.SetUrlDrawable (poll.ImageLink); TextView pollLayoutTitle = pollLayout.FindViewById<TextView> (Resource.Id.pollview_cellTitle); pollLayoutTitle.Text = poll.Question; TextView pollLayoutResponsesCountText = pollLayout.FindViewById<TextView> (Resource.Id.pollview_voteCounts); pollLayoutResponsesCountText.Text = poll.SubmissionCount.ToString() + " Responses"; pollLayout.Click += delegate { this.ViewPoll (poll); }; pollLinearLayout.AddView(pollLayout); } horizontalScrollView.AddView (pollLinearLayout); return horizontalScrollView; }