Example #1
0
        public override View GetView(int position, Android.Views.View convertView, Android.Views.ViewGroup parent)
        {
            View view = convertView;

            if (view == null)
            {
                view = LayoutInflater.From(Context).Inflate(Resource.Layout.AbcRankTaskItems, null);
            }
            else
            {
                ((BitmapDrawable)view.FindViewById <ImageView>(Resource.Id.abcRankMeidaElementImage).Drawable).Bitmap.Recycle();
            }

            var item = GetItem(position);

            if (item.Media != null)
            {
                var bitmap = AssetHelper.GetBitmap(Context, item.Media.ImagePath);
                if (bitmap != null)
                {
                    view.FindViewById <ImageView>(Resource.Id.abcRankMeidaElementImage).SetImageBitmap(bitmap);
                }
            }
            else
            {
                view.FindViewById <ImageView>(Resource.Id.abcRankMeidaElementImage).Visibility = ViewStates.Gone;
                view.FindViewById <TextView>(Resource.Id.abcRankElementName).Text = item.Name;
            }

            return(view);
        }
Example #2
0
        public override View GetView(int position, Android.Views.View convertView, Android.Views.ViewGroup parent)
        {
            var view = convertView;

            if (view != null)
            {
                ((BitmapDrawable)view.FindViewById <ImageView>(Resource.Id.ivMeidaElementImage).Drawable).Bitmap.Recycle();
            }
            else
            {
                view = layoutInflater.Inflate(Resource.Layout.MediaElement, null);
            }

            var imageView = view.FindViewById <ImageView>(Resource.Id.ivMeidaElementImage);

            imageView.SetImageBitmap(AssetHelper.GetBitmap(Context, GetItem(position).Media.ImagePath));
            return(view);
        }
        public override View GetView(int position, Android.Views.View convertView, Android.Views.ViewGroup parent)
        {
            View view = convertView;

            if (view == null)
            {
                view = LayoutInflater.From(Context).Inflate(Resource.Layout.AbcRankSolutionItems, null);
            }
            else
            {
                ((BitmapDrawable)view.FindViewById <ImageView>(Resource.Id.ivAbcRankSolutionItem).Drawable).Bitmap.Recycle();
            }


            var item = items.ElementAt(position);

            if (item.Name == null)
            {
                // if there is no item as solution show the placeholder question mark without text
                prepareUiElementsForImage(BitmapFactory.DecodeResource(Context.Resources, Resource.Drawable.ic_help_black_24dp), view.FindViewById <ImageView>(Resource.Id.ivAbcRankSolutionItem), view.FindViewById <TextView>(Resource.Id.abcRankSolutionElementName));
            }
            else
            {
                // if there is an item at this position of the solution
                if (item.Media != null)
                {
                    // if there is an item with media element
                    prepareUiElementsForImage(AssetHelper.GetBitmap(Context, item.Media.ImagePath), view.FindViewById <ImageView>(Resource.Id.ivAbcRankSolutionItem), view.FindViewById <TextView>(Resource.Id.abcRankSolutionElementName));
                }
                else
                {
                    // if there is an item with image and contains only text
                    view.FindViewById <TextView>(Resource.Id.abcRankSolutionElementName).Text     = items.ElementAt(position).Name;
                    view.FindViewById <TextView>(Resource.Id.abcRankSolutionElementName).TextSize = 40.0f;
                }
            }

            return(view);
        }