コード例 #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 ContactsAdapterViewHolder(itemView, Click, LongClick);
         return(vh);
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
         return(null);
     }
 }
コード例 #2
0
        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);
            }
        }