Ejemplo n.º 1
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View view = convertView;

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

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

            PoiViewItem item = this[position];

            view.FindViewById <ImageView>(Resource.Id.InfoAvailable).Visibility =
                item.IsImportant() ? ViewStates.Visible : ViewStates.Invisible;

            view.FindViewById <TextView>(Resource.Id.Title).Text = item.Poi.Name;

            view.FindViewById <TextView>(Resource.Id.Country).Text = item.Poi.Country != null?
                                                                     PoiCountryHelper.GetCountryName(item.Poi.Country.Value) : "Unknown";

            view.FindViewById <TextView>(Resource.Id.Description).Text =
                $"{item.Poi.Altitude:F0} m | {item.GpsLocation.Distance.Value/1000f:F2} km | {item.GpsLocation.Bearing.Value:F2}°";

            _thumbnail = view.FindViewById <ImageView>(Resource.Id.Thumbnail);
            //_thumbnail.SetColorFilter(ColorFilterPoiItem.GetColorFilter(item));
            _thumbnail.SetImageResource(PoiCategoryHelper.GetImage(item.Poi.Category));

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

            if (_showOptions)
            {
                deleteButton.SetOnClickListener(this);
                deleteButton.Tag = position;

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

                likeButton.SetImageResource(item.Poi.Favorite ? Android.Resource.Drawable.ButtonStarBigOn : Android.Resource.Drawable.ButtonStarBigOff);
            }
            else
            {
                deleteButton.Visibility = ViewStates.Gone;
                likeButton.Visibility   = ViewStates.Gone;
            }

            view.SetBackgroundResource(Resource.Drawable.bg_activity);
            view.Background.Alpha = item.Selected ? 100 : 0;
            return(view);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
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);
        }