Example #1
0
        protected override void OnElementChanged(ElementChangedEventArgs <Label> e)
        {
            base.OnElementChanged(e);
            if (e.NewElement != null)
            {
                try
                {
                    this.Control.SetText(HtmlUtils.GetHtml(Element.Text), Android.Widget.TextView.BufferType.Normal);
                }
                catch (System.Exception ex)
                {
                    this.Control.Text = Element.Text;
                    DependencyService.Get <ILog>().SendLog("ItemLabelRenderer:" + ex.Message);
                }

                var itemLabel   = (XamCnblogs.UI.Controls.ItemLabel)Element;
                var lineSpacing = itemLabel.LineSpacing;
                var maxLines    = itemLabel.MaxLines;

                this.Control.SetLineSpacing(1f, (float)lineSpacing);
                if (maxLines > 1)
                {
                    this.Control.SetMaxLines(maxLines);
                    this.Control.Ellipsize = global::Android.Text.TextUtils.TruncateAt.End;
                }
            }
        }
Example #2
0
        protected override void ConvertAsync(RecyclerView.ViewHolder holder, ArticlesModel model)
        {
            var baseHolder   = holder as BaseAdapter.BaseViewHolder;
            var linearLayout = (baseHolder.GetView(Resource.Id.linearLayout) as LinearLayout);

            linearLayout.Tag = model.Id.ToString();
            linearLayout.SetOnClickListener(this);
            (baseHolder.GetView(Resource.Id.txtTitle) as TextView).Text        = model.Title;
            (baseHolder.GetView(Resource.Id.txtDscription) as TextView).Text   = model.Description;
            (baseHolder.GetView(Resource.Id.txtPostdate) as TextView).Text     = DateTimeUtils.CommonTime(Convert.ToDateTime(model.PostDate));
            (baseHolder.GetView(Resource.Id.txtDiggCount) as TextView).Text    = model.DiggCount + " " + context.Resources.GetString(Resource.String.digg);
            (baseHolder.GetView(Resource.Id.txtViewCount) as TextView).Text    = model.ViewCount + " " + context.Resources.GetString(Resource.String.read);
            (baseHolder.GetView(Resource.Id.txtCommentCount) as TextView).Text = model.CommentCount + " " + context.Resources.GetString(Resource.String.comment);
            if (model.Author != null)
            {
                (baseHolder.GetView(Resource.Id.txtAuthor) as TextView).Text = HtmlUtils.GetHtml(model.Author).ToString();
                try
                {
                    Picasso.With(context)
                    .Load(model.Avatar)
                    .Placeholder(Resource.Drawable.placeholder)
                    .Error(Resource.Drawable.placeholder)
                    .Transform(new CircleTransform())
                    .Into(baseHolder.GetView(Resource.Id.llAvatar) as ImageView);
                }
                catch (Exception ex)
                {
                }
            }
        }
Example #3
0
        private void BindView(StatusModel model)
        {
            handler.Post(() =>
            {
                toolbar.Title    = HtmlUtils.GetHtml(model.UserDisplayName).ToString() + "µÄÉÁ´æ";
                userName.Text    = HtmlUtils.GetHtml(model.UserDisplayName).ToString();
                txtPostdate.Text = DateTimeUtils.CommonTime(Convert.ToDateTime(model.DateAdded));
                if (model.CommentCount > 0)
                {
                    commentCount.Text = model.CommentCount + " " + Resources.GetString(Resource.String.comment);
                }
                imgDelete.SetOnClickListener(this);
                if (model.IsPrivate)
                {
                    imgPrivate.Visibility = ViewStates.Visible;
                    try
                    {
                        Picasso.With(this)
                        .Load(Resource.Drawable.isPrivate)
                        .Into(imgPrivate);
                    }
                    catch
                    {
                    }
                }
                else
                {
                    imgPrivate.Visibility = ViewStates.Gone;
                }
                if (model.IsLucky)
                {
                    var Content  = model.Content + " ";
                    var spanText = new SpannableString(HtmlUtils.GetHtml(Content));
                    spanText.SetSpan(new CenteredImageSpan(this.ApplicationContext, Resource.Drawable.luckystar), spanText.Length() - 1, spanText.Length(), SpanTypes.InclusiveExclusive);

                    txtBody.SetText(spanText, TextView.BufferType.Spannable);
                }
                else
                {
                    txtBody.SetText(HtmlUtils.GetHtml(model.Content), TextView.BufferType.Spannable);
                }
                try
                {
                    Picasso.With(this)
                    .Load(model.UserIconUrl)
                    .Placeholder(Resource.Drawable.placeholder)
                    .Error(Resource.Drawable.placeholder)
                    .Transform(new CircleTransform())
                    .Into(imgUserUrl);
                }
                catch
                {
                }
            });
        }
Example #4
0
        protected override void ConvertAsync(RecyclerView.ViewHolder holder, QuestionsModel model)
        {
            var baseHolder   = holder as BaseAdapter.BaseViewHolder;
            var linearLayout = (baseHolder.GetView(Resource.Id.linearLayout) as LinearLayout);

            linearLayout.Tag = model.Qid.ToString();
            linearLayout.SetOnClickListener(this);
            (baseHolder.GetView(Resource.Id.txtTitle) as TextView).Text       = model.Title;
            (baseHolder.GetView(Resource.Id.txtSummary) as TextView).Text     = model.Summary;
            (baseHolder.GetView(Resource.Id.txtDateAdded) as TextView).Text   = DateTimeUtils.CommonTime(Convert.ToDateTime(model.DateAdded));
            (baseHolder.GetView(Resource.Id.txtAnswerCount) as TextView).Text = model.AnswerCount + " " + context.Resources.GetString(Resource.String.answer);
            (baseHolder.GetView(Resource.Id.txtViewCount) as TextView).Text   = model.ViewCount + " " + context.Resources.GetString(Resource.String.read);

            var txtTag = (baseHolder.GetView(Resource.Id.txtTag) as TextView);

            if (model.Tags != null && model.Tags.Length > 0)
            {
                txtTag.Visibility = ViewStates.Visible;
                txtTag.Text       = " " + model.Tags.Replace(',', ' ');
            }
            else
            {
                txtTag.Visibility = ViewStates.Gone;
            }

            var txtGold = (baseHolder.GetView(Resource.Id.txtGold) as TextView);

            if (model.Award > 0)
            {
                txtGold.Visibility = ViewStates.Visible;
                txtGold.Text       = model.Award.ToString();
            }
            else
            {
                txtGold.Visibility = ViewStates.Gone;
            }
            if (model.QuestionUserInfo != null && model.QuestionUserInfo.UserID > 0)
            {
                (baseHolder.GetView(Resource.Id.txtUserName) as TextView).Text = HtmlUtils.GetHtml(model.QuestionUserInfo.UserName).ToString();
                try
                {
                    Picasso.With(context)
                    .Load("https://pic.cnblogs.com/face/" + model.QuestionUserInfo.IconName)
                    .Placeholder(Resource.Drawable.placeholder)
                    .Error(Resource.Drawable.placeholder)
                    .Transform(new CircleTransform())
                    .Into(baseHolder.GetView(Resource.Id.imgIconName) as ImageView);
                }
                catch (Exception)
                {
                }
            }
        }
Example #5
0
 private void UpdateNativeControl()
 {
     try
     {
         this.Control.SetText(HtmlUtils.GetHtml(Element.Text), Android.Widget.TextView.BufferType.Normal);
     }
     catch (System.Exception ex)
     {
         this.Control.Text = Element.Text;
         DependencyService.Get <ILog>().SaveLog("ItemLabelRenderer", ex);
     }
 }
Example #6
0
        protected override void ConvertAsync(RecyclerView.ViewHolder holder, NewsCommentModel model)
        {
            var baseHolder = holder as BaseAdapter.BaseViewHolder;
            var itemview   = baseHolder.GetConvertView();

            itemview.Tag = model.CommentID.ToString();
            (baseHolder.GetView(Resource.Id.username) as TextView).Text  = HtmlUtils.GetHtml(model.UserName).ToString();
            (baseHolder.GetView(Resource.Id.comment) as TextView).Text   = HtmlUtils.GetHtml(model.CommentContent).ToString();
            (baseHolder.GetView(Resource.Id.dateAdded) as TextView).Text = DateTimeUtils.CommonTime(model.DateAdded);
            (baseHolder.GetView(Resource.Id.floor) as TextView).Text     = model.Floor + context.Resources.GetString(Resource.String.floor1);
            if (model.AgreeCount > 0)
            {
                (baseHolder.GetView(Resource.Id.agreeCount) as TextView).Text = " " + model.AgreeCount.ToString();
            }
            if (model.AntiCount > 0)
            {
                (baseHolder.GetView(Resource.Id.antiCount) as TextView).Text = " " + model.AntiCount.ToString();
            }
            (baseHolder.GetView(Resource.Id.progressBar) as ProgressBar).Visibility = ViewStates.Gone;
            var imgDelete = (baseHolder.GetView(Resource.Id.imgDelete) as ImageButton);
            var imgEdit   = (baseHolder.GetView(Resource.Id.imgEdit) as ImageButton);

            if (model.CommentID > 0 && User != null && model.UserName == User.DisplayName)
            {
                imgDelete.Visibility = ViewStates.Visible;
                imgDelete.Tag        = model.CommentID.ToString();
                imgDelete.SetOnClickListener(this);
                imgEdit.Visibility = ViewStates.Visible;
                imgEdit.Tag        = baseHolder.AdapterPosition.ToString();
                imgEdit.SetOnClickListener(this);
            }
            else
            {
                imgDelete.Visibility = ViewStates.Gone;
                imgEdit.Visibility   = ViewStates.Gone;
            }
            try
            {
                var face = model.FaceUrl == "" ? "https://pic.cnblogs.com/face/sample_face.gif" : model.FaceUrl;
                Picasso.With(context)
                .Load(face)
                .Placeholder(Resource.Drawable.placeholder)
                .Error(Resource.Drawable.placeholder)
                .Transform(new CircleTransform())
                .Into(baseHolder.GetView(Resource.Id.faceUrl) as ImageView);
            }
            catch (Exception)
            {
            }
        }
Example #7
0
        protected override void ConvertAsync(RecyclerView.ViewHolder holder, SearchModel model)
        {
            var baseHolder   = holder as BaseAdapter.BaseViewHolder;
            var linearLayout = (baseHolder.GetView(Resource.Id.linearLayout) as LinearLayout);

            if (model.Id == null)
            {
                linearLayout.Tag = model.Uri.ToString();
            }
            else
            {
                linearLayout.Tag = model.Id.ToString();
            }
            linearLayout.SetOnClickListener(this);

            (baseHolder.GetView(Resource.Id.txtTitle) as TextView).Text        = HtmlUtils.GetHtml(model.Title).ToString();
            (baseHolder.GetView(Resource.Id.txtDscription) as TextView).Text   = HtmlUtils.GetHtml(model.Content).ToString();
            (baseHolder.GetView(Resource.Id.txtPostdate) as TextView).Text     = DateTimeUtils.CommonTime(Convert.ToDateTime(model.PublishTime));
            (baseHolder.GetView(Resource.Id.txtDiggCount) as TextView).Text    = model.VoteTimes + " " + context.Resources.GetString(Resource.String.digg);
            (baseHolder.GetView(Resource.Id.txtViewCount) as TextView).Text    = model.ViewTimes + " " + context.Resources.GetString(Resource.String.read);
            (baseHolder.GetView(Resource.Id.txtCommentCount) as TextView).Text = model.CommentTimes + " " + context.Resources.GetString(Resource.String.comment);
            var txtAuthor = (baseHolder.GetView(Resource.Id.txtAuthor) as TextView);

            if (model.UserName != null)
            {
                (txtAuthor.Parent as View).Visibility = ViewStates.Visible;
                txtAuthor.Text = model.UserName;
                try
                {
                    Picasso.With(context)
                    .Load(model.UserAlias)
                    .Placeholder(Resource.Drawable.placeholder)
                    .Error(Resource.Drawable.placeholder)
                    .Transform(new CircleTransform())
                    .Into(baseHolder.GetView(Resource.Id.llAvatar) as ImageView);
                }
                catch (Exception ex)
                {
                }
            }
            else
            {
                (txtAuthor.Parent as View).Visibility = ViewStates.Gone;
            }
        }
        protected override async void ConvertAsync(RecyclerView.ViewHolder holder, QuestionCommentsModel model)
        {
            var baseHolder = holder as BaseAdapter.BaseViewHolder;
            var itemview   = baseHolder.GetConvertView();

            itemview.Tag = model.CommentID;
            (baseHolder.GetView(Resource.Id.txtDateAdded) as TextView).Text = DateTimeUtils.CommonTime(Convert.ToDateTime(model.DateAdded));
            (baseHolder.GetView(Resource.Id.txtContent) as TextView).SetText(HtmlUtils.GetHtml(model.ConvertedContent == null? model.Content: model.ConvertedContent), TextView.BufferType.Spannable);
            var imgUserUrl = (baseHolder.GetView(Resource.Id.imgIconName) as ImageView);
            var imgDelete  = (baseHolder.GetView(Resource.Id.imgDelete) as ImageButton);

            (baseHolder.GetView(Resource.Id.progressBar) as ProgressBar).Visibility = ViewStates.Gone;

            imgDelete.Tag = model.CommentID;
            imgDelete.SetOnClickListener(this);
            if (User != null && User.UserId == model.PostUserInfo.UCUserID)
            {
                User.Score = model.PostUserInfo.QScore;
                await SQLiteUtils.Instance().UpdateUser(User);

                imgDelete.Visibility = ViewStates.Visible;
            }
            else
            {
                imgDelete.Visibility = ViewStates.Gone;
            }
            if (model.PostUserInfo != null && model.PostUserInfo.UserID > 0)
            {
                (baseHolder.GetView(Resource.Id.txtUserName) as TextView).Text = HtmlUtils.GetHtml(model.PostUserInfo.UserName).ToString();
                (baseHolder.GetView(Resource.Id.txtScore) as TextView).Text    = HtmlUtils.GetScoreName(model.PostUserInfo.QScore) + " ¡¤ " + model.PostUserInfo.QScore + "Ô°¶¹";
                try
                {
                    Picasso.With(context)
                    .Load("https://pic.cnblogs.com/face/" + model.PostUserInfo.IconName)
                    .Placeholder(Resource.Drawable.placeholder)
                    .Error(Resource.Drawable.placeholder)
                    .Transform(new CircleTransform())
                    .Into(imgUserUrl);
                }
                catch
                {
                }
            }
        }
Example #9
0
        protected override void ConvertAsync(RecyclerView.ViewHolder holder, KbArticlesModel model)
        {
            var baseHolder   = holder as BaseAdapter.BaseViewHolder;
            var linearLayout = (baseHolder.GetView(Resource.Id.linearLayout) as LinearLayout);

            linearLayout.Tag = model.Id.ToString();
            linearLayout.SetOnClickListener(this);
            (baseHolder.GetView(Resource.Id.txtSummary) as TextView).Text   = model.Summary;
            (baseHolder.GetView(Resource.Id.txtPostdate) as TextView).Text  = DateTimeUtils.CommonTime(Convert.ToDateTime(model.DateAdded));
            (baseHolder.GetView(Resource.Id.txtDiggCount) as TextView).Text = model.DiggCount + " " + context.Resources.GetString(Resource.String.digg);
            (baseHolder.GetView(Resource.Id.txtViewCount) as TextView).Text = model.ViewCount + " " + context.Resources.GetString(Resource.String.read);

            var Title = (baseHolder.GetView(Resource.Id.txtTitle) as TextView);

            Title.Text = model.Title;
            if (model.Author != null)
            {
                Title.Text += " - " + HtmlUtils.GetHtml(model.Author).ToString();
            }
        }
Example #10
0
        public void GetClientKbArticleSuccess(KbArticlesModel model)
        {
            if (model != null)
            {
                kbarticle     = model;
                toolbar.Title = model.Title;
                if (model.Author != null)
                {
                    toolbar.Title += " - " + HtmlUtils.GetHtml(model.Author).ToString();
                }
                txtPostdate.Text = "发布于:" + DateTimeUtils.CommonTime(kbarticle.DateAdded);

                if (kbarticle.DiggCount > 0)
                {
                    txtDigg.Text = kbarticle.DiggCount.ToString();
                }
                if (kbarticle.ViewCount > 0)
                {
                    txtRead.Text = kbarticle.ViewCount.ToString();
                }
                (txtComments.Parent as FrameLayout).Click += delegate
                {
                    Toast.MakeText(this, "很抱歉,暂未开放此功能。", ToastLength.Short).Show();
                };
                (txtBookmark.Parent as FrameLayout).Click += delegate
                {
                    var linkurl = "http://kb.cnblogs.com/page/" + kbarticle.Id + "/";
                    var title   = kbarticle.Title + "_知识库_博客园";
                    BookmarkAddActivity.Start(this, linkurl, title, true);
                };

                if (kbarticle.Body == null || kbarticle.Body == "")
                {
                    OnRefresh();
                }
                else
                {
                    GetServiceKbArticleSuccess(model);
                }
            }
        }
        protected override void ConvertAsync(RecyclerView.ViewHolder holder, ArticleCommentModel model)
        {
            var baseHolder = holder as BaseAdapter.BaseViewHolder;

            (baseHolder.GetView(Resource.Id.author) as TextView).Text   = HtmlUtils.GetHtml(model.Author).ToString();
            (baseHolder.GetView(Resource.Id.body) as TextView).Text     = HtmlUtils.GetHtml(model.Body).ToString();
            (baseHolder.GetView(Resource.Id.createAt) as TextView).Text = DateTimeUtils.CommonTime(Convert.ToDateTime(model.DateAdded));
            (baseHolder.GetView(Resource.Id.floor) as TextView).Text    = model.Floor + context.Resources.GetString(Resource.String.floor1);
            try
            {
                var face = model.FaceUrl == "" ? "https://pic.cnblogs.com/face/sample_face.gif" : model.FaceUrl;
                Picasso.With(context)
                .Load(face)
                .Placeholder(Resource.Drawable.placeholder)
                .Error(Resource.Drawable.placeholder)
                .Transform(new CircleTransform())
                .Into(baseHolder.GetView(Resource.Id.avatar) as ImageView);
            }
            catch (Exception)
            {
            }
        }
        protected override void ConvertAsync(RecyclerView.ViewHolder holder, StatusCommentsModel model)
        {
            var baseHolder = holder as BaseAdapter.BaseViewHolder;
            var itemview   = baseHolder.GetConvertView();

            itemview.Tag = model.Id;
            (baseHolder.GetView(Resource.Id.txtUserName) as TextView).Text = HtmlUtils.GetHtml(model.UserDisplayName).ToString();
            (baseHolder.GetView(Resource.Id.txtPostdate) as TextView).Text = DateTimeUtils.CommonTime(Convert.ToDateTime(model.DateAdded));
            (baseHolder.GetView(Resource.Id.txtContent) as TextView).SetText(HtmlUtils.GetHtml(model.Content), TextView.BufferType.Spannable);
            var imgUserUrl = (baseHolder.GetView(Resource.Id.imgUserUrl) as ImageView);

            (baseHolder.GetView(Resource.Id.progressBar) as ProgressBar).Visibility = ViewStates.Gone;
            var imgDelete = (baseHolder.GetView(Resource.Id.imgDelete) as ImageButton);

            imgDelete.Tag = model.Id;
            imgDelete.SetOnClickListener(this);
            if (User != null && User.UserId == model.UserGuid && model.Id > 0)
            {
                imgDelete.Visibility = ViewStates.Visible;
            }
            else
            {
                imgDelete.Visibility = ViewStates.Gone;
            }
            try
            {
                Picasso.With(context)
                .Load(model.UserIconUrl)
                .Placeholder(Resource.Drawable.placeholder)
                .Error(Resource.Drawable.placeholder)
                .Transform(new CircleTransform())
                .Into(imgUserUrl);
            }
            catch
            {
            }
        }
Example #13
0
        private void BindView()
        {
            handler.Post(() =>
            {
                txtTitle.Text     = question.Title;
                txtDateAdded.Text = DateTimeUtils.CommonTime(question.DateAdded);
                if (question.Award > 0)
                {
                    this.txtGold.Text       = question.Award.ToString();
                    this.txtGold.Visibility = ViewStates.Visible;
                }
                else
                {
                    this.txtGold.Visibility = ViewStates.Gone;
                }
                if (question.DealFlag == 1)
                {
                    this.txtDealFlag.Text     = Resources.GetString(Resource.String.question_dealflag_1);
                    this.txtDealFlag.Selected = false;
                }
                else if (question.DealFlag == -1)
                {
                    this.txtDealFlag.Text     = Resources.GetString(Resource.String.question_dealflag_2);
                    this.txtDealFlag.Selected = true;
                }
                else
                {
                    this.txtDealFlag.Text     = Resources.GetString(Resource.String.question_dealflag_0);
                    this.txtDealFlag.Selected = true;
                }
                if (question.Tags != null && question.Tags.Length > 0)
                {
                    txtTag.Visibility = ViewStates.Visible;
                    txtTag.Text       = " " + question.Tags.Replace(',', ' ');
                }
                else
                {
                    txtTag.Visibility = ViewStates.Gone;
                }
                if (question.DiggCount > 0)
                {
                    txtDigg.Text = question.DiggCount.ToString();
                }
                if (question.ViewCount > 0)
                {
                    txtRead.Text = question.ViewCount.ToString();
                }
                if (question.AnswerCount > 0)
                {
                    txtComments.Text = question.AnswerCount.ToString();
                }

                if (question.Content == null || question.Content == "")
                {
                    OnRefresh();
                }
                else
                {
                    var content = HtmlUtils.ReadHtml(Assets);
                    var body    = HtmlUtils.ReplaceHtml(question.Content).Trim('"');
                    if (question.Addition != null)
                    {
                        body += " <h2>ÎÊÌâ²¹³ä£º</h2>" + question.Addition.Content;
                    }
                    txtBody.LoadDataWithBaseURL("file:///android_asset/", content.Replace("#title#", "").Replace("#body#", body), "text/html", "utf-8", null);
                }
                if (question.QuestionUserInfo != null && question.QuestionUserInfo.UserID > 0)
                {
                    txtUserName.Text = HtmlUtils.GetHtml(question.QuestionUserInfo.UserName).ToString();
                    txtScore.Text    = HtmlUtils.GetScoreName(question.QuestionUserInfo.QScore) + " ¡¤ " + question.QuestionUserInfo.QScore + "Ô°¶¹ ¡¤ ";
                    try
                    {
                        Picasso.With(this)
                        .Load("https://pic.cnblogs.com/face/" + question.QuestionUserInfo.IconName)
                        .Placeholder(Resource.Drawable.placeholder)
                        .Error(Resource.Drawable.placeholder)
                        .Transform(new CircleTransform())
                        .Into(imgIconName);
                    }
                    catch (Exception)
                    {
                    }
                }
            });
        }
Example #14
0
        protected override void ConvertAsync(RecyclerView.ViewHolder holder, StatusModel model)
        {
            var baseHolder   = holder as BaseAdapter.BaseViewHolder;
            var linearLayout = (baseHolder.GetView(Resource.Id.linearLayout) as LinearLayout);

            linearLayout.Tag = model.Id;
            linearLayout.SetOnClickListener(this);
            var txtDesc = (baseHolder.GetView(Resource.Id.txtDesc) as TextView);
            var txtParentCommentContent = (baseHolder.GetView(Resource.Id.txtParentCommentContent) as TextView);

            (baseHolder.GetView(Resource.Id.txtUserName) as TextView).Text = HtmlUtils.GetHtml(model.UserDisplayName).ToString();
            (baseHolder.GetView(Resource.Id.txtPostdate) as TextView).Text = DateTimeUtils.CommonTime(Convert.ToDateTime(model.DateAdded));
            var commentCount = (baseHolder.GetView(Resource.Id.txtCommentCount) as TextView);

            if (model.CommentCount > 0)
            {
                commentCount.Text = " " + model.CommentCount;
            }
            else
            {
                commentCount.Text = "";
            }
            var content = (baseHolder.GetView(Resource.Id.txtContent) as TextView);

            (baseHolder.GetView(Resource.Id.progressBar) as ProgressBar).Visibility = ViewStates.Gone;
            var imgUserUrl = (baseHolder.GetView(Resource.Id.imgUserUrl) as ImageView);
            var imgPrivate = (baseHolder.GetView(Resource.Id.imgPrivate) as ImageView);
            var imgDelete  = (baseHolder.GetView(Resource.Id.imgDelete) as ImageButton);

            imgDelete.Tag = model.Id;
            imgDelete.SetOnClickListener(this);
            if (User != null && User.UserId == model.UserGuid && model.Id > 0)
            {
                imgDelete.Visibility = ViewStates.Visible;
            }
            else
            {
                imgDelete.Visibility = ViewStates.Gone;
            }
            if (model.StatusId > 0)
            {
                commentCount.Visibility            = ViewStates.Gone;
                txtDesc.Text                       = "回复了您的评论";
                txtParentCommentContent.Visibility = ViewStates.Visible;
                txtParentCommentContent.SetText(HtmlUtils.GetHtml(model.ParentCommentContent), TextView.BufferType.Spannable);
            }
            else
            {
                commentCount.Visibility            = ViewStates.Visible;
                txtParentCommentContent.Visibility = ViewStates.Gone;
                txtDesc.Text     = "发布了";
                imgDelete.Tag    = model.Id;
                linearLayout.Tag = model.Id;
            }
            if (model.IsPrivate)
            {
                imgPrivate.Visibility = ViewStates.Visible;
                try
                {
                    Picasso.With(context)
                    .Load(Resource.Drawable.isPrivate)
                    .Into(imgPrivate);
                }
                catch
                {
                }
            }
            else
            {
                imgPrivate.Visibility = ViewStates.Gone;
            }
            if (model.IsLucky)
            {
                var Content  = "\u3000" + model.Content + " ";
                var spanText = new SpannableString(HtmlUtils.GetHtml(Content));
                try
                {
                    var imageSpan = new CenteredImageSpan(context, Resource.Drawable.luckystar);
                    spanText.SetSpan(imageSpan, spanText.Length() - 1, spanText.Length(), SpanTypes.InclusiveExclusive);
                }
                catch (Exception ex)
                {
                    MobclickAgent.ReportError(context, ex.Message);
                    spanText.SetSpan(context, spanText.Length() - 1, spanText.Length(), SpanTypes.InclusiveExclusive);
                }

                content.SetText(spanText, TextView.BufferType.Spannable);
            }
            else
            {
                content.SetText(HtmlUtils.GetHtml(model.Content), TextView.BufferType.Spannable);
            }
            try
            {
                Picasso.With(context)
                .Load(model.UserIconUrl)
                .Placeholder(Resource.Drawable.placeholder)
                .Error(Resource.Drawable.placeholder)
                .Transform(new CircleTransform())
                .Into(imgUserUrl);
            }
            catch
            {
            }
        }
Example #15
0
        public void GetClientArticleSuccess(ArticlesModel model)
        {
            if (model != null)
            {
                handler.Post(() =>
                {
                    article          = model;
                    txtTitle.Text    = article.Title;
                    txtAuthor.Text   = HtmlUtils.GetHtml(article.Author).ToString();
                    txtPostdate.Text = DateTimeUtils.CommonTime(article.PostDate);

                    if (article.DiggCount > 0)
                    {
                        txtDigg.Text = article.DiggCount.ToString();
                    }
                    if (article.ViewCount > 0)
                    {
                        txtRead.Text = article.ViewCount.ToString();
                    }
                    if (article.CommentCount > 0)
                    {
                        txtComments.Text = article.CommentCount.ToString();
                    }
                    (txtComments.Parent as FrameLayout).Click += delegate
                    {
                        ArticleCommentsActivity.Start(this, article.BlogApp, article.Id);
                    };
                    (txtBookmark.Parent as FrameLayout).Click += delegate
                    {
                        var linkurl = article.Url;
                        var title   = article.Title + " - " + article.Author + " - ²©¿ÍÔ°";
                        BookmarkAddActivity.Start(this, linkurl, title, true);
                    };

                    if (article.Body == null || article.Body == "")
                    {
                        OnRefresh();
                    }
                    else
                    {
                        GetServiceArticleSuccess(model);
                    }
                    try
                    {
                        Picasso.With(this)
                        .Load(article.Avatar)
                        .Placeholder(Resource.Drawable.placeholder)
                        .Error(Resource.Drawable.placeholder)
                        .Transform(new CircleTransform())
                        .Into(imgAvatar);
                    }
                    catch (Exception)
                    {
                    }
                });
            }
            else
            {
                OnRefresh();
            }
        }