public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
 {
     try
     {
         //Setup your layout here >> Style_NearBy_view
         var itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.Style_NearBy_view, parent, false);
         var vh       = new NearByAdapterViewHolder(itemView, Click, LongClick);
         return(vh);
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
         return(null);
     }
 }
Exemplo n.º 2
0
 public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
 {
     try
     {
         //Setup your layout here >> Style_NearBy_view
         var itemView = LayoutInflater.From(parent.Context)?.Inflate(Resource.Layout.Style_NearBy_view, parent, false);
         var vh       = new NearByAdapterViewHolder(itemView, FollowButtonClick, Click, LongClick);
         return(vh);
     }
     catch (Exception exception)
     {
         Methods.DisplayReportResultTrack(exception);
         return(null !);
     }
 }
Exemplo n.º 3
0
        public void Initialize(NearByAdapterViewHolder holder, Get_Nearby_Users_Object.Nearby_Users users)
        {
            try
            {
                if (holder.Image.Tag?.ToString() != "loaded")
                {
                    var AvatarSplit     = users.avatar.Split('/').Last();
                    var getImage_Avatar = IMethods.MultiMedia.GetMediaFrom_Disk(IMethods.IPath.FolderDiskImage, AvatarSplit);
                    if (getImage_Avatar != "File Dont Exists")
                    {
                        ImageServiceLoader.Load_Image(holder.Image, "no_profile_image.png", getImage_Avatar, 1);
                        holder.Image.Tag = "loaded";
                    }
                    else
                    {
                        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";
                }


                //Online Or offline
                if (users.lastseen_status == "on")
                {
                    //Online
                    if (holder.ImageOnline.Tag?.ToString() != "true")
                    {
                        holder.ImageOnline.Tag = "true";
                        holder.ImageOnline.SetImageResource(Resource.Drawable.Green_Color);
                    }

                    if (holder.LastTimeOnline.Tag?.ToString() != "true")
                    {
                        holder.LastTimeOnline.Tag  = "true";
                        holder.LastTimeOnline.Text = Activity_Context.GetString(Resource.String.Lbl_Online);
                    }
                }
                else
                {
                    if (holder.ImageOnline.Tag?.ToString() != "true")
                    {
                        holder.ImageOnline.Tag = "true";
                        holder.ImageOnline.SetImageResource(Resource.Drawable.Grey_Offline);
                    }

                    if (holder.LastTimeOnline.Tag?.ToString() != "true")
                    {
                        holder.LastTimeOnline.Tag  = "true";
                        holder.LastTimeOnline.Text = IMethods.ITime.TimeAgo(int.Parse(users.lastseen_unix_time));
                    }
                }

                if (holder.Name.Tag?.ToString() != "true")
                {
                    holder.Name.Tag = "true";
                    string name = IMethods.Fun_String.DecodeString(IMethods.Fun_String.DecodeStringWithEnter(users.name));
                    holder.Name.Text = IMethods.Fun_String.SubStringCutOf(name, 14);
                }

                if (users.is_following == "yes" || users.is_following == "Yes") // My Friend
                {
                    if (holder.Button.Tag?.ToString() != "friends")
                    {
                        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 //Not Friend
                {
                    if (holder.Button.Tag?.ToString() != "false")
                    {
                        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";
                    }
                }

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