Ejemplo n.º 1
0
        private async void OnDatabaseEvent(IONDatabase database, DatabaseEvent de)
        {
            if (!de.table.Equals(typeof(JobRow)))
            {
                return;
            }

            var index = IndexOfJob(JobRecordWithId(de.id)?.data);

            if (index < 0)
            {
                return;
            }

            switch (de.action)
            {
            case DatabaseEvent.EAction.Deleted:
                records.RemoveAt(index);
                NotifyItemRemoved(index);
                break;

            case DatabaseEvent.EAction.Inserted:
                var job = await ion.database.QueryForAsync <JobRow>(de.id);

                ion.PostToMain(() => {
                    records.Insert(index, new JobRecord(job));
                    NotifyItemInserted(index);
                });
                break;

            case DatabaseEvent.EAction.Modified:
                NotifyItemChanged(index);
                break;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Posts a new DeviceManager event to the device manager handler.
 /// </summary>
 /// <param name="dme">Dme.</param>
 private void NotifyOfDeviceManagerEvent(DeviceManagerEvent dme)
 {
     if (onDeviceManagerEvent != null)
     {
         ion.PostToMain(() => {
             try {
                 onDeviceManagerEvent(dme);
             } catch (Exception e) {
                 Log.E(this, "Failed to post device manager event", e);
             }
         });
     }
 }