Пример #1
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;
         });
     }
 }
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            answerId   = Intent.GetIntExtra("answerId", 0);
            questionId = Intent.GetIntExtra("questionId", 0);
            SetToolBarNavBack();
            StatusBarUtil.SetColorStatusBars(this);
            SetToolBarTitle("»Ø´ðÆÀÂÛ");
            //ÏÔʾͼƬÅäÖÃ
            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();
            edit_content = FindViewById <EditText>(Resource.Id.edit_content);
            btn_submit   = FindViewById <Button>(Resource.Id.btn_submit);
            userToken    = UserTokenUtil.GetToken(this);
            //btn_submit.enabvle
            btn_submit.Click += (s, e) =>
            {
                Add();
            };
            edit_content.TextChanged += (s, e) =>
            {
                string temp = edit_content.Text.TrimStart().TrimEnd();
                if (!string.IsNullOrEmpty(temp))
                {
                    btn_submit.Enabled = true;
                    if (atUserName != null && atUserName.Length > 0 && temp.Contains(atUserName))
                    {
                        isAt = true;
                    }
                    else
                    {
                        isAt = false;
                    }
                }
                else
                {
                    btn_submit.Enabled = false;
                }
            };

            _swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout);
            _swipeRefreshLayout.SetColorSchemeResources(Resource.Color.primary);
            _swipeRefreshLayout.SetOnRefreshListener(this);
            _swipeRefreshLayout.Post(() =>
            {
                _swipeRefreshLayout.Refreshing = true;
            });
            _recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView);
            _recyclerView.SetLayoutManager(new Android.Support.V7.Widget.LinearLayoutManager(this));
            _recyclerView.AddItemDecoration(new RecyclerViewDecoration(this, (int)Orientation.Vertical));
            initRecyclerView();
            userInfo = UserInfoShared.GetUserInfo(this);
        }
Пример #3
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);
            }
        }
Пример #4
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;
                });
            }
        }
Пример #5
0
 public override bool ShouldOverrideUrlLoading(WebView view, string url)
 {
     if (url.IndexOf(Constact.Callback) > -1)
     {
         Uri uri   = new Uri(url.Replace("#", "?"));
         var query = uri.Query.TrimStart('?').Split('&');
         foreach (var item in query)
         {
             var q = item.Split('=');
             if (q[0] == "code")
             {
                 var code = q[1];
                 System.Diagnostics.Debug.Write(code);
                 Token token = AccessTokenUtil.GetToken(context);
                 AuthorizationRequest.Authorization_Code(token, code, (userToken) =>
                 {
                     System.Diagnostics.Debug.Write(userToken.access_token);
                     UserTokenUtil.SaveToken(userToken, context);
                     // ActivityCompat.FinishAfterTransition(context);
                     context.StartActivity(new Intent(context, typeof(MainActivity)));
                     MobclickAgent.OnProfileSignIn(code);
                 },
                                                         error =>
                 {
                     MobclickAgent.ReportError(context, "µÇ¼ʧ°Ü" + error);
                     System.Diagnostics.Debug.Write(error);
                 });
             }
         }
         // view.stoploading();
     }
     return(base.ShouldOverrideUrlLoading(view, url));
 }
Пример #6
0
 //ɾ³ýÎÒµÄÉÁ´æÆÀÂÛ
 void DeleteComment(StatusCommentsModel model)
 {
     Android.Support.V7.App.AlertDialog.Builder builder = new Android.Support.V7.App.AlertDialog.Builder(this);
     builder.SetCancelable(true);
     string[] btns = Resources.GetStringArray(Resource.Array.DialogDelete);
     builder.SetItems(btns, (s, e) =>
     {
         ProgressDialog progressDialog = new ProgressDialog(this);
         progressDialog.SetProgressStyle(ProgressDialogStyle.Spinner);
         progressDialog.SetMessage("ɾ³ýÖÐ....");
         progressDialog.Show();
         StatusService.DeleteComment(UserTokenUtil.GetToken(this), model.StatusId.ToString(), model.Id.ToString(), () => {
             RunOnUiThread(() =>
             {
                 progressDialog.Hide();
                 listStatusComment.Remove(model);
                 adapter.SetNewData(listStatusComment);
                 AlertUtil.ToastShort(this, "ɾ³ý³É¹¦");
             });
         },
                                     (error => {
             RunOnUiThread(() =>
             {
                 progressDialog.Hide();
                 AlertUtil.ToastShort(this, error);
             });
         }));
     }).Show();
 }
Пример #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 SubmitClick(object o, EventArgs eventargs)
        {
            bool isPrivate = false;
            var  userToken = UserTokenUtil.GetToken(this);

            if (et_content.Text.Trim().Length == 0)
            {
                return;
            }
            rg_isPrivate.CheckedChange += (s, e) =>
            {
                if (e.CheckedId == rb_true.Id)
                {
                    isPrivate = true;
                }
                else if (e.CheckedId == rb_false.Id)
                {
                    isPrivate = false;
                }
            };
            if (userToken.IsExpire)
            {
                Android.Support.V7.App.AlertDialog.Builder alertDialog = new Android.Support.V7.App.AlertDialog.Builder(this)
                                                                         .SetTitle("登录提示")
                                                                         .SetMessage("未登录或登录token已经过期")
                                                                         .SetPositiveButton("授权", (s1, e1) =>
                {
                    StartActivity(new Intent(this, typeof(loginactivity)));
                })
                                                                         .SetNegativeButton("取消", (s1, e1) =>
                {
                    return;
                });
                alertDialog.Create().Show();
            }
            var dialog = new ProgressDialog(this);

            dialog.SetProgressStyle(ProgressDialogStyle.Spinner);
            dialog.SetCancelable(false);
            dialog.SetCanceledOnTouchOutside(false);
            dialog.SetTitle(Resources.GetString(Resource.String.bookmark_add));
            dialog.SetMessage("提交中.......");
            dialog.Show();
            var result = await StatusService.Add(userToken, et_content.Text.Trim(), isPrivate);

            if (result.Success)
            {
                dialog.Hide();
                AlertUtil.ToastShort(this, "发布成功");
                ActivityCompat.FinishAfterTransition(this);
            }
            else
            {
                dialog.Hide();
                AlertUtil.ToastShort(this, result.Message);
            }
        }
Пример #10
0
        public bool LoginExpire()
        {
            var userToken = UserTokenUtil.GetToken(context);

            if (userToken.IsExpire || string.IsNullOrEmpty(userToken.access_token))
            {
                return(true);
            }
            return(false);
        }
Пример #11
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Create your application here
            StatusBarUtil.SetColorStatusBars(this);
            SetToolBarNavBack();

            rg_isPrivate         = FindViewById <RadioGroup>(Resource.Id.rg_isPrivate);
            rb_false             = FindViewById <RadioButton>(Resource.Id.rb_false);
            rb_true              = FindViewById <RadioButton>(Resource.Id.rb_true);
            btn_submit           = FindViewById <Button>(Resource.Id.btn_submit);
            btn_submit.Enabled   = false;
            ly_expire            = FindViewById <LinearLayout>(Resource.Id.ly_expire);
            tv_startLogin        = FindViewById <TextView>(Resource.Id.tv_startLogin);
            et_content           = FindViewById <EditText>(Resource.Id.et_content);
            tv_startLogin.Click += (s, e) =>
            {
                StartActivity(new Intent(this, typeof(loginactivity)));
            };

            AlertUtil.ToastLong(this, "当前线程id:" + Thread.CurrentThread.ManagedThreadId);

            string title = Intent.GetStringExtra("title");
            string url   = Intent.GetStringExtra("url");



            Token token = UserTokenUtil.GetToken(this);

            if (token.IsExpire)
            {
                btn_submit.Enabled   = false;
                ly_expire.Visibility = ViewStates.Visible;
            }
            else
            {
                btn_submit.Enabled   = true;
                ly_expire.Visibility = ViewStates.Gone;
            }
            et_content.TextChanged += (s, e) =>
            {
                string content = et_content.Text.Trim();
                if (!string.IsNullOrEmpty(content))
                {
                    btn_submit.Enabled = true;
                }
                else
                {
                    btn_submit.Enabled = false;
                }
            };
            btn_submit.Click += SubmitClick;
        }
Пример #12
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;
                });
            }
        }
Пример #13
0
        private void Add()
        {
            string body      = edit_content.Text.TrimEnd().TrimStart();
            var    userToken = UserTokenUtil.GetToken(this);
            var    userInfo  = UserInfoShared.GetUserInfo(this);

            if (userToken.IsExpire)
            {
                Android.Support.V7.App.AlertDialog.Builder alertDialog = new Android.Support.V7.App.AlertDialog.Builder(this)
                                                                         .SetTitle("µÇ¼Ìáʾ")
                                                                         .SetMessage("δµÇ¼»òµÇ¼tokenÒѾ­¹ýÆÚ")
                                                                         .SetPositiveButton("ÊÚȨ", (s1, e1) =>
                {
                    StartActivity(new Intent(this, typeof(loginactivity)));
                })
                                                                         .SetNegativeButton("È¡Ïû", (s1, e1) =>
                {
                    return;
                });
                alertDialog.Create().Show();
            }
            else
            {
                if (string.IsNullOrEmpty(body))
                {
                    AlertUtil.ToastShort(this, "ÇëÊäÈëÄÚÈÝ");
                    return;
                }
                ProgressDialog dialog = new ProgressDialog(this);
                dialog.SetTitle("ÆÀÂÛ");
                dialog.SetMessage("Ìá½»ÆÀÂÛÖÐ.....");
                dialog.Show();
                QuestionService.EditQuestionAnswerComment(userToken, body, questionId, answerId, commentId, userInfo.SpaceUserId, () => {
                    RunOnUiThread(() =>
                    {
                        dialog.Hide();
                        AlertUtil.ToastShort(this, "ÆÀÂ۳ɹ¦");
                        edit_content.Text  = "";
                        btn_submit.Enabled = false;
                        ActivityCompat.FinishAfterTransition(this);
                    });
                }, (error) => {
                    RunOnUiThread(() =>
                    {
                        dialog.Hide();
                        AlertUtil.ToastShort(this, error);
                        btn_submit.Enabled = true;
                    });
                });
            }
        }
Пример #14
0
        private async void Add()
        {
            string body      = edit_content.Text.TrimEnd().TrimStart();
            var    userToken = UserTokenUtil.GetToken(this);
            var    userInfo  = UserInfoShared.GetUserInfo(this);

            if (userToken.IsExpire)
            {
                Android.Support.V7.App.AlertDialog.Builder alertDialog = new Android.Support.V7.App.AlertDialog.Builder(this)
                                                                         .SetTitle("µÇ¼Ìáʾ")
                                                                         .SetMessage("δµÇ¼»òµÇ¼tokenÒѾ­¹ýÆÚ")
                                                                         .SetPositiveButton("ÊÚȨ", (s1, e1) =>
                {
                    StartActivity(new Intent(this, typeof(loginactivity)));
                })
                                                                         .SetNegativeButton("È¡Ïû", (s1, e1) =>
                {
                    return;
                });
                alertDialog.Create().Show();
            }
            else
            {
                if (string.IsNullOrEmpty(body))
                {
                    AlertUtil.ToastShort(this, "ÇëÊäÈëÄÚÈÝ");
                    return;
                }
                ProgressDialog dialog = new ProgressDialog(this);
                dialog.SetTitle("ÆÀÂÛ");
                dialog.SetMessage("Ìá½»ÆÀÂÛÖÐ.....");
                dialog.Show();
                var result = await QuestionService.AddQuestionAnswer(userToken, userInfo.BlogApp, userInfo.DisplayName, body, questionId, userInfo.SpaceUserId);

                if (result.Success)
                {
                    dialog.Hide();
                    AlertUtil.ToastShort(this, "ÆÀÂ۳ɹ¦");
                    edit_content.Text  = "";
                    btn_submit.Enabled = false;
                    OnRefresh();
                }
                else
                {
                    dialog.Hide();
                    AlertUtil.ToastShort(this, result.Message);
                    btn_submit.Enabled = true;
                }
            }
        }
Пример #15
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetToolBarNavBack();
            StatusBarUtil.SetColorStatusBars(this);
            SetToolBarTitle(Resources.GetString(Resource.String.bookmark_my));
            _swipeRefreshLayout = 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;
            }, 3000);
            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 = 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;
            }

            bookMarkList = await listBookmarkServer();

            if (bookMarkList != null && bookMarkList.Count > 0)
            {
                initRecycler();
            }
        }
Пример #16
0
        private async void Add()
        {
            ProgressDialog dialog = new ProgressDialog(this);

            dialog.SetTitle("评论");
            dialog.SetMessage("提交评论中.....");
            string body      = edit_content.Text.TrimEnd().TrimStart();
            var    userToken = UserTokenUtil.GetToken(this);

            if (userToken.IsExpire)
            {
                Android.Support.V7.App.AlertDialog.Builder alertDialog = new Android.Support.V7.App.AlertDialog.Builder(this)
                                                                         .SetTitle("登录提示")
                                                                         .SetMessage("未登录或登录token已经过期")
                                                                         .SetPositiveButton("授权", (s1, e1) =>
                {
                    StartActivity(new Intent(this, typeof(loginactivity)));
                })
                                                                         .SetNegativeButton("取消", (s1, e1) =>
                {
                    return;
                });
                alertDialog.Create().Show();
            }
            if (string.IsNullOrEmpty(body))
            {
                AlertUtil.ToastShort(this, "请输入内容");
                return;
            }
            dialog.Show();
            var result = await ArticleService.AddArticleComment(userToken, blogApp, postId, body);

            if (result.Success)
            {
                dialog.Hide();
                AlertUtil.ToastShort(this, "评论成功");
                edit_content.Text  = "";
                btn_submit.Enabled = false;
                OnRefresh();
            }
            else
            {
                dialog.Hide();
                AlertUtil.ToastShort(this, result.Message);
                btn_submit.Enabled = true;
            }
        }
Пример #17
0
        private async Task listSearchService(Action <List <ZzkDocumentViewModel> > successCallBack)
        {
            var result = await ZzkService.List(UserTokenUtil.GetToken(this), pageIndex, category, keyword);

            if (result.Success)
            {
                try
                {
                    successCallBack(result.Data);
                }
                catch (Exception ex)
                {
                    MobclickAgent.ReportError(this, ex.ToString());
                    System.Diagnostics.Debug.Write(ex.ToString());
                }
            }
        }
Пример #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 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();
        }
Пример #20
0
        public override async void OnViewCreated(View view, Bundle savedInstanceState)
        {
            //SetToolBarTitle(Resources.GetString(Resource.String.myBlog));
            //显示图片配置
            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();
            swipeRefreshLayout = View.FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout);
            swipeRefreshLayout.SetColorSchemeColors(Resources.GetColor(Resource.Color.primary));
            swipeRefreshLayout.SetOnRefreshListener(this);
            tv_seniority    = View.FindViewById <TextView>(Resource.Id.tv_seniority);
            ly_unLogin      = View.FindViewById <LinearLayout>(Resource.Id.ly_unLogin);
            ly_logged       = View.FindViewById <LinearLayout>(Resource.Id.ly_logged);
            tv_subTitle     = View.FindViewById <TextView>(Resource.Id.tv_subTitle);
            tv_postCount    = View.FindViewById <TextView>(Resource.Id.tv_postCount);
            ll_blog         = View.FindViewById <LinearLayout>(Resource.Id.ll_blog);
            ll_status       = View.FindViewById <LinearLayout>(Resource.Id.ll_status);
            ll_question     = View.FindViewById <LinearLayout>(Resource.Id.ll_question);
            tv_myBookmark   = View.FindViewById <TextView>(Resource.Id.tv_myBookmark);
            tv_about        = view.FindViewById <TextView>(Resource.Id.tv_about);
            tv_about.Click += (s, e) =>
            {
                AboutActivity.Enter(Activity);
            };
            ly_unLogin.Click += (s, e) =>
            {
                StartActivity(new Intent(Activity, typeof(loginactivity)));
            };

            tv_userName   = View.FindViewById <TextView>(Resource.Id.tv_userName);
            iv_userAvatar = View.FindViewById <ImageView>(Resource.Id.iv_userAvatar);
            userToken     = UserTokenUtil.GetToken(Activity);
            OnRefresh();
            //用户token 未过期
        }
Пример #21
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();
            }
        }
Пример #22
0
        /// <summary>
        /// ɾ³ýÎÒµÄÉÁ´æ
        /// </summary>
        /// <param name="model"></param>
        private void Delete(StatusModel model)
        {
            ProgressDialog progressDialog = new ProgressDialog(Activity);

            progressDialog.SetProgressStyle(ProgressDialogStyle.Spinner);
            progressDialog.SetMessage("ɾ³ýÖÐ....");
            progressDialog.Show();
            StatusService.Delete(UserTokenUtil.GetToken(Activity), model.Id, (success) => {
                Activity.RunOnUiThread(() =>
                {
                    progressDialog.Hide();
                    statusList.Remove(model);
                    adapter.SetNewData(statusList);
                });
            }, (error) => {
                Activity.RunOnUiThread(() =>
                {
                    progressDialog.Hide();
                    AlertUtil.ToastShort(Activity, error);
                });
            });
        }
Пример #23
0
        //Ìí¼ÓÉÁ´æÆÀÂÛʼþ
        public async void AddCommentClick(Object o, EventArgs e)
        {
            string content = edit_content.Text.Trim();

            if (string.IsNullOrEmpty(content))
            {
                return;
            }
            if (!string.IsNullOrEmpty(displayUserName))
            {
                content = content.Replace(displayUserName, displayUserName + " ");
            }
            ProgressDialog progressDialog = new ProgressDialog(this);

            progressDialog.SetProgressStyle(ProgressDialogStyle.Spinner);
            progressDialog.SetMessage("Ìí¼ÓÆÀÂÛÖÐ....");
            progressDialog.Show();
            var result = await StatusService.AddComment(UserTokenUtil.GetToken(this), statusId.ToString(), replyToUserId, parentCommentId, content);

            if (result.Success)
            {
                RunOnUiThread(async() =>
                {
                    progressDialog.Hide();
                    await StatusService.ListStatusComment(AccessTokenUtil.GetToken(this), statusId, callBackSuccess, callBackError);
                    edit_content.Text = "";
                    AlertUtil.ToastShort(this, "ÆÀÂ۳ɹ¦");
                });
            }
            else
            {
                RunOnUiThread(() =>
                {
                    progressDialog.Hide();
                    AlertUtil.ToastShort(this, result.Message);
                });
            }
        }
Пример #24
0
 protected override async void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     answerId   = Intent.GetIntExtra("answerId", 0);
     questionId = Intent.GetIntExtra("questionId", 0);
     commentId  = Intent.GetIntExtra("commentId", 0);
     content    = Intent.GetStringExtra("content");
     SetToolBarNavBack();
     StatusBarUtil.SetColorStatusBars(this);
     SetToolBarTitle("±à¼­ÆÀÂÛ");
     //ÏÔʾͼƬÅäÖÃ
     edit_content = FindViewById <EditText>(Resource.Id.edit_content);
     btn_submit   = FindViewById <Button>(Resource.Id.btn_submit);
     userToken    = UserTokenUtil.GetToken(this);
     if (!string.IsNullOrEmpty(content))
     {
         edit_content.SetText(HtmlUtil.GetHtml(content), TextView.BufferType.Spannable);
         btn_submit.Enabled = true;
     }
     //btn_submit.enabvle
     btn_submit.Click += (s, e) =>
     {
         Add();
     };
     edit_content.TextChanged += (s, e) =>
     {
         string temp = edit_content.Text.TrimStart().TrimEnd();
         if (!string.IsNullOrEmpty(temp))
         {
             btn_submit.Enabled = true;
         }
         else
         {
             btn_submit.Enabled = false;
         }
     };
     userInfo = UserInfoShared.GetUserInfo(this);
 }
Пример #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
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Create your application here
            StatusBarUtil.SetColorStatusBars(this);
            SetToolBarNavBack();

            rg_flags = FindViewById <RadioGroup>(Resource.Id.rg_flags);
            rb_false = FindViewById <RadioButton>(Resource.Id.rb_false);
            rb_true  = FindViewById <RadioButton>(Resource.Id.rb_true);

            edit_title         = FindViewById <EditText>(Resource.Id.edit_title);
            edit_tags          = FindViewById <EditText>(Resource.Id.edit_tags);
            edit_content       = FindViewById <EditText>(Resource.Id.edit_content);
            btn_submit         = FindViewById <Button>(Resource.Id.btn_submit);
            btn_submit.Enabled = true;
            ly_expire          = FindViewById <LinearLayout>(Resource.Id.ly_expire);
            tv_startLogin      = FindViewById <TextView>(Resource.Id.tv_startLogin);
            ll_content         = FindViewById <LinearLayout>(Resource.Id.ll_content);

            ll_content.Click += (s, e) =>
            {
                edit_content.Focusable = true;
            };
            tv_startLogin.Click += (s, e) =>
            {
                StartActivity(new Intent(this, typeof(loginactivity)));
            };
            userToken = UserTokenUtil.GetToken(this);
            //radiobutton单击事件
            rg_flags.CheckedChange += (s, e) =>
            {
                if (e.CheckedId == rb_true.Id)
                {
                    flags = "1";
                }
                else if (e.CheckedId == rb_false.Id)
                {
                    flags = "0";
                }
            };
            //验证是否登录
            if (userToken.IsExpire)
            {
                btn_submit.Enabled   = false;
                ly_expire.Visibility = ViewStates.Visible;
            }
            else
            {
                btn_submit.Enabled   = true;
                ly_expire.Visibility = ViewStates.Gone;
            }
            //验证提交按钮
            edit_title.TextChanged += (s, e) =>
            {
                if (string.IsNullOrEmpty(edit_title.Text.Trim()) || string.IsNullOrEmpty(edit_content.Text.Trim()))
                {
                    btn_submit.Enabled = false;
                }
                else
                {
                    btn_submit.Enabled = true;
                }
            };
            edit_content.TextChanged += (s, e) =>
            {
                if (string.IsNullOrEmpty(edit_content.Text.Trim()) || string.IsNullOrEmpty(edit_title.Text.Trim()))
                {
                    btn_submit.Enabled = false;
                }
                else
                {
                    btn_submit.Enabled = true;
                }
            };
            btn_submit.Click += AddQuestionClick;
        }
Пример #28
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Create your application here
            StatusBarUtil.SetColorStatusBars(this);
            SetToolBarNavBack();

            edit_url             = FindViewById <EditText>(Resource.Id.edit_url);
            edit_title           = FindViewById <EditText>(Resource.Id.edit_title);
            edit_summary         = FindViewById <EditText>(Resource.Id.edit_summary);
            edit_tags            = FindViewById <EditText>(Resource.Id.edit_tags);
            btn_submit           = FindViewById <Button>(Resource.Id.btn_submit);
            ly_expire            = FindViewById <LinearLayout>(Resource.Id.ly_expire);
            tv_startLogin        = FindViewById <TextView>(Resource.Id.tv_startLogin);
            tv_startLogin.Click += (s, e) =>
            {
                StartActivity(new Intent(this, typeof(loginactivity)));
            };
            AlertUtil.ToastLong(this, "当前线程id:" + Thread.CurrentThread.ManagedThreadId);

            string title = Intent.GetStringExtra("title");
            string url   = Intent.GetStringExtra("url");

            mode = Intent.GetStringExtra("mode");

            edit_url.Text   = string.IsNullOrEmpty(url)?"":url;
            edit_title.Text = string.IsNullOrEmpty(title)?"":title;
            Token token = UserTokenUtil.GetToken(this);

            if (mode == "edit")
            {
                string editTitle = Resources.GetString(Resource.String.bookmark_edit);
                btn_submit.Text = editTitle;
                SetToolBarTitle(editTitle);
                string summary = Intent.GetStringExtra("summary");
                string tags    = Intent.GetStringExtra("tags");
                wzLinkId = Intent.GetIntExtra("id", 0);
                if (!string.IsNullOrEmpty(summary))
                {
                    edit_summary.Text = summary;
                }
                if (!string.IsNullOrEmpty(tags))
                {
                    edit_tags.Text = tags;
                }
            }
            else if (mode == "add")
            {
                btn_submit.Text = "添加收藏";
            }
            //判断是否登录
            if (token.IsExpire)
            {
                btn_submit.Enabled   = false;
                ly_expire.Visibility = ViewStates.Visible;
            }
            else
            {
                btn_submit.Enabled   = true;
                ly_expire.Visibility = ViewStates.Gone;
            }
            btn_submit.Click += async(s, e) =>
            {
                var userToken = UserTokenUtil.GetToken(this);
                if (userToken.IsExpire)
                {
                    Android.Support.V7.App.AlertDialog.Builder alertDialog = new Android.Support.V7.App.AlertDialog.Builder(this)
                                                                             .SetTitle("登录提示")
                                                                             .SetMessage("未登录或登录token已经过期")
                                                                             .SetPositiveButton("授权", (s1, e1) =>
                    {
                        StartActivity(new Intent(this, typeof(loginactivity)));
                    })
                                                                             .SetNegativeButton("取消", (s1, e1) =>
                    {
                        return;
                    });
                    alertDialog.Create().Show();
                }
                if (edit_summary.Text.Length > 200)
                {
                    AlertUtil.ToastShort(this, "摘要不能超过200字符");
                    return;
                }
                if (token.IsExpire)
                {
                    AlertUtil.ToastShort(this, "未登录或登录token已经过期,请邓丽");
                    return;
                }
                var model = new BookmarksModel();
                model.Title   = edit_title.Text;
                model.LinkUrl = edit_url.Text;
                model.Summary = edit_summary.Text;
                model.Tags    = edit_tags.Text.Split(',').ToList();
                var dialog = new ProgressDialog(this);
                dialog.SetProgressStyle(ProgressDialogStyle.Spinner);
                dialog.SetCancelable(false);
                dialog.SetCanceledOnTouchOutside(false);
                dialog.SetTitle(Resources.GetString(Resource.String.bookmark_add));
                dialog.SetMessage("提交中.......");
                dialog.Show();
                if (mode == "add")
                {
                    var result = await BookmarksService.Add(token, model);

                    if (result.Success)
                    {
                        btn_submit.Enabled = false;
                        dialog.Hide();
                        AlertUtil.ToastLong(this, result.Message + "添加收藏成功");
                        this.Finish();
                        System.Diagnostics.Debug.Write(result.Message);
                    }
                    else
                    {
                        dialog.Hide();
                        AlertUtil.ToastLong(this, result.Message);
                        System.Diagnostics.Debug.Write(result);
                    }
                }
                if (mode == "edit")
                {
                    model.WzLinkId = wzLinkId;
                    BookmarksService.Edit(token, model, (result) => {
                        if (result.IsSuccess)
                        {
                            RunOnUiThread(() => {
                                dialog.Hide();
                                btn_submit.Enabled = false;
                                AlertUtil.ToastLong(this, result.Message + "编辑收藏成功");
                            });
                            System.Diagnostics.Debug.Write(result.Message);
                        }
                        else
                        {
                            RunOnUiThread(() =>
                            {
                                dialog.Hide();
                                AlertUtil.ToastLong(this, result.Message);
                                System.Diagnostics.Debug.Write(result);
                            });
                        }
                    });
                }
            };
        }
Пример #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
 public void Logout()
 {
     UserTokenUtil.SaveToken(new ApiModel.Token(), context);
 }