コード例 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // on set notre layout
            SetContentView(Resource.Layout.Accueil);

            alarmListView = FindViewById <ListView>(Resource.Id.listView);
            refreshButton = FindViewById <Button>(Resource.Id.refreshButton);

            refreshButton.Click += new EventHandler(async(sender, e) =>
            {
                User u = UserItemManager.GetUser("0");

                alarmsInverted = await AlarmServerManager.getAlarms(u.Profil);
                alarms         = AlarmItemManager.GetAlarms();

                alarmListAdapter      = new AlarmItemListAdapter(this, alarms);
                alarmListView.Adapter = alarmListAdapter;
            });

            /*
             * alarm = new AlarmItem();
             * alarm.IDAlarm = 1;
             * alarm.Status = true;
             * alarm.Chambre = "Chambre 1";
             * alarm.NomPersonnelAidant = "Amadou";
             * alarm.NomOccupant = "Diaby";
             * alarm.DtDebut = "23:05";
             * AlarmItemManager.AddAlarm(alarm);
             */
        }
コード例 #2
0
        public override Android.Views.View GetView(int position, Android.Views.View convertView, Android.Views.ViewGroup parent)
        {
            // Get our object for position
            var alarm = alarms[position];

            // TODO: use this code to populate the row, and remove the above view
            Android.Views.View view = convertView; // re-use an existing view, if one is available
            if (view == null)                      // otherwise create a new one
            {
                view = context.LayoutInflater.Inflate(Resource.Layout.CustomRowView, null);
            }

            listeButton = view.FindViewById <Button>(Resource.Id.PriseEnChargeButton);
            String etat;

            if (alarm.Status == false)
            {
                etat = "Non pris en charge";
            }
            else
            {
                listeButton.Enabled = false;
                listeButton.SetBackgroundColor(Color.Gray);
                etat = "Pris en charge par " + alarm.NomPersonnelAidant;
            }
            view.FindViewById <TextView>(Resource.Id.DateTime).Text         = alarm.DtDebut;
            view.FindViewById <TextView>(Resource.Id.AlarmDescription).Text = "Alarme : Appel de la chambre " + alarm.Chambre +
                                                                              " (" + alarm.NomOccupant + ")" + "\n Type:" + alarm.Display;
            view.FindViewById <TextView>(Resource.Id.Status).Text           = "Etat : " + etat;
            view.FindViewById <Button>(Resource.Id.PriseEnChargeButton).Tag = position;

            listeButton.Click += async(sender, e) => {
                var user    = UserItemManager.GetUser("0");
                var Cstatus = await AlarmServerManager.changeStatusAsync(alarms[Convert.ToInt32(((Button)sender).Tag)].IDAlarm, user.IdSS);

                if (Cstatus)
                {
                    Button clickedButton = (Button)sender;
                    alarm = alarms[Convert.ToInt32(clickedButton.Tag)];
                    alarm.NomPersonnelAidant    = user.Lastname;
                    alarm.PrenomPersonnelAidant = user.Firstname;
                    //int r = 0;
                    //r = AlarmItemManager.AddAlarm(alarm);
                    alarms                = AlarmItemManager.GetAlarms();
                    alarmListView         = context.FindViewById <ListView>(Resource.Id.listView);
                    alarmListAdapter      = new AlarmItemListAdapter(context, alarms);
                    alarmListView.Adapter = alarmListAdapter;
                }
                else
                {
                    User u = UserItemManager.GetUser("0");
                    AlarmItemManager.DeleteAlarms();
                    var alarmsInverted = await AlarmServerManager.getAlarms(u.Profil);

                    alarms                = AlarmItemManager.GetAlarms();
                    alarmListView         = context.FindViewById <ListView>(Resource.Id.listView);
                    alarmListAdapter      = new AlarmItemListAdapter(context, alarms);
                    alarmListView.Adapter = alarmListAdapter;
                }
            }
            ;
            return(view);
        }