Beispiel #1
0
        void initRecyclerKbArticles()
        {
            adapterKbArticles = new BaseRecyclerViewAdapter <KbArticles>(this.Activity, kbArticlesList, Resource.Layout.item_recyclerview_kbarticles, LoadMoreKbarticles);
            _recyclerView.SetAdapter(adapterKbArticles);
            adapterKbArticles.ItemClick += (position, tag) =>
            {
                System.Diagnostics.Debug.Write(position, tag);
                //AlertUtil.ToastShort(this.Activity, tag);
                DetailKbArticlesActivity.Enter(Activity, int.Parse(tag));
            };
            adapterKbArticles.ItemLongClick += (tag, position) =>
            {
                //AlertUtil.ToastShort(this.Activity, tag);
            };
            string read = Resources.GetString(Resource.String.read);
            string digg = Resources.GetString(Resource.String.digg);

            adapterKbArticles.OnConvertView += (holder, position) =>
            {
                holder.SetText(Resource.Id.tv_dateAdded, kbArticlesList[position].DateAdded.ToCommonString());
                holder.SetText(Resource.Id.tv_viewCount, kbArticlesList[position].ViewCount + " " + read);
                holder.SetText(Resource.Id.tv_summary, kbArticlesList[position].Summary);
                holder.SetText(Resource.Id.tv_diggCount, kbArticlesList[position].Diggcount + " " + digg);
                holder.SetText(Resource.Id.tv_title, kbArticlesList[position].Title);
                holder.SetText(Resource.Id.tv_author, kbArticlesList[position].Author);
                holder.GetView <CardView>(Resource.Id.ly_item).Tag = kbArticlesList[position].Id.ToString();
            };
        }
        void initRecycler()
        {
            adapter = new BaseRecyclerViewAdapter <QuestionCommentViewModel>(this, answerCommentList, Resource.Layout.item_recyclerview_questionAnswerComment, LoadMore);
            _recyclerView.SetAdapter(adapter);
            adapter.ItemClick += (position, tag) => {
                parentCommentId = int.Parse(tag);
                atUserName      = "******" + "@" + answerCommentList[position].PostUserName + "£º" + "</a>";
                edit_content.SetText(HtmlUtil.GetHtml(atUserName), TextView.BufferType.Spannable);
            };
            adapter.ItemLongClick += ItemLongClick;
            string read    = Resources.GetString(Resource.String.read);
            string comment = Resources.GetString(Resource.String.comment);
            string digg    = Resources.GetString(Resource.String.digg);

            adapter.OnConvertView += (holder, position) =>
            {
                var model = answerCommentList[position];
                holder.SetText(Resource.Id.tv_commentUserName, model.PostUserName);
                holder.SetText(Resource.Id.tv_commentDateAdded, model.DateAdded.ToCommonString());
                if (!string.IsNullOrEmpty(model.Content.Trim()))
                {
                    (holder.GetView <TextView>(Resource.Id.tv_commentContent)).SetText(HtmlUtil.GetHtml(model.Content.Trim()), TextView.BufferType.Spannable);
                }
                holder.SetText(Resource.Id.tv_ding, model.DiggCount.ToString());
                holder.SetText(Resource.Id.tv_cai, model.BuryCount.ToString());
                holder.GetView <LinearLayout>(Resource.Id.ly_item).Tag = model.CommentID.ToString();
                //holder.SetText(Resource.Id.tv_commentCount, model..ToString());
                //holder.SetText(Resource.Id.tv_scoreName, HtmlUtil.GetScoreName(model));

                if (model.PostUserInfo != null)
                {
                    holder.SetImageLoader(Resource.Id.iv_commentUserIcon, options, Constact.CnblogsPic + model.PostUserInfo.IconName);
                }
            };
        }
Beispiel #3
0
 async void initRecycler()
 {
     adapter = new BaseRecyclerViewAdapter <Article>(this, articleList, Resource.Layout.item_recyclerview_myblog, LoadMore);
     _recyclerView.SetAdapter(adapter);
     adapter.ItemClick += (position, tag) =>
     {
         System.Diagnostics.Debug.Write(position, tag);
         var intent = new Intent(this, typeof(DetailBlogActivity));
         intent.PutExtra("id", int.Parse(tag));
         StartActivity(intent);
     };
     adapter.ItemLongClick += (tag, position) =>
     {
         //AlertUtil.ToastShort(this, tag);
     };
     adapter.OnConvertView += (holder, position) =>
     {
         holder.SetText(Resource.Id.tv_postDate, articleList[position].PostDate.ToString("yyyy-MM-dd HH:ss"));
         holder.SetText(Resource.Id.tv_viewCount, articleList[position].ViewCount.ToString());
         holder.SetText(Resource.Id.tv_commentCount, articleList[position].CommentCount.ToString());
         holder.SetText(Resource.Id.tv_description, articleList[position].Description);
         holder.SetText(Resource.Id.tv_diggCount, articleList[position].Diggcount.ToString());
         holder.SetText(Resource.Id.tv_title, articleList[position].Title.Replace("\n", "").Replace("  ", ""));
         holder.GetView <LinearLayout>(Resource.Id.ly_item).Tag = articleList[position].Id.ToString();
         holder.SetTagUrl(Resource.Id.iv_avatar, articleList[position].Avatar);
         //ImageLoader.Instance.DisplayImage(articleList[position].Avatar, Resource.Id.iv_avatar);
     };
 }
Beispiel #4
0
 void initRecycler()
 {
     adapter = new BaseRecyclerViewAdapter <NewsViewModel>(this.Activity, newsList, Resource.Layout.item_recyclerview_news, LoadMore);
     _recyclerView.SetAdapter(adapter);
     adapter.ItemClick += (position, tag) =>
     {
         System.Diagnostics.Debug.Write(position, tag);
         //AlertUtil.ToastShort(this.Activity, tag);
         DetailNewsActivity.Enter(Activity, int.Parse(tag));
     };
     adapter.ItemLongClick += (tag, position) =>
     {
         //AlertUtil.ToastShort(this.Activity, tag);
     };
     adapter.OnConvertView += (holder, position) =>
     {
         var model = newsList[position];
         holder.SetText(Resource.Id.tv_description, model.Summary);
         holder.SetText(Resource.Id.tv_title, model.Title);
         holder.SetText(Resource.Id.tv_commentCount, model.CommentCount.ToString());
         holder.SetText(Resource.Id.tv_dateAdded, model.DateAdded.ToCommonString());
         holder.SetText(Resource.Id.tv_diggCount, model.DiggCount.ToString());
         holder.SetText(Resource.Id.tv_viewCount, model.ViewCount.ToString());
         holder.GetView <CardView>(Resource.Id.ly_item).Tag = model.Id.ToString();
         holder.SetImageLoader(Resource.Id.iv_topicIcon, options, model.TopicIcon);
     };
 }
Beispiel #5
0
        void initRecycler()
        {
            adapter = new BaseRecyclerViewAdapter <StatusModel>(this.Activity, statusList, Resource.Layout.item_recyclerview_status, LoadMore);
            _recyclerView.SetAdapter(adapter);
            adapter.ItemClick += (position, tag) =>
            {
                System.Diagnostics.Debug.Write(position, tag);
                //AlertUtil.ToastShort(this.Activity, tag);
                StatusesCommentActivity.Enter(Activity, int.Parse(tag));
            };
            adapter.ItemLongClick += (tag, _position) =>
            {
                if (Activity is MyStatusActivity && position == 0)
                {
                    AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
                    builder.SetCancelable(true);
                    string[] btns  = Resources.GetStringArray(Resource.Array.DialogDelete);
                    var      model = statusList.Find(f => f.Id == int.Parse(tag));
                    builder.SetItems(btns, (s, e) =>
                    {
                        if (e.Which == 0)
                        {
                            Delete(model);
                        }
                    }).Show();
                    //AlertUtil.ToastShort(this.Activity, tag);
                }
            };
            string comment = Resources.GetString(Resource.String.comment);

            adapter.OnConvertView += (holder, position) =>
            {
                //if (position >= statusList.Count)
                //    return;
                var model      = statusList[position];
                var tv_comment = holder.GetView <TextView>(Resource.Id.tv_commentCount);
                if (model.CommentCount == 0)
                {
                    tv_comment.Visibility = ViewStates.Gone;
                }
                else
                {
                    tv_comment.Visibility = ViewStates.Visible;
                    tv_comment.Text       = model.CommentCount.ToString();
                }
                holder.SetText(Resource.Id.tv_dateAdded, model.DateAdded.ToCommonString());
                (holder.GetView <TextView>(Resource.Id.tv_content)).SetText(HtmlUtil.GetHtml(model.Content), TextView.BufferType.Spannable);
                holder.SetText(Resource.Id.tv_userDisplayName, model.UserDisplayName);
                holder.GetView <LinearLayout>(Resource.Id.ly_item).Tag  = model.Id.ToString();
                holder.GetView <ImageView>(Resource.Id.iv_userIcon).Tag = (model.UserIconUrl);
                holder.SetImageLoader(Resource.Id.iv_userIcon, options, model.UserIconUrl);
            };
        }
        void initRecycler()
        {
            adapter = new BaseRecyclerViewAdapter <QuestionModel>(this.Activity, listQuestion, Resource.Layout.item_recyclerview_question, LoadMore);
            _recyclerView.SetAdapter(adapter);
            adapter.ItemClick += (position, tag) =>
            {
                System.Diagnostics.Debug.Write(position, tag);
                //AlertUtil.ToastShort(this.Activity, tag);
                QuestionActivity.Enter(Activity, int.Parse(tag));
            };
            adapter.ItemLongClick += (tag, position) =>
            {
                //AlertUtil.ToastShort(this.Activity, tag);
            };
            string read   = Resources.GetString(Resource.String.read);
            string answer = Resources.GetString(Resource.String.answer);

            try
            {
                adapter.OnConvertView += (holder, position) =>
                {
                    var model = listQuestion[position];
                    holder.SetText(Resource.Id.tv_dateAdded, model.DateAdded.ToCommonString());
                    holder.SetText(Resource.Id.tv_title, model.Title);
                    //holder.SetText(Resource.Id.tv_summary, model.Summary);
                    //holder.SetText(Resource.Id.tv_viewCount, read + " " + model.ViewCount.ToString());
                    holder.SetText(Resource.Id.tv_answerCount, model.AnswerCount.ToString());
                    holder.SetText(Resource.Id.tv_awardCount, model.Award.ToString());
                    TextView tv_tags = (holder.GetView <TextView>(Resource.Id.tv_tags));
                    if (!string.IsNullOrEmpty(model.Tags))
                    {
                        tv_tags.Visibility = ViewStates.Visible;
                        tv_tags.Text       = model.Tags.Replace(',', ' ');
                    }
                    else
                    {
                        tv_tags.Visibility = ViewStates.Gone;
                    }
                    if (model.QuestionUserInfo != null && model.QuestionUserInfo.UserID > 0)
                    {
                        holder.SetText(Resource.Id.tv_userName, model.QuestionUserInfo.UserName);
                        holder.SetImageLoader(Resource.Id.iv_avatar, options, Constact.CnblogsPic + model.QuestionUserInfo.IconName);
                    }
                    holder.GetView <CardView>(Resource.Id.ly_item).Tag = model.Qid.ToString();
                    //holder.SetTag(Resource.Id.ly_item, model.Qid.ToString());
                };
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Write(ex.ToString());
            }
        }
        void initRecycler()
        {
            listStatusComment = listStatusComment.OrderByDescending(s => s.DateAdded).ToList();
            adapter           = new BaseRecyclerViewAdapter <StatusCommentsModel>(this, listStatusComment, Resource.Layout.item_recyclerview_statusComment, () => { });
            _recyclerView.SetAdapter(adapter);
            adapter.ItemClick += (position, tag) =>
            {
                var currentCommentModel = listStatusComment.Find(p => p.Id == int.Parse(tag));
                var userInfo            = UserInfoShared.GetUserInfo(this);
                if (userInfo.DisplayName == currentCommentModel.UserDisplayName)
                {
                    return;
                }
                parentCommentId = currentCommentModel.Id;
                replyToUserId   = currentCommentModel.UserId;
                atUserName      = "******" + currentCommentModel.UserId + "'>@" + currentCommentModel.UserDisplayName + "£º</a>";
                displayUserName = currentCommentModel.UserDisplayName;
                edit_content.SetText(HtmlUtil.GetHtml(atUserName), TextView.BufferType.Spannable);
                // edit_content.Text = "@"+currentCommentModel.UserDisplayName;
            };
            adapter.ItemLongClick += (tag, position) =>
            {
                //ɾ³ýÎÒÆÀÂÛÉÁ´æ
                var model = listStatusComment.Find(f => f.Id == int.Parse(tag));
                var user  = UserInfoShared.GetUserInfo(this);
                if (model.UserDisplayName == user.DisplayName)
                {
                    DeleteComment(model);
                }
            };
            string read = Resources.GetString(Resource.String.read);
            string digg = Resources.GetString(Resource.String.digg);

            adapter.OnConvertView += (holder, position) =>
            {
                holder.SetText(Resource.Id.tv_commentDateAdded, listStatusComment[position].DateAdded.ToCommonString());
                (holder.GetView <TextView>(Resource.Id.tv_commentContent)).SetText(HtmlUtil.GetHtml(listStatusComment[position].Content), TextView.BufferType.Spannable);
                holder.SetImageLoader(Resource.Id.iv_commentUserIcon, options, listStatusComment[position].UserIconUrl);
                holder.SetText(Resource.Id.tv_commentUserName, listStatusComment[position].UserDisplayName);
                holder.SetText(Resource.Id.tv_floor, adapter.ItemCount - position - 1 + "Â¥");
                holder.SetTag(Resource.Id.ly_item, listStatusComment[position].Id.ToString());
            };
        }
Beispiel #8
0
        async void initRecycler()
        {
            adapter = new BaseRecyclerViewAdapter <NewsCommentViewModel>(this, commentList, Resource.Layout.item_newsComment, LoadMore);
            _recyclerView.SetAdapter(adapter);
            adapter.ItemClick += (position, tag) =>
            {
                //System.Diagnostics.Debug.Write(position, tag);
                //var intent = new Intent(this, typeof(DetailBlogActivity));
                //intent.PutExtra("id", int.Parse(tag));
                //StartActivity(intent);
            };
            adapter.ItemLongClick += (tag, position) =>
            {
                if (!isAt)//目前仅支持at一次
                {
                    isAt       = true;
                    PARENTID   = commentList[position].ParentCommentID;
                    atUserName = commentList[position].UserName;
                    string temp = edit_content.Text;
                    edit_content.Text = "@" + atUserName + temp;
                    edit_content.SetSelection(edit_content.Text.Length);
                }
                //AlertUtil.ToastShort(this, tag);
            };
            string read    = Resources.GetString(Resource.String.read);
            string comment = Resources.GetString(Resource.String.comment);
            string digg    = Resources.GetString(Resource.String.digg);

            adapter.OnConvertView += (holder, position) =>
            {
                var model = commentList[position];
                holder.SetText(Resource.Id.tv_commentUserName, model.UserName);
                holder.SetText(Resource.Id.tv_ding, model.AgreeCount.ToString());
                holder.SetText(Resource.Id.tv_cai, model.AntiCount.ToString());
                holder.SetText(Resource.Id.tv_commentUserName, model.UserName);
                holder.SetText(Resource.Id.tv_commentDateAdded, model.DateAdded.ToCommonString());
                (holder.GetView <TextView>(Resource.Id.tv_commentContent)).SetText(HtmlUtil.GetHtml(model.CommentContent), TextView.BufferType.Spannable);
                holder.SetText(Resource.Id.tv_floor, model.Floor + "楼");
                holder.GetView <LinearLayout>(Resource.Id.ly_item).Tag = model.CommentID.ToString();
                holder.SetImageLoader(Resource.Id.iv_commentUserIcon, options, model.FaceUrl);
            };
        }
        void initRecycler()
        {
            adapter = new BaseRecyclerViewAdapter <QuestionAnswerViewModel>(this, answerList, Resource.Layout.item_recyclerview_questionAnswer, LoadMore);
            _recyclerView.SetAdapter(adapter);
            adapter.ItemClick += (position, tag) =>
            {
                QuestionAnswerCommentActivity.Enter(this, questionId, int.Parse(tag));
            };
            adapter.ItemLongClick += ItemLongClick;
            string read    = Resources.GetString(Resource.String.read);
            string comment = Resources.GetString(Resource.String.comment);
            string digg    = Resources.GetString(Resource.String.digg);

            adapter.OnConvertView += (holder, position) =>
            {
                var model = answerList[position];
                holder.SetText(Resource.Id.tv_commentUserName, model.UserName);
                holder.SetText(Resource.Id.tv_commentDateAdded, model.DateAdded.ToCommonString());
                if (!string.IsNullOrEmpty(model.Answer.Trim()))
                {
                    (holder.GetView <TextView>(Resource.Id.tv_commentContent)).SetText(HtmlUtil.GetHtml(model.Answer.Trim()), TextView.BufferType.Spannable);
                }
                //holder.SetText(Resource.Id.tv_userName, model.UserName);
                holder.GetView <LinearLayout>(Resource.Id.ly_item).Tag = model.AnswerID.ToString();
                holder.SetText(Resource.Id.tv_commentCount, model.CommentCounts.ToString());
                holder.SetText(Resource.Id.tv_scoreName, HtmlUtil.GetScoreName(model.Score));
                if (model.IsBest)
                {
                    holder.GetView <TextView>(Resource.Id.tv_isBest).Visibility = ViewStates.Visible;
                }
                else
                {
                    holder.GetView <TextView>(Resource.Id.tv_isBest).Visibility = ViewStates.Gone;
                }
                if (model != null)
                {
                    holder.SetImageLoader(Resource.Id.iv_commentUserIcon, options, Constact.CnblogsPic + model.AnswerUserInfo.IconName);
                }
            };
        }
 void initRecycler()
 {
     try
     {
         adapter = new BaseRecyclerViewAdapter <Article>(this.Activity, articleList, Resource.Layout.item_recyclerview_article, LoadMore);
         _recyclerView.SetAdapter(adapter);
         adapter.ItemClick += (position, tag) =>
         {
             System.Diagnostics.Debug.Write(position, tag);
             //AlertUtil.ToastShort(this.Activity, tag);
             var intent = new Intent(Activity, typeof(DetailBlogActivity));
             intent.PutExtra("id", int.Parse(tag));
             StartActivity(intent);
         };
         adapter.ItemLongClick += (tag, position) =>
         {
             //AlertUtil.ToastShort(this.Activity, tag);
         };
         adapter.OnConvertView += (holder, position) =>
         {
             holder.SetText(Resource.Id.tv_author, articleList[position].Author);
             holder.SetText(Resource.Id.tv_postDate, articleList[position].PostDate.ToCommonString());
             holder.SetText(Resource.Id.tv_viewCount, articleList[position].ViewCount.ToString());
             holder.SetText(Resource.Id.tv_commentCount, articleList[position].CommentCount.ToString());
             holder.SetText(Resource.Id.tv_description, articleList[position].Description);
             holder.SetText(Resource.Id.tv_diggCount, articleList[position].Diggcount.ToString());
             holder.SetText(Resource.Id.tv_title, articleList[position].Title);
             //holder.SetTag(Resource.Id.ly_item, articleList[position].Id.ToString());
             holder.GetView <CardView>(Resource.Id.ly_item).Tag = articleList[position].Id.ToString();
             holder.SetTagUrl(Resource.Id.iv_avatar, articleList[position].Avatar);
             holder.SetImageLoader(Resource.Id.iv_avatar, options, articleList[position].Avatar);
         };
     }
     catch (Exception ex)
     {
     }
 }
Beispiel #11
0
        void initRecycler()
        {
            adapter = new BaseRecyclerViewAdapter <ArticleCommentModel>(this, commentList, Resource.Layout.item_recyclerview_statusComment, LoadMore);
            _recyclerView.SetAdapter(adapter);
            adapter.ItemClick += (position, tag) =>
            {
                System.Diagnostics.Debug.Write(position, tag);
                var intent = new Intent(this, typeof(DetailBlogActivity));
                intent.PutExtra("id", int.Parse(tag));
                StartActivity(intent);
            };
            adapter.ItemLongClick += (tag, position) =>
            {
                if (!isAt)
                {
                    isAt = true;
                    string temp = edit_content.Text;
                    edit_content.Text = "@" + atUserName + temp;
                    edit_content.SetSelection(edit_content.Text.Length);
                }
            };
            string read    = Resources.GetString(Resource.String.read);
            string comment = Resources.GetString(Resource.String.comment);
            string digg    = Resources.GetString(Resource.String.digg);

            adapter.OnConvertView += (holder, position) =>
            {
                var model = commentList[position];
                holder.SetText(Resource.Id.tv_commentUserName, model.Author);
                holder.SetText(Resource.Id.tv_commentDateAdded, model.DateAdded.ToCommonString());
                (holder.GetView <TextView>(Resource.Id.tv_commentContent)).SetText(HtmlUtil.GetHtml(model.Body), TextView.BufferType.Spannable);
                holder.SetText(Resource.Id.tv_floor, model.Floor + "楼");
                holder.GetView <LinearLayout>(Resource.Id.ly_item).Tag = model.Id.ToString();
                holder.SetImageLoader(Resource.Id.iv_commentUserIcon, options, model.FaceUrl);
            };
        }
        async void initRecycler()
        {
            adapter = new BaseRecyclerViewAdapter <ZzkDocumentViewModel>(this, searchList, Resource.Layout.item_recyclerview_search, LoadMore);
            _recyclerView.SetAdapter(adapter);
            adapter.ItemClick += (position, tag) =>
            {
                var tempModel = searchList[position];
                tempModel.Title = tempModel.Title.Replace("<strong>", "").Replace("</strong>", "");
                switch (category)
                {
                case "Blog":
                    string  tempstr = tempModel.Uri.Replace("http://www.cnblogs.com/", "");
                    string  blogApp = tempstr.Substring(0, tempstr.IndexOf("/"));
                    Article article = new Article()
                    {
                        Id = int.Parse(tempModel.Id), Avatar = "", BlogApp = blogApp, Title = tempModel.Title, Author = tempModel.UserName, Url = tempModel.Uri, PostDate = tempModel.PublishTime, CommentCount = tempModel.CommentTimes, ViewCount = tempModel.ViewTimes, Diggcount = tempModel.VoteTimes
                    };
                    DetailBlogActivity.Enter(this, int.Parse(tag), article);
                    break;

                case "News":
                    NewsViewModel news = new NewsViewModel()
                    {
                        Id = int.Parse(tempModel.Id), Title = tempModel.Title, ViewCount = tempModel.ViewTimes, CommentCount = tempModel.CommentTimes, DiggCount = tempModel.VoteTimes, DateAdded = tempModel.PublishTime
                    };
                    DetailNewsActivity.Enter(this, int.Parse(tag), news);
                    break;

                case "Question":
                    QuestionActivity.Enter(this, int.Parse(tag), true);
                    break;

                case "Kb":
                    KbArticles kb = new KbArticles()
                    {
                        Id = int.Parse(tempModel.Id), Title = tempModel.Title, ViewCount = tempModel.ViewTimes, DateAdded = tempModel.PublishTime, Author = tempModel.UserName
                    };
                    DetailKbArticlesActivity.Enter(this, int.Parse(tag), kb);
                    break;

                default:
                    break;
                }
            };
            adapter.ItemLongClick += (tag, position) =>
            {
                AlertUtil.ToastShort(this, tag);
            };
            string read    = Resources.GetString(Resource.String.read);
            string comment = Resources.GetString(Resource.String.comment);
            string digg    = Resources.GetString(Resource.String.digg);

            adapter.OnConvertView += (holder, position) =>
            {
                var tempModel = searchList[position];
                if (tempModel.Id == null && !string.IsNullOrEmpty(tempModel.Uri))//问答id返回的是null,自己正则获取
                {
                    Regex regex = new Regex("\\d");
                    tempModel.Id = regex.Match(tempModel.Uri).Value;
                }
                //holder.SetText(Resource.Id.tv_dateAdded, tempModel.PublishTime.ToCommonString());
                holder.SetText(Resource.Id.tv_viewCount, tempModel.ViewTimes + " " + read);
                holder.SetText(Resource.Id.tv_commentCount, tempModel.CommentTimes + " " + comment);
                holder.SetText(Resource.Id.tv_diggCount, tempModel.VoteTimes + " " + digg);
                holder.SetText(Resource.Id.tv_url, tempModel.Uri);
                holder.SetText(Resource.Id.tv_author, tempModel.UserName);

                holder.GetView <LinearLayout>(Resource.Id.ly_item).Tag          = tempModel.Id.ToString();
                (holder.GetView <TextView>(Resource.Id.tv_title)).TextFormatted = Html.FromHtml(tempModel.Title.replaceStrongToFont());
                string tempstr = "<font color='#707070'>" + tempModel.PublishTime.ToString("yyyy年MM月dd日 HH:mm") + "</font>  " + tempModel.Content.replaceStrongToFont();
                (holder.GetView <TextView>(Resource.Id.tv_summary)).TextFormatted = Html.FromHtml(tempstr);
            };
        }
Beispiel #13
0
        async void initRecycler()
        {
            adapter = new BaseRecyclerViewAdapter <BookmarksModel>(this, bookMarkList, Resource.Layout.item_recyclerview_myBookmark, LoadMore);
            //  View  footerView = LayoutInflater.From(Activity).Inflate(Resource.Layout.item_recyclerView_footer_loading, null);
            _recyclerView.SetAdapter(adapter);
            adapter.ItemClick += (position, tag) =>
            {
                System.Diagnostics.Debug.Write(position, tag);
                //  AlertUtil.ToastShort(this, tag);
                //  var intent = new Intent(this, typeof(DetailBlogActivity));
                //intent.PutExtra("id", int.Parse(tag));
                //StartActivity(intent);
            };
            adapter.ItemLongClick += (tag, position) =>
            {
                //AlertUtil.ToastShort(this,tag);
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.SetCancelable(true);
                string[] items = Resources.GetStringArray(Resource.Array.DialogMenu);

                ProgressDialog progressDialog = new ProgressDialog(this);
                progressDialog.SetProgressStyle(ProgressDialogStyle.Spinner);
                progressDialog.SetMessage("删除中....");
                var model = bookMarkList.Find(f => f.WzLinkId == int.Parse(tag));
                builder.SetItems(items, (s, e) =>
                {
                    switch (e.Which)
                    {
                    case 0:
                        Delete(progressDialog, model);
                        break;

                    case 1:
                        AddBookmarkActivity.Enter(this, model.WzLinkId, model.LinkUrl, model.Title, model.Tag, model.Summary, "edit");
                        break;

                    case 2:
                        AlertUtil.ToastShort(this, "该功能暂时未推出,敬请期待");
                        break;
                    }
                });
                builder.Show();
            };
            string read    = Resources.GetString(Resource.String.read);
            string comment = Resources.GetString(Resource.String.comment);
            string digg    = Resources.GetString(Resource.String.digg);

            adapter.OnConvertView += (holder, position) =>
            {
                var model = bookMarkList[position];
                holder.SetText(Resource.Id.tv_dateAdded, model.DateAdded.ToString("yyyy-MM-dd HH:ss"));
                holder.SetText(Resource.Id.tv_title, model.Title);
                holder.SetText(Resource.Id.tv_summary, model.Summary);
                holder.SetText(Resource.Id.tv_url, model.LinkUrl);
                holder.GetView <CardView>(Resource.Id.ly_item).Tag = model.WzLinkId.ToString();
                TextView tv_tags    = (holder.GetView <TextView>(Resource.Id.tv_tags));
                TextView tv_summary = (holder.GetView <TextView>(Resource.Id.tv_summary));
                if (!string.IsNullOrEmpty(model.Tag))
                {
                    tv_tags.Visibility = ViewStates.Visible;
                    tv_tags.Text       = model.Tag.Replace(",", " ");
                    //holder.SetText(Resource.Id.tv_tags, model.Tag.Replace(",", " "));
                }
                else
                {
                    tv_tags.Visibility = ViewStates.Gone;
                }
                if (!string.IsNullOrEmpty(model.Summary))
                {
                    tv_summary.Visibility = ViewStates.Visible;
                    tv_summary.Text       = model.Summary;
                }
                else
                {
                    tv_summary.Visibility = ViewStates.Gone;
                }
            };
        }