Пример #1
0
		public void BindDataToView(CommentFeedFragment master, int containerId, Comment comment)
		{
			UserImage.BindDataToView(master.FragmentManager, containerId, comment.user, true, false, null);

			Username.Text = comment.user.username;
			if (!Username.HasOnClickListeners)
			{
				Username.Click += (sender, e) =>
				{
					if (master.post.userPoster.IsMe())
					{
						return;
					}
					TenServiceHelper.GoToGuestProfile(master.FragmentManager, containerId, comment.user);
				};
			}

			TimeRemaining.Text = StringUtils.GetPrettyDateAbs(comment.datestamp);
			Caption.Text = comment.text;
		}
Пример #2
0
		public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
		{
			View view = inflater.Inflate(Resource.Layout.SinglePostActivity, container, false);

			View toolbarLayout = view.FindViewById(Resource.Id.toolbarLayout);
			ImageView toolbarImageFarLeft = (ImageView)toolbarLayout.FindViewById(Resource.Id.toolbar_imageFarLeft);
			toolbarImageFarLeft.Visibility = ViewStates.Visible;
			Drawable backArrow = Context.Resources.GetDrawable(Resource.Drawable.abc_ic_ab_back_mtrl_am_alpha);
			backArrow.SetColorFilter(Resources.GetColor(Resource.Color.tenBlue), PorterDuff.Mode.SrcAtop);
			toolbarImageFarLeft.SetImageDrawable(backArrow);
			toolbarImageFarLeft.Click += (sender, e) =>
			{
				FragmentManager.PopBackStack();
			};
			ImageView toolbarImageFarRight = (ImageView)toolbarLayout.FindViewById(Resource.Id.toolbar_imageFarRight);
			toolbarImageFarRight.Visibility = ViewStates.Visible;
			toolbarImageFarRight.SetImageResource(Resource.Drawable.actions);
			toolbarImageFarRight.Click += (sender, e) =>
			{
				if (post.userPoster.IsMe() && post.isReposted == false)
				{
					Android.Support.V7.App.AlertDialog.Builder alert = new Android.Support.V7.App.AlertDialog.Builder(Context);
					alert.SetTitle(Strings.delete_post);
					alert.SetMessage(Strings.delete_post_confirm);
					alert.SetPositiveButton(Strings.delete, (senderAlert, args) =>
					{
						DeletePost();
					});
					alert.SetNegativeButton(Strings.cancel, (senderAlert, args) => { });
					alert.Show();
				}
				else
				{
					Android.Support.V7.App.AlertDialog.Builder alert = new Android.Support.V7.App.AlertDialog.Builder(Context);
					alert.SetTitle(Strings.report_post);
					alert.SetMessage(Strings.report_post_confirm);
					alert.SetPositiveButton(Strings.report, (senderAlert, args) =>
					{
						ReportPost();
					});
					alert.SetNegativeButton(Strings.cancel, (senderAlert, args) => { });
					alert.Show();
				}
			};

			bottomView = view.FindViewById(Resource.Id.bottomView);

			SuggestionsLayout Suggestions = view.FindViewById<SuggestionsLayout>(Resource.Id.suggestionsLayout);
			Suggestions.InitView();
			Suggestions.UserSelected += (User obj) =>
			{
				inputField.AddUsername(obj.username);
			};

			inputField = view.FindViewById<CharacterLimitedSuggestionEditText>(Resource.Id.inputField);
			inputField.BindDataToView(null, DealWithAddCommentButton, Activity, Suggestions);
			inputField.FocusDidChanged += (bool obj) =>
			{
				ViewGroup.MarginLayoutParams para = (ViewGroup.MarginLayoutParams)((View)bottomView.Parent).LayoutParameters;
				if (obj)
				{
					para.BottomMargin = 0;
				}
				else {
					para.BottomMargin = ViewUtils.dpToPx(Activity, 50);
				}
			};
			WebImage userimage = view.FindViewById<WebImage>(Resource.Id.userimage);
			userimage.BindDataToView(FragmentManager, Resource.Id.fragment_container_page, Globe.SharedInstance.User, false, false, null);

			addCommentButton = view.FindViewById<ImageButton>(Resource.Id.addCommentButton);
			addCommentButton.Click += async (sender, ev) =>
			{

				string text = StringUtils.TrimWhiteSpaceAndNewLine(inputField.Text);

				if (!String.IsNullOrEmpty(text) && text != Strings.add_a_comment_placeholder)
				{
					addCommentButton.Enabled = false;
					ViewUtils.HideKeyboard(TabHostActivity.GetTabHost(), inputField);

					ProgressDialog progress = new ProgressDialog(Context);
					progress.Indeterminate = true;
					progress.SetProgressStyle(ProgressDialogStyle.Spinner);
					progress.SetMessage(Strings.adding_comment);
					progress.SetCancelable(false);
					progress.Show();


					try
					{
						Comment res = await TenServices.AddComment(post, text);
						if (res != null)
						{
							if (CommentFeedFragment.TableItems.Count > 0 && CommentFeedFragment.TableItems[0].idComment == -1)
							{
								CommentFeedFragment.TableItems.RemoveAt(0);
							}

							CommentFeedFragment.TableItems.Add(res);
							CommentFeedFragment.ListViewAdapater.NotifyDataSetChanged();
							CommentFeedFragment.ifFeedEmpty();
							inputField.Text = "";
							ViewUtils.HideKeyboard(TabHostActivity.GetTabHost(), inputField);
							((View)inputField.Parent).RequestFocus();


							CommentFeedFragment.HeaderFragment.HighlightCommentButton();
						}
					}
					catch (RESTError e)
					{
						if (e.Message == "Invalid comment length")
						{
							FailBecauseCommentLength();
						}
					}
					finally
					{
						addCommentButton.Enabled = true;
						progress.Dismiss();
					}
				}
			};

			CommentFeedFragment = new CommentFeedFragment(post);
			CommentFeedFragment.Master = this;
			CommentFeedFragment.EmptyTableString = Strings.no_comments;
			CommentFeedFragment.Target = FeedTypeEnum.FeedType.SinglePost;
			CommentFeedFragment.bottomView = bottomView;
			CommentFeedFragment.containerId = containerId;
			CommentFeedFragment.NewPageContainerID = Resource.Id.newpage_container;
			ChildFragmentManager.BeginTransaction().Add(Resource.Id.fragment_container, CommentFeedFragment).Commit();


			return view;
		}