@nstudio/ui-collectionview 4.0.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +396 -0
  3. package/angular/collectionview.component.d.ts +82 -0
  4. package/angular/esm2020/collectionview.component.mjs +394 -0
  5. package/angular/esm2020/index.mjs +19 -0
  6. package/angular/esm2020/nstudio-ui-collectionview-angular.mjs +5 -0
  7. package/angular/fesm2015/nstudio-ui-collectionview-angular.mjs +421 -0
  8. package/angular/fesm2015/nstudio-ui-collectionview-angular.mjs.map +1 -0
  9. package/angular/fesm2020/nstudio-ui-collectionview-angular.mjs +416 -0
  10. package/angular/fesm2020/nstudio-ui-collectionview-angular.mjs.map +1 -0
  11. package/angular/index.d.ts +8 -0
  12. package/angular/package.json +26 -0
  13. package/common.d.ts +191 -0
  14. package/common.js +610 -0
  15. package/common.js.map +1 -0
  16. package/index.android.d.ts +117 -0
  17. package/index.android.js +1097 -0
  18. package/index.android.js.map +1 -0
  19. package/index.d.ts +16 -0
  20. package/index.ios.d.ts +118 -0
  21. package/index.ios.js +1123 -0
  22. package/index.ios.js.map +1 -0
  23. package/package.json +57 -0
  24. package/platforms/android/AndroidManifest.xml +3 -0
  25. package/platforms/android/include.gradle +7 -0
  26. package/platforms/android/java/com/nativescript/collectionview/Adapter.java +66 -0
  27. package/platforms/android/java/com/nativescript/collectionview/AdapterInterface.java +19 -0
  28. package/platforms/android/java/com/nativescript/collectionview/CollectionViewCellHolder.java +12 -0
  29. package/platforms/android/java/com/nativescript/collectionview/GridLayoutManager.java +72 -0
  30. package/platforms/android/java/com/nativescript/collectionview/OnScrollListener.java +35 -0
  31. package/platforms/android/java/com/nativescript/collectionview/PreCachingGridLayoutManager.java +51 -0
  32. package/platforms/android/java/com/nativescript/collectionview/RecycledViewPool.java +85 -0
  33. package/platforms/android/java/com/nativescript/collectionview/RecyclerView.java +46 -0
  34. package/platforms/android/java/com/nativescript/collectionview/SizeChangedListener.java +6 -0
  35. package/platforms/android/java/com/nativescript/collectionview/SpanSizeLookup.java +26 -0
  36. package/platforms/android/native-api-usage.json +29 -0
  37. package/platforms/android/res/layout/collectionview.xml +5 -0
  38. package/platforms/android/ui_collectionview.aar +0 -0
  39. package/react/index.d.ts +119 -0
  40. package/react/index.js +148 -0
  41. package/react/index.js.map +1 -0
  42. package/svelte/index.d.ts +21 -0
  43. package/svelte/index.js +143 -0
  44. package/svelte/index.js.map +1 -0
  45. package/vue/component.d.ts +38 -0
  46. package/vue/component.js +104 -0
  47. package/vue/component.js.map +1 -0
  48. package/vue/index.d.ts +4 -0
  49. package/vue/index.js +12 -0
  50. package/vue/index.js.map +1 -0
@@ -0,0 +1,1097 @@
1
+ /* eslint-disable no-redeclare */
2
+ import { ChangeType, ContentView, Property, ProxyViewContainer, Trace, Utils, View, booleanConverter, paddingBottomProperty, paddingLeftProperty, paddingRightProperty, paddingTopProperty, profile } from '@nativescript/core';
3
+ import { reorderLongPressEnabledProperty, reorderingEnabledProperty, reverseLayoutProperty, scrollBarIndicatorVisibleProperty } from './common';
4
+ import { CLog, CLogTypes, CollectionViewBase, ListViewViewTypes, isScrollEnabledProperty, orientationProperty } from './common';
5
+ export * from './common';
6
+ let CollectionViewCellHolder;
7
+ let CollectionViewRecyclerView;
8
+ var SimpleCallback = /** @class */ (function (_super) {
9
+ __extends(SimpleCallback, _super);
10
+ function SimpleCallback(param1, param2) {
11
+ var _this = _super.call(this, param1, param2) || this;
12
+ _this.startPosition = -1;
13
+ _this.endPosition = -1;
14
+ return global.__native(_this);
15
+ }
16
+ SimpleCallback.prototype.onMove = function (recyclerview, viewHolder, target) {
17
+ var startPosition = viewHolder.getAdapterPosition();
18
+ var endPosition = target.getAdapterPosition();
19
+ if (this.startPosition === -1) {
20
+ this.startPosition = startPosition;
21
+ }
22
+ this.endPosition = endPosition;
23
+ var owner = this.owner && this.owner.get();
24
+ if (owner) {
25
+ owner._reorderItemInSource(startPosition, endPosition);
26
+ return true;
27
+ }
28
+ return false;
29
+ };
30
+ SimpleCallback.prototype.onSelectedChanged = function (viewHolder, state) {
31
+ if (viewHolder) {
32
+ if (this.startPosition === -1) {
33
+ this.startPosition = viewHolder.getAdapterPosition();
34
+ }
35
+ }
36
+ if (!viewHolder) {
37
+ // this is where we identify the end of the drag and call the end event
38
+ var owner = this.owner && this.owner.get();
39
+ if (this.endPosition === -1) {
40
+ this.endPosition = this.startPosition;
41
+ }
42
+ if (owner) {
43
+ var item = owner.getItemAtIndex(this.startPosition);
44
+ owner._callItemReorderedEvent(this.startPosition, this.endPosition, item);
45
+ }
46
+ this.startPosition = -1;
47
+ this.endPosition = -1;
48
+ owner.isDragging = false;
49
+ }
50
+ };
51
+ SimpleCallback.prototype.onSwiped = function (viewHolder, direction) { };
52
+ SimpleCallback.prototype.isItemViewSwipeEnabled = function () {
53
+ // disabled for now
54
+ return false;
55
+ };
56
+ SimpleCallback.prototype.isLongPressDragEnabled = function () {
57
+ // we use our custom longpress gesture handler
58
+ return false;
59
+ };
60
+ return SimpleCallback;
61
+ }(androidx.recyclerview.widget.ItemTouchHelper.SimpleCallback));
62
+ var LongPressGestureListenerImpl = /** @class */ (function (_super) {
63
+ __extends(LongPressGestureListenerImpl, _super);
64
+ function LongPressGestureListenerImpl(_owner) {
65
+ var _this = _super.call(this) || this;
66
+ _this._owner = _owner;
67
+ return global.__native(_this);
68
+ }
69
+ LongPressGestureListenerImpl.prototype.onLongPress = function (motionEvent) {
70
+ var owner = this._owner && this._owner.get();
71
+ if (owner) {
72
+ owner.onReorderLongPress(motionEvent);
73
+ }
74
+ };
75
+ return LongPressGestureListenerImpl;
76
+ }(android.view.GestureDetector.SimpleOnGestureListener));
77
+ let LayoutParams;
78
+ const extraLayoutSpaceProperty = new Property({
79
+ name: 'extraLayoutSpace'
80
+ });
81
+ const itemViewCacheSizeProperty = new Property({
82
+ name: 'itemViewCacheSize'
83
+ });
84
+ const nestedScrollingEnabledProperty = new Property({
85
+ name: 'nestedScrollingEnabled',
86
+ defaultValue: true,
87
+ valueConverter: booleanConverter
88
+ });
89
+ export class CollectionView extends CollectionViewBase {
90
+ constructor() {
91
+ super(...arguments);
92
+ this.templateTypeNumberString = new Map();
93
+ this.templateStringTypeNumber = new Map();
94
+ this._currentNativeItemType = 0;
95
+ this.currentSpanCount = 1;
96
+ // used to store viewHolder and thus their corresponding Views
97
+ // used to "destroy" cells when possible
98
+ this._viewHolders = new Set();
99
+ this._scrollOrLoadMoreChangeCount = 0;
100
+ this.scrolling = false;
101
+ this.needsScrollStartEvent = false;
102
+ this.animateItemUpdate = false;
103
+ this.defaultPoolSize = 10;
104
+ this.desiredPoolSize = new Map();
105
+ this.isDragging = false;
106
+ this._layedOut = false;
107
+ }
108
+ createNativeView() {
109
+ // storing the class in a property for reuse in the future cause a materializing which is pretty slow!
110
+ if (!CollectionViewRecyclerView) {
111
+ CollectionViewRecyclerView = com.nativescript.collectionview.RecyclerView;
112
+ }
113
+ const recyclerView = CollectionViewRecyclerView.createRecyclerView(this._context);
114
+ // const expMgr = new RecyclerViewExpandableItemManager(null);
115
+ // adapter.setDisplayHeadersAtStartUp(true).setStickyHeaders(true); //Make headers sticky
116
+ // Endless scroll with 1 item threshold
117
+ // .setLoadingMoreAtStartUp(true)
118
+ // .setEndlessScrollListener(this, new ProgressItem())
119
+ // .setEndlessScrollThreshold(1); //Default=1
120
+ // const fastScroller = new com.l4digital.fastscroll.FastScroller(this._context);
121
+ // fastScroller.setSectionIndexer(adapter);
122
+ // fastScroller.attachRecyclerView(recyclerView);
123
+ return recyclerView;
124
+ }
125
+ initNativeView() {
126
+ this.setOnLayoutChangeListener();
127
+ super.initNativeView();
128
+ this.recycledViewPool = new com.nativescript.collectionview.RecycledViewPool();
129
+ this.recycledViewPoolDisposeListener = new com.nativescript.collectionview.RecycledViewPool.ViewPoolListener({
130
+ onViewHolderDisposed: (holder) => {
131
+ if (Trace.isEnabled()) {
132
+ CLog(CLogTypes.log, 'onViewHolderDisposed', holder);
133
+ }
134
+ if (this._viewHolders) {
135
+ this._viewHolders.delete(holder);
136
+ }
137
+ const isNonSync = holder['defaultItemView'] === true;
138
+ const view = isNonSync ? holder.view.content : holder.view;
139
+ const args = {
140
+ eventName: CollectionViewBase.itemDisposingEvent,
141
+ index: holder.getAdapterPosition(),
142
+ object: this,
143
+ view,
144
+ android: holder
145
+ };
146
+ this.notify(args);
147
+ if (view && view.isLoaded) {
148
+ view.callUnloaded();
149
+ }
150
+ view._isAddedToNativeVisualTree = false;
151
+ //@ts-ignore
152
+ view.parent = null;
153
+ view._tearDownUI();
154
+ }
155
+ });
156
+ this.recycledViewPool.mListener = this.recycledViewPoolDisposeListener;
157
+ const recyclerListener = (this.recyclerListener = new androidx.recyclerview.widget.RecyclerView.RecyclerListener({
158
+ onViewRecycled: (holder) => {
159
+ if (Trace.isEnabled()) {
160
+ CLog(CLogTypes.log, 'onViewRecycled', holder);
161
+ }
162
+ const isNonSync = holder['defaultItemView'] === true;
163
+ const view = isNonSync ? holder.view.content : holder.view;
164
+ const args = {
165
+ eventName: CollectionViewBase.itemRecyclingEvent,
166
+ index: holder.getAdapterPosition(),
167
+ object: this,
168
+ view,
169
+ android: holder
170
+ };
171
+ this.notify(args);
172
+ }
173
+ }));
174
+ this.android.setRecyclerListener(recyclerListener);
175
+ this.android.setRecycledViewPool(this.recycledViewPool);
176
+ // nativeView.owner = new WeakRef(this);
177
+ // nativeView.sizeChangedListener = new com.nativescript.collectionview.SizeChangedListener({
178
+ // onSizeChanged: (w, h, oldW, oldH) => this.onSizeChanged(w, h),
179
+ // });
180
+ // const orientation = this._getLayoutManagarOrientation();
181
+ // initGridLayoutManager();
182
+ if (CollectionViewBase.layoutStyles[this.layoutStyle]) {
183
+ this.android.layoutManager = CollectionViewBase.layoutStyles[this.layoutStyle].createLayout(this);
184
+ }
185
+ else {
186
+ this.android.layoutManager = new com.nativescript.collectionview.PreCachingGridLayoutManager(this._context, 1);
187
+ // layoutManager = new PreCachingGridLayoutManager(this._context, 1);
188
+ // (layoutManager as any).owner = new WeakRef(this);
189
+ }
190
+ // this.spanSize
191
+ this.android.setLayoutManager(this.android.layoutManager);
192
+ this.android.sizeChangedListener = new com.nativescript.collectionview.SizeChangedListener({
193
+ onSizeChanged() { },
194
+ onMeasure: () => this.updateInnerSize()
195
+ });
196
+ this.spanSize = this._getSpanSize;
197
+ // const animator = new com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator();
198
+ // // Change animations are enabled by default since support-v7-recyclerview v22.
199
+ // // Need to disable them when using animation indicator.
200
+ // animator.setSupportsChangeAnimations(false);
201
+ // this.android.setItemAnimator(animator);
202
+ this.refresh();
203
+ }
204
+ disposeNativeView() {
205
+ // clear the cache
206
+ // this.eachChildView((view) => {
207
+ // view.parent._removeView(view);
208
+ // return true;
209
+ // });
210
+ // this._realizedItems.clear();
211
+ this.android.setRecyclerListener(null);
212
+ this.android.setRecycledViewPool(null);
213
+ this.recycledViewPoolDisposeListener = null;
214
+ this.recycledViewPool = null;
215
+ if (this.android.scrollListener) {
216
+ this.android.removeOnScrollListener(this.android.scrollListener);
217
+ this.android.scrollListener = null;
218
+ this._nScrollListener = null;
219
+ }
220
+ this.android.sizeChangedListener = null;
221
+ this.android.layoutManager = null;
222
+ this._listViewAdapter = null;
223
+ this._itemTouchHelper = null;
224
+ this._simpleItemTouchCallback = null;
225
+ this.disposeViewHolderViews();
226
+ this._hlayoutParams = null;
227
+ this._vlayoutParams = null;
228
+ this.clearTemplateTypes();
229
+ super.disposeNativeView();
230
+ }
231
+ onLoaded() {
232
+ super.onLoaded();
233
+ this.attachScrollListener();
234
+ this.refresh();
235
+ }
236
+ getViewForItemAtIndex(index) {
237
+ return this.enumerateViewHolders((v) => (v.getAdapterPosition() === index ? v.view : undefined));
238
+ }
239
+ //@ts-ignore
240
+ set spanSize(inter) {
241
+ if (!(typeof inter === 'function')) {
242
+ return;
243
+ }
244
+ this._getSpanSize = inter;
245
+ const layoutManager = this.layoutManager;
246
+ if (layoutManager && layoutManager['setSpanSizeLookup']) {
247
+ if (inter) {
248
+ layoutManager['setSpanSizeLookup'](new com.nativescript.collectionview.SpanSizeLookup(new com.nativescript.collectionview.SpanSizeLookup.Interface({
249
+ getSpanSize: (position) => {
250
+ const dataItem = this.getItemAtIndex(position);
251
+ return Math.min(inter(dataItem, position), this.currentSpanCount);
252
+ }
253
+ })));
254
+ }
255
+ else {
256
+ layoutManager['setSpanSizeLookup'](null);
257
+ }
258
+ }
259
+ }
260
+ get spanSize() {
261
+ return this._getSpanSize;
262
+ }
263
+ attachScrollListener() {
264
+ if (this._scrollOrLoadMoreChangeCount > 0 && this.isLoaded) {
265
+ if (!this.android) {
266
+ return;
267
+ }
268
+ if (!this.android.scrollListener) {
269
+ this._nScrollListener = new com.nativescript.collectionview.OnScrollListener.Listener({
270
+ onScrollStateChanged: this.onScrollStateChanged.bind(this),
271
+ onScrolled: this.onScrolled.bind(this)
272
+ });
273
+ this.android.scrollListener = new com.nativescript.collectionview.OnScrollListener(this._nScrollListener);
274
+ this.android.addOnScrollListener(this.android.scrollListener);
275
+ }
276
+ }
277
+ }
278
+ detachScrollListener() {
279
+ if (this._scrollOrLoadMoreChangeCount === 0 && this.isLoaded) {
280
+ if (!this.android) {
281
+ return;
282
+ }
283
+ if (this.android.scrollListener) {
284
+ this.android.removeOnScrollListener(this.android.scrollListener);
285
+ this.android.scrollListener = null;
286
+ this._nScrollListener = null;
287
+ }
288
+ }
289
+ }
290
+ computeScrollEventData(view, eventName, dx, dy) {
291
+ const horizontal = this.isHorizontal();
292
+ const offset = horizontal ? view.computeHorizontalScrollOffset() : view.computeVerticalScrollOffset();
293
+ const range = horizontal ? view.computeHorizontalScrollRange() : view.computeVerticalScrollRange();
294
+ const extent = horizontal ? view.computeHorizontalScrollExtent() : view.computeVerticalScrollExtent();
295
+ return {
296
+ object: this,
297
+ eventName,
298
+ scrollOffset: offset / Utils.layout.getDisplayDensity(),
299
+ scrollOffsetPercentage: offset / (range - extent),
300
+ dx,
301
+ dy
302
+ };
303
+ }
304
+ onScrolled(view, dx, dy) {
305
+ if (!this || !this.scrolling) {
306
+ return;
307
+ }
308
+ if (this.needsScrollStartEvent) {
309
+ this.needsScrollStartEvent = false;
310
+ if (this.hasListeners(CollectionViewBase.scrollStartEvent)) {
311
+ this.notify(this.computeScrollEventData(view, CollectionViewBase.scrollStartEvent, dx, dy));
312
+ }
313
+ }
314
+ if (this.hasListeners(CollectionViewBase.scrollEvent)) {
315
+ this.notify(this.computeScrollEventData(view, CollectionViewBase.scrollEvent, dx, dy));
316
+ }
317
+ if (this.hasListeners(CollectionViewBase.loadMoreItemsEvent) && this.items) {
318
+ const layoutManager = view.getLayoutManager();
319
+ if (layoutManager['findLastCompletelyVisibleItemPosition']) {
320
+ const lastVisibleItemPos = layoutManager['findLastCompletelyVisibleItemPosition']();
321
+ const loadMoreItemIndex = this.items.length - this.loadMoreThreshold;
322
+ if (lastVisibleItemPos === loadMoreItemIndex) {
323
+ this.notify({
324
+ eventName: CollectionViewBase.loadMoreItemsEvent,
325
+ object: this
326
+ });
327
+ }
328
+ }
329
+ else if (layoutManager['findLastCompletelyVisibleItemPositions'] && layoutManager['getSpanCount']) {
330
+ let positions = Array.create('int', layoutManager['getSpanCount']());
331
+ positions = layoutManager['findLastCompletelyVisibleItemPositions'](positions);
332
+ let lastVisibleItemPos = 0;
333
+ for (let i = 0; i < positions.length; i++) {
334
+ if (positions[i] > lastVisibleItemPos) {
335
+ lastVisibleItemPos = positions[i];
336
+ }
337
+ }
338
+ const loadMoreItemIndex = this.items.length - this.loadMoreThreshold;
339
+ if (lastVisibleItemPos >= loadMoreItemIndex) {
340
+ this.notify({
341
+ eventName: CollectionViewBase.loadMoreItemsEvent,
342
+ object: this
343
+ });
344
+ }
345
+ }
346
+ }
347
+ }
348
+ onScrollStateChanged(view, newState) {
349
+ if (this.scrolling && newState === 0) {
350
+ // SCROLL_STATE_IDLE
351
+ this.scrolling = false;
352
+ if (this.hasListeners(CollectionViewBase.scrollEndEvent)) {
353
+ this.notify(this.computeScrollEventData(view, CollectionViewBase.scrollEndEvent));
354
+ }
355
+ }
356
+ else if (!this.scrolling && newState === 1) {
357
+ //SCROLL_STATE_DRAGGING
358
+ this.needsScrollStartEvent = true;
359
+ this.scrolling = true;
360
+ }
361
+ }
362
+ addEventListener(arg, callback, thisArg) {
363
+ super.addEventListener(arg, callback, thisArg);
364
+ if (arg === CollectionViewBase.scrollEvent || arg === CollectionViewBase.scrollStartEvent || arg === CollectionViewBase.scrollEndEvent || arg === CollectionViewBase.loadMoreItemsEvent) {
365
+ this._scrollOrLoadMoreChangeCount++;
366
+ this.attachScrollListener();
367
+ }
368
+ }
369
+ removeEventListener(arg, callback, thisArg) {
370
+ super.removeEventListener(arg, callback, thisArg);
371
+ if (arg === CollectionViewBase.scrollEvent || arg === CollectionViewBase.scrollStartEvent || arg === CollectionViewBase.scrollEndEvent || arg === CollectionViewBase.loadMoreItemsEvent) {
372
+ this._scrollOrLoadMoreChangeCount--;
373
+ this.detachScrollListener();
374
+ }
375
+ }
376
+ //@ts-ignore
377
+ get android() {
378
+ return this.nativeViewProtected;
379
+ }
380
+ get layoutManager() {
381
+ return this.android && this.android.layoutManager;
382
+ }
383
+ _getViewLayoutParams() {
384
+ if (this.isHorizontal()) {
385
+ if (!this._hlayoutParams) {
386
+ LayoutParams = LayoutParams || android.view.ViewGroup.LayoutParams;
387
+ this._hlayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
388
+ }
389
+ return this._hlayoutParams;
390
+ }
391
+ else {
392
+ if (!this._vlayoutParams) {
393
+ LayoutParams = LayoutParams || android.view.ViewGroup.LayoutParams;
394
+ this._vlayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
395
+ }
396
+ return this._vlayoutParams;
397
+ }
398
+ }
399
+ setNativePoolSize(key, nativeIndex) {
400
+ if (this.desiredPoolSize.has(key)) {
401
+ this.android.getRecycledViewPool().setMaxRecycledViews(nativeIndex, this.desiredPoolSize.get(key));
402
+ }
403
+ else {
404
+ if (this.defaultPoolSize >= 0) {
405
+ this.android.getRecycledViewPool().setMaxRecycledViews(nativeIndex, this.defaultPoolSize);
406
+ }
407
+ }
408
+ }
409
+ setPoolSizes() {
410
+ if (!this.android || !this.templateTypeNumberString) {
411
+ return;
412
+ }
413
+ this.desiredPoolSize.forEach((v, k) => {
414
+ if (this.templateTypeNumberString.has(k)) {
415
+ this.android.getRecycledViewPool().setMaxRecycledViews(this.templateTypeNumberString.get(k), v);
416
+ }
417
+ });
418
+ }
419
+ setPoolSize(key, size) {
420
+ this.desiredPoolSize.set(key, size);
421
+ this.setPoolSizes();
422
+ }
423
+ [paddingTopProperty.getDefault]() {
424
+ return { value: this._defaultPaddingTop, unit: 'px' };
425
+ }
426
+ [paddingTopProperty.setNative](value) {
427
+ this._setPadding({ top: this.effectivePaddingTop });
428
+ }
429
+ [paddingRightProperty.getDefault]() {
430
+ return { value: this._defaultPaddingRight, unit: 'px' };
431
+ }
432
+ [paddingRightProperty.setNative](value) {
433
+ this._setPadding({ right: this.effectivePaddingRight });
434
+ }
435
+ [paddingBottomProperty.getDefault]() {
436
+ return { value: this._defaultPaddingBottom, unit: 'px' };
437
+ }
438
+ [paddingBottomProperty.setNative](value) {
439
+ this._setPadding({ bottom: this.effectivePaddingBottom });
440
+ }
441
+ [paddingLeftProperty.getDefault]() {
442
+ return { value: this._defaultPaddingLeft, unit: 'px' };
443
+ }
444
+ [paddingLeftProperty.setNative](value) {
445
+ this._setPadding({ left: this.effectivePaddingLeft });
446
+ }
447
+ [orientationProperty.getDefault]() {
448
+ return 'vertical';
449
+ }
450
+ [orientationProperty.setNative](value) {
451
+ const layoutManager = this.layoutManager;
452
+ if (!layoutManager || !layoutManager['setOrientation']) {
453
+ return;
454
+ }
455
+ if (this.isHorizontal()) {
456
+ layoutManager['setOrientation'](0);
457
+ }
458
+ else {
459
+ layoutManager['setOrientation'](1);
460
+ }
461
+ this.updateScrollBarVisibility(this.scrollBarIndicatorVisible);
462
+ }
463
+ [isScrollEnabledProperty.setNative](value) {
464
+ const layoutManager = this.layoutManager;
465
+ if (layoutManager && layoutManager.setScrollEnabled) {
466
+ layoutManager.setScrollEnabled(value);
467
+ }
468
+ }
469
+ [reverseLayoutProperty.setNative](value) {
470
+ const layoutManager = this.layoutManager;
471
+ if (layoutManager && layoutManager.setReverseLayout) {
472
+ layoutManager.setReverseLayout(value);
473
+ // layoutManager['setStackFromEnd'](value);
474
+ }
475
+ }
476
+ [nestedScrollingEnabledProperty.setNative](value) {
477
+ if (this.android) {
478
+ this.android.setNestedScrollingEnabled(value);
479
+ }
480
+ }
481
+ [extraLayoutSpaceProperty.setNative](value) {
482
+ const layoutManager = this.layoutManager;
483
+ if (layoutManager && layoutManager['setExtraLayoutSpace']) {
484
+ layoutManager['setExtraLayoutSpace'](value);
485
+ }
486
+ }
487
+ [itemViewCacheSizeProperty.setNative](value) {
488
+ if (this.android) {
489
+ this.android.setItemViewCacheSize(value);
490
+ }
491
+ }
492
+ [scrollBarIndicatorVisibleProperty.getDefault]() {
493
+ return true;
494
+ }
495
+ [scrollBarIndicatorVisibleProperty.setNative](value) {
496
+ this.updateScrollBarVisibility(value);
497
+ }
498
+ updateScrollBarVisibility(value) {
499
+ if (!this.android) {
500
+ return;
501
+ }
502
+ if (this.orientation === 'horizontal') {
503
+ this.android.setHorizontalScrollBarEnabled(value);
504
+ }
505
+ else {
506
+ this.android.setVerticalScrollBarEnabled(value);
507
+ }
508
+ }
509
+ enumerateViewHolders(cb) {
510
+ let result, v;
511
+ for (let it = this._viewHolders.values(), cellItemView = null; (cellItemView = it.next().value);) {
512
+ result = cb(cellItemView);
513
+ if (result) {
514
+ return result;
515
+ }
516
+ }
517
+ return result;
518
+ }
519
+ startDragging(index) {
520
+ if (this.reorderEnabled && this._itemTouchHelper) {
521
+ // let viewHolder: CollectionViewCellHolder;
522
+ const viewHolder = this.enumerateViewHolders((v) => (v.getAdapterPosition() === index ? v : undefined));
523
+ if (viewHolder) {
524
+ this.startViewHolderDragging(index, viewHolder);
525
+ }
526
+ }
527
+ }
528
+ startViewHolderDragging(index, viewHolder) {
529
+ // isDragging is to prevent longPress from triggering and starting a new drag
530
+ // when triggered manually
531
+ if (!this.isDragging && this.shouldMoveItemAtIndex(index)) {
532
+ this.isDragging = true;
533
+ this._itemTouchHelper.startDrag(viewHolder);
534
+ }
535
+ }
536
+ onReorderLongPress(motionEvent) {
537
+ if (!this.android) {
538
+ return;
539
+ }
540
+ const view = this.android.findChildViewUnder(motionEvent.getX(), motionEvent.getY());
541
+ const viewHolder = view != null ? this.android.getChildViewHolder(view) : null;
542
+ if (viewHolder) {
543
+ this.startViewHolderDragging(viewHolder.getAdapterPosition(), viewHolder);
544
+ }
545
+ }
546
+ _reorderItemInSource(oldPosition, newPosition) {
547
+ const adapter = this._listViewAdapter;
548
+ // 3. Tell adapter to render the model update.
549
+ adapter.notifyItemMoved(oldPosition, newPosition);
550
+ // on android _reorderItemInSource is call on every "move" and needs to update the adapter/items
551
+ // we will call events only at then end
552
+ super._reorderItemInSource(oldPosition, newPosition, false);
553
+ }
554
+ [reorderLongPressEnabledProperty.setNative](value) {
555
+ if (!this.android) {
556
+ return;
557
+ }
558
+ if (value) {
559
+ if (!this._longPressGesture) {
560
+ this._longPressGesture = new androidx.core.view.GestureDetectorCompat(this._context, new LongPressGestureListenerImpl(new WeakRef(this)));
561
+ this._itemTouchListerner = new androidx.recyclerview.widget.RecyclerView.OnItemTouchListener({
562
+ onInterceptTouchEvent: (view, event) => {
563
+ if (this.reorderEnabled && this._longPressGesture) {
564
+ this._longPressGesture.onTouchEvent(event);
565
+ }
566
+ return false;
567
+ },
568
+ onTouchEvent: (param0, param1) => { },
569
+ onRequestDisallowInterceptTouchEvent: (disallowIntercept) => { }
570
+ });
571
+ }
572
+ this.android.addOnItemTouchListener(this._itemTouchListerner);
573
+ }
574
+ else {
575
+ if (this._itemTouchListerner) {
576
+ this.android.removeOnItemTouchListener(this._itemTouchListerner);
577
+ }
578
+ }
579
+ }
580
+ [reorderingEnabledProperty.setNative](value) {
581
+ if (!this.android) {
582
+ return;
583
+ }
584
+ if (value) {
585
+ if (!this._simpleItemTouchCallback) {
586
+ const ItemTouchHelper = androidx.recyclerview.widget.ItemTouchHelper;
587
+ this._simpleItemTouchCallback = new SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.START | ItemTouchHelper.END, 0);
588
+ this._simpleItemTouchCallback.owner = new WeakRef(this);
589
+ this._itemTouchHelper = new androidx.recyclerview.widget.ItemTouchHelper(this._simpleItemTouchCallback);
590
+ this._itemTouchHelper.attachToRecyclerView(this.android);
591
+ }
592
+ }
593
+ }
594
+ onItemViewLoaderChanged() {
595
+ if (this.itemViewLoader) {
596
+ this.refresh();
597
+ }
598
+ }
599
+ onItemTemplateSelectorChanged(oldValue, newValue) {
600
+ super.onItemTemplateSelectorChanged(oldValue, newValue);
601
+ this.clearTemplateTypes();
602
+ this.refresh();
603
+ }
604
+ onItemTemplateChanged(oldValue, newValue) {
605
+ super.onItemTemplateChanged(oldValue, newValue); // TODO: update current template with the new one
606
+ this.refresh();
607
+ }
608
+ onItemTemplatesChanged(oldValue, newValue) {
609
+ super.onItemTemplatesChanged(oldValue, newValue); // TODO: update current template with the new one
610
+ this.refresh();
611
+ }
612
+ setOnLayoutChangeListener() {
613
+ if (this.android) {
614
+ const owner = this;
615
+ this.layoutChangeListenerIsSet = true;
616
+ this.layoutChangeListener =
617
+ this.layoutChangeListener ||
618
+ new android.view.View.OnLayoutChangeListener({
619
+ onLayoutChange(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) {
620
+ if (left !== oldLeft || top !== oldTop || right !== oldRight || bottom !== oldBottom) {
621
+ owner.onLayout(left, top, right, bottom);
622
+ if (owner.hasListeners(View.layoutChangedEvent)) {
623
+ owner._raiseLayoutChangedEvent();
624
+ }
625
+ }
626
+ }
627
+ });
628
+ this.android.addOnLayoutChangeListener(this.layoutChangeListener);
629
+ }
630
+ }
631
+ _updateSpanCount() {
632
+ const layoutManager = this.layoutManager;
633
+ if (layoutManager && layoutManager['setSpanCount']) {
634
+ const newValue = (this.currentSpanCount = this.computeSpanCount());
635
+ if (newValue !== layoutManager['getSpanCount']()) {
636
+ layoutManager['setSpanCount'](newValue);
637
+ layoutManager.requestLayout();
638
+ }
639
+ }
640
+ }
641
+ updateInnerSize() {
642
+ super.updateInnerSize();
643
+ this._updateSpanCount();
644
+ }
645
+ _onColWidthPropertyChanged(oldValue, newValue) {
646
+ this._updateSpanCount();
647
+ super._onColWidthPropertyChanged(oldValue, newValue);
648
+ }
649
+ _onRowHeightPropertyChanged(oldValue, newValue) {
650
+ this._updateSpanCount();
651
+ super._onRowHeightPropertyChanged(oldValue, newValue);
652
+ }
653
+ onLayout(left, top, right, bottom) {
654
+ this._layedOut = true;
655
+ super.onLayout(left, top, right, bottom);
656
+ const p = CollectionViewBase.plugins[this.layoutStyle];
657
+ if (p && p.onLayout) {
658
+ p.onLayout(this, left, top, right, bottom);
659
+ }
660
+ this.plugins.forEach((k) => {
661
+ const p = CollectionViewBase.plugins[k];
662
+ p.onLayout && p.onLayout(this, left, top, right, bottom);
663
+ });
664
+ // there is no need to call refresh if it was triggered before with same size.
665
+ // this refresh is just to handle size change
666
+ const layoutKey = this._innerWidth + '_' + this._innerHeight;
667
+ if (this._isDataDirty || (this._lastLayoutKey && this._lastLayoutKey !== layoutKey)) {
668
+ setTimeout(() => this.refresh(), 0);
669
+ }
670
+ this._lastLayoutKey = layoutKey;
671
+ }
672
+ onSourceCollectionChanged(event) {
673
+ if (!this._listViewAdapter || this._dataUpdatesSuspended) {
674
+ return;
675
+ }
676
+ if (Trace.isEnabled()) {
677
+ CLog(CLogTypes.log, 'onItemsChanged', event.action, event.index, event.addedCount, event.removed, event.removed && event.removed.length);
678
+ }
679
+ switch (event.action) {
680
+ case ChangeType.Delete: {
681
+ this._listViewAdapter.notifyItemRangeRemoved(event.index, event.removed.length);
682
+ return;
683
+ }
684
+ case ChangeType.Add: {
685
+ if (event.addedCount > 0) {
686
+ this._listViewAdapter.notifyItemRangeInserted(event.index, event.addedCount);
687
+ }
688
+ // Reload the items to avoid duplicate Load on Demand indicators:
689
+ return;
690
+ }
691
+ case ChangeType.Update: {
692
+ if (event.addedCount > 0) {
693
+ this._listViewAdapter.notifyItemRangeChanged(event.index, event.addedCount);
694
+ }
695
+ return;
696
+ }
697
+ case ChangeType.Splice: {
698
+ const added = event.addedCount;
699
+ const removed = (event.removed && event.removed.length) || 0;
700
+ if (added > 0 && added === removed) {
701
+ // notifyItemRangeChanged wont create a fade effect
702
+ if (!this.animateItemUpdate) {
703
+ this._listViewAdapter.notifyItemRangeChanged(event.index, added);
704
+ }
705
+ else {
706
+ this._listViewAdapter.notifyItemRangeRemoved(event.index, added);
707
+ this._listViewAdapter.notifyItemRangeInserted(event.index, added);
708
+ }
709
+ }
710
+ else {
711
+ if (!this.animateItemUpdate) {
712
+ if (added > removed) {
713
+ if (removed > 0) {
714
+ this._listViewAdapter.notifyItemRangeChanged(event.index, removed);
715
+ }
716
+ this._listViewAdapter.notifyItemRangeInserted(event.index + removed, added - removed);
717
+ }
718
+ else {
719
+ if (added > 0) {
720
+ this._listViewAdapter.notifyItemRangeChanged(event.index, added);
721
+ }
722
+ this._listViewAdapter.notifyItemRangeRemoved(event.index + added, removed - added);
723
+ }
724
+ }
725
+ else {
726
+ if (event.removed && event.removed.length > 0) {
727
+ this._listViewAdapter.notifyItemRangeRemoved(event.index, event.removed.length);
728
+ }
729
+ if (event.addedCount > 0) {
730
+ this._listViewAdapter.notifyItemRangeInserted(event.index, event.addedCount);
731
+ }
732
+ }
733
+ }
734
+ return;
735
+ }
736
+ }
737
+ this._listViewAdapter.notifyDataSetChanged();
738
+ }
739
+ eachChild(callback) {
740
+ // used for css updates (like theme change)
741
+ this.enumerateViewHolders((v) => {
742
+ const view = v.view;
743
+ if (view) {
744
+ if (view.parent instanceof CollectionView) {
745
+ callback(view);
746
+ }
747
+ else {
748
+ // in some cases (like item is unloaded from another place (like angular) view.parent becomes undefined)
749
+ if (view.parent) {
750
+ callback(view.parent);
751
+ }
752
+ }
753
+ }
754
+ });
755
+ }
756
+ refreshVisibleItems() {
757
+ if (!this.android) {
758
+ return;
759
+ }
760
+ const ids = Array.from(this._viewHolders)
761
+ .map((s) => s['position'])
762
+ .filter((s) => s !== null)
763
+ .sort((a, b) => a - b);
764
+ this._listViewAdapter.notifyItemRangeChanged(ids[0], ids[ids.length - 1] - ids[0] + 1);
765
+ }
766
+ isItemAtIndexVisible(index) {
767
+ if (!this.android) {
768
+ return false;
769
+ }
770
+ const layoutManager = this.layoutManager;
771
+ if (layoutManager['findFirstVisibleItemPosition']) {
772
+ const first = layoutManager.findFirstVisibleItemPosition();
773
+ const last = layoutManager.findLastVisibleItemPosition();
774
+ return index >= first && index <= last;
775
+ }
776
+ return false;
777
+ }
778
+ refresh() {
779
+ if (!this.android) {
780
+ return;
781
+ }
782
+ if (!this.isLoaded) {
783
+ this._isDataDirty = true;
784
+ return;
785
+ }
786
+ this._isDataDirty = false;
787
+ this._lastLayoutKey = this._innerWidth + '_' + this._innerHeight;
788
+ let adapter = this._listViewAdapter;
789
+ if (!adapter) {
790
+ adapter = this._listViewAdapter = this.createComposedAdapter();
791
+ adapter.setHasStableIds(!!this._itemIdGenerator);
792
+ this.android.setAdapter(adapter);
793
+ }
794
+ else if (!this.android.getAdapter()) {
795
+ this.android.setAdapter(adapter);
796
+ }
797
+ this._updateSpanCount();
798
+ adapter.notifyDataSetChanged();
799
+ const args = {
800
+ eventName: CollectionViewBase.dataPopulatedEvent,
801
+ object: this
802
+ };
803
+ this.notify(args);
804
+ }
805
+ //@ts-ignore
806
+ get scrollOffset() {
807
+ if (!this.android) {
808
+ return 0;
809
+ }
810
+ return (this.isHorizontal() ? this.android.computeHorizontalScrollOffset() : this.android.computeVerticalScrollOffset()) / Utils.layout.getDisplayDensity();
811
+ }
812
+ get verticalOffsetX() {
813
+ if (!this.android) {
814
+ return 0;
815
+ }
816
+ return this.android.computeHorizontalScrollOffset() / Utils.layout.getDisplayDensity();
817
+ }
818
+ get verticalOffsetY() {
819
+ if (!this.android) {
820
+ return 0;
821
+ }
822
+ return this.android.computeVerticalScrollOffset() / Utils.layout.getDisplayDensity();
823
+ }
824
+ scrollToIndex(index, animated = true) {
825
+ if (!this.android) {
826
+ return;
827
+ }
828
+ if (animated) {
829
+ this.android.smoothScrollToPosition(index);
830
+ }
831
+ else {
832
+ this.android.scrollToPosition(index);
833
+ }
834
+ }
835
+ _setPadding(newPadding) {
836
+ if (this.android) {
837
+ const padding = {
838
+ top: this.android.getPaddingTop(),
839
+ right: this.android.getPaddingRight(),
840
+ bottom: this.android.getPaddingBottom(),
841
+ left: this.android.getPaddingLeft()
842
+ };
843
+ // tslint:disable-next-line:prefer-object-spread
844
+ const newValue = Object.assign(padding, newPadding);
845
+ this.android.setClipToPadding(false);
846
+ this.android.setPadding(newValue.left, newValue.top, newValue.right, newValue.bottom);
847
+ this.updateInnerSize();
848
+ }
849
+ }
850
+ createComposedAdapter() {
851
+ const adapter = new com.nativescript.collectionview.Adapter();
852
+ adapter.adapterInterface = new com.nativescript.collectionview.AdapterInterface({
853
+ getItemId: this.getItemId.bind(this),
854
+ getItemViewType: this.getItemViewType.bind(this),
855
+ getItemCount: this.getItemCount.bind(this),
856
+ onCreateViewHolder: this.onCreateViewHolder.bind(this),
857
+ onBindViewHolder: this.onBindViewHolder.bind(this),
858
+ onViewRecycled: this.onViewRecycled.bind(this)
859
+ });
860
+ // const composedAdapter = new com.h6ah4i.android.widget.advrecyclerview.composedadapter.ComposedAdapter();
861
+ // composedAdapter.addAdapter(new CollectionViewAdapter(new WeakRef(this)));
862
+ return adapter;
863
+ }
864
+ getItemCount() {
865
+ return this.items ? this.items.length : 0;
866
+ }
867
+ getItem(i) {
868
+ if (this.items && i < this.items.length) {
869
+ return this.getItemAtIndex(i);
870
+ }
871
+ return null;
872
+ }
873
+ getItemId(i) {
874
+ let id = -1;
875
+ if (this._itemIdGenerator && this.items) {
876
+ const item = this.getItemAtIndex(i);
877
+ id = this._itemIdGenerator(item, i, this.items);
878
+ }
879
+ return long(id);
880
+ }
881
+ onItemIdGeneratorChanged(oldValue, newValue) {
882
+ super.onItemIdGeneratorChanged(oldValue, newValue);
883
+ if (this._listViewAdapter) {
884
+ this._listViewAdapter.setHasStableIds(!!newValue);
885
+ }
886
+ }
887
+ clearTemplateTypes() {
888
+ this._currentNativeItemType = 0;
889
+ this.templateTypeNumberString.clear();
890
+ this.templateStringTypeNumber.clear();
891
+ }
892
+ getItemViewType(position) {
893
+ let selectorType = 'default';
894
+ if (this._itemTemplateSelector) {
895
+ const selector = this._itemTemplateSelector;
896
+ const dataItem = this.getItemAtIndex(position);
897
+ if (dataItem) {
898
+ selectorType = selector(dataItem, position, this.items);
899
+ }
900
+ }
901
+ return this.templateKeyToNativeItem(selectorType);
902
+ // if (!this.templateTypeNumberString.has(selectorType)) {
903
+ // resultType = this._currentNativeItemType;
904
+ // this.templateTypeNumberString.set(selectorType, resultType);
905
+ // this.templateStringTypeNumber.set(resultType, selectorType);
906
+ // this._currentNativeItemType++;
907
+ // } else {
908
+ // resultType = this.templateTypeNumberString.get(selectorType);
909
+ // }
910
+ // return resultType;
911
+ }
912
+ templateKeyToNativeItem(key) {
913
+ if (!this.templateTypeNumberString) {
914
+ this.templateTypeNumberString = new Map();
915
+ this._currentNativeItemType = 0;
916
+ this._itemTemplatesInternal.forEach((v, i) => {
917
+ this.templateTypeNumberString.set(v.key, this._currentNativeItemType);
918
+ this.templateStringTypeNumber.set(this._currentNativeItemType, v.key);
919
+ this.setNativePoolSize(v.key, this._currentNativeItemType);
920
+ this._currentNativeItemType++;
921
+ });
922
+ this._currentNativeItemType = Math.max(this._itemTemplatesInternal.size, 100);
923
+ // templates will be numbered 0,1,2,3... for named templates
924
+ // default/unnamed templates will be numbered 100, 101, 102, 103...
925
+ }
926
+ if (!this.templateTypeNumberString.has(key)) {
927
+ this.templateTypeNumberString.set(key, this._currentNativeItemType);
928
+ this.templateStringTypeNumber.set(this._currentNativeItemType, key);
929
+ this.setNativePoolSize(key, this._currentNativeItemType);
930
+ this._currentNativeItemType++;
931
+ }
932
+ return this.templateTypeNumberString.get(key);
933
+ }
934
+ nativeItemToTemplateKey(item) {
935
+ let result;
936
+ this.templateTypeNumberString?.forEach((value, key, map) => {
937
+ if (value === item) {
938
+ result = key;
939
+ }
940
+ }, this);
941
+ return result;
942
+ }
943
+ disposeViewHolderViews() {
944
+ this.enumerateViewHolders((v) => {
945
+ const view = v.view;
946
+ if (view && view.isLoaded) {
947
+ view.callUnloaded();
948
+ }
949
+ view._isAddedToNativeVisualTree = false;
950
+ view._tearDownUI();
951
+ v.view = null;
952
+ v.clickListener = null;
953
+ });
954
+ this._viewHolders = new Set();
955
+ }
956
+ getKeyByValue(viewType) {
957
+ return this.templateStringTypeNumber.get(viewType);
958
+ }
959
+ onCreateViewHolder(parent, viewType) {
960
+ let view = this.getViewForViewType(ListViewViewTypes.ItemView, this.getKeyByValue(viewType));
961
+ const isNonSync = view === undefined;
962
+ // dont create unecessary StackLayout if template.createView returns. Will happend when not using Vue or angular
963
+ if (isNonSync || view instanceof ProxyViewContainer) {
964
+ const parentView = new ContentView();
965
+ parentView.id = 'collectionViewHolder';
966
+ view = parentView;
967
+ }
968
+ view._setupAsRootView(this._context);
969
+ view._isAddedToNativeVisualTree = true;
970
+ //@ts-ignore
971
+ view.parent = this;
972
+ view.callLoaded();
973
+ if (!CollectionViewCellHolder) {
974
+ CollectionViewCellHolder = com.nativescript.collectionview.CollectionViewCellHolder;
975
+ }
976
+ const holder = new CollectionViewCellHolder(view.nativeView);
977
+ const collectionView = this;
978
+ const clickListener = new android.view.View.OnClickListener({
979
+ onClick: () => {
980
+ const position = holder.getAdapterPosition();
981
+ collectionView.notify({
982
+ eventName: CollectionViewBase.itemTapEvent,
983
+ object: collectionView,
984
+ index: position,
985
+ item: collectionView.getItem(position),
986
+ view: holder.view
987
+ });
988
+ }
989
+ });
990
+ view.nativeView.setOnClickListener(clickListener);
991
+ holder.clickListener = clickListener;
992
+ holder.view = view;
993
+ const layoutParams = this._getViewLayoutParams();
994
+ view.nativeView.setLayoutParams(layoutParams);
995
+ if (isNonSync) {
996
+ holder['defaultItemView'] = true;
997
+ }
998
+ this._viewHolders.add(holder);
999
+ if (Trace.isEnabled()) {
1000
+ CLog(CLogTypes.log, 'onCreateViewHolder', this._viewHolders.size);
1001
+ }
1002
+ return holder;
1003
+ }
1004
+ onBindViewHolder(holder, position) {
1005
+ if (Trace.isEnabled()) {
1006
+ CLog(CLogTypes.log, 'onBindViewHolder', position);
1007
+ }
1008
+ let view = holder.view;
1009
+ const bindingContext = this._prepareItem(view, position);
1010
+ const isNonSync = holder['defaultItemView'] === true;
1011
+ holder['position'] = position;
1012
+ view = isNonSync ? view.content : view;
1013
+ const args = {
1014
+ eventName: CollectionViewBase.itemLoadingEvent,
1015
+ index: position,
1016
+ object: this,
1017
+ view,
1018
+ bindingContext,
1019
+ android: holder
1020
+ };
1021
+ this.notify(args);
1022
+ if (isNonSync && args.view !== view) {
1023
+ view = args.view;
1024
+ // the view has been changed on the event handler
1025
+ holder.view.content = args.view;
1026
+ }
1027
+ view.notify({ eventName: CollectionViewBase.bindedEvent });
1028
+ let width = this._effectiveColWidth;
1029
+ let height = this._effectiveRowHeight;
1030
+ if (this._getSpanSize) {
1031
+ const spanSize = this._getSpanSize(bindingContext, position);
1032
+ const horizontal = this.isHorizontal();
1033
+ if (horizontal) {
1034
+ height *= spanSize;
1035
+ }
1036
+ else {
1037
+ width *= spanSize;
1038
+ }
1039
+ }
1040
+ if (width || !view.width) {
1041
+ view.width = Utils.layout.toDeviceIndependentPixels(width);
1042
+ }
1043
+ if (height || !view.height) {
1044
+ view.height = Utils.layout.toDeviceIndependentPixels(height);
1045
+ }
1046
+ if (this.hasListeners(CollectionViewBase.displayItemEvent)) {
1047
+ this.notify({
1048
+ eventName: CollectionViewBase.displayItemEvent,
1049
+ index: position,
1050
+ object: this,
1051
+ cell: holder
1052
+ });
1053
+ }
1054
+ if (Trace.isEnabled()) {
1055
+ CLog(CLogTypes.log, 'onBindViewHolder done ', position);
1056
+ }
1057
+ }
1058
+ onViewRecycled(holder) {
1059
+ holder['position'] = null;
1060
+ }
1061
+ }
1062
+ CollectionView.DEFAULT_TEMPLATE_VIEW_TYPE = 0;
1063
+ CollectionView.CUSTOM_TEMPLATE_ITEM_TYPE = 1;
1064
+ __decorate([
1065
+ profile,
1066
+ __metadata("design:type", Function),
1067
+ __metadata("design:paramtypes", []),
1068
+ __metadata("design:returntype", void 0)
1069
+ ], CollectionView.prototype, "createNativeView", null);
1070
+ __decorate([
1071
+ profile,
1072
+ __metadata("design:type", Function),
1073
+ __metadata("design:paramtypes", []),
1074
+ __metadata("design:returntype", void 0)
1075
+ ], CollectionView.prototype, "initNativeView", null);
1076
+ __decorate([
1077
+ profile,
1078
+ __metadata("design:type", Function),
1079
+ __metadata("design:paramtypes", []),
1080
+ __metadata("design:returntype", void 0)
1081
+ ], CollectionView.prototype, "refresh", null);
1082
+ __decorate([
1083
+ profile,
1084
+ __metadata("design:type", Function),
1085
+ __metadata("design:paramtypes", [android.view.ViewGroup, Number]),
1086
+ __metadata("design:returntype", void 0)
1087
+ ], CollectionView.prototype, "onCreateViewHolder", null);
1088
+ __decorate([
1089
+ profile,
1090
+ __metadata("design:type", Function),
1091
+ __metadata("design:paramtypes", [CollectionViewCellHolder, Number]),
1092
+ __metadata("design:returntype", void 0)
1093
+ ], CollectionView.prototype, "onBindViewHolder", null);
1094
+ itemViewCacheSizeProperty.register(CollectionViewBase);
1095
+ extraLayoutSpaceProperty.register(CollectionViewBase);
1096
+ nestedScrollingEnabledProperty.register(CollectionViewBase);
1097
+ //# sourceMappingURL=index.android.js.map