Пример #1
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                if (viewHolder is SelectContactsAdapterViewHolder holder)
                {
                    var item = UserList[position];
                    if (item != null)
                    {
                        holder.CheckBox.Checked = item.Selected;

                        GlideImageLoader.LoadImage(ActivityContext, item.Avatar, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);

                        holder.Name.Text = WoWonderTools.GetNameFinal(item);

                        if (item.Verified == "1")
                        {
                            holder.Name.SetCompoundDrawablesWithIntrinsicBounds(0, 0, Resource.Drawable.icon_checkmark_small_vector, 0);
                        }

                        holder.About.Text = Methods.FunString.SubStringCutOf(WoWonderTools.GetAboutFinal(item), 25);
                    }
                }
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
Пример #2
0
        private void Initialize(ContactsAdapterViewHolder holder, UserDataObject users)
        {
            try
            {
                GlideImageLoader.LoadImage(ActivityContext, users.Avatar, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable, true);

                holder.Name.Text = Methods.FunString.SubStringCutOf(WoWonderTools.GetNameFinal(users), 20);

                switch (users.Verified)
                {
                case "1":
                    holder.Name.SetCompoundDrawablesWithIntrinsicBounds(0, 0, Resource.Drawable.icon_checkmark_small_vector, 0);
                    break;
                }

                switch (Type)
                {
                case TypeTextSecondary.None:
                    holder.About.Visibility = ViewStates.Gone;
                    break;

                default:
                    holder.About.Text = Type == TypeTextSecondary.About ? Methods.FunString.SubStringCutOf(WoWonderTools.GetAboutFinal(users), 25) : ActivityContext.GetString(Resource.String.Lbl_Last_seen) + " " + Methods.Time.TimeAgo(Convert.ToInt32(users.LastseenUnixTime), true);
                    break;
                }

                //Online Or offline
                var online = WoWonderTools.GetStatusOnline(Convert.ToInt32(users.LastseenUnixTime), users.LastseenStatus);
                holder.ImageLastSeen.SetImageResource(online ? Resource.Drawable.Green_Color : Resource.Drawable.Grey_Offline);

                switch (ShowButton)
                {
                case false:
                    return;

                default:
                    WoWonderTools.SetAddFriendCondition(users.IsFollowing, holder.Button);
                    break;
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Пример #3
0
        //Lang
        //private void LangPref_OnPreferenceChange(object sender, Preference.PreferenceChangeEventArgs eventArgs)
        //{
        //    try
        //    {
        //        if (eventArgs.Handled)
        //        {
        //            var etp = (ListPreference) sender;
        //            var value = eventArgs.NewValue;

        //            AppSettings.Lang = value.ToString();

        //            MainSettings.SetApplicationLang(Activity, AppSettings.Lang);

        //            Toast.MakeText(ActivityContext, GetText(Resource.String.Lbl_Application_Restart), ToastLength.Long)?.Show();

        //            var intent = new Intent(Activity, typeof(SplashScreenActivity));
        //            intent.AddCategory(Intent?.CategoryHome);
        //            intent.SetAction(Intent?.ActionMain);
        //            intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask | ActivityFlags.ClearTask);
        //            Activity.StartActivity(intent);
        //            Activity.FinishAffinity();

        //            AppSettings.Lang = value.ToString();
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        Methods.DisplayReportResultTrack(e);
        //    }
        //}

        #endregion

        //On Change
        public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key)
        {
            try
            {
                var dataUser = ListUtils.MyProfileList?.FirstOrDefault();

                if (key.Equals("about_me_key"))
                {
                    // Set summary to be the user-description for the selected value
                    Preference etp = FindPreference("about_me_key");
                    if (dataUser != null)
                    {
                        SAbout = WoWonderTools.GetAboutFinal(dataUser);

                        MainSettings.SharedData.Edit()?.PutString("about_me_key", SAbout)?.Commit();
                        etp.Summary = SAbout;
                    }

                    string getvalue = MainSettings.SharedData.GetString("about_me_key", SAbout);
                    etp.Summary = getvalue;
                }
                else if (key.Equals("Night_Mode_key"))
                {
                    // Set summary to be the user-description for the selected value
                    Preference etp = FindPreference("Night_Mode_key");

                    string getValue = MainSettings.SharedData.GetString("Night_Mode_key", string.Empty);
                    if (getValue == MainSettings.LightMode)
                    {
                        etp.Summary = ActivityContext.GetString(Resource.String.Lbl_Light);
                    }
                    else if (getValue == MainSettings.DarkMode)
                    {
                        etp.Summary = ActivityContext.GetString(Resource.String.Lbl_Dark);
                    }
                    else if (getValue == MainSettings.DefaultMode)
                    {
                        etp.Summary = ActivityContext.GetString(Resource.String.Lbl_SetByBattery);
                    }
                    else
                    {
                        etp.Summary = getValue;
                    }
                }
                //else if (key.Equals("Lang_key"))
                //{
                //    var valueAsText = LangPref.Entry;
                //    if (!string.IsNullOrEmpty(valueAsText))
                //    {
                //        AppSettings.FlowDirectionRightToLeft = false;
                //        if (valueAsText.ToLower().Contains("english"))
                //        {
                //           // MainSettings.SharedData.Edit()?.PutString("Lang_key", "en")?.Commit();
                //            LangPref.SetValueIndex(1);
                //        }
                //        else if (valueAsText.ToLower().Contains("arabic"))
                //        {
                //            //MainSettings.SharedData.Edit()?.PutString("Lang_key", "ar")?.Commit();
                //            LangPref.SetValueIndex(2);
                //            AppSettings.FlowDirectionRightToLeft = true;
                //        }
                //        else if (valueAsText.ToLower().Contains("german"))
                //        {
                //            //MainSettings.SharedData.Edit()?.PutString("Lang_key", "de")?.Commit();
                //            LangPref.SetValueIndex(3);
                //        }
                //        else if (valueAsText.ToLower().Contains("greek"))
                //        {
                //            //MainSettings.SharedData.Edit()?.PutString("Lang_key", "el")?.Commit();
                //            LangPref.SetValueIndex(4);
                //        }
                //        else if (valueAsText.ToLower().Contains("spanish"))
                //        {
                //           // MainSettings.SharedData.Edit()?.PutString("Lang_key", "es")?.Commit();
                //            LangPref.SetValueIndex(5);
                //        }
                //        else if (valueAsText.ToLower().Contains("french"))
                //        {
                //           // MainSettings.SharedData.Edit()?.PutString("Lang_key", "fr")?.Commit();
                //            LangPref.SetValueIndex(6);
                //        }
                //        else if (valueAsText.ToLower().Contains("italian"))
                //        {
                //          //  MainSettings.SharedData.Edit()?.PutString("Lang_key", "it")?.Commit();
                //            LangPref.SetValueIndex(7);
                //        }
                //        else if (valueAsText.ToLower().Contains("japanese"))
                //        {
                //           // MainSettings.SharedData.Edit()?.PutString("Lang_key", "ja")?.Commit();
                //            LangPref.SetValueIndex(8);
                //        }
                //        else if (valueAsText.ToLower().Contains("dutch"))
                //        {
                //           // MainSettings.SharedData.Edit()?.PutString("Lang_key", "nl")?.Commit();
                //            LangPref.SetValueIndex(9);
                //        }
                //        else if (valueAsText.ToLower().Contains("portuguese"))
                //        {
                //          //  MainSettings.SharedData.Edit()?.PutString("Lang_key", "pt")?.Commit();
                //            LangPref.SetValueIndex(10);
                //        }
                //        else if (valueAsText.ToLower().Contains("romanian"))
                //        {
                //           // MainSettings.SharedData.Edit()?.PutString("Lang_key", "ro")?.Commit();
                //            LangPref.SetValueIndex(11);
                //        }
                //        else if (valueAsText.ToLower().Contains("russian"))
                //        {
                //          //  MainSettings.SharedData.Edit()?.PutString("Lang_key", "ru")?.Commit();
                //            LangPref.SetValueIndex(12);
                //        }
                //        else if (valueAsText.ToLower().Contains("russian"))
                //        {
                //           // MainSettings.SharedData.Edit()?.PutString("Lang_key", "ru")?.Commit();
                //            LangPref.SetValueIndex(13);
                //        }
                //        else if (valueAsText.ToLower().Contains("albanian"))
                //        {
                //            //MainSettings.SharedData.Edit()?.PutString("Lang_key", "sq")?.Commit();
                //            LangPref.SetValueIndex(14);
                //        }
                //        else if (valueAsText.ToLower().Contains("serbian"))
                //        {
                //            //MainSettings.SharedData.Edit()?.PutString("Lang_key", "sr")?.Commit();
                //            LangPref.SetValueIndex(15);
                //        }
                //        else if (valueAsText.ToLower().Contains("turkish"))
                //        {
                //            //MainSettings.SharedData.Edit()?.PutString("Lang_key", "tr")?.Commit();
                //            LangPref.SetValueIndex(16);
                //        }
                //        else
                //        {
                //           // MainSettings.SharedData.Edit()?.PutString("Lang_key", "Auto")?.Commit();
                //            LangPref.SetValueIndex(0);
                //        }
                //    }
                //    else
                //    {
                //        //MainSettings.SharedData.Edit()?.PutString("Lang_key", "Auto")?.Commit();
                //        LangPref.SetValueIndex(0);
                //    }
                //}
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
        private void Initialize(ContactsAdapterViewHolder holder, UserDataObject users)
        {
            try
            {
                if (users.Avatar == "addImage")
                {
                    holder.ImageLastseen.Visibility = ViewStates.Gone;
                }

                GlideImageLoader.LoadImage(ActivityContext, users.Avatar, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);

                holder.Name.Text = Methods.FunString.SubStringCutOf(WoWonderTools.GetNameFinal(users), 25);

                if (users.Verified == "1")
                {
                    holder.Name.SetCompoundDrawablesWithIntrinsicBounds(0, 0, Resource.Drawable.icon_checkmark_small_vector, 0);
                }

                if (Type == TypeTextSecondary.None)
                {
                    holder.About.Visibility = ViewStates.Gone;
                }
                else
                {
                    holder.About.Text = Type == TypeTextSecondary.About ? Methods.FunString.SubStringCutOf(WoWonderTools.GetAboutFinal(users), 35) : ActivityContext.GetString(Resource.String.Lbl_Last_seen) + " " + Methods.Time.TimeAgo(int.Parse(users.LastseenUnixTime), true);
                }

                //Online Or offline
                var online = WoWonderTools.GetStatusOnline(int.Parse(users.LastseenUnixTime), users.LastseenStatus);
                if (online)
                {
                    holder.ImageLastseen.SetImageResource(Resource.Drawable.Green_Online);
                    if (AppSettings.ShowOnlineOfflineMessage)
                    {
                        var data = ListOnline.Contains(users.Name);
                        if (data == false)
                        {
                            ListOnline.Add(users.Name);

                            Toast toast = Toast.MakeText(ActivityContext, users.Name + " " + ActivityContext.GetString(Resource.String.Lbl_Online), ToastLength.Short);
                            toast.SetGravity(GravityFlags.Center, 0, 0);
                            toast.Show();
                        }
                    }
                }
                else
                {
                    holder.ImageLastseen.SetImageResource(Resource.Drawable.Grey_Offline);
                }

                if (ShowButton)
                {
                    switch (users.IsFollowing)
                    {
                    // My Friend
                    case "1":
                    {
                        holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed);
                        holder.Button.SetTextColor(Color.ParseColor("#ffffff"));
                        if (AppSettings.ConnectivitySystem == 1)        // Following
                        {
                            holder.Button.Text = ActivityContext.GetText(Resource.String.Lbl_Following);
                        }
                        else         // Friend
                        {
                            holder.Button.Text = ActivityContext.GetText(Resource.String.Lbl_Friends);
                        }
                        holder.Button.Tag = "true";
                        break;
                    }

                    // Request
                    case "2":
                        holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends);
                        holder.Button.SetTextColor(Color.ParseColor("#444444"));
                        holder.Button.Text = ActivityContext.GetText(Resource.String.Lbl_Request);
                        holder.Button.Tag  = "Request";
                        break;

                    //Not Friend
                    case "0":
                    {
                        holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends);
                        holder.Button.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                        if (AppSettings.ConnectivitySystem == 1)         // Following
                        {
                            holder.Button.Text = ActivityContext.GetText(Resource.String.Lbl_Follow);
                        }
                        else         // Friend
                        {
                            holder.Button.Text = ActivityContext.GetText(Resource.String.Lbl_AddFriends);
                        }
                        holder.Button.Tag = "false";

                        var dbDatabase = new SqLiteDatabase();
                        dbDatabase.Delete_UsersContact(users.UserId);
                        dbDatabase.Dispose();
                        break;
                    }

                    default:
                    {
                        holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed);
                        holder.Button.SetTextColor(Color.ParseColor("#ffffff"));
                        if (AppSettings.ConnectivitySystem == 1)         // Following
                        {
                            holder.Button.Text = ActivityContext.GetText(Resource.String.Lbl_Following);
                        }
                        else         // Friend
                        {
                            holder.Button.Text = ActivityContext.GetText(Resource.String.Lbl_Friends);
                        }

                        users.IsFollowing = "1";
                        holder.Button.Tag = "true";
                        break;
                    }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        private void LoadDataUser(UserDataObject data)
        {
            try
            {
                //Cover
                GlideImageLoader.LoadImage(this, data.Cover, ImageUserCover, ImageStyle.CenterCrop, ImagePlaceholders.Drawable);

                //profile_picture
                GlideImageLoader.LoadImage(this, data.Avatar, ImageUserProfile, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);

                TextSanitizer sanitizer = new TextSanitizer(TxtAbout, this);
                sanitizer.Load(WoWonderTools.GetAboutFinal(data));

                TxtFullname.Text = WoWonderTools.GetNameFinal(data);
                TxtUserName.Text = "@" + data.Username;

                if (data.Details.DetailsClass != null)
                {
                    var following = Methods.FunString.FormatPriceValue(Convert.ToInt32(data.Details.DetailsClass?.FollowingCount));
                    var followers = Methods.FunString.FormatPriceValue(Convert.ToInt32(data.Details.DetailsClass?.FollowersCount));

                    if (AppSettings.ConnectivitySystem == 1)
                    {
                        TxtFollowing.Visibility      = ViewStates.Visible;
                        TxtFollowingCount.Visibility = ViewStates.Visible;

                        TxtFollowers.Visibility      = ViewStates.Visible;
                        TxtFollowersCount.Visibility = ViewStates.Visible;

                        TxtFollowing.Text      = GetText(Resource.String.Lbl_Following);
                        TxtFollowingCount.Text = following;

                        TxtFollowers.Text      = GetText(Resource.String.Lbl_Followers);
                        TxtFollowersCount.Text = followers;
                    }
                    else
                    {
                        TxtFollowing.Visibility      = ViewStates.Visible;
                        TxtFollowingCount.Visibility = ViewStates.Visible;

                        TxtFollowers.Visibility      = ViewStates.Gone;
                        TxtFollowersCount.Visibility = ViewStates.Gone;

                        TxtFollowing.Text      = GetText(Resource.String.Lbl_Friends);
                        TxtFollowingCount.Text = following;
                    }
                }

                switch (data.IsFollowing)
                {
                // My Friend
                case "1":
                    AddFriendOrFollowButton.Visibility = ViewStates.Visible;
                    AddFriendOrFollowButton.SetColor(Color.ParseColor(AppSettings.MainColor));
                    AddFriendOrFollowButton.SetImageResource(Resource.Drawable.ic_tick);
                    AddFriendOrFollowButton.Tag = "friends";
                    break;

                // Request
                case "2":
                    AddFriendOrFollowButton.Visibility = ViewStates.Visible;
                    AddFriendOrFollowButton.SetColor(Color.ParseColor(AppSettings.MainColor));
                    AddFriendOrFollowButton.SetImageResource(Resource.Drawable.ic_requestAdd);
                    AddFriendOrFollowButton.Tag = "request";
                    break;

                //Not Friend
                case "0":
                    AddFriendOrFollowButton.Visibility = ViewStates.Visible;
                    AddFriendOrFollowButton.SetColor(Color.ParseColor("#8c8a8a"));
                    AddFriendOrFollowButton.SetImageResource(Resource.Drawable.ic_add);
                    AddFriendOrFollowButton.Tag = "Add";
                    break;
                }

                if (Methods.FunString.StringNullRemover(data.Gender) != "Empty")
                {
                    TxtGenderText.Text = data.Gender.ToLower() switch
                    {
                        "male" => GetText(Resource.String.Radio_Male),
                        "female" => GetText(Resource.String.Radio_Female),
                        _ => data.Gender
                    };

                    GenderLiner.Visibility = ViewStates.Visible;
                }
                else
                {
                    GenderLiner.Visibility = ViewStates.Gone;
                }

                if (Methods.FunString.StringNullRemover(data.Address) != "Empty")
                {
                    LocationLiner.Visibility = ViewStates.Visible;
                    TxtLocationText.Text     = data.Address;
                }
                else
                {
                    LocationLiner.Visibility = ViewStates.Gone;
                }

                if (AppSettings.EnableShowPhoneNumber)
                {
                    if (Methods.FunString.StringNullRemover(data.PhoneNumber) != "Empty")
                    {
                        MobileLiner.Visibility = ViewStates.Visible;
                        TxtMobileText.Text     = data.PhoneNumber;
                    }
                    else
                    {
                        MobileLiner.Visibility = ViewStates.Gone;
                    }
                }
                else
                {
                    MobileLiner.Visibility = ViewStates.Gone;
                }

                if (Methods.FunString.StringNullRemover(data.Website) != "Empty")
                {
                    WebsiteLiner.Visibility = ViewStates.Visible;
                    TxtWebsiteText.Text     = data.Website;
                }
                else
                {
                    WebsiteLiner.Visibility = ViewStates.Gone;
                }

                if (Methods.FunString.StringNullRemover(data.Working) != "Empty")
                {
                    WorkLiner.Visibility = ViewStates.Visible;
                    TxtWorkText.Text     = data.Working;
                }
                else
                {
                    WorkLiner.Visibility = ViewStates.Gone;
                }

                if (Methods.FunString.StringNullRemover(data.Facebook) == "Empty")
                {
                    BtnFacebook.Enabled = false;
                    BtnFacebook.SetColor(Color.ParseColor("#8c8a8a"));
                }
                else
                {
                    BtnFacebook.Enabled = true;
                }

                if (Methods.FunString.StringNullRemover(data.Google) == "Empty")
                {
                    BtnGoogle.Enabled = false;
                    BtnGoogle.SetColor(Color.ParseColor("#8c8a8a"));
                }
                else
                {
                    BtnGoogle.Enabled = true;
                }

                if (Methods.FunString.StringNullRemover(data.Twitter) == "Empty")
                {
                    BtnTwitter.Enabled = false;
                    BtnTwitter.SetColor(Color.ParseColor("#8c8a8a"));
                }
                else
                {
                    BtnTwitter.Enabled = true;
                }

                if (Methods.FunString.StringNullRemover(data.Youtube) == "Empty")
                {
                    BtnYoutube.Enabled = false;
                    BtnYoutube.SetColor(Color.ParseColor("#8c8a8a"));
                }
                else
                {
                    BtnYoutube.Enabled = true;
                }

                if (Methods.FunString.StringNullRemover(data.Vk) == "Empty")
                {
                    BtnVk.Enabled = false;
                    BtnVk.SetColor(Color.ParseColor("#8c8a8a"));
                }
                else
                {
                    BtnVk.Enabled = true;
                }

                if (Methods.FunString.StringNullRemover(data.Instagram) == "Empty")
                {
                    BtnInstegram.Enabled = false;
                    BtnInstegram.SetColor(Color.ParseColor("#8c8a8a"));
                }
                else
                {
                    BtnInstegram.Enabled = true;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }