Exemplo n.º 1
0
 private void OnModelChanged (ModelChangedMessage msg)
 {
     if (msg.Model == currentEntry) {
         // Listen for changes regarding current running entry
         if (msg.PropertyName == TimeEntryModel.PropertyState
             || msg.PropertyName == TimeEntryModel.PropertyStartTime
             || msg.PropertyName == TimeEntryModel.PropertyStopTime
             || msg.PropertyName == TimeEntryModel.PropertyDeletedAt) {
             if (currentEntry.State == TimeEntryState.Finished || currentEntry.DeletedAt.HasValue) {
                 currentEntry = TimeEntryModel.GetDraft ();
             }
             Rebind ();
         }
     } else if (msg.Model is TimeEntryModel) {
         // When some other time entry becomes Running we need to switch over to that
         if (msg.PropertyName == TimeEntryModel.PropertyState
             || msg.PropertyName == TimeEntryModel.PropertyIsShared) {
             var entry = (TimeEntryModel)msg.Model;
             if (entry.State == TimeEntryState.Running && ForCurrentUser (entry)) {
                 currentEntry = entry;
                 Rebind ();
             }
         }
     }
 }
Exemplo n.º 2
0
        private void OnModelChangedMessage (ModelChangedMessage msg)
        {
            if (currentUser == null || msg.Model != currentUser)
                return;

            if (msg.PropertyName == UserModel.PropertyRemoteId
                || msg.PropertyName == UserModel.PropertyEmail
                || msg.PropertyName == UserModel.PropertyName) {
                OnUserChanged ();
            }
        }
        protected override void OnModelChanged (ModelChangedMessage msg)
        {
            base.OnModelChanged (msg);

            if (msg.Model != TimeEntry && msg.Model is TimeEntryModel) {
                // When some other time entry becomes IsRunning we need to switch over to that
                if (msg.PropertyName == TimeEntryModel.PropertyState
                    || msg.PropertyName == TimeEntryModel.PropertyIsShared) {
                    var entry = (TimeEntryModel)msg.Model;
                    if (entry.State == TimeEntryState.Running && ForCurrentUser (entry)) {
                        TimeEntry = entry;
                        Rebind ();
                    }
                }
            }
        }
        private void OnModelChanged (ModelChangedMessage msg)
        {
            if (currentTimeEntry == msg.Model) {
                if (msg.PropertyName == TimeEntryModel.PropertyState
                    || msg.PropertyName == TimeEntryModel.PropertyDescription
                    || msg.PropertyName == TimeEntryModel.PropertyStartTime
                    || msg.PropertyName == TimeEntryModel.PropertyProjectId
                    || msg.PropertyName == TimeEntryModel.PropertyTaskId
                    || msg.PropertyName == TimeEntryModel.PropertyUserId) {

                    if (currentTimeEntry.State != TimeEntryState.Running || !ForCurrentUser (currentTimeEntry)) {
                        currentTimeEntry = null;
                    }

                    SyncNotification ();
                }
            } else if (currentTimeEntry != null
                       && msg.Model.Id == currentTimeEntry.ProjectId
                       && msg.Model == currentTimeEntry.Project) {
                if (msg.PropertyName == ProjectModel.PropertyName
                    || msg.PropertyName == ProjectModel.PropertyClientId) {
                    SyncNotification ();
                }
            } else if (currentTimeEntry != null
                       && currentTimeEntry.ProjectId != null
                       && currentTimeEntry.Project != null
                       && msg.Model.Id == currentTimeEntry.Project.ClientId
                       && msg.Model == currentTimeEntry.Project.Client) {
                if (msg.PropertyName == ClientModel.PropertyName) {
                    SyncNotification ();
                }
            } else if (msg.Model is TimeEntryModel) {
                var entry = (TimeEntryModel)msg.Model;
                if (msg.PropertyName == TimeEntryModel.PropertyState
                    || msg.PropertyName == TimeEntryModel.PropertyIsShared
                    || msg.PropertyName == TimeEntryModel.PropertyIsPersisted
                    || msg.PropertyName == TimeEntryModel.PropertyUserId) {
                    if (entry.IsShared && entry.IsPersisted && entry.State == TimeEntryState.Running && ForCurrentUser (entry)) {
                        currentTimeEntry = entry;
                        SyncNotification ();
                    }
                }
            }
        }
        private void OnModelChanged(ModelChangedMessage msg)
        {
            var inter = msg.Model as TInter;

            if (inter == null)
            {
                return;
            }

            if (msg.PropertyName == Model.PropertyIsShared ||
                msg.PropertyName == IntermediateModel <Model, Model> .PropertyFromId ||
                msg.PropertyName == IntermediateModel <Model, Model> .PropertyFromId)
            {
                if (IsOurInter(inter) && !relations.Contains(inter))
                {
                    AddRelation(inter);
                }
            }
        }
Exemplo n.º 6
0
        private void OnModelChangedMessage(ModelChangedMessage msg)
        {
            lock (Model.SyncRoot) {
                var model    = msg.Model;
                var property = msg.PropertyName;

                if (!model.IsShared)
                {
                    return;
                }

                if (property == Model.PropertyIsMerging)
                {
                    return;
                }

                if (property == Model.PropertyIsShared)
                {
                    // No need to mark newly created property as changed:
                    if (createdModels.Any((r) => r.Target == model))
                    {
                        return;
                    }
                }

                // We only care about persisted models (and models which were just marked as non-persistent)
                if (property != Model.PropertyIsPersisted && !model.IsPersisted)
                {
                    return;
                }

                // Ignore changes which we don't store in the database (IsShared && IsPersisted are exceptions)
                if (property != Model.PropertyIsShared &&
                    property != Model.PropertyIsPersisted &&
                    ignoreCache.HasAttribute(model, property))
                {
                    return;
                }

                changedModels.Add(model);
                ScheduleCommit();
            }
        }
Exemplo n.º 7
0
            private void OnModelChanged (ModelChangedMessage msg)
            {
                // Protect against Java side being GCed
                if (Handle == IntPtr.Zero)
                    return;

                if (msg.Model == currentTimeEntry) {
                    // Listen for changes regarding current running entry
                    if (msg.PropertyName == TimeEntryModel.PropertyState
                        || msg.PropertyName == TimeEntryModel.PropertyStopTime
                        || msg.PropertyName == TimeEntryModel.PropertyDeletedAt) {
                        if (currentTimeEntry.State == TimeEntryState.Finished || currentTimeEntry.DeletedAt.HasValue) {
                            currentTimeEntry = TimeEntryModel.GetDraft ();
                        }
                        NotifyDataSetChanged ();
                    }
                } else if (msg.Model is TimeEntryModel) {
                    // When some other time entry becomes IsRunning we need to switch over to that
                    if (msg.PropertyName == TimeEntryModel.PropertyState
                        || msg.PropertyName == TimeEntryModel.PropertyIsShared) {
                        var entry = (TimeEntryModel)msg.Model;
                        if (entry.State == TimeEntryState.Running && ForCurrentUser (entry)) {
                            currentTimeEntry = entry;
                            NotifyDataSetChanged ();
                        }
                    }
                }
            }
        private void OnModelChanged (ModelChangedMessage msg)
        {
            // Protect against Java side being GCed
            if (Handle == IntPtr.Zero)
                return;

            if (msg.Model == model
                && msg.PropertyName == TimeEntryModel.PropertyWorkspaceId) {
                modelsView.WorkspaceId = WorkspaceId;
            } else if (msg.Model is UserModel
                       && msg.PropertyName == UserModel.PropertyDefaultWorkspaceId) {
                modelsView.WorkspaceId = WorkspaceId;
            }
        }
 private void OnModelChanged (ModelChangedMessage msg)
 {
     if (msg.Model == model) {
         // Listen for changes regarding current running entry
         if (msg.PropertyName == TimeEntryModel.PropertyState
             || msg.PropertyName == TimeEntryModel.PropertyStartTime
             || msg.PropertyName == TimeEntryModel.PropertyStopTime
             || msg.PropertyName == TimeEntryModel.PropertyDescription
             || msg.PropertyName == TimeEntryModel.PropertyIsBillable
             || msg.PropertyName == TimeEntryModel.PropertyProjectId
             || msg.PropertyName == TimeEntryModel.PropertyTaskId) {
             Rebind ();
         }
     } else if (model != null && model.ProjectId == msg.Model.Id && model.Project == msg.Model) {
         if (msg.PropertyName == ProjectModel.PropertyName
             || msg.PropertyName == ProjectModel.PropertyColor
             || msg.PropertyName == ProjectModel.PropertyClientId) {
             Rebind ();
         }
     } else if (model != null && model.TaskId == msg.Model.Id && model.Task == msg.Model) {
         if (msg.PropertyName == TaskModel.PropertyName) {
             Rebind ();
         }
     } else if (model != null && model.ProjectId != null && model.Project != null
                && model.Project.ClientId == msg.Model.Id && model.Project.Client == msg.Model) {
         if (msg.PropertyName == ClientModel.PropertyName) {
             Rebind ();
         }
     } else if (model != null && msg.Model is TimeEntryTagModel) {
         var inter = (TimeEntryTagModel)msg.Model;
         if (inter.FromId == model.Id) {
             // Schedule rebind, as if we do it right away the RelatedModelsCollection will not
             // have been updated yet
             DispatchQueue.MainQueue.DispatchAfter (TimeSpan.FromMilliseconds (1), Rebind);
         }
     }
 }
Exemplo n.º 10
0
        private void OnModelChanged (ModelChangedMessage msg)
        {
            if (Handle == IntPtr.Zero)
                return;

            if (msg.Model == model) {
                EnsureModel ();
            }
        }
Exemplo n.º 11
0
 protected virtual void OnModelChanged (ModelChangedMessage msg)
 {
     if (msg.Model == TimeEntry) {
         // Listen for changes regarding current running entry
         if (msg.PropertyName == TimeEntryModel.PropertyState
             || msg.PropertyName == TimeEntryModel.PropertyStartTime
             || msg.PropertyName == TimeEntryModel.PropertyStopTime
             || msg.PropertyName == TimeEntryModel.PropertyDescription
             || msg.PropertyName == TimeEntryModel.PropertyIsBillable
             || msg.PropertyName == TimeEntryModel.PropertyProjectId
             || msg.PropertyName == TimeEntryModel.PropertyTaskId
             || msg.PropertyName == TimeEntryModel.PropertyDeletedAt) {
             Rebind ();
         }
     } else if (TimeEntry != null && TimeEntry.ProjectId == msg.Model.Id && TimeEntry.Project == msg.Model) {
         if (msg.PropertyName == ProjectModel.PropertyName
             || msg.PropertyName == ProjectModel.PropertyColor
             || msg.PropertyName == ProjectModel.PropertyClientId) {
             Rebind ();
         }
     } else if (TimeEntry != null && TimeEntry.TaskId == msg.Model.Id && TimeEntry.Task == msg.Model) {
         if (msg.PropertyName == TaskModel.PropertyName) {
             Rebind ();
         }
     } else if (TimeEntry != null && TimeEntry.ProjectId != null && TimeEntry.Project != null
                && model.Project.ClientId == msg.Model.Id && TimeEntry.Project.Client == msg.Model) {
         if (msg.PropertyName == ClientModel.PropertyName) {
             Rebind ();
         }
     } else if (TimeEntry != null && msg.Model is TimeEntryTagModel) {
         var inter = (TimeEntryTagModel)msg.Model;
         if (inter.FromId == TimeEntry.Id) {
             // Schedule rebind, as if we do it right away the RelatedModelsCollection will not
             // have been updated yet
             Android.App.Application.SynchronizationContext.Post ((state) => {
                 Rebind ();
             }, null);
         }
     }
 }