57 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
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
Adlai Holler
4cf571c830 [ASCollectionView] Add Support for Interactive Reordering (#2221)
[ASTableView] Add Support for Interactive Reordering
2016-09-14 22:31:04 -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
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
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
Scott Goodson
8308a4ce49 [AsyncDisplayKit] Adopt #pragma once, remove last remaining dispatch_sync (UIScreen scale). 2016-03-19 19:56:41 -07:00
Eric Jensen
ddd5ff1f75 Correct spelling errors 2016-03-15 21:56:51 -07:00
Scott Goodson
c4f6c9035b [ASDataController] If app code issues edit commands before first reload, ignore them, as UIKit will call -reloadData. 2016-03-05 20:52:00 -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
b75d6627bb Revert "Revert "Revert "[ASCollectionView / ASTableView] Optimize reloadData and reloadSection: methods.""" 2016-02-19 23:26:29 -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
Luke Zhao
40791dd859 optimize reload data, reload sections, & move nodes performance & logic 2016-02-18 14:44:16 -08:00
Rahul Malik
3e5daf4ccd Update data source protocols to make synchronous node creation api methods optional. 2016-02-09 22:47:43 -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
a2cf2a88e6 Overhaul header files / includes to eliminate circular references that Xcode 7 is angry about. 2015-12-25 19:22:00 -08:00
Adlai Holler
8e104f4887 Merge branch 'master' into update-objc
Conflicts:
	AsyncDisplayKit/ASCollectionView.h
	AsyncDisplayKit/ASDisplayNode.h
	AsyncDisplayKit/Details/ASDataController.h
	AsyncDisplayKit/Details/UIView+ASConvenience.h
	AsyncDisplayKit/Layout/ASLayoutSpec.h
2015-10-28 21:10:27 -07:00
Huy Nguyen
5ea4b1b92d Implement ASChangeSetDataController. 2015-10-26 06:22:30 +02:00
Levi McCallum
722b90f1cf Implement basic immediate reloadData method on table and collection view 2015-10-22 21:28:44 -07:00
Levi McCallum
c33d6efa8a WIP synchronous reload data on collection view 2015-10-22 21:28:30 -07:00
Levi McCallum
71966f3549 Relayout all nodes in backing store on relayoutAllNodes 2015-10-15 11:40:51 -07:00
Levi McCallum
34f3065825 Use local method for introspecting data controller constrained sizes 2015-10-15 11:40:50 -07:00
Levi McCallum
e9eadac4ae Stub out ASCollectionDataController subclass 2015-10-15 11:40:48 -07:00
Levi McCallum
cefbcef831 Documentation updates 2015-10-15 11:38:47 -07:00
Adlai Holler
8bb9d173dc Merge branch 'master' into update-objc
Conflicts:
	AsyncDisplayKit/ASDisplayNode+Subclasses.h
	AsyncDisplayKit/ASMultiplexImageNode.h
	AsyncDisplayKit/ASViewController.h
	AsyncDisplayKit/Details/ASDataController.h
2015-10-05 13:24:16 -07:00
Steven Ramkumar
d09888f9c2 Add a indexPathForNode: to ASTableView 2015-09-22 12:09:56 -07:00
Adlai Holler
c010ddad3b Update all the files in the Details group 2015-09-17 13:30:28 -07:00
Huy Nguyen
7249661990 Improve relayout when constrained size of all nodes is changed:
- In -layoutSubviews of table and collection views, detect changes that cause a different constrained size for nodes, and trigger relayout immediately.
- Orientation change can be handled by this solution. So, no need to observe to its events.
- Update Kittens example to support iPad (easier to catch bugs on these devices) and add a title to navigation bar (looks a bit nicer).
2015-08-13 06:28:47 +03:00
Huy Nguyen
a3c2dbf8cd Table and collection views' async data source can provide different constrained size per node. And because the size is of type ASSizeRange, it has a min size that is very helpful in many cases.. 2015-08-12 22:45:08 +03:00
Huy Nguyen
e657bedd40 Automatically relayout cells after orientation changed. 2015-08-09 00:36:58 +03:00
Ethan Nagel
f497639124 Add support automatically adjusting the content offset to UITableView as well as support for performing endUpdates with no animations. Additionally, there are critical bug fixes for ASDataController (begin/end updates delegates not called in correct order) and ASRangeController (failure to fully refresh internal state when inserts or delete are made.) 2015-07-20 14:05:56 -07:00
Huy Nguyen
cfac6c992a [appledoc] Fix appledoc warnings. (#553) 2015-07-10 19:02:04 +07:00
Scott Goodson
8fa092fb77 Complete overhaul of ASFlowLayoutController.
Introduced ASIndexPath for efficient handling of index paths in C++ vectors,
while maintaining the readability of ".section" and ".row" instead of
".first" and ".second" inside of complicated business logic.

Confirmed that the working range calls are firing appropriately during
ASTableViewStressTest, including the deallocation of the rich text placeholders
provided by ASTextNode.
2015-07-04 20:22:04 -07:00
Scott Goodson
57465c7fd3 Overhaul ASDataController and extensively test ASTableView.
This diff resolves all known consistency issues with ASTableView and ASCollectionView.
It includes significantly more aggressive thrash-testing in ASTableViewStressTest,
which now passes on a variety of device and simulator configurations.  It also updates
the unit tests run on every commit to ensure any regression is caught quickly.

A few of the salient changes in this diff:
- ASTableView now uses Rene's ASCollectionViewLayoutController, and actually uses a
UICollectionViewFlowLayout without any UICollectionView.  This resolves an issue where
ASFlowLayoutController was generating slightly out-of-bounds indicies when programmatically
scrolling past the end of the table content.  Because the custom implementation is likely
faster, I will revisit this later with profiling and possibly returning to the custom impl.
- There is now a second copy of the _nodes array maintained by ASDataController.  It shares
the same node instances, but this does add some overhead to manipulating the arrays. I've
filed a task to follow up with optimization, as there are several great opportunities to
make it faster.  However, I don't believe the overhead is a significant issue, and it does
guarantee correctness in even the toughest app usage scenarios.
- ASDataController no longer supports calling its delegate /before/ edit operations.  No
other class was relying on this behavior, and it would be unusual for an app developer to
use ASDataController directly.  However, it is possible that someone with a custom view
that integrates with ASDataController and ASRangeController could be affected by this.
- Further cleanup of organization, naming, additional comments, reduced code length
wherever possible.  Overall, significantly more accessible to a new reader.
2015-06-28 18:03:45 -07:00
Scott Goodson
06cfe68cbd Clean up ASDataController for readability & API naming consistency. 2015-06-27 11:06:54 -07:00
Scott Goodson
c700618862 Improvements to thread safety during closely spaced edit events.
This applies primarily when beginUpdates / endUpdates is not used.
Due to user interaction-driven edits, like reloads or adding content
at the bottom, sometimes this is unavoidable in app design and thus
critical.

I have a diff in flight to make ASDataController / ASRangeController
robust against very aggressive thrash testing, which will be added
both to the unit test suite and this new example project.
2015-06-21 21:04:09 -07:00
Ethan Nagel
3f509dbd2f add completion block to reloadData methods 2015-03-26 16:32:44 -07:00
Ryan Nystrom
4fa03a01d1 Functioning Preload range
Refactor how we do ranges so they can be arbitrarily managed. Introduce the concept of a preload range.
2015-02-26 15:41:32 -08:00
Nadine Salter
b023cfbb2a Merge pull request #303 from facebook/enable_async_data_fetching
Move ASTableView & ASCollectionView data fetching to background thread
2015-02-23 15:25:36 -08:00
Ryan Nystrom
ad474fce8e Make project imports consistent 2015-02-23 14:55:15 -08:00
Li Tan
831aa47ae0 Address comments 2015-02-11 19:15:08 -08:00