Project: titanium
Issue TIMOB-16879: ScrollableView: Add "insertViewsAt()" method
The ScrollableView currently supports the ".addView()" method to programmatically append additional views to the end of the collection. However, it has no method to insert one or more views at the beginning (prepend), or somewhere in the middle of the collection. A [suggested workaround|http://developer.appcelerator.com/question/161891/scrollable-view---insert-a-view-into-a-specific-spot] for this limitation involves getting the views array with .getViews(), updating the array, then re-assiging the views array back to the control with .setViews(). While this works, it is not efficient and causes significant flickering on the UI with complex views, every time .setViews() is used. It would be great to have a method like ".insertViewsAt(idx, views)" so one item (or more) can be prepended or inserted at specific locations without requiring the entire views collection to be re-bound and rendered. This would also bring the ScrollableView control in line with ListView and TableView, both of which feature "insert" methods. In my particular case; I'm using a ScrollableView to page through over 500 views which are fairly complex. Loading all views into the ScrollableView is not an option as that takes too much memory and crashes the app. My solution is to have a sliding range that loads 9 views at a time (4 before and 4 after the current page) on the ScrollableView. And as the user moves left or right, it dynamically prepends or appends more views as needed, removing views also from the opposite end so only 9 views are loaded at any given time. Appending with addView() works well (no need for setViews(), so no flickering), but prepending with the getViews()/update/setViews() process does not work well in these situations.
Story points: 5