public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View view = convertView;

            if (view == null)
            {
                view = _context.LayoutInflater.Inflate(Resource.Layout.DownloadItemListLayout, parent, false);
            }

            view.Tag = position;
            view.SetOnClickListener(this);

            DownloadViewItem item = this[position];

            view.FindViewById <TextView>(Resource.Id.PoiItemCategoryAsText).Text = PoiCategoryHelper.GetCategoryName(_context.Resources, item.fromDatabase.Category);

            string downloadDateText;
            string pointCountText;
            bool   updateAvailable   = false;
            bool   alreadyDownloaded = item.fromDatabase.DownloadDate != null;

            if (item.fromDatabase.DownloadDate.HasValue)
            {
                alreadyDownloaded = true;

                if (item.fromInternet.DateCreated > item.fromDatabase.DateCreated)
                {
                    updateAvailable = true;
                }

                downloadDateText = _context.Resources.GetText(Resource.String.Download_DownloadedOn) + ": " + item.fromDatabase.DownloadDate.Value.ToString("yyyy-MM-dd");
                pointCountText   = _context.Resources.GetText(Resource.String.Download_PointCount) + ": " + item.fromDatabase.PointCount;
            }
            else
            {
                downloadDateText = _context.Resources.GetText(Resource.String.Download_NotDownloadedYet);
                pointCountText   = _context.Resources.GetText(Resource.String.Download_PointCount) + ": " + item.fromInternet.PointCount;
            }

            view.FindViewById <TextView>(Resource.Id.PoiItemDownloadedDate).Text = downloadDateText;
            view.FindViewById <TextView>(Resource.Id.PoiItemDateCreated).Text    = pointCountText;

            var image = view.FindViewById <ImageView>(Resource.Id.PoiItemCategoryAsIcon);

            image.SetColorFilter(ColorFilterDownloadItem.GetColorFilter(!alreadyDownloaded, updateAvailable));
            image.SetImageResource(PoiCategoryHelper.GetImage(item.fromDatabase.Category));

            var deleteButton = view.FindViewById <ImageButton>(Resource.Id.PoiDeleteButton);

            deleteButton.SetOnClickListener(this);
            deleteButton.Tag     = position;
            deleteButton.Enabled = alreadyDownloaded;

            var refreshButton = view.FindViewById <ImageButton>(Resource.Id.PoiRefreshButton);

            refreshButton.SetOnClickListener(this);
            refreshButton.Tag        = position;
            refreshButton.Visibility = updateAvailable ? ViewStates.Visible : ViewStates.Gone;

            return(view);
        }
Exemple #2
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View view = convertView;

            if (view == null)
            {
                view = context.LayoutInflater.Inflate(Resource.Layout.CategoryItem, parent, false);
            }

            PoiCategory?item = this[position];

            if (item.HasValue)
            {
                view.FindViewById <TextView>(Resource.Id.PoiItemCategoryAsText).Text = PoiCategoryHelper.GetCategoryName(context.Resources, item.Value);
                view.FindViewById <ImageView>(Resource.Id.PoiItemCategoryAsIcon).SetImageResource(PoiCategoryHelper.GetImage(item.Value));
            }
            else
            {
                view.FindViewById <TextView>(Resource.Id.PoiItemCategoryAsText).Text = context.Resources.GetText(Resource.String.Common_AllCategories);
                view.FindViewById <ImageView>(Resource.Id.PoiItemCategoryAsIcon).SetImageResource(Resource.Drawable.c_basic);
            }

            return(view);
        }