public void LoadUserData(UserDataObject cl, bool friends = true)
        {
            try
            {
                PPrivacy = cl.PPrivacy;

                GlideImageLoader.LoadImage(Activity, cl.Avatar, ImageUser, ImageStyle.CircleCrop, ImagePlaceholders.Color);

                AboutTab.TextSanitizerAutoLink.Load(AppTools.GetAboutFinal(cl));
                AboutTab.TxtGender.Text = cl.Gender;
                AboutTab.TxtEmail.Text  = cl.Email;
                if (string.IsNullOrEmpty(cl.Website))
                {
                    AboutTab.WebsiteLinearLayout.Visibility = ViewStates.Gone;
                }
                else
                {
                    AboutTab.TxtWebsite.Text = cl.Website;
                    AboutTab.WebsiteLinearLayout.Visibility = ViewStates.Visible;
                }

                TxtUserName.Text = "@" + cl.Username;

                var font = Typeface.CreateFromAsset(Application.Context.Resources.Assets, "ionicons.ttf");
                TxtFullName.SetTypeface(font, TypefaceStyle.Normal);

                var textHighLighter = AppTools.GetNameFinal(cl);

                if (cl.Verified == "1")
                {
                    textHighLighter += " " + IonIconsFonts.CheckmarkCircled;
                }

                if (cl.BusinessAccount == "1")
                {
                    textHighLighter += " " + IonIconsFonts.SocialUsd;
                }

                var decorator = TextDecorator.Decorate(TxtFullName, textHighLighter);

                if (cl.Verified == "1")
                {
                    decorator.SetTextColor(Resource.Color.Post_IsVerified, IonIconsFonts.CheckmarkCircled);
                }

                if (cl.BusinessAccount == "1")
                {
                    decorator.SetTextColor(Resource.Color.Post_IsBusiness, IonIconsFonts.SocialUsd);
                }

                decorator.Build();

                TxtPostCount.Text = Methods.FunString.FormatPriceValue(Int32.Parse(cl.PostsCount));

                if (cl.Followers != null && int.TryParse(cl.Followers, out var numberFollowers))
                {
                    TxtFollowersCount.Text = Methods.FunString.FormatPriceValue(numberFollowers);
                }

                if (cl.Following != null && int.TryParse(cl.Following, out var numberFollowing))
                {
                    TxtFollowingCount.Text = Methods.FunString.FormatPriceValue(numberFollowing);
                }

                if (!string.IsNullOrEmpty(cl.Google))
                {
                    AboutTab.Google = cl.Google;
                    AboutTab.SocialGoogle.SetTypeface(font, TypefaceStyle.Normal);
                    AboutTab.SocialGoogle.Text            = IonIconsFonts.SocialGoogle;
                    AboutTab.SocialGoogle.Visibility      = ViewStates.Visible;
                    AboutTab.SocialLinksLinear.Visibility = ViewStates.Visible;
                }

                if (!string.IsNullOrEmpty(cl.Facebook))
                {
                    AboutTab.Facebook = cl.Facebook;
                    AboutTab.SocialFacebook.SetTypeface(font, TypefaceStyle.Normal);
                    AboutTab.SocialFacebook.Text          = IonIconsFonts.SocialFacebook;
                    AboutTab.SocialFacebook.Visibility    = ViewStates.Visible;
                    AboutTab.SocialLinksLinear.Visibility = ViewStates.Visible;
                }

                if (!string.IsNullOrEmpty(cl.Website))
                {
                    AboutTab.Website = cl.Website;
                    AboutTab.WebsiteButton.SetTypeface(font, TypefaceStyle.Normal);
                    AboutTab.WebsiteButton.Text           = IonIconsFonts.AndroidGlobe;
                    AboutTab.WebsiteButton.Visibility     = ViewStates.Visible;
                    AboutTab.SocialLinksLinear.Visibility = ViewStates.Visible;
                }


                if (!string.IsNullOrEmpty(cl.Twitter))
                {
                    AboutTab.Twitter = cl.Twitter;
                    AboutTab.SocialTwitter.SetTypeface(font, TypefaceStyle.Normal);
                    AboutTab.SocialTwitter.Text           = IonIconsFonts.SocialTwitter;
                    AboutTab.SocialTwitter.Visibility     = ViewStates.Visible;
                    AboutTab.SocialLinksLinear.Visibility = ViewStates.Visible;
                }

                BtnMessage.Visibility = cl.IsFollowing != null && (cl.CPrivacy == "1" || cl.CPrivacy == "2" && cl.IsFollowing.Value) ? ViewStates.Visible : ViewStates.Invisible;

                if (cl.IsFollowing != null)
                {
                    SIsFollowing = cl.IsFollowing.Value;
                }

                if (!friends)
                {
                    return;
                }
                if (cl.IsFollowing != null && cl.IsFollowing.Value) // My Friend
                {
                    FollowButton.SetBackgroundColor(Color.ParseColor("#efefef"));
                    FollowButton.SetTextColor(Color.ParseColor("#444444"));
                    FollowButton.Text = Context.GetText(Resource.String.Lbl_Following);
                    FollowButton.Tag  = "true";
                }
                else
                {
                    //Not Friend
                    FollowButton.SetBackgroundResource(Resource.Drawable.buttonFlatNormal);
                    FollowButton.SetTextColor(Color.ParseColor("#ffffff"));
                    FollowButton.Text = Context.GetText(Resource.String.Lbl_Follow);
                    FollowButton.Tag  = "false";
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
示例#2
0
        private async void LoadProfile()
        {
            try
            {
                if (ListUtils.MyProfileList.Count == 0)
                {
                    await ApiRequest.GetProfile_Api(Activity);
                }

                var data = ListUtils.MyProfileList.FirstOrDefault();
                if (data != null)
                {
                    GlideImageLoader.LoadImage(Activity, data.Avatar, ImageUser, ImageStyle.CircleCrop, ImagePlaceholders.Color);

                    //TxtFullName.Text = AppTools.GetNameFinal(data);
                    CollapsingToolbar.Title = AppTools.GetNameFinal(data);
                    TxtUserName.Text        = "@" + data.Username;

                    TxtPostCount.Text = Methods.FunString.FormatPriceValue(Int32.Parse(data.Favourites));

                    if (data.Followers != null && int.TryParse(data.Followers, out var numberFollowers))
                    {
                        TxtFollowersCount.Text = Methods.FunString.FormatPriceValue(numberFollowers);
                    }

                    if (data.Following != null && int.TryParse(data.Following, out var numberFollowing))
                    {
                        TxtFollowingCount.Text = Methods.FunString.FormatPriceValue(numberFollowing);
                    }

                    var font = Typeface.CreateFromAsset(Application.Context.Resources.Assets, "ionicons.ttf");
                    TxtFullName.SetTypeface(font, TypefaceStyle.Normal);

                    var textHighLighter = AppTools.GetNameFinal(data);
                    var textIsPro       = string.Empty;

                    if (data.Verified == "1")
                    {
                        textHighLighter += " " + IonIconsFonts.CheckmarkCircled;
                    }

                    if (data.BusinessAccount == "1")
                    {
                        textIsPro        = " " + IonIconsFonts.SocialUsd;
                        textHighLighter += textIsPro;
                    }

                    var decorator = TextDecorator.Decorate(TxtFullName, textHighLighter);

                    if (data.Verified == "1")
                    {
                        decorator.SetTextColor(Resource.Color.Post_IsVerified, IonIconsFonts.CheckmarkCircled);
                    }

                    if (data.BusinessAccount == "1")
                    {
                        decorator.SetTextColor(Resource.Color.Post_IsBusiness, IonIconsFonts.SocialUsd);
                    }

                    decorator.Build();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }