public static UITableViewCell FillCellWithMember(UITableViewCell cell, CodeProjectMember member)
        {
            (cell.ViewWithTag(100) as UILabel).Text = member.Name;
            (cell.ViewWithTag(101) as UILabel).Text = "Posts: " + (member.ArticleCount + member.BlogCount);
            (cell.ViewWithTag(102) as UILabel).Text = member.Reputation;

            CodeProjectDatabase database = new CodeProjectDatabase();

            byte[] gravatar = database.GetGravatar(member.Id);
            if (gravatar != null)
            {
                UIImage image = UIImage.LoadFromData(NSData.FromArray(gravatar));
                (cell.ViewWithTag(105) as UIImageView).Image = image;
            }

            return(cell);
        }
        public CodeprojectMemberViewModel(CodeProjectMember member, Action <string> gotoPageAction, Action <string> deleteMember)
        {
            this.GotoPageCommand     = new ButtonCommandBinding <string>(gotoPageAction);
            this.DeleteMemberCommand = new ButtonCommandBinding <string>(deleteMember);
            this.member = member;

            var db = new CodeProjectDatabase();

            byte[] avatar = db.GetGravatar(this.member.Id);

            if (avatar != null)
            {
                BitmapImage  bitmapImage = new BitmapImage();
                MemoryStream ms          = new MemoryStream(avatar);
                bitmapImage.SetSource(ms);

                AvatarImage = bitmapImage;
            }
        }
Ejemplo n.º 3
0
        CodeProjectMember LoadGravatar()
        {
            var db = new CodeProjectDatabase();

            byte[] avatar = db.GetGravatar(Member.Id);
            if (avatar != null)
            {
            }
            else
            {
                WebImageRetriever imageDownloader = new WebImageRetriever();
                Task imageDownload = imageDownloader.GetImageStreamAsync(new Uri(Member.ImageUrl)).ContinueWith(t => {
                    avatar = t.Result;
                });

                imageDownload.Wait();
            }

            Member.Avatar = avatar;
            return(Member);
        }
Ejemplo n.º 4
0
        public override Android.Views.View GetView(int position, Android.Views.View convertView, Android.Views.ViewGroup parent)
        {
            var view = convertView ?? activity.LayoutInflater.Inflate(
                Resource.Layout.CodeProjectMemberListItem, parent, false);
            var memberName       = view.FindViewById <TextView> (Resource.Id.textViewMemberName);
            var memberReputation = view.FindViewById <TextView> (Resource.Id.textViewReputation);
            var memberPostCnt    = view.FindViewById <TextView> (Resource.Id.textViewPostCnt);
            var memberIcon       = view.FindViewById <ImageView> (Resource.Id.imageViewMemberImage);

            memberName.Text       = list[position].Name;
            memberReputation.Text = list[position].Reputation;
            memberPostCnt.Text    = "Posts: " + (list[position].ArticleCount + list[position].BlogCount);

            int textAppearanceLarge = TextAppearanceHeight(Android.Resource.Attribute.TextAppearanceLarge);
            int textAppearanceSmall = TextAppearanceHeight(Android.Resource.Attribute.TextAppearanceSmall);

            int bitmapSize = textAppearanceLarge + textAppearanceSmall;
            CodeProjectDatabase database = new CodeProjectDatabase();

            byte[] gravatar = database.GetGravatar(list[position].Id);
            if (gravatar != null)
            {
                Bitmap image   = BitmapFactory.DecodeByteArray(gravatar, 0, gravatar.Length);
                int    maxSide = Math.Max(image.Height, image.Width);

                float scale = (float)bitmapSize / maxSide;

                memberIcon.SetImageBitmap(Bitmap.CreateScaledBitmap(image,
                                                                    (int)Math.Ceiling(scale * image.Width),
                                                                    (int)Math.Ceiling(scale * image.Height),
                                                                    false));
                image.Recycle();
            }

            return(view);
        }