This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove performBatchUpdates calls to prevent data disparity;
- Loading branch information
Showing
11 changed files
with
219 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
Xamarin.Forms.Platform.iOS.UnitTests/ObservableItemsSourceTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using NUnit.Framework; | ||
|
||
namespace Xamarin.Forms.Platform.iOS.UnitTests | ||
{ | ||
[TestFixture(Category = "CollectionView")] | ||
public class IndexPathTests | ||
{ | ||
[Test] | ||
public void GenerateIndexPathRange() | ||
{ | ||
var result = IndexPathHelpers.GenerateIndexPathRange(0, 0, 5); | ||
|
||
Assert.That(result.Length, Is.EqualTo(5)); | ||
Assert.That(result[0].Section, Is.EqualTo(0)); | ||
Assert.That((int)result[0].Item, Is.EqualTo(0)); | ||
|
||
Assert.That(result[4].Section, Is.EqualTo(0)); | ||
Assert.That((int)result[4].Item, Is.EqualTo(4)); | ||
} | ||
|
||
[Test] | ||
public void GenerateIndexPathRangeForLoop() | ||
{ | ||
// Section 0 | ||
// 5 items, looped 3 times | ||
// Looking for all the items corresponding to indexes 2, 3, and 4 | ||
|
||
var result = IndexPathHelpers.GenerateLoopedIndexPathRange(0, 15, 3, 2, 3); | ||
|
||
// Source: | ||
// 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4 | ||
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 | ||
|
||
|
||
// Result: | ||
// 2, 3, 4, 2, 3, 4, 2, 3, 4 | ||
// 2, 3, 4, 7, 8, 9, 12, 13, 14 | ||
|
||
Assert.That(result.Length, Is.EqualTo(9)); | ||
|
||
Assert.That(result[0].Section, Is.EqualTo(0)); | ||
Assert.That(result[1].Section, Is.EqualTo(0)); | ||
Assert.That(result[2].Section, Is.EqualTo(0)); | ||
Assert.That(result[3].Section, Is.EqualTo(0)); | ||
Assert.That(result[4].Section, Is.EqualTo(0)); | ||
Assert.That(result[5].Section, Is.EqualTo(0)); | ||
Assert.That(result[6].Section, Is.EqualTo(0)); | ||
Assert.That(result[7].Section, Is.EqualTo(0)); | ||
Assert.That(result[8].Section, Is.EqualTo(0)); | ||
|
||
Assert.That((int)result[0].Item, Is.EqualTo(2)); | ||
Assert.That((int)result[1].Item, Is.EqualTo(3)); | ||
Assert.That((int)result[2].Item, Is.EqualTo(4)); | ||
Assert.That((int)result[3].Item, Is.EqualTo(7)); | ||
Assert.That((int)result[4].Item, Is.EqualTo(8)); | ||
Assert.That((int)result[5].Item, Is.EqualTo(9)); | ||
Assert.That((int)result[6].Item, Is.EqualTo(12)); | ||
Assert.That((int)result[7].Item, Is.EqualTo(13)); | ||
Assert.That((int)result[8].Item, Is.EqualTo(14)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
Xamarin.Forms.Platform.iOS/CollectionView/IndexPathHelpers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Foundation; | ||
|
||
namespace Xamarin.Forms.Platform.iOS | ||
{ | ||
public static class IndexPathHelpers | ||
{ | ||
public static NSIndexPath[] GenerateIndexPathRange(int section, int startIndex, int count) | ||
{ | ||
var result = new NSIndexPath[count]; | ||
|
||
for (int n = 0; n < count; n++) | ||
{ | ||
result[n] = NSIndexPath.Create(section, startIndex + n); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
public static NSIndexPath[] GenerateLoopedIndexPathRange(int section, int sectionCount, int iterations, int startIndex, int count) | ||
{ | ||
var result = new NSIndexPath[iterations * count]; | ||
var step = sectionCount / iterations; | ||
|
||
for (int r = 0; r < iterations; r++) | ||
{ | ||
for (int n = 0; n < count; n++) | ||
{ | ||
var index = startIndex + (r * step) + n; | ||
result[(r * count) + n] = NSIndexPath.Create(section, index); | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.