Example #1
0
        private void HolderDelegate(CachingViewHolder holder, Boiler item, int index)
        {
            holder.FindCachedViewById <TextView>(Resource.Id.NameTextView).Text     = item.Name;
            holder.FindCachedViewById <TextView>(Resource.Id.MetaDataTextView).Text =
                $"{GetString(Resource.String.NumberOfMeasurments)} {item.Count}\n" +
                $"{GetString(Resource.String.CreatedAt)} {item.DateCreated.ToShortDateString()}";

            var button = holder.FindCachedViewById <ImageView>(Resource.Id.DeleteButton);

            if (!button.HasOnClickListeners)
            {
                button.Click += (s, e) =>
                {
                    var position = holder.AdapterPosition;
                    new AlertDialog.Builder(Context)
                    .SetTitle(GetString(Resource.String.Delete))
                    .SetMessage($"{GetString(Resource.String.DeleteBoilerQ)} {VM.Boilers[position].Name}?")
                    .SetPositiveButton(GetString(Resource.String.Yes), (s1, e1) => VM.DeleteBoiler(VM.Boilers[position]))
                    .SetNegativeButton(GetString(Resource.String.No), (s1, e1) => { })
                    .Create()
                    .Show();
                }
            }
            ;
        }