Пример #1
0
 // Create new views (invoked by the layout manager)
 public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
 {
     try
     {
         //Setup your layout here >> Style_HContact_view
         var itemView = LayoutInflater.From(parent.Context)
                        .Inflate(Resource.Layout.Style_HContact_view, parent, false);
         var vh = new SearchUser_AdapterViewHolder(itemView, OnClick, OnLongClick);
         return(vh);
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
         return(null);
     }
 }
Пример #2
0
        public void Initialize(SearchUser_AdapterViewHolder holder, GetSearchObject.User item)
        {
            try
            {
                ImageCacheLoader.LoadImage(item.Avatar, holder.Image, false, true);


                string name = IMethods.Fun_String.DecodeString(item.Name);
                holder.Name.Text = IMethods.Fun_String.SubStringCutOf(name, 14);

                string lastSeen = Activity_Context.GetText(Resource.String.Lbl_Last_seen) + " ";
                var    time     = IMethods.ITime.TimeAgo(int.Parse(item.LastseenUnixTime));
                holder.About.Text = lastSeen + time;

                if (item.is_following == "1") // My Friend
                {
                    holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed);
                    holder.Button.SetTextColor(Color.ParseColor("#ffffff"));
                    if (AppSettings.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 = "true";
                }
                else if (item.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 (item.is_following == "0") //Not Friend
                {
                    holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends);
                    holder.Button.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                    if (AppSettings.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(item.UserId);
                    dbDatabase.Dispose();
                }
                else
                {
                    holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed);
                    holder.Button.SetTextColor(Color.ParseColor("#ffffff"));
                    if (AppSettings.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);
                    }
                }

                if (!holder.Button.HasOnClickListeners)
                {
                    holder.Button.Click += async(sender, args) =>
                    {
                        try
                        {
                            if (!IMethods.CheckConnectivity())
                            {
                                Toast.MakeText(Activity_Context, Activity_Context.GetString(Resource.String.Lbl_Error_check_internet_connection), 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 (AppSettings.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(AppSettings.MainColor));
                                    if (AppSettings.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(item.UserId);
                                    dbDatabase.Dispose();
                                }

                                await Task.Run(async() =>
                                {
                                    var(apiStatus, respond) = await Global.Follow_User(item.UserId).ConfigureAwait(false);
                                });
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    }
                }
                ;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }