Esempio n. 1
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            var vh = holder as ViewHolder;

            // get Exhibit from displayedExhibitSet at position
            var exhibit = displayedExhibitSet.ActiveSet.ElementAt(position);

            // update the holder with new data
            vh.Name.SetText(exhibit.Name, TextView.BufferType.Normal);

            var doubleDistance = exhibit.GetDistance(location) * 1000;

            string distance;

            if (doubleDistance > 1000)
            {
                distance = Math.Round((decimal)doubleDistance / 1000, 2) + "km";
            }
            else
            {
                distance = Math.Round((decimal)doubleDistance, 2) + "m";
            }

            //Remove this if not needed
            vh.View.ContentDescription = exhibit.Id;

            vh.Distance.SetText(distance, TextView.BufferType.Normal);

            BitmapDrawable drawable = exhibit.Image.GetDrawable(context, 100, 100);
            Bitmap         bmp      = drawable.Bitmap;

            vh.Image.SetImageBitmap(ImageManipulation.GetCroppedImage(bmp, 100));
        }