Example #1
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;
            }
        }