Пример #1
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();
 }
Пример #2
0
        async void GetArticleContent(Action successCallBack)
        {
            try
            {
                var result = await HttpClient.ArticleService.GetArticle(AccessTokenUtil.GetToken(this), ID);

                if (result.Success)
                {
                    string content = result.Data;
                    content = content.ReplaceHtml().Trim('"');
                    content = HtmlUtil.ReadHtml(Assets).Replace("#body#", content).Replace("#title#", "").Replace("#author#", "").Replace("#date#", "");
                    wb_content.LoadDataWithBaseURL("file:///android_asset/", content, "text/html", "utf-8", null);
                    firstImgSrc = HtmlUtil.GetHtmlFirstImgUrl(content);
                    successCallBack();
                }
                else
                {
                    AlertUtil.ToastShort(this, result.Message);
                }
            }
            catch (Exception ex)
            {
                MobclickAgent.ReportError(this, ex.ToString());
                AlertUtil.ToastShort(this, ex.Message);
            }
        }
Пример #3
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;
         });
     }
 }
Пример #4
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);
            }
        }
Пример #5
0
        async void GetKbArticleContent(Action callBack)
        {
            try
            {
                var result = await HttpClient.KbArticlesService.GetKbArticles(AccessTokenUtil.GetToken(this), ID);

                if (result.Success)
                {
                    string content = result.Data;
                    firstImgUrl = HtmlUtil.GetHtmlFirstImgUrl(content);
                    content     = content.ReplaceHtml().Trim('"');
                    content     = HtmlUtil.ReadHtml(Assets).Replace("#body#", content).Replace("#title#", kbArticles.Title).Replace("#author#", "作者:" + kbArticles.Author).Replace("#date#", "发布日期:" + kbArticles.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();
                }
            }
            catch (Exception ex)
            {
                AlertUtil.ToastShort(this, ex.Message);
                MobclickAgent.ReportError(this, ex.ToString());
                callBack();
            }
        }
Пример #6
0
        private async void LoadMore()
        {
            if (_swipeRefreshLayout.Refreshing)
            {
                _swipeRefreshLayout.Post(() =>
                {
                    _swipeRefreshLayout.Refreshing = false;
                });
            }
            pageIndex++;
            var result = new ApiResult <List <QuestionModel> >();

            if (isMy)
            {
                result = await QuestionService.ListQuestion(userToken, position, pageIndex, true, userInfo.SpaceUserId);
            }
            else
            {
                result = await QuestionService.ListQuestion(accessToken, position, pageIndex, false, 0);
            }
            if (result.Success)
            {
                var tempList = result.Data;
                listQuestion.AddRange(tempList);
                adapter.SetNewData(listQuestion);
            }
            else
            {
                AlertUtil.ToastShort(Activity, result.Message);
            }
        }
Пример #7
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;
                });
            }
        }
Пример #8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Create your application here
            StatusBarUtil.SetColorStatusBars(this);
            SetToolBarNavBack();
            shareWidget        = new UMengShareWidget(this);
            wb_content         = FindViewById <WebView>(Resource.Id.wb_content);
            tv_ding            = FindViewById <TextView>(Resource.Id.tv_ding);
            btn_mark           = FindViewById <Button>(Resource.Id.btn_mark);
            btn_comment        = FindViewById <Button>(Resource.Id.btn_comment);
            tv_view            = FindViewById <TextView>(Resource.Id.tv_view);
            swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout);
            swipeRefreshLayout.SetColorSchemeColors(Resources.GetColor(Resource.Color.primary));
            swipeRefreshLayout.SetOnRefreshListener(this);

            btn_mark.Click += (s, e) =>
            {
                AddBookmarkActivity.Enter(this, string.Format(Constact.KbPage, ID), news.Title, "add");
            };
            btn_comment.Click += (s, e) =>
            {
                NewsCommentActivity.Enter(this, ID);
            };

            wb_content.Settings.DomStorageEnabled       = true;
            wb_content.Settings.JavaScriptEnabled       = true;    //支持js
            wb_content.Settings.DefaultTextEncodingName = "utf-8"; //设置编码方式utf-8
            wb_content.Settings.SetSupportZoom(false);             //不可缩放
            wb_content.Settings.DisplayZoomControls = false;       //隐藏原生的缩放控件
            wb_content.Settings.BuiltInZoomControls = false;       //设置内置的缩放控件
            wb_content.Settings.CacheMode           = CacheModes.CacheElseNetwork;
            wb_content.ScrollBarStyle = ScrollbarStyles.InsideOverlay;
            wb_content.Settings.LoadsImagesAutomatically = true; //支持自动加载图片
            wb_content.Settings.UseWideViewPort          = true; //将图片调整到合适webview的大小
            wb_content.Settings.SetLayoutAlgorithm(WebSettings.LayoutAlgorithm.SingleColumn);
            var jsInterface = new  WebViewJSInterface(this);

            wb_content.SetWebViewClient(ContentWebViewClient.Instance(this));
            wb_content.AddJavascriptInterface(jsInterface, "openlistner");
            jsInterface.CallFromPageReceived += delegate(object sender, WebViewJSInterface.CallFromPageReceivedEventArgs e)
            {
                PhotoActivity.Enter(this, e.Result.Split(','), e.Index);
            };
            ID = Intent.GetIntExtra("id", 0);
            if (ID == 0)
            {
                Android.OS.Handler handle = new Android.OS.Handler();
                handle.PostDelayed(() =>
                {
                    Finish();
                }, 2000);
                AlertUtil.ToastShort(this, "获取id错误立即返回");
            }
            InitNews();

            //shareWidget = new UMengShareWidget(this);
        }
Пример #9
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Create your application here
            StatusBarUtil.SetColorStatusBars(this);
            ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(this).WriteDebugLogs().Build();//³õʼ»¯Í¼Æ¬¼ÓÔØ¿ò¼Ü

            ImageLoader.Instance.Init(configuration);
            //ÏÔʾͼƬÅäÖÃ
            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();
            SetToolBarNavBack();
            _swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout);
            _swipeRefreshLayout.SetColorScheme(Resource.Color.primary);
            tv_dateAdded       = FindViewById <TextView>(Resource.Id.tv_dateAdded);
            tv_userDisplayName = FindViewById <TextView>(Resource.Id.tv_userDisplayName);
            iv_userIcon        = FindViewById <ImageView>(Resource.Id.iv_userIcon);
            tv_content         = FindViewById <TextView>(Resource.Id.tv_content);
            edit_content       = FindViewById <EditText>(Resource.Id.edit_content);
            btn_submit         = FindViewById <Button>(Resource.Id.btn_submit);
            btn_submit.Click  += AddCommentClick;
            statusId           = Intent.GetIntExtra("id", 0);
            GetClientStatus(statusId);
            shareWidget   = new UMengShareWidget(this);
            _recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView);
            _recyclerView.SetLayoutManager(new LinearLayoutManager(this));


            _swipeRefreshLayout.Post(() => {
                _swipeRefreshLayout.Refreshing = true;
            });
            _swipeRefreshLayout.Refresh += async(s, e) =>
            {
                await StatusService.ListStatusComment(AccessTokenUtil.GetToken(this), statusId, callBackSuccess, callBackError);
            };
            edit_content.TextChanged += (s, e) =>
            {
                if (string.IsNullOrEmpty(edit_content.Text.Trim()))
                {
                    btn_submit.Enabled = false;
                }
                else
                {
                    btn_submit.Enabled = true;
                }
            };
            AlertUtil.ToastShort(this, "Ïß³ÌID" + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString());
            await StatusService.ListStatusComment(AccessTokenUtil.GetToken(this), statusId, callBackSuccess, callBackError);

            _recyclerView.AddItemDecoration(new RecyclerViewDecoration(this, (int)Orientation.Vertical));
        }
Пример #10
0
 //ÇëÇóÉÁ´æÆÀÂÛʧ°ÜµÄ»Øµ÷
 void callBackError(string error)
 {
     AlertUtil.ToastShort(this, "Ïß³ÌID" + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString());
     _swipeRefreshLayout.PostDelayed(() =>
     {
         _swipeRefreshLayout.Refreshing = false;
     }, 1000);
     AlertUtil.ToastShort(this, "»ñÈ¡Êý¾Ýʧ°Ü" + error);
 }
Пример #11
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);
            }
        }
Пример #12
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;
                }
            }
        }
Пример #13
0
 void ItemLongClick(string tag, int position)
 {
     if (userInfo.DisplayName == answerList[position].UserName)
     {
         AlertDialog.Builder builder = new AlertDialog.Builder(this);
         builder.SetCancelable(true);
         string[] btns     = new string[] { "ɾ³ý", "ÐÞ¸Ä" };
         int      answerId = int.Parse(tag);
         builder.SetItems(btns, (s, e) =>
         {
             if (e.Which == 0)
             {
                 ProgressDialog progressDialog = new ProgressDialog(this);
                 progressDialog.SetProgressStyle(ProgressDialogStyle.Spinner);
                 progressDialog.SetMessage("ɾ³ýÖÐ....");
                 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();
                 }
                 progressDialog.Show();
                 QuestionService.DeleteQuestionAnswer(userToken, questionId, answerId, (error) =>
                 {
                     RunOnUiThread(() =>
                     {
                         progressDialog.Hide();
                         AlertUtil.ToastShort(this, "ɾ³ý»Ø´ðʧ°Ü" + error);
                     });
                 }, () =>
                 {
                     RunOnUiThread(() =>
                     {
                         progressDialog.Hide();
                         AlertUtil.ToastShort(this, "ɾ³ý»Ø´ð³É¹¦");
                     });
                 });
             }
             else if (e.Which == 1)
             {
                 QuestionEditAnswerActivity.Enter(this, questionId, answerId, answerList[position].Answer);
             }
         }).Show();
     }
 }
Пример #14
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;
                });
            }
        }
Пример #15
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;
        }
Пример #16
0
 public override bool OnMenuItemClick(IMenuItem menuItem)
 {
     if (menuItem.ItemId == Resource.Id.search)
     {
         string category = string.Empty;
         if (tv_blog.Selected)
         {
             category = "Blog";
         }
         else if (tv_news.Selected)
         {
             if (newsFragment.currentPosition == 0)
             {
                 category = "Kb";
             }
             else
             {
                 category = "News";
             }
             System.Diagnostics.Debug.Write("position", newsFragment.currentPosition.ToString());
         }
         else if (tv_question.Selected)
         {
             category = "Question";
         }
         else
         {
             category = "Blog";
         }
         SearchResultActivity.Enter(category, this);
     }
     if (menuItem.ItemId == Resource.Id.add)
     {
         if (tv_status.Selected)
         {
             AddStatusActivity.Enter(this);
         }
         else if (tv_question.Selected)
         {
             AddQuestionActivity.Enter(this);
         }
         AlertUtil.ToastShort(this, "添加");
     }
     if (menuItem.ItemId == Resource.Id.setting)
     {
         if (tv_userCenter.Selected)
         {
             SettingActivity.Enter(this);
         }
     }
     return(true);
 }
Пример #17
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;
                    });
                });
            }
        }
Пример #18
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;
                }
            }
        }
Пример #19
0
        private void Add()
        {
            string body = edit_content.Text.TrimEnd().TrimStart();

            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.EditQuestionAnswer(userToken, body, questionId, answerId, 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;
                    });
                });
            }
        }
Пример #20
0
        private async void LoadMore()
        {
            var result = await QuestionService.ListQuestionAnswer(userToken, questionId);

            if (result.Success)
            {
                var tempList = result.Data;
                answerList.AddRange(tempList);
                adapter.SetNewData(answerList);
            }
            else
            {
                AlertUtil.ToastShort(this, result.Message);
            }
        }
Пример #21
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;
            }
        }
Пример #22
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);
            }
        }
Пример #23
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);
            }
        }
Пример #24
0
 public override bool OnKeyDown(Keycode keycode, KeyEvent e)
 {
     if (keycode == Keycode.Back && e.Action == KeyEventActions.Down)
     {
         if (!firstBackTime.HasValue || DateTime.Now.Second - firstBackTime.Value.Second > 2)
         {
             AlertUtil.ToastShort(this, "再按一次退出");
             firstBackTime = DateTime.Now;
         }
         else
         {
             removeAllActivity();
         }
         return(true);
     }
     return(base.OnKeyDown(keycode, e));
 }
Пример #25
0
 //ÇëÇóÉÁ´æÆÀÂ۳ɹ¦µÄ»Øµ÷
 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);
 }
Пример #26
0
        public async void OnRefresh()
        {
            var result = await QuestionService.ListQuestionAnswer(userToken, questionId);

            if (result.Success)
            {
                answerList = result.Data;
                adapter.SetNewData(answerList);
            }
            else
            {
                AlertUtil.ToastShort(this, result.Message);
            }
            _swipeRefreshLayout.PostDelayed(() =>
            {
                _swipeRefreshLayout.Refreshing = false;
            }, 1000);
        }
Пример #27
0
        private async void initRecyclerView()
        {
            var result = await QuestionService.ListQuestionAnswer(AccessTokenUtil.GetToken(this), questionId);

            if (result.Success)
            {
                answerList = result.Data;
                initRecycler();
            }
            else
            {
                AlertUtil.ToastShort(this, result.Message);
            }
            _swipeRefreshLayout.PostDelayed(() =>
            {
                _swipeRefreshLayout.Refreshing = false;
            }, 1000);
        }
Пример #28
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);
            }
        }
Пример #29
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);
            }
        }
Пример #30
0
        private async void LoadMore()
        {
            pageIndex++;
            var result = await NewsService.ListNewsComment(accessToken, POSTID, pageIndex);

            if (result.Success)
            {
                var tempList = result.Data;
                if (tempList != null && tempList.Count != 0)
                {
                    commentList.AddRange(tempList);
                    adapter.SetNewData(commentList);
                    System.Diagnostics.Debug.Write("页数:" + pageIndex + "数据总条数:" + commentList.Count);
                }
            }
            else
            {
                AlertUtil.ToastShort(this, result.Message);
            }
        }