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);
        }
Пример #2
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);
        }
Пример #3
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;
                    });
                });
            }
        }
Пример #4
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;
                }
            }
        }
Пример #5
0
        void initRecycler()
        {
            listStatusComment = listStatusComment.OrderByDescending(s => s.DateAdded).ToList();
            adapter           = new BaseRecyclerViewAdapter <StatusCommentsModel>(this, listStatusComment, Resource.Layout.item_recyclerview_statusComment, () => { });
            _recyclerView.SetAdapter(adapter);
            adapter.ItemClick += (position, tag) =>
            {
                var currentCommentModel = listStatusComment.Find(p => p.Id == int.Parse(tag));
                var userInfo            = UserInfoShared.GetUserInfo(this);
                if (userInfo.DisplayName == currentCommentModel.UserDisplayName)
                {
                    return;
                }
                parentCommentId = currentCommentModel.Id;
                replyToUserId   = currentCommentModel.UserId;
                atUserName      = "******" + currentCommentModel.UserId + "'>@" + currentCommentModel.UserDisplayName + "£º</a>";
                displayUserName = currentCommentModel.UserDisplayName;
                edit_content.SetText(HtmlUtil.GetHtml(atUserName), TextView.BufferType.Spannable);
                // edit_content.Text = "@"+currentCommentModel.UserDisplayName;
            };
            adapter.ItemLongClick += (tag, position) =>
            {
                //ɾ³ýÎÒÆÀÂÛÉÁ´æ
                var model = listStatusComment.Find(f => f.Id == int.Parse(tag));
                var user  = UserInfoShared.GetUserInfo(this);
                if (model.UserDisplayName == user.DisplayName)
                {
                    DeleteComment(model);
                }
            };
            string read = Resources.GetString(Resource.String.read);
            string digg = Resources.GetString(Resource.String.digg);

            adapter.OnConvertView += (holder, position) =>
            {
                holder.SetText(Resource.Id.tv_commentDateAdded, listStatusComment[position].DateAdded.ToCommonString());
                (holder.GetView <TextView>(Resource.Id.tv_commentContent)).SetText(HtmlUtil.GetHtml(listStatusComment[position].Content), TextView.BufferType.Spannable);
                holder.SetImageLoader(Resource.Id.iv_commentUserIcon, options, listStatusComment[position].UserIconUrl);
                holder.SetText(Resource.Id.tv_commentUserName, listStatusComment[position].UserDisplayName);
                holder.SetText(Resource.Id.tv_floor, adapter.ItemCount - position - 1 + "Â¥");
                holder.SetTag(Resource.Id.ly_item, listStatusComment[position].Id.ToString());
            };
        }
Пример #6
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();
            }
        }
Пример #7
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);
 }
Пример #8
0
        async void UpdateViewStatus(Action callBack, Action callBackError)
        {
            if (!UserUtil.Instance(Activity).LoginExpire())
            {
                ly_unLogin.Visibility = ViewStates.Gone;
                ly_logged.Visibility  = ViewStates.Visible;

                userInfo = UserInfoShared.GetUserInfo(Activity);
                userBlog = UserBlogShared.GetUserBlog(Activity);

                if (userInfo.SpaceUserId == 0)
                {
                    var result = await UserInfoService.GetUser(userToken);

                    if (result.Success)
                    {
                        userInfo = result.Data;
                        UserInfoShared.SetUserInfo(userInfo, Activity);
                        callBack();
                    }
                    else
                    {
                        callBackError();
                    }
                }
                if (userBlog.BlogId == 0)
                {
                    var result = await UserInfoService.GetUserBlog(userToken, userInfo.BlogApp);

                    if (result.Success)
                    {
                        userBlog = result.Data;
                        UserBlogShared.SetUserBlog(userBlog, Activity);
                        tv_subTitle.Text  = userBlog.SubTitle.ToDBC();
                        tv_postCount.Text = userBlog.PostCount.ToString();
                        callBack();
                    }
                    else
                    {
                        callBackError();
                    }
                }
                //用户信息
                tv_userName.Text  = userInfo.DisplayName;
                tv_seniority.Text = "园龄:" + userInfo.Seniority + "积分:" + userInfo.Score;
                ImageLoader.Instance.DisplayImage(userInfo.Avatar, iv_userAvatar, options);
                //用户博客信息
                tv_subTitle.Text     = userBlog.SubTitle.ToDBC();
                tv_postCount.Text    = userBlog.PostCount.ToString();
                ll_blog.Click       -= UnLoginClick;
                ll_status.Click     -= UnLoginClick;
                ll_question.Click   -= UnLoginClick;
                tv_myBookmark.Click -= UnLoginClick;
                if (!loggedClickRegistered)
                {
                    ll_blog.Click       += MyBlogClick;
                    ll_status.Click     += MyStatusClick;
                    ll_question.Click   += MyQuestionClick;
                    tv_myBookmark.Click += MyBookMarkClick;
                }
                loggedClickRegistered = true;
                callBack();
            }
            else
            {
                ImageLoader.Instance.DisplayImage("drawable://" + Resource.Drawable.icon_userDefault, iv_userAvatar, options);
                ly_unLogin.Visibility = ViewStates.Visible;
                ly_logged.Visibility  = ViewStates.Gone;//用户layout不显示
                tv_postCount.Text     = "0";

                ll_blog.Click       -= MyBlogClick;
                ll_status.Click     -= MyStatusClick;
                ll_question.Click   -= MyQuestionClick;
                tv_myBookmark.Click -= MyBookMarkClick;
                if (!unLoginClickRegistered)
                {
                    ll_blog.Click       += UnLoginClick;
                    ll_status.Click     += UnLoginClick;
                    ll_question.Click   += UnLoginClick;
                    tv_myBookmark.Click += UnLoginClick;
                }
                unLoginClickRegistered = true;
                callBack();
            }
        }
Пример #9
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();
            }
        }
Пример #10
0
        public async void AddQuestionClick(object o, EventArgs e)
        {
            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();
            }
            string content = edit_content.Text.Trim();
            string title   = edit_content.Text.Trim();
            string tags    = edit_tags.Text.Trim();

            if (string.IsNullOrEmpty(content) || content.Length > 100000 || content.Length < 20)
            {
                AlertUtil.ToastShort(this, "提问内容20-100000个字符之间");
                return;
            }
            if (string.IsNullOrEmpty(title) || title.Length > 100000 || title.Length < 20)
            {
                AlertUtil.ToastShort(this, "标题6-200分字符");
                return;
            }
            if (!string.IsNullOrEmpty(tags))
            {
                var tagCount = tags.Split(',').Length;
                if (tagCount > 5)
                {
                    AlertUtil.ToastShort(this, "不能超过5个标签,以中文都好隔开");
                    return;
                }
            }
            var userInfo = UserInfoShared.GetUserInfo(this);
            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 QuestionService.Add(userToken, title, content, tags, flags, userInfo.SpaceUserId.ToString());

            if (result.Success)
            {
                RunOnUiThread(() =>
                {
                    dialog.Hide();
                    edit_content.Text = "";
                    edit_title.Text   = "";
                    edit_tags.Text    = "";
                    rb_true.Checked   = true;
                    AlertUtil.ToastShort(this, "发布问答成功");
                    ActivityCompat.FinishAfterTransition(this);
                });
            }
            else
            {
                RunOnUiThread(() =>
                {
                    dialog.Hide();
                    AlertUtil.ToastShort(this, result.Message);
                });
            }
        }