private async void btnSend_Click(object sender, EventArgs e)
        {
            string content = textComments.Text;

            if (string.IsNullOrWhiteSpace(content))
            {
                Msg.AppMsg.MakeText(this, "请输入评论内容", Msg.AppMsg.STYLE_INFO).Show();
                return;
            }
            waitDialog = CommonHelper.CreateLoadingDialog(this, "正在发送评论数据,请稍后...");
            try
            {
                waitDialog.Show();
                if (await NewsService.AddNewComments(CommonHelper.token, newsInfo.Id, content))
                {
                    Msg.AppMsg.MakeText(this, GetString(Resource.String.publish_comments_success), Msg.AppMsg.STYLE_INFO).Show();
                    await ptrl.AutoRefresh();
                }
                else
                {
                    Msg.AppMsg.MakeText(this, GetString(Resource.String.publish_comments_fail), Msg.AppMsg.STYLE_INFO).Show();
                }
            }
            catch (Exception ex)
            {
                Msg.AppMsg.MakeText(this, GetString(Resource.String.publish_comments_fail), Msg.AppMsg.STYLE_INFO).Show();
                Log.Debug("error:", ex.Message);
            }
            finally
            {
                waitDialog.Cancel();
            }
        }
예제 #2
0
 private async void bindControls()
 {
     FindViewById <TextView>(Resource.Id.head_title).Text = "新闻详情";
     webView = FindViewById <PullableWebView>(Resource.Id.webview);
     ptrl    = FindViewById <PullToRefreshLayout>(Resource.Id.refresh_view);
     ptrl.setOnRefreshListener(this);
     webView.Settings.DefaultTextEncodingName  = "utf-8";
     webView.Settings.LoadsImagesAutomatically = true;
     webView.SetWebViewClient(new MyWebViewClient());
     webView.ScrollBarStyle             = ScrollbarStyles.InsideOverlay;
     webView.Settings.JavaScriptEnabled = false;
     webView.Settings.SetSupportZoom(false);
     webView.Settings.BuiltInZoomControls = false;
     webView.Settings.CacheMode           = CacheModes.CacheElseNetwork;
     webView.Settings.SetLayoutAlgorithm(WebSettings.LayoutAlgorithm.SingleColumn);
     btnBack                = FindViewById <Button>(Resource.Id.title_bar_back);
     btnBack.Click         += delegate { Finish(); };
     btnViewComments        = FindViewById <Button>(Resource.Id.footbar_comments);
     btnViewComments.Click += delegate
     {
         Intent intent = new Intent(this, typeof(NewsCommentsActitvity));
         intent.PutExtra("newsInfo", JsonConvert.SerializeObject(newsInfo));
         StartActivity(intent);
     };
     CommonHelper.InitalShare(this, null, true, "博客园新闻分享", newsInfo.Title, newsInfo.TopicIcon, string.Format("https://news.cnblogs.com/n/{0}/", newsInfo.Id));
     CommonHelper.InitalBookMark(this, string.Format("https://news.cnblogs.com/n/{0}/", newsInfo.Id), newsInfo.Title);
     btnWriteComments        = FindViewById <Button>(Resource.Id.footbar_write_comment);
     btnWriteComments.Click += delegate
     {
         BottomSheetDialog bottomSheetDiaolog = new BottomSheetDialog(this);
         var      inflater     = GetSystemService(Context.LayoutInflaterService) as LayoutInflater;
         EditText textComments = FindViewById <EditText>(Resource.Id.text_comments);
         View     view         = inflater.Inflate(Resource.Layout.write_comments, null);
         TextView textCancel   = view.FindViewById <TextView>(Resource.Id.text_cancel);
         textCancel.Click += delegate { bottomSheetDiaolog.Dismiss(); };
         TextView textSend = view.FindViewById <TextView>(Resource.Id.text_send_comments);
         textSend.Click += async delegate
         {
             string content = textComments.Text;
             if (string.IsNullOrWhiteSpace(content))
             {
                 Msg.AppMsg.MakeText(this, "请输入评论内容", Msg.AppMsg.STYLE_INFO).Show();
                 return;
             }
             Dialog waitDialog = CommonHelper.CreateLoadingDialog(this, "正在发送评论数据,请稍后...");
             try
             {
                 waitDialog.Show();
                 if (await NewsService.AddNewComments(CommonHelper.token, newsInfo.Id, content))
                 {
                     Msg.AppMsg.MakeText(this, GetString(Resource.String.publish_comments_success), Msg.AppMsg.STYLE_INFO).Show();
                     bottomSheetDiaolog.Dismiss();
                 }
                 else
                 {
                     Msg.AppMsg.MakeText(this, GetString(Resource.String.publish_comments_fail), Msg.AppMsg.STYLE_INFO).Show();
                 }
             }
             catch (Exception ex)
             {
                 Msg.AppMsg.MakeText(this, GetString(Resource.String.publish_comments_fail), Msg.AppMsg.STYLE_INFO).Show();
                 Log.Debug("error:", ex.Message);
             }
             finally
             {
                 waitDialog.Cancel();
             }
         };
         bottomSheetDiaolog.SetContentView(view);
         bottomSheetDiaolog.Show();
     };
     await ptrl.AutoRefresh();
 }