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(); } }
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(); } }