Example #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            RefreshButton.SetCommand(Vm.RefreshCommand);

            // Saving the binding to avoid garbage collection
            _bindings.Add(this.SetBinding(
                              () => Vm.LastLoadedFormatted,
                              () => LastLoadedText.Text));

            _adapter = Vm.Flowers.GetRecyclerAdapter(
                BindViewHolder,
                Resource.Layout.FlowerTemplate,
                OnItemClick);

            FlowersList.SetLayoutManager(new LinearLayoutManager(this));
            FlowersList.SetAdapter(_adapter);

            // Subscribing to events to avoid linker issues in release mode ---------------------------------

            // This "fools" the linker into believing that the events are used.
            // In fact we don't even subscribe to them.
            // See https://developer.xamarin.com/guides/android/advanced_topics/linking/

            if (_falseFlag)
            {
                RefreshButton.Click += (s, e) => { };
            }
        }
Example #2
0
 public Flower GetFlowerById(int flowerId)
 {
     return(FlowersList.FirstOrDefault(x => x.FlowerId == flowerId));
 }
Example #3
0
 public bool DeleteFlower(Flower flower)
 {
     FlowersList.Remove(flower);
     return(true);
 }
Example #4
0
 public bool AddFlower(Flower flower)
 {
     FlowersList.Add(flower);
     return(true);
 }