Ejemplo n.º 1
0
 // Function
 public void Add(Get_User_Data_Object.Followers userFollowers)
 {
     try
     {
         var check = mUsersContactsList.FirstOrDefault(a => a.user_id == userFollowers.user_id);
         if (check == null)
         {
             mUsersContactsList.Add(userFollowers);
             NotifyItemInserted(mUsersContactsList.IndexOf(mUsersContactsList.Last()));
         }
     }
     catch (Exception exception)
     {
         Crashes.TrackError(exception);
     }
 }
Ejemplo n.º 2
0
 public void Remove(Get_User_Data_Object.Followers users)
 {
     try
     {
         var Index = mMyFollowersList.IndexOf(mMyFollowersList.FirstOrDefault(a => a.user_id == users.user_id));
         if (Index != -1)
         {
             mMyFollowersList.Remove(users);
             NotifyItemRemoved(Index);
             NotifyItemRangeRemoved(0, ItemCount);
         }
     }
     catch (Exception e)
     {
         Crashes.TrackError(e);
     }
 }
Ejemplo n.º 3
0
        public void Initialize(UserContacts_AdapterViewHolder holder, Get_User_Data_Object.Followers users)
        {
            try
            {
                var AvatarSplit     = users.avatar.Split('/').Last();
                var getImage_Avatar = IMethods.MultiMedia.GetMediaFrom_Disk(IMethods.IPath.FolderDiskImage, AvatarSplit);
                if (getImage_Avatar != "File Dont Exists")
                {
                    if (holder.Image.Tag?.ToString() != "loaded")
                    {
                        ImageServiceLoader.Load_Image(holder.Image, "no_profile_image.png", getImage_Avatar, 1);
                        holder.Image.Tag = "loaded";
                    }
                }
                else
                {
                    if (holder.Image.Tag?.ToString() != "loaded")
                    {
                        IMethods.MultiMedia.DownloadMediaTo_DiskAsync(IMethods.IPath.FolderDiskImage, users.avatar);
                        ImageServiceLoader.Load_Image(holder.Image, "no_profile_image.png", users.avatar, 1);
                        holder.Image.Tag = "loaded";
                    }
                }

                var CoverSplit     = users.cover.Split('/').Last();
                var getImage_Cover = IMethods.MultiMedia.GetMediaFrom_Disk(IMethods.IPath.FolderDiskImage, CoverSplit);
                if (getImage_Cover == "File Dont Exists")
                {
                    IMethods.MultiMedia.DownloadMediaTo_DiskAsync(IMethods.IPath.FolderDiskImage, users.cover);
                }

                string name = IMethods.Fun_String.DecodeString(IMethods.Fun_String.DecodeStringWithEnter(users.name));
                holder.Name.Text = IMethods.Fun_String.SubStringCutOf(name, 25);

                var dataabout = IMethods.Fun_String.StringNullRemover(users.about);
                if (dataabout != "Empty")
                {
                    var about = IMethods.Fun_String.DecodeString(IMethods.Fun_String.DecodeStringWithEnter(dataabout));
                    holder.About.Text = IMethods.Fun_String.SubStringCutOf(about, 25);
                }
                else
                {
                    var about = Activity_Context.GetText(Resource.String.Lbl_DefaultAbout) + " " +
                                Settings.Application_Name;
                    holder.About.Text = IMethods.Fun_String.SubStringCutOf(about, 25);
                }

                if (users.is_following == 1) // My Friend
                {
                    holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed);
                    holder.Button.SetTextColor(Color.ParseColor("#ffffff"));
                    if (Settings.ConnectivitySystem == "1") // Following
                    {
                        holder.Button.Text = Activity_Context.GetText(Resource.String.Lbl_Following);
                    }
                    else // Friend
                    {
                        holder.Button.Text = Activity_Context.GetText(Resource.String.Lbl_Friends);
                    }

                    holder.Button.Tag = "friends";
                }
                else if (users.is_following == 2) // Request
                {
                    holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends);
                    holder.Button.SetTextColor(Color.ParseColor("#444444"));
                    holder.Button.Text = Activity_Context.GetText(Resource.String.Lbl_Request);
                    holder.Button.Tag  = "Request";
                }
                else if (users.is_following == 0) //Not Friend
                {
                    holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends);
                    holder.Button.SetTextColor(Color.ParseColor(Settings.MainColor));
                    if (Settings.ConnectivitySystem == "1") // Following
                    {
                        holder.Button.Text = Activity_Context.GetText(Resource.String.Lbl_Follow);
                    }
                    else // Friend
                    {
                        holder.Button.Text = Activity_Context.GetText(Resource.String.Lbl_AddFriends);
                    }
                    holder.Button.Tag = "false";

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

                if (!holder.Button.HasOnClickListeners)
                {
                    holder.Button.Click += (sender, args) =>
                    {
                        try
                        {
                            if (!IMethods.CheckConnectivity())
                            {
                                Toast.MakeText(Activity_Context,
                                               Activity_Context.GetString(Resource.String.Lbl_CheckYourInternetConnection),
                                               ToastLength.Short).Show();
                            }
                            else
                            {
                                if (holder.Button.Tag.ToString() == "false")
                                {
                                    holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed);
                                    holder.Button.SetTextColor(Color.ParseColor("#ffffff"));
                                    if (Settings.ConnectivitySystem == "1") // Following
                                    {
                                        holder.Button.Text = Activity_Context.GetText(Resource.String.Lbl_Following);
                                        holder.Button.Tag  = "true";
                                    }
                                    else // Request Friend
                                    {
                                        holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends);
                                        holder.Button.SetTextColor(Color.ParseColor("#444444"));
                                        holder.Button.Text = Activity_Context.GetText(Resource.String.Lbl_Request);
                                        holder.Button.Tag  = "Request";
                                    }
                                }
                                else
                                {
                                    holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends);
                                    holder.Button.SetTextColor(Color.ParseColor(Settings.MainColor));
                                    if (Settings.ConnectivitySystem == "1") // Following
                                    {
                                        holder.Button.Text = Activity_Context.GetText(Resource.String.Lbl_Follow);
                                    }
                                    else // Friend
                                    {
                                        holder.Button.Text = Activity_Context.GetText(Resource.String.Lbl_AddFriends);
                                    }
                                    holder.Button.Tag = "false";

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

                                var result = Client.Global.Follow_User(users.user_id).ConfigureAwait(false);
                            }
                        }
                        catch (Exception e)
                        {
                            Crashes.TrackError(e);
                        }
                    }
                }
                ;
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
            }
        }