Esempio n. 1
0
        public void FillMultiImagePost(PostMultiImageViewHolder vh, int position)
        {
            try
            {
                vh.AuthorName.Text = _Posts[position].AuthorName;
                var context = Android.App.Application.Context;
                vh.HeaderRating.Text = _Posts[position].Rating.ToString();
                vh.BottomRating.Text = _Posts[position].Rating.ToString();
                if (_Posts[position].Rating > 0)
                {
                    vh.HeaderRating.SetTextColor(context.Resources.GetColor(Resource.Color.mainGreen));
                    vh.BottomRating.SetTextColor(context.Resources.GetColor(Resource.Color.mainGreen));
                    var text = " + " + _Posts[position].Rating;
                    vh.HeaderRating.Text = text;
                    vh.BottomRating.Text = text;
                }
                if (_Posts[position].Rating < 0)
                {
                    vh.HeaderRating.SetTextColor(context.Resources.GetColor(Resource.Color.red));
                    vh.BottomRating.SetTextColor(context.Resources.GetColor(Resource.Color.red));
                    var text = "" + _Posts[position].Rating;
                    vh.HeaderRating.Text = text;
                    vh.BottomRating.Text = text;
                }
                vh.PostTime.Text = _Posts[position].PostTime;
                vh.Title.Text    = _Posts[position].Title;
                if (_Posts[position].Description != null && !String.IsNullOrEmpty(_Posts[position].Description.ToString()))
                {
                    vh.Description.Text       = _Posts[position].Description.ToString();
                    vh.Description.Visibility = ViewStates.Visible;
                }
                else
                {
                    vh.Description.Text       = String.Empty;
                    vh.Description.Visibility = ViewStates.Gone;
                }

                SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
                Color textColor = context.Resources.GetColor(Resource.Color.mainGreen);

                foreach (var tag in _Posts[position].Tags)
                {
                    SpannableString tag1 = new SpannableString("#" + tag);

                    tag1.SetSpan(new ForegroundColorSpan(textColor), 0, tag1.Length(), SpanTypes.ExclusiveExclusive);
                    stringBuilder.Append(tag1);
                    stringBuilder.Append("  ");
                    //SpannableString tag2 = new SpannableString(" ");
                    //stringBuilder.Append(tag2);
                    //stringBuilder.SetSpan(new TagSpan(backgroundColor, backgroundColor), stringBuilder.Length() - tag2.Length(), stringBuilder.Length(), SpanTypes.ExclusiveExclusive);
                }
                vh.Tags.SetText(stringBuilder, TextView.BufferType.Spannable);
                vh.Comments.Text = _Posts[position].Comments.ToString();



                ImageAdapter adapter = new ImageAdapter(context, _Posts[position].Images);
                vh.Rotator.Adapter = adapter;
            }
            catch (Exception ex)
            {
                Insights.Initialize("0637c26a1b2e27693e05298f7c3c3a04c102a3c7", Application.Context);
                Insights.Report(ex, new Dictionary <string, string> {
                    { "Message", ex.Message }
                }, Insights.Severity.Error);
                var text = ex.Message;
            }
        }
Esempio n. 2
0
		public void FillMultiImagePost(PostMultiImageViewHolder vh, int position)
		{
			try
			{
				vh.AuthorName.Text = _Posts[position].AuthorName;
				var context = Android.App.Application.Context;
				vh.HeaderRating.Text = _Posts[position].Rating.ToString();
				vh.BottomRating.Text = _Posts[position].Rating.ToString();
				if (_Posts[position].Rating > 0)
				{
					vh.HeaderRating.SetTextColor(context.Resources.GetColor(Resource.Color.mainGreen));
					vh.BottomRating.SetTextColor(context.Resources.GetColor(Resource.Color.mainGreen));
					var text = " + " + _Posts[position].Rating;
					vh.HeaderRating.Text = text;
					vh.BottomRating.Text = text;
				}
				if (_Posts[position].Rating < 0)
				{
					vh.HeaderRating.SetTextColor(context.Resources.GetColor(Resource.Color.red));
					vh.BottomRating.SetTextColor(context.Resources.GetColor(Resource.Color.red));
					var text = "" + _Posts[position].Rating;
					vh.HeaderRating.Text = text;
					vh.BottomRating.Text = text;
				}
				vh.PostTime.Text = _Posts[position].PostTime;
				vh.Title.Text = _Posts[position].Title;
				if (_Posts[position].Description != null && !String.IsNullOrEmpty(_Posts[position].Description.ToString()))
				{
					vh.Description.Text = _Posts[position].Description.ToString();
					vh.Description.Visibility = ViewStates.Visible;
				}
				else {
					vh.Description.Text = String.Empty;
					vh.Description.Visibility = ViewStates.Gone;
				}

				SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
				Color textColor = context.Resources.GetColor(Resource.Color.mainGreen);

				foreach (var tag in _Posts[position].Tags)
				{
					SpannableString tag1 = new SpannableString("#" + tag);

					tag1.SetSpan(new ForegroundColorSpan(textColor), 0, tag1.Length(), SpanTypes.ExclusiveExclusive);
					stringBuilder.Append(tag1);
					stringBuilder.Append("  ");
					//SpannableString tag2 = new SpannableString(" ");
					//stringBuilder.Append(tag2);
					//stringBuilder.SetSpan(new TagSpan(backgroundColor, backgroundColor), stringBuilder.Length() - tag2.Length(), stringBuilder.Length(), SpanTypes.ExclusiveExclusive);
				}
				vh.Tags.SetText(stringBuilder, TextView.BufferType.Spannable);
				vh.Comments.Text = _Posts[position].Comments.ToString();



				ImageAdapter adapter = new ImageAdapter(context, _Posts[position].Images);
				vh.Rotator.Adapter = adapter;

			}
			catch (Exception ex)
			{
				Insights.Initialize("0637c26a1b2e27693e05298f7c3c3a04c102a3c7", Application.Context);
				Insights.Report(ex, new Dictionary<string, string> { { "Message", ex.Message } }, Insights.Severity.Error);
				var text = ex.Message;
			}
		}