177 Commits

Author SHA1 Message Date
Huy Nguyen
fb6d1830a0 Beter table/collection update history (#2562)
- Introduce thread-safe ASEventLog
- ASCollectionNode and ASTableNode share their event log with their ASDataController. The controller uses it to log change set submitting and finishing events.
- ASCollectionNode and ASTableNode print their data source and delegate in their debug description.
2016-11-08 16:44:49 -08:00
Adlai Holler
8add4619cf Reduce Traffic to Table/Collection View When Updating (#2496)
* Improve the call pattern when loading table/collection data

* When deleting sections, no need to delete rows first

* Clean up a couple things
2016-10-28 09:42:45 -07:00
george-gw
54cda5fdbb [ASCellNode] Added indexPath property. (#2468)
* [ASCellNode] Added indexPath property.

* [ASCellNode] Cached the type of scrollView we're using in the node, and placed that logic in setScrollView.

* [ASCellNode] Removed table and collection view from indexPath, since they return the index paths from the view-space.

* Changed the logic for getting indexPath so that it works even when the cell is not displayed.

* [VerticalWithinHorizontalScrolling] Explicitally synthesized indexPath property.
2016-10-27 16:56:00 -07:00
Adlai Holler
d32bf3f297 Conditionally import signpost header to fix Xcode 7 build (#2432) 2016-10-19 10:45:58 -07:00
Adlai Holler
c2ea7cfeac [Umbrella] ASCollectionView -> ASCollectionNode Migration, Separate Index Spaces (#2372)
* Separate dataSource & UIKit index spaces

Beef up our supplementary node support

Make the API way better

Go nuts

Add a unit test for UICollectionView's handling of reloadData inside batch updates

Wrap indexPathForNode: in a cache

Convert index paths in delegate methods

Go back on table view

Put collection view back

Switch up the API

Move most ASCollectionView API to ASCollectionNode

Move most table logic over to ASTableNode

Do the things

More conversion work

Keep on keepin' on

Get table view delegate API done

More porting

Simplify

Clear the delegate

More cleanup

Move more stuff around

Remove pointless file

Re-add some API

Put back more API

Use the right flag

* Some cleanup

* Remove incorrect comment

* Tweak the API

* Put back a couple methods

* update example projects (note: ASCollectionView deprecation warnings expected)

* change reloadDataWithCompletion:nil --> reloadData

* Clean up rebase

* Make deprecated numberOfItemsInSection methods optional

* Use the right flag

* Address nits

* update ASDKTube, ASDKgram & ASViewController examples
2016-10-14 17:21:16 -07:00
appleguy
4595ebc06e [ASLog] Add new ASProfilingSignpost defines for System Trace flags. (#2370)
* [Debugging / Profiling] Add kdebug_signpost calls to Range and DataController.

* [ASLog] Add new ASProfilingSignpost defines for System Trace flags.

* [ASLog] Improve kdebug_signpost logging: ASRunloopQueue and AsyncDisplay, and colors.
See https://github.com/facebook/AsyncDisplayKit/pull/2370 for screenshots.
2016-10-13 10:31:22 -07:00
Garrett Moon
8729bc0502 This is super minor, but active processor account takes into processors that may be out of commission due to boot arguments or thermal conditions. (#2373) 2016-10-12 15:54:59 -07:00
Huy Nguyen
066351bad7 Introduce ASSectionContext and ASSection (#2178)
- Objects conform to ASSectionContext protocol can be provided via ASCollectionDataSource and later retrieved from the collection view. They are guaranteed to be in sync with sections of the collection view. They can be used to store additional data associated with each section, to be used in collection view layout and the like.
- ASSection is an internal object that is the foundation for coming debugging tools.
- Unit tests included.
2016-10-01 14:04:05 -04:00
Adlai Holler
4cf571c830 [ASCollectionView] Add Support for Interactive Reordering (#2221)
[ASTableView] Add Support for Interactive Reordering
2016-09-14 22:31:04 -07:00
Michael Schneider
8897614f0e [Layout] Layout API based on content area (#2110)
* Initial commit for adding a size constraint to ASLayoutable's

* Some more commits

* Fix sample projects in extra/

* Remove preferredFrameSize test of ASEditableTextNode

* Remove preferredFrameSize from examples_extra

* Add deprecation warning to -[ASDisplayNode preferredFrameSize]

* Add deprecation warning to -[ASDisplayNode measureWithSizeRange:]

* Commit

* Commit

* Remove ASRelativeSizeRange

* Make ASRelativeSize private

* Adjust examples

* Improve setting of -[ASLayoutable size] with points or fractions

* Add ASWrapperLayoutSpec

* Improve creation of ASRelativeDimension

* Add `preferredFrameSize` back and add deprecated logging

* Add `layoutSpecBlock` setter and getter and add locking for it

* Add better documentation and fix macros to create ASRelativeDimension

* Create new ASSizeRangeMake with just a CGSize as parameter

* Update Kitten and Social App Layout example

* Add layoutThatFits: and deprecate measure:

* Rename ASRelativeDimension to ASDimension

* Fix examples for ASDimension renaming

* Remove fancy height and width setter

* Fix ASDimension helper

* Rename -[ASLayout layoutableObject] to -[ASLayout layoutable]

* Update layout related methods and more clearer documentation around how to use it

* Deprecate old ASLayout class constructors

* Don't unnecessary recalculate layout if constrained or parent size did not change

* Use shared pointer for ASDisplayNodeLayout

* Fix rebase conflicts

* Add documentation and move implementation in mm file of ASDisplayNodeLayout

* Fix test errors

* Rename ASSize to ASLayoutableSize

* Address comments

* Rename setSizeFromCGSize to setSizeWithCGSize

* Improve inline functions in ASDimension

* Fix rebase conflicts
2016-09-07 08:44:48 -07:00
Adlai Holler
6a482dc153 [ASDataController] Use 2 Threads Per CPU When Measuring Nodes (#2145)
* [ASDataController] Use custom apply function to control thread count

* Relax the test for stupid Travis CI

* Remove unneeded import
2016-08-26 10:54:55 -07:00
Adlai Holler
8edc9fe08f Ensure supplementary section count tracks item section count (#2118) 2016-08-22 20:50:09 -07:00
Adlai Holler
aedb83cfe3 [ASDataController] Remove Unused Batch Update Processing Code (#2054)
* [ASDataController] Remove dead batch updating code

* Address PR comments
2016-08-11 11:48:17 -07:00
Adlai Holler
1fbf8ad073 [ASDataController] Cancel if we lose our data source, fix bugs (#1987)
[ASRangeController] We're already on main thread, remove blocks

Make data source read-only, clarify what's asynchronous

[ASDataController] Clean up some interfaces

[ASDataController] A little more cleanup

[ASDataController] Cleanup

[ASDataController] Restore some changes, exit more often

[ASDataController] Use item counts that we already have rather than requerying them

[ASDataController] Revert weakifications

[ASDataController] Add a mechanism to measure how much work we avoided
2016-08-05 15:39:33 -07:00
Adlai Holler
7ec6f07953 [General] Remove dead code, check optional protocol selector before calling (#1970) 2016-07-22 13:09:28 -07:00
Adlai Holler
8cde594de3 [ASDataController] Add validation logic to the change set to throw exceptions on invalid updates (#1894)
[_ASHierarchyChangeSet] Oopsy daisy

[ASDataController] Tweak our update validation

[ASHierarchyChangeSet] Fix bugs

Finish up some stuff

[ASDataController] Put some stuff back

[ASChangeSetDataController] Always use changeset

[ASDataController] Put other stuff back

[_ASHierarchyChangeSet] Use fast enumeration

[_ASHierarchyChangeSet] Fix assertion format strings, return on fail so we don't crash in production

[ASDataController] Store data source item counts as vector rather than NSArray

[ASDataController] Build some tests for the update validation

[ASDataController] Fix issues with update validation

Get rid of new file

[ASDataController] Suppress changeset validation before initial reload

[ASDataController] Make invalid update log vs. exception publicly toggleable
2016-07-21 14:37:51 -07:00
Adlai Holler
1777dae300 [ASDataController] Set context variable value 2016-07-18 18:41:51 -07:00
Adlai Holler
46a911ecf4 [ASDataController] Clean up by using a dispatch_group 2016-07-18 15:01:22 -07:00
Adlai Holler
fa34888d98 [ASDataController] Migrate to GCD queue to make debugging easier 2016-07-18 12:15:27 -07:00
Hannah Troisi
4baf9bdbfe [Infer] Fix Infer errors/warnings (#1938)
* [Infer] Fix 11 Infer errors/warnings

* fix build error
2016-07-16 15:29:24 -07:00
Hannah Troisi
abf8d5b9aa [Infer] change atomic properties to nonatomic (#1932) 2016-07-16 10:46:55 -07:00
Michael Schneider
20a49f037b Comment adjustment for laying out nodes 2016-07-15 11:41:10 -07:00
Adlai Holler
e7fc5a98f2 Merge pull request #1906 from facebook/AHReduceBlockInvocations
[Performance] Various Easy Performance Wins
2016-07-15 10:14:22 -07:00
Michael Schneider
a8c5ac138d [ASDisplayNode] Always layout nodes on a background thread (#1907)
* Always layout nodes on a background thread

* Remove semaphore in ASDataController for allocating nodes and layout

* Fix variable not used error

* Remove overhead to create subarray of contexts of nodes while layout nodes

* Remove extra allocation of allocatedNodes and indexPaths array
2016-07-14 21:35:58 -07:00
Adlai Holler
2e19d11350 Reduce block invocations, other small performance bumps 2016-07-12 15:11:13 -07:00
appleguy
3b2af7eb6d [Build] Remove Unused Imports across all of AsyncDisplayKit. This uses a feature of AppCode. (#1875)
Details on the tool are here: https://www.jetbrains.com/help/idea/2016.1/optimizing-imports.html
2016-07-09 17:20:59 -07:00
Adlai Holler
c62a4d3e79 [ASCollectionView] Greatly Improve Cell Node Resizing (#1853)
* [ASCollectionView] Initial pass at reducing double-sided animations

* [ASCollectionView] Always suppress animation during node size requery

* [ASCollectionView] Rejigger the invalidation logic to support animated size changes

* [ASCollectionView] Remove unused header

* [ASCollectionView] Change comment

* [ASDataController] Remove unused variable

* [ASCollectionView] When relayout animated due to cell size change, wait until next layout pass

* [ASCollectionView] Invalidate layout synchronously

* [ASCollectionView] Only read the layout object once

* [ASCollectionView] When size changes, wait for requery before layout

* [ASCollectionView] Sort of go back to using an empty update to handle node resizing

* [ASCollectionView] Remove unused constant

* [ASCollectionView] Address PR comments

* [ASCollectionView] Prevent nested [super performBatchUpdates:] calls
2016-07-06 14:13:52 -07:00
Adlai Holler
ebaa2c157e Remove aggregate CGRect initializers in ASDataController 2016-07-01 11:47:05 -07:00
Adlai Holler
0a354f8f4e [ASDataController] Remove implementation for unused hooks 2016-06-24 15:48:23 -07:00
Adlai Holler
35056f708b [ASDataController] Improve update handling 2016-06-24 11:12:37 -07:00
Adlai Holler
457e08005f [ASDataController] Remove asyncDataFetching Option, Cleanup (#1794)
* [ASDataController] Add some assertions to clarify what queues things happen on

* [ASCollectionDataController] Optimize willReloadData

* [ASDataController] Minor optimizations, no functional changes

* [ASDataController] Always reload data on _editingTransactionQueue

* [ASDataController] Remove async data fetching option, deprecate callbacks

* [ASDataController] Not mutable

* [ASMultidimensionalArrayUtils] Use fast enumeration

* Optimize ASMultidimensionalArrayUtils
2016-06-23 21:08:44 -07:00
Hannah Troisi
c857e809f4 Clean up header comments (for consistent Facebook licensing info) (#1741)
[Licensing] Clean up header comments (for consistent Facebook licensing info)
2016-06-11 23:31:39 -07:00
Eric Horacek
fc5eef3269 Repopulate supplementary views on item-level changes
Currently within `ASCollectionView`, there is an assumption that there will always be a static number of supplementary views per section—even when additional items are added or removed from that section. This is evidenced by the fact that when you invoke -[ASCollectionView insertItemsAtIndexPaths:], the data source method -[ASCollectionDataSource collectionView:nodeForSupplementaryElementOfKind:atIndexPath:] is not invoked, preventing consumers from specifying a new number of supplementary nodes for the new set of items.

With this change, the set of supplementary nodes for a section is now recalculated not only on section-level mutations, but also on item-level mutations as well. This adds item-level counterparts to the section-level `-prepareFor...` subclassing hooks in `ASDataController+Subclasses.h` to make this possible.

This should fix #1278 and #1322

This has been tested in my project and seen to fix the assertion. Open to suggestions on how to test in a more universal way.
2016-06-05 21:38:08 -07:00
Michael Schneider
6945555d60 Sort in ascending order before removing nodes and restore FIXME 2016-06-04 13:56:10 -07:00
Michael Schneider
6566b7adb7 Use asdk_inverseCompare: to reverse sort the array of index path's to delete 2016-06-04 13:56:10 -07:00
Michael Schneider
3e4b5e9e82 Sort index paths or rows in descendant order for deletion 2016-06-04 13:56:10 -07:00
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