예제 #1
0
        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 BlogService.AddArticleComments(CommonHelper.token, currentArticle.BlogApp, currentArticle.Id, content))
                {
                    Msg.AppMsg.MakeText(this, GetString(Resource.String.publish_comments_success), Msg.AppMsg.STYLE_INFO).Show();
                    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();
            }
        }
 private async void bindControls()
 {
     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 BlogService.AddArticleComments(CommonHelper.token, article.BlogApp, article.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();
     };
     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);
     //webView.Settings.UseWideViewPort = true;//设置此属性,可任意比例缩放
     btnViewComments        = FindViewById <Button>(Resource.Id.footbar_comments);
     btnViewComments.Click += delegate
     {
         Intent intent = new Intent(this, typeof(ArticleCommentsActivity));
         intent.PutExtra("current", JsonConvert.SerializeObject(article));
         StartActivity(intent);
     };
     CommonHelper.InitalShare(this, null, true, article.Author, article.Title, article.Avatar, article.Url);
     CommonHelper.InitalBookMark(this, article.Url, article.Title);
     await ptrl.AutoRefresh();
 }