コード例 #1
0
        public void GetClientArticleSuccess(ArticlesModel model)
        {
            handler.Post(() =>
            {
                article          = model;
                txtTitle.Text    = article.Title;
                txtAuthor.Text   = Html.FromHtml(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)
                {
                }
            });
        }
コード例 #2
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);
                }
            }
        }
コード例 #3
0
ファイル: NewsActivity.cs プロジェクト: zhangzhg0508/Cnblogs
        public void GetClientNewsSuccess(NewsModel model)
        {
            if (model != null)
            {
                news             = model;
                toolbar.Title    = model.Title;
                txtPostdate.Text = "发布于:" + DateTimeUtils.CommonTime(news.DateAdded);

                if (news.DiggCount > 0)
                {
                    txtDigg.Text = news.DiggCount.ToString();
                }
                if (news.ViewCount > 0)
                {
                    txtRead.Text = news.ViewCount.ToString();
                }
                if (news.CommentCount > 0)
                {
                    txtComments.Text = news.CommentCount.ToString();
                }
                (txtComments.Parent as FrameLayout).Click += delegate
                {
                    NewsCommentsActivity.Start(this, news.Id);
                };

                (txtBookmark.Parent as FrameLayout).Click += delegate
                {
                    var linkurl = "https://news.cnblogs.com/n/" + news.Id + "/";
                    var title   = news.Title + "_IT新闻_博客园";
                    BookmarkAddActivity.Start(this, linkurl, title, true);
                };
                if (news.Body == null || news.Body == "")
                {
                    OnRefresh();
                }
                else
                {
                    GetServiceNewsSuccess(model);
                }
            }
        }
コード例 #4
0
ファイル: QuestionActivity.cs プロジェクト: andy1199/Cnblogs
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Id = Intent.GetIntExtra("id", 0);
            questionPresenter = new QuestionPresenter(this);
            handler           = new Handler();

            StatusBarCompat.SetOrdinaryToolBar(this);
            toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            toolbar.SetNavigationIcon(Resource.Drawable.back_24dp);
            SetSupportActionBar(toolbar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            toolbar.SetNavigationOnClickListener(this);
            toolbar.SetOnMenuItemClickListener(this);

            swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout);
            swipeRefreshLayout.SetColorSchemeResources(Resource.Color.primary);
            swipeRefreshLayout.SetOnRefreshListener(this);

            txtTitle     = FindViewById <TextView>(Resource.Id.txtTitle);
            imgIconName  = FindViewById <ImageView>(Resource.Id.imgIconName);
            txtUserName  = FindViewById <TextView>(Resource.Id.txtUserName);
            txtScore     = FindViewById <TextView>(Resource.Id.txtScore);
            txtDateAdded = FindViewById <TextView>(Resource.Id.txtDateAdded);
            txtGold      = FindViewById <TextView>(Resource.Id.txtGold);
            txtDealFlag  = FindViewById <TextView>(Resource.Id.txtDealFlag);
            txtTag       = FindViewById <TextView>(Resource.Id.txtTag);
            this.txtDealFlag.Selected = true;
            txtBody = FindViewById <WebView>(Resource.Id.txtBody);
            txtBody.Settings.JavaScriptEnabled        = true;
            txtBody.Settings.DomStorageEnabled        = true;
            txtBody.Settings.LoadsImagesAutomatically = true;
            txtBody.Settings.DefaultTextEncodingName  = "utf-8";
            txtBody.SetWebViewClient(BodyWebViewClient.With(this));
            txtBody.ScrollBarStyle = ScrollbarStyles.InsideOverlay;
            txtBody.Settings.SetSupportZoom(false);
            txtBody.Settings.BuiltInZoomControls = false;
            txtBody.Settings.CacheMode           = CacheModes.CacheElseNetwork;
            txtBody.Settings.SetLayoutAlgorithm(WebSettings.LayoutAlgorithm.SingleColumn);
            var jsInterface = new WebViewJSInterface(this);

            txtBody.AddJavascriptInterface(jsInterface, "openlistner");
            jsInterface.CallFromPageReceived += delegate(object sender, WebViewJSInterface.CallFromPageReceivedEventArgs e)
            {
                PhotoActivity.Start(this, e.Result.Split(','), e.Index);
            };
            txtDigg          = FindViewById <TextView>(Resource.Id.txtDigg);
            txtRead          = FindViewById <TextView>(Resource.Id.txtRead);
            txtBookmark      = FindViewById <TextView>(Resource.Id.txtBookmark);
            txtComments      = FindViewById <TextView>(Resource.Id.txtComments);
            txtComments.Text = Resources.GetString(Resource.String.answer);

            (txtComments.Parent as FrameLayout).Click += delegate
            {
                if (question != null && question.Qid > 0)
                {
                    QuestionAnswersActivity.Start(this, question.Qid);
                }
            };
            (txtBookmark.Parent as FrameLayout).Click += delegate
            {
                if (question != null && question.Qid > 0)
                {
                    var linkurl = "https://q.cnblogs.com/q/" + question.Qid + "/";
                    var title   = question.Title + "_²©ÎÊ_²©¿ÍÔ°";
                    BookmarkAddActivity.Start(this, linkurl, title, true);
                }
            };
            swipeRefreshLayout.Post(async() =>
            {
                await questionPresenter.GetClientQuestion(Id);
            });
            shareAction = new ShareAction(this).SetDisplayList(SHARE_MEDIA.Weixin, SHARE_MEDIA.WeixinCircle, SHARE_MEDIA.WeixinFavorite, SHARE_MEDIA.Sina).SetShareboardclickCallback(this);
        }