示例#1
0
        private async Task <List <ArticleCommentModel> > listArticleCommentServer()
        {
            try
            {
                var token  = UserTokenUtil.GetToken(this);
                var result = await ArticleService.ListArticleComment(token, blogApp, postId, pageIndex);

                if (result.Success)
                {
                    _swipeRefreshLayout.Refreshing = false;

                    await SQLiteUtil.UpdateArticlecommentList(result.Data);

                    return(result.Data);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                MobclickAgent.ReportError(this, ex.ToString());
                System.Diagnostics.Debug.Write(ex.ToString());
                return(null);
            }
        }
示例#2
0
        public async void OnRefresh()
        {
            _swipeRefreshLayout.Post(() => {
                _swipeRefreshLayout.Refreshing = true;
            });
            pageIndex = 1;
            var result = await UserInfoService.GetMyBlogPosts(UserTokenUtil.GetToken(this), blogApp, pageIndex);

            if (result.Success)
            {
                articleList = result.Data;
                initRecycler();
                if (articleList.Count != 0)
                {
                    articleList.ForEach(f => f.MySelf = true);
                    await SQLiteUtil.UpdateArticleList(articleList);
                }
                _swipeRefreshLayout.Post(() => {
                    _swipeRefreshLayout.Refreshing = false;
                });
            }
            else
            {
                AlertUtil.ToastShort(this, result.Message);
                _swipeRefreshLayout.Post(() => {
                    _swipeRefreshLayout.Refreshing = false;
                });
            }
        }
示例#3
0
        private async void LoadMore()
        {
            pageIndex++;
            var result = await ArticleService.ListArticle(AccessTokenUtil.GetToken(this.Activity), pageIndex, position);

            if (result.Success)
            {
                var tempList = result.Data;
                if (tempList == null || tempList.Count == 0)
                {
                    AlertUtil.ToastShort(Activity, "ÍøÂ粻̫ºÃŶ");
                }
                else
                {
                    // Thread.Sleep(2000);
                    articleList.AddRange(tempList);
                    adapter.SetNewData(articleList);
                    adapter.NotifyItemRemoved(adapter.ItemCount);
                    await SQLiteUtil.UpdateArticleList(tempList);

                    System.Diagnostics.Debug.Write("Ò³Êý:" + pageIndex + "Êý¾Ý×ÜÌõÊý£º" + articleList.Count);
                }
            }
            else
            {
                AlertUtil.ToastShort(Activity, result.Message);
            }
        }
        async void GetClientStatus(int id)
        {
            try
            {
                status = await SQLiteUtil.SelectStatus(id);

                if (status != null)
                {
                    tv_userDisplayName.Text = status.UserDisplayName;
                    tv_dateAdded.Text       = status.DateAdded.ToCommonString();
                    tv_content.Text         = status.Content;
                    if (!status.UserIconUrl.Substring(status.UserIconUrl.Length - 4, 4).Contains(".png"))
                    {
                        iv_userIcon.SetImageResource(Resource.Drawable.noavatar);
                    }
                    else
                    {
                        ImageLoader.Instance.DisplayImage(status.UserIconUrl, iv_userIcon, options);
                    }
                }
            }
            catch (Exception ex)
            {
                MobclickAgent.ReportError(this, ex.ToString());
            }
        }
示例#5
0
        async void InitArticle()
        {
            string articleStr = Intent.GetStringExtra("article");

            if (!string.IsNullOrEmpty(articleStr))   //从搜索页过来的
            {
                article = JsonConvert.DeserializeObject <Article>(articleStr);
            }
            if (article == null)    //从博客页面直接点击过来的
            {
                article = await SQLiteUtil.SelectArticle(ID);
            }
            if (article != null)
            {
                OnRefresh();
                tv_author.Text       = article.Author;
                tv_postDate.Text     = article.PostDate.ToCommonString();
                tv_articleTitle.Text = article.Title.Replace("\n", "").Replace("  ", "");
                tv_view.Text         = article.ViewCount.ToString();
                tv_ding.Text         = article.Diggcount.ToString();
                btn_comment.Text     = article.CommentCount.ToString();
                if (string.IsNullOrEmpty(article.Avatar) || !article.Avatar.Substring(article.Avatar.Length - 4, 4).Contains(".png"))
                {
                    iv_avatar.SetImageResource(Resource.Drawable.noavatar);
                }
                else
                {
                    ImageLoader.Instance.DisplayImage(article.Avatar, iv_avatar, options);
                }
            }
        }
示例#6
0
 public async void OnRefresh()
 {
     try
     {
         pageIndex = 1;
         _swipeRefreshLayout.Post(() =>
         {
             _swipeRefreshLayout.Refreshing = true;
         });
         var result = new ApiResult <List <StatusModel> >();
         if (isMy)
         {
             result = await StatusService.ListStatus(userToken, position, pageIndex, true);
         }
         else
         {
             if (position != 0)
             {
                 result = await StatusService.ListStatus(UserTokenUtil.GetToken(Activity), position, pageIndex, false);
             }
             else
             {
                 result = await StatusService.ListStatus(accessToken, position, pageIndex, false);
             }
         }
         if (result.Success)
         {
             statusList = result.Data;
             if (statusList.Count != 0)
             {
                 if (isMy)
                 {
                     statusList.ForEach(f => f.MySelf = true);
                 }
                 initRecycler();
                 await SQLiteUtil.UpdateStatusList(statusList);
             }
             _swipeRefreshLayout.Post(() =>
             {
                 _swipeRefreshLayout.Refreshing = false;
             });
         }
         else
         {
             AlertUtil.ToastShort(Activity, result.Message);
             _swipeRefreshLayout.Post(() =>
             {
                 _swipeRefreshLayout.Refreshing = false;
             });
         }
     }
     catch (Exception ex)
     {
         AlertUtil.ToastShort(Activity, ex.Message);
         _swipeRefreshLayout.Post(() =>
         {
             _swipeRefreshLayout.Refreshing = false;
         });
     }
 }
示例#7
0
        private async Task <List <QuestionModel> > listQuestionService()
        {
            var result = new ApiResult <List <QuestionModel> >();

            if (isMy)
            {
                var user = UserInfoShared.GetUserInfo(this.Activity);
                result = await QuestionService.ListQuestion(UserTokenUtil.GetToken(this.Activity), position, pageIndex, true, user.SpaceUserId);
            }
            else
            {
                result = await QuestionService.ListQuestion(AccessTokenUtil.GetToken(this.Activity), position, pageIndex, false, 0);
            }
            if (result.Success)
            {
                _swipeRefreshLayout.Refreshing = false;
                try
                {
                    await SQLiteUtil.UpdateListQuestion(result.Data, isMy);

                    return(result.Data);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.Write(ex.ToString());
                    return(null);
                }
            }
            return(null);
        }
示例#8
0
        public override async void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);
            ly_expire           = view.FindViewById <LinearLayout>(Resource.Id.ly_expire);
            tv_startLogin       = view.FindViewById <TextView>(Resource.Id.tv_startLogin);
            _swipeRefreshLayout = view.FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout);
            _swipeRefreshLayout.SetColorSchemeResources(Resource.Color.primary);
            _swipeRefreshLayout.SetOnRefreshListener(this);
            userToken   = UserTokenUtil.GetToken(Activity);
            accessToken = AccessTokenUtil.GetToken(Activity);

            _recyclerView = view.FindViewById <RecyclerView>(Resource.Id.recyclerView);
            _recyclerView.SetLayoutManager(new Android.Support.V7.Widget.LinearLayoutManager(this.Activity));
            //_recyclerView.AddItemDecoration(new RecyclerViewDecoration(this.Activity, (int)Orientation.Vertical));
            try
            {
                if (position != 0 || isMy) //³ýÁË×îÐÂÉÁ´æ£¬ÆäËûµÄ¶¼Òªusertoken
                {
                    if (UserUtil.Instance(Activity).LoginExpire())
                    {
                        ly_expire.Visibility           = ViewStates.Visible;
                        _swipeRefreshLayout.Visibility = ViewStates.Gone;
                        tv_startLogin.Click           += (s, e) =>
                        {
                            Activity.StartActivity(new Intent(Activity, typeof(loginactivity)));
                        };
                    }
                    else
                    {
                        ly_expire.Visibility           = ViewStates.Gone;
                        _swipeRefreshLayout.Visibility = ViewStates.Visible;
                        statusList = await SQLiteUtil.SelectStatusList(Constact.PageSize, isMy);

                        if (statusList != null && statusList.Count != 0)
                        {
                            initRecycler();
                        }
                        OnRefresh();
                    }
                }
                else
                {
                    ly_expire.Visibility           = ViewStates.Gone;
                    _swipeRefreshLayout.Visibility = ViewStates.Visible;
                    statusList = await SQLiteUtil.SelectStatusList(Constact.PageSize);

                    if (statusList != null && statusList.Count != 0)
                    {
                        initRecycler();
                    }
                    OnRefresh();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Write("statusTabFragment", ex.ToString());
            }
        }
示例#9
0
        public async void OnRefresh()
        {
            _swipeRefreshLayout.Post(() => {
                _swipeRefreshLayout.Refreshing = true;
            });
            pageIndex = 1;
            if (position == 3)
            {
                var result = await KbArticlesService.ListKbArticle(AccessTokenUtil.GetToken(this.Activity), pageIndex);

                if (result.Success)
                {
                    //var tempList = result.Data;
                    kbArticlesList = result.Data;
                    adapterKbArticles.SetNewData(kbArticlesList);
                    if (kbArticlesList != null && kbArticlesList.Count != 0)
                    {
                        await SQLiteUtil.UpdateKbArticlesList(result.Data);
                    }
                    _swipeRefreshLayout.Refreshing = false;
                }
                else
                {
                    AlertUtil.ToastShort(Activity, result.Message);
                    _swipeRefreshLayout.Refreshing = false;
                }
            }
            else
            {
                var result = await NewsService.ListNews(AccessTokenUtil.GetToken(this.Activity), pageIndex, position);

                if (result.Success)
                {
                    newsList = result.Data;
                    if (position == 1)
                    {
                        newsList.ForEach(f => f.IsHot = true);
                    }
                    if (position == 2)
                    {
                        newsList.ForEach(f => f.IsRecommend = true);
                    }
                    adapter.SetNewData(newsList);
                    if (newsList != null && newsList.Count != 0)
                    {
                        await SQLiteUtil.UpdateNewsList(newsList);
                    }
                    _swipeRefreshLayout.Refreshing = false;
                }
                else
                {
                    AlertUtil.ToastShort(Activity, result.Message);
                    _swipeRefreshLayout.Refreshing = false;
                }
            }
        }
示例#10
0
        public async void OnRefresh()
        {
            _swipeRefreshLayout.Post(() =>
            {
                _swipeRefreshLayout.Refreshing = true;
            });
            pageIndex = 1;
            var result = new ApiResult <List <QuestionModel> >();

            if (isMy)
            {
                //var user = UserInfoShared.GetUserInfo(this.Activity);
                result = await QuestionService.ListQuestion(UserTokenUtil.GetToken(this.Activity), position, pageIndex, true, userInfo.SpaceUserId);
            }
            else
            {
                result = await QuestionService.ListQuestion(AccessTokenUtil.GetToken(this.Activity), position, pageIndex, false, 0);
            }
            if (result.Success)
            {
                listQuestion = result.Data;
                if (!isFirstRefresh)
                {
                    adapter.SetNewData(listQuestion);
                }
                else
                {
                    initRecycler();
                    try
                    {
                        await SQLiteUtil.UpdateListQuestion(listQuestion, isMy);
                    }
                    catch (Exception ex)
                    {
                        //todo
                        //AlertUtil.ToastShort(Activity,ex.ToString());
                    }
                }
                isFirstRefresh = false;
                _swipeRefreshLayout.Post(() =>
                {
                    _swipeRefreshLayout.Refreshing = false;
                });
            }
            else
            {
                AlertUtil.ToastShort(Activity, result.Message);
                _swipeRefreshLayout.Post(() =>
                {
                    _swipeRefreshLayout.Refreshing = false;
                });
            }
        }
示例#11
0
 async void GetClientQuestion(int id)
 {
     try
     {
         bool isSearch = Intent.GetBooleanExtra("issearch", false);
         if (!isSearch)
         {
             question = await SQLiteUtil.SelectQuestion(id);
         }
         BindView();
     }
     catch (Exception ex)
     {
         MobclickAgent.ReportError(this, ex.ToString());
     }
 }
示例#12
0
        private async void LoadMoreKbarticles()
        {
            pageIndex++;
            var result = await KbArticlesService.ListKbArticle(AccessTokenUtil.GetToken(this.Activity), pageIndex);

            if (result.Success)
            {
                var tempList = result.Data;
                kbArticlesList.AddRange(tempList);
                adapterKbArticles.SetNewData(kbArticlesList);
                await SQLiteUtil.UpdateKbArticlesList(tempList);
            }
            else
            {
                AlertUtil.ToastShort(Activity, result.Message);
            }
        }
 //ÇëÇóÉÁ´æÆÀÂ۳ɹ¦µÄ»Øµ÷
 async void callBackSuccess(List <StatusCommentsModel> list)
 {
     AlertUtil.ToastShort(this, "Ïß³ÌID" + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString());
     try
     {
         await SQLiteUtil.UpdateStatuscommentList(list);
     }
     catch (Exception ex)
     {
     }
     listStatusComment = list;
     initRecycler();
     _swipeRefreshLayout.PostDelayed(() =>
     {
         _swipeRefreshLayout.Refreshing = false;
     }, 500);
 }
示例#14
0
        private async Task <List <NewsViewModel> > listNewsLocal()
        {
            switch (position)
            {
            case 1:
                return(await SQLiteUtil.SelectNewsListByDigg(Constact.PageSize));

            case 2:
                return(await SQLiteUtil.SelectNewsListByHotWeek(Constact.PageSize));

            case 0:
                return(await SQLiteUtil.SelectNewsList(Constact.PageSize));

            default:
                return(await SQLiteUtil.SelectNewsList(Constact.PageSize));
            }
        }
示例#15
0
        private async void LoadMore()
        {
            pageIndex++;
            var result = await NewsService.ListNews(AccessTokenUtil.GetToken(this.Activity), pageIndex, position);

            if (result.Success)
            {
                var tempList = result.Data;
                newsList.AddRange(tempList);
                adapter.SetNewData(newsList);
                await SQLiteUtil.UpdateNewsList(tempList);
            }
            else
            {
                AlertUtil.ToastShort(Activity, result.Message);
            }
        }
示例#16
0
        public async void OnRefresh()
        {
            _swipeRefreshLayout.Post(() =>
            {
                _swipeRefreshLayout.Refreshing = true;
            });
            pageIndex = 1;
            var result = await ArticleService.ListArticle(accessToken, pageIndex, position);

            if (result.Success)
            {
                var tempList = result.Data;
                if (tempList != null && tempList.Count > 0)
                {
                    articleList = tempList;
                    if (isFirstRefresh)
                    {
                        initRecycler();
                    }
                    else
                    {
                        adapter.SetNewData(tempList);
                        isFirstRefresh = false;
                    }
                    await SQLiteUtil.UpdateArticleList(tempList);
                }
                else
                {
                    AlertUtil.ToastShort(Activity, "ÍøÂ粻̫ºÃŶ");
                }
                _swipeRefreshLayout.PostDelayed(() =>
                {
                    _swipeRefreshLayout.Refreshing = false;
                }, 800);
            }
            else
            {
                AlertUtil.ToastShort(Activity, result.Message);
                _swipeRefreshLayout.PostDelayed(() =>
                {
                    _swipeRefreshLayout.Refreshing = false;
                }, 800);
            }
        }
示例#17
0
        public override async void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);
            ly_expire           = view.FindViewById <LinearLayout>(Resource.Id.ly_expire);
            tv_startLogin       = view.FindViewById <TextView>(Resource.Id.tv_startLogin);
            _swipeRefreshLayout = view.FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout);
            _swipeRefreshLayout.SetColorSchemeResources(Resource.Color.primary);
            _swipeRefreshLayout.SetOnRefreshListener(this);
            _swipeRefreshLayout.Post(() =>
            {
                _swipeRefreshLayout.Refreshing = true;
            });
            _swipeRefreshLayout.PostDelayed(() =>
            {
                System.Diagnostics.Debug.Write("PostDelayed刷新已经完成");
                _swipeRefreshLayout.Refreshing = false;
            }, 4000);
            _recyclerView = view.FindViewById <RecyclerView>(Resource.Id.recyclerView);
            _recyclerView.SetLayoutManager(new Android.Support.V7.Widget.LinearLayoutManager(this.Activity));
            //_recyclerView.AddItemDecoration(new RecyclerViewDecoration(this.Activity, (int)Orientation.Vertical));
            Token token = UserTokenUtil.GetToken(Activity);

            if (position == 3)
            {
                //kbArticlesList = await listKbArticleLocal();
                kbArticlesList = await SQLiteUtil.SelectKbArticleList(Constact.PageSize);

                if (kbArticlesList != null)
                {
                    initRecyclerKbArticles();
                }
            }
            else
            {
                newsList = await listNewsLocal();

                if (newsList != null)
                {
                    initRecycler();
                }
            }
            OnRefresh();
        }
示例#18
0
        private async void LoadMore()
        {
            pageIndex++;
            var result = await UserInfoService.GetMyBlogPosts(UserTokenUtil.GetToken(this), blogApp, pageIndex);

            if (result.Success)
            {
                var tempList = result.Data;
                tempList.ForEach(f => f.MySelf = true);
                await SQLiteUtil.UpdateArticleList(tempList);

                articleList.AddRange(tempList);
                adapter.SetNewData(articleList);
            }
            else
            {
                AlertUtil.ToastShort(this, result.Message);
            }
        }
示例#19
0
        public override void OnCreate()
        {
            base.OnCreate();
            ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(this).WriteDebugLogs().Build();

            ImageLoader.Instance.Init(configuration);//初始化图片加载框架
            Config.Debug = true;
            SQLiteUtil.Instance();
            MobclickAgent.SetDebugMode(true);//开启调试模式,如果不开启则不会上传umeng统计
            MobclickAgent.OpenActivityDurationTrack(false);
            MobclickAgent.SetScenarioType(this, MobclickAgent.EScenarioType.EUmNormal);
            PlatformConfig.SetWeixin("wx633888643fbae319", "5034ad765b2ba64dec7ed7c6618581fb");
            PlatformConfig.SetSinaWeibo("1422675167", "02975c36afd93d3ae983f8da9e596b86", "https://api.weibo.com/oauth2/default.html");
            PlatformConfig.SetQQZone("100424468", "c7394704798a158208a74ab60104f0ba");
            if (!BuildConfig.Debug)
            {
                AndroidEnvironment.UnhandledExceptionRaiser += AndroidEnvironment_UnhandledExceptionRaiser;
            }
            activities = new List <Activity>();
        }
        async void  InitKbArticle()
        {
            string kbStr = Intent.GetStringExtra("kb");

            if (string.IsNullOrEmpty(kbStr))
            {
                kbArticles = await SQLiteUtil.SelectKbArticles(ID);
            }
            else
            {
                kbArticles = JsonConvert.DeserializeObject <KbArticles>(kbStr);
            }
            if (kbArticles != null)
            {
                OnRefresh();
                tv_view.Text = kbArticles.ViewCount.ToString();
                tv_ding.Text = kbArticles.Diggcount.ToString();
                SetToolBarTitle(kbArticles.Title);
            }
        }
示例#21
0
        async void GetNewsContent(Action callBack)
        {
            try
            {
                if (string.IsNullOrEmpty(news.Body))
                {
                    var result = await HttpClient.NewsService.GetNewsDetail(AccessTokenUtil.GetToken(this), ID);

                    if (result.Success)
                    {
                        news.Body = result.Data;
                        await SQLiteUtil.UpdateNews(news);

                        firstImgUrl = HtmlUtil.GetHtmlFirstImgUrl(news.Body);
                        news.Body   = news.Body.ReplaceHtml().Trim('"');
                        string content = HtmlUtil.ReadHtml(Assets).Replace("#body#", news.Body).Replace("#title#", news.Title).Replace("#author#", "").Replace("#date#", "发布日期:" + news.DateAdded.ToString("yyyy年MM月dd日 HH:mm"));
                        wb_content.LoadDataWithBaseURL("file:///android_asset/", content, "text/html", "utf-8", null);
                        callBack();
                    }
                    else
                    {
                        AlertUtil.ToastShort(this, result.Message);
                        callBack();
                    }
                }
                else
                {
                    news.Body = news.Body.ReplaceHtml().Trim('"');
                    string content = HtmlUtil.ReadHtml(Assets).Replace("#body#", news.Body).Replace("#title#", news.Title).Replace("#author#", "").Replace("#date#", "发布日期:" + news.DateAdded.ToString("yyyy年MM月dd日 HH:mm"));
                    wb_content.LoadDataWithBaseURL("file:///android_asset/", content, "text/html", "utf-8", null);
                    firstImgUrl = HtmlUtil.GetHtmlFirstImgUrl(news.Body);
                    callBack();
                }
            }
            catch (Exception ex)
            {
                AlertUtil.ToastShort(this, ex.ToString());
                callBack();
                MobclickAgent.ReportError(this, ex.ToString());
            }
        }
示例#22
0
        async void InitNews()
        {
            string newsStr = Intent.GetStringExtra("news");

            if (string.IsNullOrEmpty(newsStr))//从搜索直接进入的
            {
                news = await SQLiteUtil.SelectNews(ID);
            }
            else
            {
                news = JsonConvert.DeserializeObject <NewsViewModel>(newsStr);
            }
            if (news != null)
            {
                OnRefresh();
                tv_view.Text     = news.ViewCount.ToString();
                tv_ding.Text     = news.DiggCount.ToString();
                btn_comment.Text = news.CommentCount.ToString();
                SetToolBarTitle(news.Title);
            }
        }
示例#23
0
        private async Task <List <KbArticles> > listKbArticlesServer()
        {
            var result = await KbArticlesService.ListKbArticle(AccessTokenUtil.GetToken(this.Activity), pageIndex);

            if (result.Success)
            {
                _swipeRefreshLayout.Refreshing = false;
                try
                {
                    await SQLiteUtil.UpdateKbArticlesList(result.Data);

                    return(result.Data);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.Write(ex.ToString());
                    return(null);
                }
            }
            return(null);
        }
示例#24
0
        public override async void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);
            _swipeRefreshLayout = view.FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout);
            ly_expire           = view.FindViewById <LinearLayout>(Resource.Id.ly_expire);
            tv_startLogin       = view.FindViewById <TextView>(Resource.Id.tv_startLogin);
            userInfo            = UserInfoShared.GetUserInfo(this.Activity);;

            _swipeRefreshLayout.SetColorSchemeResources(Resource.Color.primary);

            _swipeRefreshLayout.SetOnRefreshListener(this);


            _recyclerView = view.FindViewById <RecyclerView>(Resource.Id.recyclerView);
            _recyclerView.SetLayoutManager(new Android.Support.V7.Widget.LinearLayoutManager(this.Activity));

            userToken   = UserTokenUtil.GetToken(Activity);
            accessToken = AccessTokenUtil.GetToken(Activity);
            if (isMy && userToken.IsExpire)
            {
                ly_expire.Visibility           = ViewStates.Visible;
                _swipeRefreshLayout.Visibility = ViewStates.Gone;
                tv_startLogin.Click           += (s, e) =>
                {
                    Activity.StartActivity(new Intent(Activity, typeof(loginactivity)));
                };
            }
            else
            {
                ly_expire.Visibility           = ViewStates.Gone;
                _swipeRefreshLayout.Visibility = ViewStates.Visible;
                listQuestion = await SQLiteUtil.SelectListQuestion(Constact.PageSize, isMy);

                if (listQuestion != null && listQuestion.Count > 0)
                {
                    initRecycler();
                }
                OnRefresh();
            }
        }
示例#25
0
        private async Task <List <BookmarksModel> > listBookmarkServer()
        {
            var result = await BookmarksService.List(UserTokenUtil.GetToken(this), Constact.PageSize, pageIndex);

            if (result.Success)
            {
                _swipeRefreshLayout.Refreshing = false;
                //bookMarkList = result.Data;
                try
                {
                    await SQLiteUtil.UpdateBookMarkList(result.Data);

                    return(result.Data);
                }
                catch (Exception ex)
                {
                    MobclickAgent.ReportError(this, ex.ToString());
                    System.Diagnostics.Debug.Write(ex.ToString());
                    return(null);
                }
            }
            return(null);
        }
示例#26
0
        private async void LoadMore()
        {
            pageIndex++;
            var result = new ApiResult <List <StatusModel> >();

            if (isMy)
            {
                result = await StatusService.ListStatus(UserTokenUtil.GetToken(this.Activity), position, pageIndex, true);
            }
            else
            {
                if (position == 0)
                {
                    result = await StatusService.ListStatus(AccessTokenUtil.GetToken(this.Activity), position, pageIndex, false);
                }
                else
                {
                    result = await StatusService.ListStatus(UserTokenUtil.GetToken(this.Activity), position, pageIndex, false);
                }
            }
            if (result.Success)
            {
                var tempList = result.Data;
                statusList.AddRange(tempList);
                adapter.SetNewData(statusList);
                if (isMy)
                {
                    tempList.ForEach(f => f.MySelf = true);
                }
                await SQLiteUtil.UpdateStatusList(tempList);
            }
            else
            {
                AlertUtil.ToastShort(Activity, result.Message);
            }
        }
示例#27
0
        public override async void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);
            try
            {
                _swipeRefreshLayout = view.FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout);
                _swipeRefreshLayout.SetColorSchemeResources(Resource.Color.primary);
                _swipeRefreshLayout.SetOnRefreshListener(this);
                _recyclerView = view.FindViewById <RecyclerView>(Resource.Id.recyclerView);
                _recyclerView.SetLayoutManager(new Android.Support.V7.Widget.LinearLayoutManager(this.Activity));
                articleList = await SQLiteUtil.SelectArticleList(Constact.PageSize);

                if (articleList != null && articleList.Count > 0)
                {
                    initRecycler();
                }
                OnRefresh();
                //_recyclerView.AddItemDecoration(new RecyclerViewDecoration(this.Activity, (int)Orientation.Vertical));
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Write(ex.ToString());
            }
        }
示例#28
0
        private async Task <List <ArticleCommentModel> > listArticleLocal()
        {
            commentList = await SQLiteUtil.SelectArticlecommentList(Constact.PageSize);

            return(commentList);
        }
示例#29
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            blogApp = Intent.GetStringExtra("blogApp");
            SetToolBarNavBack();
            StatusBarUtil.SetColorStatusBars(this);
            SetToolBarTitle(Resources.GetString(Resource.String.myBlog));
            tv_articleCount = FindViewById <TextView>(Resource.Id.tv_articleCount);
            tv_userName     = FindViewById <TextView>(Resource.Id.tv_userName);
            headPic         = FindViewById <ImageView>(Resource.Id.headPic);
            UserBlog userBlog = UserBlogShared.GetUserBlog(this);
            UserInfo userInfo = UserInfoShared.GetUserInfo(this);

            tv_articleCount.Text = "ÎÄÕÂÊý£º " + userBlog.PostCount;
            tv_userName.Text     = userInfo.DisplayName;
            //ÏÔʾͼƬÅäÖÃ
            options = new DisplayImageOptions.Builder()
                      .ShowImageForEmptyUri(Resource.Drawable.icon_yuanyou)
                      .ShowImageOnFail(Resource.Drawable.icon_yuanyou)
                      .ShowImageOnLoading(Resource.Drawable.icon_user)
                      .CacheInMemory(true)
                      .BitmapConfig(Bitmap.Config.Rgb565)
                      .CacheOnDisk(true)
                      // .Displayer(new DisplayerImageCircle(20))
                      .Build();
            ImageLoader.Instance.DisplayImage(userInfo.Avatar, headPic, options);
            _swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout);
            _swipeRefreshLayout.SetColorSchemeResources(Resource.Color.primary);
            _swipeRefreshLayout.SetOnRefreshListener(this);


            ly_expire     = FindViewById <LinearLayout>(Resource.Id.ly_expire);
            tv_startLogin = FindViewById <TextView>(Resource.Id.tv_startLogin);
            _recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView);
            _recyclerView.SetLayoutManager(new Android.Support.V7.Widget.LinearLayoutManager(this));

            Token token = UserTokenUtil.GetToken(this);

            if (token.IsExpire)
            {
                ly_expire.Visibility           = ViewStates.Visible;
                _swipeRefreshLayout.Visibility = ViewStates.Gone;
                tv_startLogin.Click           += (s, e) =>
                {
                    StartActivity(new Intent(this, typeof(loginactivity)));
                };
                return;
            }
            else
            {
                ly_expire.Visibility           = ViewStates.Gone;
                _swipeRefreshLayout.Visibility = ViewStates.Visible;
                articleList = await SQLiteUtil.SelectArticleList(Constact.PageSize, true);

                if (articleList != null)
                {
                    initRecycler();
                }
                OnRefresh();
            }
        }
示例#30
0
        private async Task <List <BookmarksModel> > listArticleLocal()
        {
            bookMarkList = await SQLiteUtil.SelectBookMarkList(Constact.PageSize);

            return(bookMarkList);
        }