public virtual void RebindTags (TimeEntryTagsView tagsView) { List<String> tagList = new List<String> (); String t; if (tagsView == null || tagsView.IsLoading) { return; } if (tagsView.Count == 0) { EditText.Text = String.Empty; return; } foreach (String tagText in tagsView.Data) { t = tagText.Length > TagMaxLength ? tagText.Substring (0, TagMaxLength - 1).Trim () + "…" : tagText; if (tagText.Length > 0) { tagList.Add (t); } } // The extra whitespace prevents the ImageSpans and the text they are over // to break at different positions, leaving zero linespacing on edge cases. var tags = new SpannableStringBuilder (String.Join (" ", tagList) + " "); int x = 0; foreach (String tagText in tagList) { tags.SetSpan (new ImageSpan (MakeTagChip (tagText)), x, x + tagText.Length, SpanTypes.ExclusiveExclusive); x = x + tagText.Length + 1; } EditText.SetText (tags, EditText.BufferType.Spannable); }
public EditTimeEntryViewController (TimeEntryModel model) { this.model = model; tagsView = new TimeEntryTagsView (model.Id); timerController = new TimerNavigationController (model); }
public EditTimeEntryViewController(TimeEntryModel model) { this.model = model; tagsView = new TimeEntryTagsView(model.Id); timerController = new TimerNavigationController(model); }
public void TestInvalidTimeEntry() { RunAsync(async delegate { var view = new TimeEntryTagsView(Guid.Empty); await WaitForLoaded(view); Assert.AreEqual(0, view.Count); }); }
public void TestInvalidTimeEntry () { RunAsync (async delegate { var view = new TimeEntryTagsView (Guid.Empty); await WaitForLoaded (view); Assert.AreEqual (0, view.Count); }); }
public override void OnDestroyView() { if (tagsView != null) { tagsView.Updated -= OnTimeEntryTagsUpdated; tagsView = null; } base.OnDestroyView(); }
protected override void Dispose(bool disposing) { if (disposing) { if (tagsView != null) { tagsView.Updated -= OnTagsUpdated; tagsView = null; } } base.Dispose(disposing); }
public void TestInitialState() { RunAsync(async delegate { var view = new TimeEntryTagsView(timeEntry.Id); await WaitForLoaded(view); Assert.AreEqual(2, view.Count); Assert.AreEqual( MakeTagsArray(DefaultTag, "Tag #2"), view.Data.ToArray() ); }); }
public void TestInitialState () { RunAsync (async delegate { var view = new TimeEntryTagsView (timeEntry.Id); await WaitForLoaded (view); Assert.AreEqual (2, view.Count); Assert.AreEqual ( MakeTagsArray (DefaultTag, "Tag #2"), view.Data.ToArray () ); }); }
public void TestAddInvalidManyToMany () { RunAsync (async delegate { var view = new TimeEntryTagsView (timeEntry.Id); await WaitForLoaded (view); await DataStore.PutAsync (new TimeEntryTagData () { TimeEntryId = timeEntry.Id, TagId = Guid.Empty, }); Assert.AreEqual (2, view.Count); }); }
public void TestDeleteTag() { RunAsync(async delegate { var view = new TimeEntryTagsView(timeEntry.Id); await WaitForLoaded(view); await DataStore.DeleteAsync(tag2); Assert.AreEqual(1, view.Count); Assert.AreEqual( MakeTagsArray(DefaultTag), view.Data.ToArray() ); }); }
public void TestAddInvalidManyToMany() { RunAsync(async delegate { var view = new TimeEntryTagsView(timeEntry.Id); await WaitForLoaded(view); await DataStore.PutAsync(new TimeEntryTagData() { TimeEntryId = timeEntry.Id, TagId = Guid.Empty, }); Assert.AreEqual(2, view.Count); }); }
protected override void OnDataSourceChanged() { if (tagsView != null && (DataSource == null || DataSource.Id == tagsView.TimeEntryId)) { tagsView.Updated -= OnTagsUpdated; tagsView = null; } if (DataSource != null) { tagsView = new TimeEntryTagsView(DataSource.Id); tagsView.Updated += OnTagsUpdated; } base.OnDataSourceChanged(); }
public void TestRenameTag() { RunAsync(async delegate { var view = new TimeEntryTagsView(timeEntry.Id); await WaitForLoaded(view); tag2.Name = "A tag"; await DataStore.PutAsync(tag2); Assert.AreEqual(2, view.Count); Assert.AreEqual( MakeTagsArray("A tag", DefaultTag), view.Data.ToArray() ); }); }
public void TestDeleteManyToMany() { RunAsync(async delegate { var view = new TimeEntryTagsView(timeEntry.Id); await WaitForLoaded(view); var inter = await GetByRemoteId <TimeEntryTagData> (1); await DataStore.DeleteAsync(inter); Assert.AreEqual(1, view.Count); Assert.AreEqual( MakeTagsArray("Tag #2"), view.Data.ToArray() ); }); }
protected override void OnDataSourceChanged() { if (tagsView != null) { tagsView.Updated -= OnTagsUpdated; tagsView = null; } if (DataSource != null) { tagsView = new TimeEntryTagsView(DataSource.Id); tagsView.Updated += OnTagsUpdated; } RebindTags(); base.OnDataSourceChanged(); }
public void TestNonDefault() { RunAsync(async delegate { var view = new TimeEntryTagsView(timeEntry.Id); await WaitForLoaded(view); Assert.IsTrue(view.HasNonDefault); var inter = await GetByRemoteId <TimeEntryTagData> (2); await DataStore.DeleteAsync(inter); Assert.IsFalse(view.HasNonDefault); inter = await GetByRemoteId <TimeEntryTagData> (1); await DataStore.DeleteAsync(inter); Assert.IsFalse(view.HasNonDefault); }); }
public virtual void RebindTags(TimeEntryTagsView tagsView) { List <String> tagList = new List <String> (); String t; if (tagsView == null || tagsView.IsLoading) { return; } if (tagsView.Count == 0) { EditText.Text = String.Empty; return; } foreach (String tagText in tagsView.Data) { t = tagText.Length > TagMaxLength?tagText.Substring(0, TagMaxLength - 1).Trim() + "…" : tagText; if (tagText.Length > 0) { tagList.Add(t); } } // The extra whitespace prevents the ImageSpans and the text they are over // to break at different positions, leaving zero linespacing on edge cases. var tags = new SpannableStringBuilder(String.Join(" ", tagList) + " "); int x = 0; foreach (String tagText in tagList) { tags.SetSpan(new ImageSpan(MakeTagChip(tagText)), x, x + tagText.Length, SpanTypes.ExclusiveExclusive); x = x + tagText.Length + 1; } EditText.SetText(tags, EditText.BufferType.Spannable); }
public void TestAddManyToMany () { RunAsync (async delegate { var view = new TimeEntryTagsView (timeEntry.Id); await WaitForLoaded (view); var updateTask = WaitForUpdates (view); await DataStore.PutAsync (new TimeEntryTagData () { TimeEntryId = timeEntry.Id, TagId = tag3.Id, }); // Wait for the tag to be loaded and the view be updated: await updateTask; Assert.AreEqual (3, view.Count); Assert.AreEqual ( MakeTagsArray (DefaultTag, "Tag #2", "Tag #3"), view.Data.ToArray () ); }); }
public void TestAddManyToManyForOther() { RunAsync(async delegate { var view = new TimeEntryTagsView(timeEntry.Id); await WaitForLoaded(view); var updateTask = WaitForUpdates(view); await DataStore.PutAsync(new TimeEntryTagData() { TimeEntryId = Guid.NewGuid(), TagId = tag3.Id, }); // Wait to be sure the view has had a chance to ignore this relation: await Task.WhenAny(updateTask, Task.Delay(10)); Assert.AreEqual(2, view.Count); Assert.AreEqual( MakeTagsArray(DefaultTag, "Tag #2"), view.Data.ToArray() ); }); }
public void TestAddManyToMany() { RunAsync(async delegate { var view = new TimeEntryTagsView(timeEntry.Id); await WaitForLoaded(view); var updateTask = WaitForUpdates(view); await DataStore.PutAsync(new TimeEntryTagData() { TimeEntryId = timeEntry.Id, TagId = tag3.Id, }); // Wait for the tag to be loaded and the view be updated: await updateTask; Assert.AreEqual(3, view.Count); Assert.AreEqual( MakeTagsArray(DefaultTag, "Tag #2", "Tag #3"), view.Data.ToArray() ); }); }
public void TestReplaceManyToMany() { RunAsync(async delegate { var view = new TimeEntryTagsView(timeEntry.Id); await WaitForLoaded(view); var inter = await GetByRemoteId <TimeEntryTagData> (2); await DataStore.DeleteAsync(inter); await DataStore.PutAsync(new TimeEntryTagData() { TimeEntryId = timeEntry.Id, TagId = tag2.Id, }); // We're not awaitng on the updated event as the view should update immediatelly as the TagData // should still be cached. Assert.AreEqual(2, view.Count); Assert.AreEqual( MakeTagsArray(DefaultTag, "Tag #2"), view.Data.ToArray() ); }); }
public void TestAddManyToManyForOther () { RunAsync (async delegate { var view = new TimeEntryTagsView (timeEntry.Id); await WaitForLoaded (view); var updateTask = WaitForUpdates (view); await DataStore.PutAsync (new TimeEntryTagData () { TimeEntryId = Guid.NewGuid (), TagId = tag3.Id, }); // Wait to be sure the view has had a chance to ignore this relation: await Task.WhenAny (updateTask, Task.Delay (10)); Assert.AreEqual (2, view.Count); Assert.AreEqual ( MakeTagsArray (DefaultTag, "Tag #2"), view.Data.ToArray () ); }); }
public override void OnDestroyView () { if (tagsView != null) { tagsView.Updated -= OnTimeEntryTagsUpdated; tagsView = null; } base.OnDestroyView (); }
public void TestReplaceManyToMany () { RunAsync (async delegate { var view = new TimeEntryTagsView (timeEntry.Id); await WaitForLoaded (view); var inter = await GetByRemoteId<TimeEntryTagData> (2); await DataStore.DeleteAsync (inter); await DataStore.PutAsync (new TimeEntryTagData () { TimeEntryId = timeEntry.Id, TagId = tag2.Id, }); // We're not awaitng on the updated event as the view should update immediatelly as the TagData // should still be cached. Assert.AreEqual (2, view.Count); Assert.AreEqual ( MakeTagsArray (DefaultTag, "Tag #2"), view.Data.ToArray () ); }); }
public void TestRenameTag () { RunAsync (async delegate { var view = new TimeEntryTagsView (timeEntry.Id); await WaitForLoaded (view); tag2.Name = "A tag"; await DataStore.PutAsync (tag2); Assert.AreEqual (2, view.Count); Assert.AreEqual ( MakeTagsArray ("A tag", DefaultTag), view.Data.ToArray () ); }); }
public void TestMarkDeletedTag () { RunAsync (async delegate { var view = new TimeEntryTagsView (timeEntry.Id); await WaitForLoaded (view); tag2.DeletedAt = Time.UtcNow; await DataStore.PutAsync (tag2); Assert.AreEqual (1, view.Count); Assert.AreEqual ( MakeTagsArray (DefaultTag), view.Data.ToArray () ); }); }
public void TestMarkDeletedManyToMany () { RunAsync (async delegate { var view = new TimeEntryTagsView (timeEntry.Id); await WaitForLoaded (view); var inter = await GetByRemoteId<TimeEntryTagData> (1); inter.DeletedAt = Time.UtcNow; await DataStore.PutAsync (inter); Assert.AreEqual (1, view.Count); Assert.AreEqual ( MakeTagsArray ("Tag #2"), view.Data.ToArray () ); }); }
public void TestNonDefault () { RunAsync (async delegate { var view = new TimeEntryTagsView (timeEntry.Id); await WaitForLoaded (view); Assert.IsTrue (view.HasNonDefault); var inter = await GetByRemoteId<TimeEntryTagData> (2); await DataStore.DeleteAsync (inter); Assert.IsFalse (view.HasNonDefault); inter = await GetByRemoteId<TimeEntryTagData> (1); await DataStore.DeleteAsync (inter); Assert.IsFalse (view.HasNonDefault); }); }