Ejemplo n.º 1
0
 public void onRefresh(PullToRefreshLayout pullToRefreshLayout)
 {
     BaseService.ExeRequest(async() =>
     {
         news = await NewsService.GetNews(CommonHelper.token, 1, pageSize);
         comAdaper.RefreshItems(news);
         pullToRefreshLayout.refreshFinish(0);
     }, this.Activity);
 }
 public void onRefresh(PullToRefreshLayout pullToRefreshLayout)
 {
     BaseService.ExeRequest(async() =>
     {
         articles = await BlogService.GetPickedArticles(CommonHelper.token, 1, pageSize);
         comAdaper.RefreshItems(this.articles);
         pullToRefreshLayout.refreshFinish(0);
     }, this.Activity);
 }
 public void onRefresh(PullToRefreshLayout pullToRefreshLayout)
 {
     BaseService.ExeRequest(async() =>
     {
         articles = await BlogService.GetBolggerPosts(CommonHelper.token, CommonHelper.userInfo.BlogApp, 1);
         comAdaper.RefreshItems(articles);
         pullToRefreshLayout.refreshFinish(0);
     }, this);
 }
Ejemplo n.º 4
0
 public void onRefresh(PullToRefreshLayout pullToRefreshLayout)
 {
     BaseService.ExeRequest(async() =>
     {
         bookMarks = await BookMarkService.GetBookMarks(CommonHelper.token, 1, 15);
         comAdaper.RefreshItems(bookMarks);
         pullToRefreshLayout.refreshFinish(0);
     }, this);
 }
Ejemplo n.º 5
0
 public void onRefresh(PullToRefreshLayout pullToRefreshLayout)
 {
     BaseService.ExeRequest(async() =>
     {
         comments = (await BlogService.GetArticleComments(CommonHelper.token, currentArticle.BlogApp, currentArticle.Id, 1, 15));
         comAdaper.RefreshItems(comments);
         pullToRefreshLayout.refreshFinish(0);
     }, this);
 }
 public void onRefresh(PullToRefreshLayout pullToRefreshLayout)
 {
     BaseService.ExeRequest(async() =>
     {
         comments = (await NewsService.GetNewsComments(CommonHelper.token, newsInfo.Id, 1, 25));
         comAdaper.RefreshItems(comments);
         pullToRefreshLayout.refreshFinish(0);
     }, this);
 }
 public void onLoadMore(PullToRefreshLayout pullToRefreshLayout)
 {
     BaseService.ExeRequest(async() =>
     {
         int pageIndex    = this.articles.Count / pageSize + 1;
         var moreArticles = await BlogService.GetKBArticles(CommonHelper.token, pageIndex, pageSize);
         if (moreArticles.Count > 0)
         {
             articles.AddRange(moreArticles);
             comAdaper.RefreshItems(this.articles);
             int index = (articles.Count - 15) - 3;
             plistView.Invalidate();
             plistView.SetSelection(index);
         }
         else
         {
             Msg.AppMsg.MakeText(this.Activity, "No More Item", Msg.AppMsg.STYLE_INFO).Show();
         }
         pullToRefreshLayout.refreshFinish(0);
     }, this.Activity);
 }
 public void onRefresh(PullToRefreshLayout pullToRefreshLayout)
 {
     BaseService.ExeRequest(async() =>
     {
         content = await BlogService.GetArticleContent(CommonHelper.token, article.Id);
         content = content.Replace("\\r\\n", "</br>").Replace("\\n", "</br>").Replace("\\t", "&nbsp;&nbsp;&nbsp;&nbsp;").Replace("\\", string.Empty);
         content = content.Substring(1, content.Length - 2);
         using (var stream = Assets.Open("articlecontent.html"))
         {
             StreamReader sr = new StreamReader(stream);
             string html     = sr.ReadToEnd();
             sr.Close();
             sr.Dispose();
             html = html.Replace("#title#", article.Title)
                    .Replace("#author#", article.Author)
                    .Replace("#time#", article.PostDate.ToShortDateString())
                    .Replace("#content#", content);
             webView.LoadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null);
         }
         pullToRefreshLayout.refreshFinish(0);
     }, this);
 }
Ejemplo n.º 9
0
        public void onRefresh(PullToRefreshLayout pullToRefreshLayout)
        {
            int id = -1, markType = 1;

            try
            {
                //通过收藏URL判断书签类型
                if (bookMark.LinkUrl.Contains("https://news"))
                {
                    //新闻
                    int lastIndex = bookMark.LinkUrl.LastIndexOf("/");
                    if (lastIndex <= 27)
                    {
                        id = Convert.ToInt32(bookMark.LinkUrl.Substring(27, bookMark.LinkUrl.Length - 27));
                    }
                    else
                    {
                        id = Convert.ToInt32(bookMark.LinkUrl.Substring(27, bookMark.LinkUrl.Length - 28));
                    }
                    markType = 1;
                    CommonHelper.InitalShare(this, null, true, "博客园新闻分享", bookMark.Title, "", bookMark.LinkUrl);
                }
                else if (bookMark.LinkUrl.Contains("http://kb."))
                {
                    //知识库
                    int lastIndex = bookMark.LinkUrl.LastIndexOf("/");
                    if (lastIndex <= 27)
                    {
                        id = Convert.ToInt32(bookMark.LinkUrl.Substring(27, bookMark.LinkUrl.Length - 27));
                    }
                    else
                    {
                        id = Convert.ToInt32(bookMark.LinkUrl.Substring(27, bookMark.LinkUrl.Length - 28));
                    }
                    markType = 2;
                    Button btnViewComments = FindViewById <Button>(Resource.Id.footbar_comments);
                    btnViewComments.Visibility = ViewStates.Gone;
                    LinearLayout linearWriteComments = FindViewById <LinearLayout>(Resource.Id.footbar_write_comment);
                    linearWriteComments.Visibility = ViewStates.Gone;
                    CommonHelper.InitalShare(this, null, true, "知识库分享", bookMark.Title, "", bookMark.LinkUrl);
                }
                else
                {
                    //默认博客类型
                    markType = 3;
                    int startindex = bookMark.LinkUrl.LastIndexOf("/");
                    //bookMark.WzLinkId
                    id = Convert.ToInt32(bookMark.LinkUrl.Substring(startindex + 1, bookMark.LinkUrl.Length - startindex - 6));
                    CommonHelper.InitalShare(this, null, true, "博客园文章分享", bookMark.Title, "", bookMark.LinkUrl);
                }
            }
            catch (Exception)
            {
            }
            if (id == -1)
            {
                using (var stream = Assets.Open("articlecontent.html"))
                {
                    StreamReader sr   = new StreamReader(stream);
                    string       html = sr.ReadToEnd();
                    sr.Close();
                    sr.Dispose();
                    html = html.Replace("#title#", bookMark.Title)
                           .Replace("#author#", "")
                           .Replace("#time#", "收藏于 " + bookMark.DateAdded.ToString("yyyy/MM/dd hh:mm:ss"))
                           .Replace("#content#", "尴尬,这篇文章有点儿小问题,等会儿再看吧");
                    webView.LoadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null);
                }
                pullToRefreshLayout.refreshFinish(0);
            }
            else
            {
                CommonHelper.InitalBookMark(this, bookMark.LinkUrl, bookMark.Title);
                BaseService.ExeRequest(async() =>
                {
                    switch (markType)
                    {
                    case 1:
                        content = await NewsService.GetNewInfo(CommonHelper.token, id);
                        break;

                    case 2:
                        content = await BlogService.GetKbArticleContent(CommonHelper.token, id);
                        break;

                    case 3:
                        content = await BlogService.GetArticleContent(CommonHelper.token, id);
                        break;
                    }
                    content = content.Replace("\\r\\n", "</br>").Replace("\\n", "</br>").Replace("\\t", "&nbsp;&nbsp;&nbsp;&nbsp;").Replace("\\", string.Empty);
                    content = content.Substring(1, content.Length - 2);
                    using (var stream = Assets.Open("articlecontent.html"))
                    {
                        StreamReader sr = new StreamReader(stream);
                        string html     = sr.ReadToEnd();
                        sr.Close();
                        sr.Dispose();
                        html = html.Replace("#title#", bookMark.Title)
                               .Replace("#author#", "")
                               .Replace("#time#", "收藏于 " + bookMark.DateAdded.ToString("yyyy/MM/dd hh:mm:ss"))
                               .Replace("#content#", content);
                        webView.LoadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null);
                    }
                    pullToRefreshLayout.refreshFinish(0);
                }, this);
            }
        }