Ejemplo n.º 1
0
 public static UserUtil Instance(Context context)
 {
     if (instance == null)
     {
         instance = new UserUtil(context);
     }
     return(instance);
 }
Ejemplo n.º 2
0
        public override async void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);
            ly_expire           = view.FindViewById <LinearLayout>(Resource.Id.ly_expire);
            tv_startLogin       = view.FindViewById <TextView>(Resource.Id.tv_startLogin);
            _swipeRefreshLayout = view.FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout);
            _swipeRefreshLayout.SetColorSchemeResources(Resource.Color.primary);
            _swipeRefreshLayout.SetOnRefreshListener(this);
            userToken   = UserTokenUtil.GetToken(Activity);
            accessToken = AccessTokenUtil.GetToken(Activity);

            _recyclerView = view.FindViewById <RecyclerView>(Resource.Id.recyclerView);
            _recyclerView.SetLayoutManager(new Android.Support.V7.Widget.LinearLayoutManager(this.Activity));
            //_recyclerView.AddItemDecoration(new RecyclerViewDecoration(this.Activity, (int)Orientation.Vertical));
            try
            {
                if (position != 0 || isMy) //³ýÁË×îÐÂÉÁ´æ£¬ÆäËûµÄ¶¼Òªusertoken
                {
                    if (UserUtil.Instance(Activity).LoginExpire())
                    {
                        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;
                        statusList = await SQLiteUtil.SelectStatusList(Constact.PageSize, isMy);

                        if (statusList != null && statusList.Count != 0)
                        {
                            initRecycler();
                        }
                        OnRefresh();
                    }
                }
                else
                {
                    ly_expire.Visibility           = ViewStates.Gone;
                    _swipeRefreshLayout.Visibility = ViewStates.Visible;
                    statusList = await SQLiteUtil.SelectStatusList(Constact.PageSize);

                    if (statusList != null && statusList.Count != 0)
                    {
                        initRecycler();
                    }
                    OnRefresh();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Write("statusTabFragment", ex.ToString());
            }
        }
Ejemplo n.º 3
0
 void InitViewUserInfo(UserInfo userInfo)
 {
     if (!UserUtil.Instance(Activity).LoginExpire())
     {
         tv_userName.Text  = userInfo.DisplayName;
         tv_seniority.Text = "园龄:" + userInfo.Seniority + "积分:" + userInfo.Score;
         ImageLoader.Instance.DisplayImage(userInfo.Avatar, iv_userAvatar, options);
     }
     else
     {
         ImageLoader.Instance.DisplayImage("drawable://" + Resource.Drawable.icon_userDefault, iv_userAvatar, options);
     }
 }
Ejemplo n.º 4
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();
            }
        }