/// <summary> /// Traverses through the comments tree in "pre-order" fashion. Builds the buttons and adds to the UI along the way. /// </summary> /// <param name="comment"></param> /// <param name="depth">Maintain the depth of the current comment in the tree</param> private void comment_tree_traversal(Comment comment, int depth) { if (comment == null) { return; } else { CommentButton curr_button = new CommentButton(comment, depth); Grid.SetRow(curr_button, num_comments); num_comments++; comment_buttons.Add(curr_button); RowDefinition row = new RowDefinition(); row.Height = GridLength.Auto; comment_grid.RowDefinitions.Add(row); comment_grid.Children.Add(curr_button); if (comment.replies != null) { comment.replies.data.children.Remove(comment.replies.data.children.Last()); foreach (CommentChild child_comment in comment.replies.data.children) { int next_depth = depth + 1; comment_tree_traversal(child_comment.data, next_depth); } } } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { base.OnCreateView(inflater, container, savedInstanceState); var view = inflater.Inflate(Resource.Layout.PageVideoPlayer, container, false); //Find all controls that need programmatic access _webView = view.FindViewById <WebView>(Resource.Id.webView1); _listView = view.FindViewById <ListView>(Resource.Id.listComments); _textDesc = view.FindViewById <TextView>(Resource.Id.textDesc); _textVotes = view.FindViewById <TextView>(Resource.Id.textVotes); _editComment = view.FindViewById <EditText>(Resource.Id.editComment); _commentButton = view.FindViewById <Button>(Resource.Id.buttonComment); _voteButton = view.FindViewById <ToggleButton>(Resource.Id.buttonVote); _webView.Settings.JavaScriptEnabled = true; Vm = Navigator.GetAndRemoveParameter <VideoViewModel>(ViewModelLocator.VIDEO_DETAILS); //Static data _webView.LoadUrl(Vm.FormattedURL); _textDesc.Text = Vm.Model.Description; //Bind data _votesBinding = this.SetBinding(() => Vm.VotesFormatted, () => TextVotes.Text); _voteStatusBinding = this.SetBinding(() => Vm.Model.HasUserVoted, () => VoteButton.Checked, BindingMode.OneWay); _commentBinding = this.SetBinding(() => EditComment.Text); VoteButton.SetCommand("Click", Vm.VoteCommand); CommentButton.SetCommand("Click", Vm.SaveCommentCommand, _commentBinding); ListView.Adapter = Vm.Model.Comments.GetAdapter(GetView); return(view); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); //Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); SetContentView(Resource.Layout.PageVideoPlayer); _webView = FindViewById <WebView>(Resource.Id.webView1); _listView = FindViewById <ListView>(Resource.Id.listComments); _editComment = FindViewById <EditText>(Resource.Id.editComment); _commentButton = FindViewById <Button>(Resource.Id.buttonComment); var view = LayoutInflater.Inflate(Resource.Layout.HeaderVideoPlayer, ListView, false); _listView.AddHeaderView(view); _textDesc = view.FindViewById <TextView>(Resource.Id.textDesc); _textVotes = view.FindViewById <TextView>(Resource.Id.textVotes); _voteButton = view.FindViewById <ToggleButton>(Resource.Id.buttonVote); _webView.Settings.JavaScriptEnabled = true; try { var key = Intent.GetStringExtra(MyNavigationService.ParamKey); Vm = Navigator.GetAndRemoveParameter <VideoViewModel>(key); } catch (Exception e) { Console.WriteLine("Player opened without a video"); Finish(); return; } //Static data _webView.LoadUrl(Vm.FormattedURL); _textDesc.Text = Vm.Model.Description; //Bind data _votesBinding = this.SetBinding(() => Vm.VotesFormatted, () => TextVotes.Text); _voteStatusBinding = this.SetBinding(() => Vm.Model.HasUserVoted, () => VoteButton.Checked, BindingMode.OneWay); _commentBinding = this.SetBinding(() => EditComment.Text); VoteButton.SetCommand("Click", Vm.VoteCommand); CommentButton.SetCommand("Click", Vm.SaveCommentCommand, _commentBinding); _commentButton.Click += (sender, args) => { ((InputMethodManager)GetSystemService(InputMethodService)).HideSoftInputFromWindow( CurrentFocus.WindowToken, HideSoftInputFlags.NotAlways); _editComment.Text = ""; }; _editComment.Click += delegate { _listView.SetSelection(Vm.Model.Comments.Count - 1); }; ListView.Adapter = Vm.Model.Comments.GetAdapter(GetView); }
void OnPropertyChanged(object sender, PropertyChangedEventArgs args) { var name = args.PropertyName; if (name.Equals("IsLikedByUser")) { LikeButton.SetTitleColor(ViewModel.LikeButtonTextColor.ToUIColor(), UIControlState.Normal); LikeButton.SetTitle(ViewModel.LikeButtonText, UIControlState.Normal); } else if (name.Equals("IsCommentedByUser")) { CommentButton.SetTitleColor(ViewModel.CommentButtonTextColor.ToUIColor(), UIControlState.Normal); CommentButton.SetTitle(ViewModel.CommentButtonText, UIControlState.Normal); } else if (name.Equals("IsSharedByUser")) { ShareButton.SetTitleColor(ViewModel.ShareButtonTextColor.ToUIColor(), UIControlState.Normal); ShareButton.SetTitle(ViewModel.ShareButtonText, UIControlState.Normal); } }
void InitUI() { // Adjust constraints as needed PhotoImageViewHeightConstraint.Constant = ViewModel.ShowImage ? _photoImageViewDefaultHeightConstraint : 0; // Map values to UI elements BodyTextView.Text = null; BodyTextView.Text = ViewModel.Text; BodyTextViewHeightConstraint.Constant = BodyTextView.SizeThatFits(new CGSize(BodyTextView.Frame.Width, nfloat.MaxValue)).Height; TimeLabel.Text = ViewModel.ShowDateTime ? ViewModel.DisplayDateTime : string.Empty; NameLabel.SetHighlightText(ViewModel.UserName, ViewModel.UserName.IndexOf("@"), UIColor.LightGray); LikeButton.SetTitle(ViewModel.LikeButtonText, UIControlState.Normal); LikeButton.SetTitleColor(ViewModel.LikeButtonTextColor.ToUIColor(), UIControlState.Normal); CommentButton.SetTitle(ViewModel.CommentButtonText, UIControlState.Normal); CommentButton.SetTitleColor(ViewModel.CommentButtonTextColor.ToUIColor(), UIControlState.Normal); ShareButton.SetTitle(ViewModel.ShareButtonText, UIControlState.Normal); ShareButton.SetTitleColor(ViewModel.ShareButtonTextColor.ToUIColor(), UIControlState.Normal); if (ViewModel.ShowImage) { ActivityIndicator.StartAnimating(); } else { ActivityIndicator.StopAnimating(); } SocialTypeImageView.Image = UIImage.FromBundle(ViewModel.SocialMediaImage); SocialTypeImageView.Hidden = !ViewModel.ShowSocialMediaImage; UserImageView.SetImage( url: new NSUrl(ViewModel.UserImageUrl), placeholder: UIImage.FromBundle(ViewModel.UserImagePlaceholder) ); if (ViewModel.ShowImage) { PhotoImageView.SetImage( url: new NSUrl(ViewModel.ImageUrl), completionHandler: ((UIImage image, NSError error, SDImageCacheType cacheType, NSUrl imageUrl) => { ActivityIndicator.StopAnimating(); }) ); } else { PhotoImageView.Image = null; } if (ViewModel.ShowTimeline) { ContainerViewLeadingConstraint.Constant = _containerViewTimelineLeadingConstraint; TimelineView.Hidden = false; } else { ContainerViewLeadingConstraint.Constant = _containerViewDefaultLeadingConstraint; TimelineView.Hidden = true; } CommentButton.Hidden = !ViewModel.ShowCommentButton; ShareButton.Hidden = !ViewModel.ShowShareButton; // TODO: Remove this when we're ready to support sharing ShareButton.Hidden = true; }
void ReleaseDesignerOutlets() { if (Actor_Name != null) { Actor_Name.Dispose(); Actor_Name = null; } if (Actor_NameHeight != null) { Actor_NameHeight.Dispose(); Actor_NameHeight = null; } if (ActorImage != null) { ActorImage.Dispose(); ActorImage = null; } if (BackgroundContentFriendJoined != null) { BackgroundContentFriendJoined.Dispose(); BackgroundContentFriendJoined = null; } if (BackgroundProductSold != null) { BackgroundProductSold.Dispose(); BackgroundProductSold = null; } if (btn_OtherUsers != null) { btn_OtherUsers.Dispose(); btn_OtherUsers = null; } if (btnDotsTop != null) { btnDotsTop.Dispose(); btnDotsTop = null; } if (btnOpenInvitedProfile != null) { btnOpenInvitedProfile.Dispose(); btnOpenInvitedProfile = null; } if (ButtonFacebook != null) { ButtonFacebook.Dispose(); ButtonFacebook = null; } if (ButtonInviteFriends != null) { ButtonInviteFriends.Dispose(); ButtonInviteFriends = null; } if (ButtonProductSold != null) { ButtonProductSold.Dispose(); ButtonProductSold = null; } if (ButtonRewardClaimed != null) { ButtonRewardClaimed.Dispose(); ButtonRewardClaimed = null; } if (ButtonTwitter != null) { ButtonTwitter.Dispose(); ButtonTwitter = null; } if (CollectionUserView != null) { CollectionUserView.Dispose(); CollectionUserView = null; } if (CommentButton != null) { CommentButton.Dispose(); CommentButton = null; } if (CommentsText != null) { CommentsText.Dispose(); CommentsText = null; } if (ContectRewardClaimed != null) { ContectRewardClaimed.Dispose(); ContectRewardClaimed = null; } if (ContectRewardClaimedAspectRatio != null) { ContectRewardClaimedAspectRatio.Dispose(); ContectRewardClaimedAspectRatio = null; } if (ContectRewardClaimedRightBackground != null) { ContectRewardClaimedRightBackground.Dispose(); ContectRewardClaimedRightBackground = null; } if (ContectRewardClaimedTitle != null) { ContectRewardClaimedTitle.Dispose(); ContectRewardClaimedTitle = null; } if (ContentCollectionAvatarView != null) { ContentCollectionAvatarView.Dispose(); ContentCollectionAvatarView = null; } if (ContentCollectionAvatarViewAspectRatio != null) { ContentCollectionAvatarViewAspectRatio.Dispose(); ContentCollectionAvatarViewAspectRatio = null; } if (ContentCollectionCheckInView != null) { ContentCollectionCheckInView.Dispose(); ContentCollectionCheckInView = null; } if (ContentCollectionCheckInViewAspectRatio != null) { ContentCollectionCheckInViewAspectRatio.Dispose(); ContentCollectionCheckInViewAspectRatio = null; } if (ContentFriendJoined != null) { ContentFriendJoined.Dispose(); ContentFriendJoined = null; } if (ContentFriendJoinedAspectRatio != null) { ContentFriendJoinedAspectRatio.Dispose(); ContentFriendJoinedAspectRatio = null; } if (ContentFriendJoinedBackground != null) { ContentFriendJoinedBackground.Dispose(); ContentFriendJoinedBackground = null; } if (ContentFriendJoinedPhoto != null) { ContentFriendJoinedPhoto.Dispose(); ContentFriendJoinedPhoto = null; } if (ContentFriendJoinedUserName != null) { ContentFriendJoinedUserName.Dispose(); ContentFriendJoinedUserName = null; } if (ContentHeaderView != null) { ContentHeaderView.Dispose(); ContentHeaderView = null; } if (ContentImage != null) { ContentImage.Dispose(); ContentImage = null; } if (ContentImageAspectRatio != null) { ContentImageAspectRatio.Dispose(); ContentImageAspectRatio = null; } if (ContentImageTextCaption != null) { ContentImageTextCaption.Dispose(); ContentImageTextCaption = null; } if (ContentMap != null) { ContentMap.Dispose(); ContentMap = null; } if (ContentMapAspectRatio != null) { ContentMapAspectRatio.Dispose(); ContentMapAspectRatio = null; } if (ContentMapView != null) { ContentMapView.Dispose(); ContentMapView = null; } if (ContentProductSold != null) { ContentProductSold.Dispose(); ContentProductSold = null; } if (ContentProductSoldAspectRatio != null) { ContentProductSoldAspectRatio.Dispose(); ContentProductSoldAspectRatio = null; } if (ContentProductSoldTextView != null) { ContentProductSoldTextView.Dispose(); ContentProductSoldTextView = null; } if (ContentShare != null) { ContentShare.Dispose(); ContentShare = null; } if (ContentShareAspectRatio != null) { ContentShareAspectRatio.Dispose(); ContentShareAspectRatio = null; } if (ContentText != null) { ContentText.Dispose(); ContentText = null; } if (ContentTextHeight != null) { ContentTextHeight.Dispose(); ContentTextHeight = null; } if (ContentVideo != null) { ContentVideo.Dispose(); ContentVideo = null; } if (ContentVideoAspectRatio != null) { ContentVideoAspectRatio.Dispose(); ContentVideoAspectRatio = null; } if (ContentVideoButtonPlay != null) { ContentVideoButtonPlay.Dispose(); ContentVideoButtonPlay = null; } if (ContentWebView != null) { ContentWebView.Dispose(); ContentWebView = null; } if (ContentWebViewAspectRatio != null) { ContentWebViewAspectRatio.Dispose(); ContentWebViewAspectRatio = null; } if (Creation_Date != null) { Creation_Date.Dispose(); Creation_Date = null; } if (Creation_DateHeight != null) { Creation_DateHeight.Dispose(); Creation_DateHeight = null; } if (GradientImageView != null) { GradientImageView.Dispose(); GradientImageView = null; } if (GradientImageViewAspect != null) { GradientImageViewAspect.Dispose(); GradientImageViewAspect = null; } if (IconContentFriendJoined != null) { IconContentFriendJoined.Dispose(); IconContentFriendJoined = null; } if (IconProductSold != null) { IconProductSold.Dispose(); IconProductSold = null; } if (Label_ContectReward_Claimed != null) { Label_ContectReward_Claimed.Dispose(); Label_ContectReward_Claimed = null; } if (LabelFriendsWelcome != null) { LabelFriendsWelcome.Dispose(); LabelFriendsWelcome = null; } if (LikeButton != null) { LikeButton.Dispose(); LikeButton = null; } if (LikesText != null) { LikesText.Dispose(); LikesText = null; } if (LikesView != null) { LikesView.Dispose(); LikesView = null; } if (LikesViewHeightAspecnRatio != null) { LikesViewHeightAspecnRatio.Dispose(); LikesViewHeightAspecnRatio = null; } if (LineSeparator != null) { LineSeparator.Dispose(); LineSeparator = null; } if (MainBackgroundView != null) { MainBackgroundView.Dispose(); MainBackgroundView = null; } if (MainView != null) { MainView.Dispose(); MainView = null; } if (PointsIconWidthConstraint != null) { PointsIconWidthConstraint.Dispose(); PointsIconWidthConstraint = null; } if (ProductSoldCount != null) { ProductSoldCount.Dispose(); ProductSoldCount = null; } if (ProductSoldMainBackground != null) { ProductSoldMainBackground.Dispose(); ProductSoldMainBackground = null; } if (ProductSoldTitle != null) { ProductSoldTitle.Dispose(); ProductSoldTitle = null; } if (ProductSoldUpBackground != null) { ProductSoldUpBackground.Dispose(); ProductSoldUpBackground = null; } if (PtsText != null) { PtsText.Dispose(); PtsText = null; } if (ReadCommentButtonHeight != null) { ReadCommentButtonHeight.Dispose(); ReadCommentButtonHeight = null; } if (ReadCommentsButton != null) { ReadCommentsButton.Dispose(); ReadCommentsButton = null; } if (RewardClaimedCount != null) { RewardClaimedCount.Dispose(); RewardClaimedCount = null; } if (SmileButton != null) { SmileButton.Dispose(); SmileButton = null; } if (TextContentFriendJoined != null) { TextContentFriendJoined.Dispose(); TextContentFriendJoined = null; } if (TextProductSold != null) { TextProductSold.Dispose(); TextProductSold = null; } if (TextQuoteLineSeparatorHeight != null) { TextQuoteLineSeparatorHeight.Dispose(); TextQuoteLineSeparatorHeight = null; } if (TopActionText != null) { TopActionText.Dispose(); TopActionText = null; } if (TopActionTextHeight != null) { TopActionTextHeight.Dispose(); TopActionTextHeight = null; } if (TopPaddingView != null) { TopPaddingView.Dispose(); TopPaddingView = null; } if (TopPaddingViewAspect != null) { TopPaddingViewAspect.Dispose(); TopPaddingViewAspect = null; } if (TopView != null) { TopView.Dispose(); TopView = null; } if (TopViewHeight != null) { TopViewHeight.Dispose(); TopViewHeight = null; } if (uiProfileButton != null) { uiProfileButton.Dispose(); uiProfileButton = null; } if (vDotsTop != null) { vDotsTop.Dispose(); vDotsTop = null; } if (vDotsTopHeight != null) { vDotsTopHeight.Dispose(); vDotsTopHeight = null; } }
void ReleaseDesignerOutlets() { if (TimelineView != null) { TimelineView.Dispose(); TimelineView = null; } if (ActivityIndicator != null) { ActivityIndicator.Dispose(); ActivityIndicator = null; } if (BodyTextView != null) { BodyTextView.Dispose(); BodyTextView = null; } if (BodyTextViewHeightConstraint != null) { BodyTextViewHeightConstraint.Dispose(); BodyTextViewHeightConstraint = null; } if (CommentButton != null) { CommentButton.Dispose(); CommentButton = null; } if (ContainerView != null) { ContainerView.Dispose(); ContainerView = null; } if (LikeButton != null) { LikeButton.Dispose(); LikeButton = null; } if (NameLabel != null) { NameLabel.Dispose(); NameLabel = null; } if (PhotoImageView != null) { PhotoImageView.Dispose(); PhotoImageView = null; } if (PhotoImageViewHeightConstraint != null) { PhotoImageViewHeightConstraint.Dispose(); PhotoImageViewHeightConstraint = null; } if (ShareButton != null) { ShareButton.Dispose(); ShareButton = null; } if (SocialTypeImageView != null) { SocialTypeImageView.Dispose(); SocialTypeImageView = null; } if (TimeLabel != null) { TimeLabel.Dispose(); TimeLabel = null; } if (UserImageView != null) { UserImageView.Dispose(); UserImageView = null; } if (ContainerViewLeadingConstraint != null) { ContainerViewLeadingConstraint.Dispose(); ContainerViewLeadingConstraint = null; } }
/// <summary> /// "Comment" button will be clicked on /// </summary> public void ClickOnCommentButton() { CommentButton.Click(); }