141 Commits

Author SHA1 Message Date
Michael Schneider
45ff5634fe Use NSFastEnumeration for enumerating though eyes of completedNodes 2016-06-04 13:56:10 -07:00
Michael Schneider
f72261bd10 Remove comment and use sorted array for reloading data 2016-06-04 13:56:10 -07:00
ricky
01dbc86778 First pass of comments
* make variable naming reflect ASEnvironmentTraitCollection vs ASTraitCollection
* move trait propagation to cell allocation instead of via a nested block
* move trait propagation when setting a displaynode's supernode instead of when adding a subnode
* fixed misspelling of "colection"
2016-06-03 09:59:24 -07:00
ricky
59a26ee111 [ASTraitCollection] Bug fixing/LayoutSpec propagation
* Fixed bug in `ASEnvironmentMergeObjectAndState`
* New ASLayoutSpec methods for `setChild`/`setChildren`/`setChild:forIdentifier:` have been added to take in a trait collection.
* Added `setChild:`-like methods for ASLayoutSpecs take a traitCollection
* Fixed instances where nodes in a data controller were not getting their trait collections
* propagate traitCollection in ASDisplayNode on insertSubnode or addSubnode
2016-05-23 16:37:40 -07:00
Michael Schneider
eee2262262 Match creation of subarrays for nodes and contexts in ASDataController 2016-05-13 22:51:40 +02:00
Michael Schneider
33b76bbce0 Use calloc’d array for subarray of contexts 2016-05-13 21:38:25 +02:00
Michael Schneider
7d902d98c9 Fix passing wrong constrained size to nodes
In _layoutNodesFromContexts:ofKind:completion: we pass the full array of contexts to _layoutNodes:fromContexts:atIndexesOfRange:ofKind: but for nodes we pass a subarray of nodes instead based on the batchCount. As batchRange we always start from 0 to batchCount. We now use the same indexes that we use to create the subarray of nodes to get a subarray of contexts that we pass to _layoutNodes:fromContexts:atIndexesOfRange:ofKind:.
2016-05-13 21:06:16 +02:00
rcancro
4b54144f55 Levi's comments 2016-05-11 10:21:11 -07:00
rcancro
9d622c7eac changed DisplayTraits to TraitCollection 2016-05-10 14:45:03 -07:00
rcancro
8bb4eba080 Initial attempt at implementing Display Traits
Initial attempt to get display traits working with ASEnvironment.

To get proper ASDisplayTraits support, you must use an ASViewController. The ASViewController implements UITraitCollection-related methods (`traitCollectionDidChange:`, `willTransitionToTraitCollection:withTransitionCoordinator:`, viewWillTransitionToSize:withTransitionCoordinator`) to update the internal ASDisplayTraits and propagate them to subnodes.

ASTableNode and ASCollectionNode don't actually have their cells as subnodes, so a little bit of trickery is involved (on `setEnvironment:` the table/collection node gets its data controllers completedNodes and propagates the new traits. see `ASDisplayTraitsCollectionTableSetEnvironmentState`). The data controller also passes the current display traits when creating new cells.

ASViewController also supports the ability to return a custom set of display traits. So if you have a modal dialog that should always be told it is in a compact size class, you can set the override block before displaying the VC.

A new example, called Display Traits, has been added. It shows how display traits can be used in a ASViewController with a normal ASDisplayNode as its root, as well as in ASViewControllers hosting table nodes and collection nodes. There is also an example of overriding the default display traits of a VC.

Please provide feedback!
2016-05-10 14:44:22 -07:00
Michael Schneider
2ab82f5995 Move to fast enumeration for iterating through an array
We move from block based enumeration for the array to fast enumeration as from a benchmark perspective this is faster. For the dictionary we stay with block based enumeration as looking up the value for the key in e.g. fast enumeration would be slower as using the block based API where we get the key and value for passed in
2016-04-26 10:45:35 -07:00
Scott Goodson
a9b02e8632 [ASDataController] Handle incorrect client code that returns a nil ASCellNode (assert, but use zero-size cell in production). 2016-04-06 21:34:06 -07:00
Michael Schneider
c6f00b1541 Use batchCount for indexes passed into internal layout nodes method and NSMaxRange 2016-03-27 17:54:40 -07:00
Michael Schneider
0284e55359 Add explicit range parameter for internal layout nodes method and better documentation 2016-03-27 17:48:17 -07:00
Michael Schneider
552b79deaa Remove onMainThread: argument in internal layout nodes method 2016-03-27 17:48:17 -07:00
Michael Schneider
1f9e9b8483 Refactor ASDataController layout nodes methods 2016-03-27 17:48:17 -07:00
Eric Jensen
17aebcbaba Add a space between the ? and : in ternarys 2016-03-17 10:38:51 -07:00
appleguy
d9ef0922d8 Merge pull request #1354 from ejensen/cleanup
[Refactoring] Objective-C 2.0 / Modern syntax for arrays, dictionaries, numbers; logic simplification
2016-03-17 01:06:33 -07:00
Eric Jensen
33fda7ab49 - Use modern Objective-C syntax.
-  Simplify comparisons.
-  Remove dead stores.
2016-03-15 22:34:29 -07:00
Eric Jensen
ddd5ff1f75 Correct spelling errors 2016-03-15 21:56:51 -07:00
Scott Goodson
6a32e5ccc0 [ASDataController] If app code issues edit commands before first reload, ignore them, as UIKit will call -reloadData. 2016-03-05 20:27:36 -08:00
Scott Goodson
cc7ca4a08f [ASDataController] If app code issues edit commands before first reload, ignore them, as UIKit will call -reloadData. 2016-03-05 20:22:18 -08:00
Michael Schneider
aa2ae87c81 Add -waitUntilAllUpdatesAreCommitted to ASTableView and ASCollectionView
The API allows consumer of ASTableView or ASCollectionCiew to block execution of the main thread until all section and row updates are committed.
2016-03-02 19:38:14 -08:00
appleguy
07ad27c7f6 Merge pull request #1291 from nguyenhuy/container_object
[ASDataController] Performance tuning for array enumeration, etc.
2016-02-29 14:24:17 -08:00
Huy Nguyen
6d463daac7 ASDataController improvements
- _populateFromDataSourceWithSectionIndexSet doesn't accept a mutanle array but allocate one itself.
- Remove _populateFromEntireDataSourceWithMutableContexts.
- ASIndexedNodeContext executes its block, nil out the block and return the result.
2016-02-29 14:03:40 -08:00
Huy Nguyen
b098d80796 Performance improvements in ASDataController based on @Adlai-Holler comments in #1288 2016-02-29 11:36:48 -08:00
appleguy
2a89c1d3d6 Merge pull request #1288 from nguyenhuy/container_object
[ASDataController] Introduce ASIndexedNodeContext for efficiency and simplicity in managing nodes, indexPaths, and their constraints.
2016-02-29 01:10:38 -08:00
Huy Nguyen
54cde1a3db Introduce ASIndexedNodeContext
- It is a container object that holds enough information to construct and measure a cell node
- All information is gathered on main thread. This allows ASDataController to capture the correct state of its data source before going to background.
2016-02-29 01:00:16 -08:00
Scott Goodson
eac85b6c9a [ASDisplayNode] Optimize -setNeedsDisplay, deep mutable array copies.
These optimizations are surprisingly impactful.  -setNeedsDisplay being called
for every node triggered cancelAsyncDisplay, locking, and memory management overhead
that is completely avoidable because Core Animation triggers first display automatically.

The mutable array copy optimizations reduced this key cost by over 10x, from 52ms to 5ms
on an iPad Air 2 / A8X with a real-world test case.
2016-02-28 20:54:56 -08:00
appleguy
b75d6627bb Revert "Revert "Revert "[ASCollectionView / ASTableView] Optimize reloadData and reloadSection: methods.""" 2016-02-19 23:26:29 -08:00
appleguy
2b10d84a2b Revert "fix scheduling issue that causes collectionView to not animate" 2016-02-19 23:26:12 -08:00
Scott Goodson
a1061301e0 [ASDataController] Revert the reloadData optimizations again - need to fix apps relying on prior behavior.
The optimization seems correct now, but apps like Pinterest have some core code relying on edit operation
order that is actually not permitted by UIKit (and this diff) but were tolerated previously.  We will
re-land this once we have time to adapt the code.
2016-02-19 21:31:39 -08:00
appleguy
32aa333c21 Revert "[ASCollectionView / ASTableView] Optimize reloadData and reloadSection: methods." 2016-02-18 19:50:06 -08:00
appleguy
33d4c8693d Merge pull request #1171 from lkzhao/ASDataController-reload
[ASCollectionView / ASTableView] Optimize reloadData and reloadSection: methods.
2016-02-18 17:36:14 -08:00
Luke Zhao
40791dd859 optimize reload data, reload sections, & move nodes performance & logic 2016-02-18 14:44:16 -08:00
Rahul Malik
19cc368d15 In addition to allocating nodes in the background, perform that operation concurrently in ASDataController 2016-02-17 22:30:58 -08:00
Bin Liu
db1a91234d Improve reload handling in BatchUpdates 2016-02-16 11:04:21 -08:00
Scott Goodson
fce722b0c8 [ASDisplayNode] Allow display-scheduling method to be called concurrently. 2016-02-13 00:58:56 -08:00
Bin Liu
88ff693327 Fixes in ChangeSet and DataController 2016-02-11 23:51:32 -08:00
Bin Liu
9e53dcd402 Fix allocatedNodes Subarray to match indexPaths subarray 2016-02-10 01:35:07 -08:00
Rahul Malik
c4f489b074 Address comments. 2016-02-04 16:56:29 -08:00
Rahul Malik
521c3fa1c1 Move ASCellNode allocation off the main thread by the addition of a node block
API in ASDataController. Move allocations and loaded node layouts to occur
during batch layout phase.
2016-02-04 10:38:59 -08:00
Huy Nguyen
56c6bd681b Revert "Revert commit 83aaa46, thus bring 2e4d716 back"
This reverts commit 209425c22ce84ecbb7ab631753ec8fc34dd9cbb0.
2016-01-26 12:05:02 -08:00
Huy Nguyen
209425c22c Revert commit 83aaa46, thus bring 2e4d716 back 2016-01-24 23:38:05 -08:00
Scott Goodson
83aaa4637e Revert "ASDataController now handles reloadData more efficiently and notify its delegate once instead of a series of deletes and inserts"
This reverts commit 2e4d716e0b65465d9c65b5821668c38e5fa956c9.

Possible issue with this commit.
2016-01-22 20:33:33 -08:00
Huy Nguyen
2e4d716e0b ASDataController now handles reloadData more efficiently and notify its delegate once instead of a series of deletes and inserts 2016-01-21 11:21:21 -08:00
Scott Goodson
df10f8f19a Check array size before accessing section - rare crash for improper data source use, de-escalated to messaging nil. 2016-01-14 00:25:53 -08:00
Scott Goodson
7dff6ffa14 Re-enable program flow instrumentation for Coveralls. More null-specifiers.
This does cause tests to crash at the end, which unfortunately seems like a known Xcode 7 bug.
2015-12-25 22:13:35 -08:00
Garrett Moon
941a732fd6 Rename and move ASMainSerialQueue to its own class 2015-12-11 10:53:06 -08:00
Garrett Moon
066596314e Fix deadlock when an editing transaction needs to perform its work on the main thread, and then elsewhere, on the main thread, we block waiting for all editing transactions to finish 2015-12-11 10:45:23 -08:00