@nstudio/ui-collectionview 5.0.5 → 5.1.4
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.
- package/angular/esm2020/collectionview.component.mjs +16 -26
- package/angular/esm2020/index.mjs +2 -2
- package/angular/fesm2015/nstudio-ui-collectionview-angular.mjs +15 -25
- package/angular/fesm2015/nstudio-ui-collectionview-angular.mjs.map +1 -1
- package/angular/fesm2020/nstudio-ui-collectionview-angular.mjs +15 -25
- package/angular/fesm2020/nstudio-ui-collectionview-angular.mjs.map +1 -1
- package/common.d.ts +9 -26
- package/common.js +17 -17
- package/common.js.map +1 -1
- package/index.android.d.ts +15 -13
- package/index.android.js +110 -141
- package/index.android.js.map +1 -1
- package/index.d.ts +27 -1
- package/index.ios.d.ts +1 -8
- package/index.ios.js +28 -28
- package/index.ios.js.map +1 -1
- package/package.json +1 -1
- package/react/index.js +4 -1
- package/react/index.js.map +1 -1
- package/svelte/index.js.map +1 -1
- package/vue/component.js +3 -3
- package/vue/component.js.map +1 -1
package/index.android.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* eslint-disable no-redeclare */
|
2
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 '
|
3
|
+
import { reorderLongPressEnabledProperty, reorderingEnabledProperty, reverseLayoutProperty, scrollBarIndicatorVisibleProperty } from '.';
|
4
4
|
import { CLog, CLogTypes, CollectionViewBase, ListViewViewTypes, isScrollEnabledProperty, orientationProperty } from './common';
|
5
5
|
export * from './common';
|
6
6
|
let CollectionViewCellHolder;
|
@@ -125,6 +125,7 @@ export class CollectionView extends CollectionViewBase {
|
|
125
125
|
initNativeView() {
|
126
126
|
this.setOnLayoutChangeListener();
|
127
127
|
super.initNativeView();
|
128
|
+
const nativeView = this.nativeViewProtected;
|
128
129
|
this.recycledViewPool = new com.nativescript.collectionview.RecycledViewPool();
|
129
130
|
this.recycledViewPoolDisposeListener = new com.nativescript.collectionview.RecycledViewPool.ViewPoolListener({
|
130
131
|
onViewHolderDisposed: (holder) => {
|
@@ -136,14 +137,7 @@ export class CollectionView extends CollectionViewBase {
|
|
136
137
|
}
|
137
138
|
const isNonSync = holder['defaultItemView'] === true;
|
138
139
|
const view = isNonSync ? holder.view.content : holder.view;
|
139
|
-
|
140
|
-
eventName: CollectionViewBase.itemDisposingEvent,
|
141
|
-
index: holder.getAdapterPosition(),
|
142
|
-
object: this,
|
143
|
-
view,
|
144
|
-
android: holder
|
145
|
-
};
|
146
|
-
this.notify(args);
|
140
|
+
this.notifyForItemAtIndex(CollectionViewBase.itemDisposingEvent, view, holder.getAdapterPosition(), view.bindingContext, holder);
|
147
141
|
if (view && view.isLoaded) {
|
148
142
|
view.callUnloaded();
|
149
143
|
}
|
@@ -161,44 +155,39 @@ export class CollectionView extends CollectionViewBase {
|
|
161
155
|
}
|
162
156
|
const isNonSync = holder['defaultItemView'] === true;
|
163
157
|
const view = isNonSync ? holder.view.content : holder.view;
|
164
|
-
|
165
|
-
eventName: CollectionViewBase.itemRecyclingEvent,
|
166
|
-
index: holder.getAdapterPosition(),
|
167
|
-
object: this,
|
168
|
-
view,
|
169
|
-
android: holder
|
170
|
-
};
|
171
|
-
this.notify(args);
|
158
|
+
this.notifyForItemAtIndex(CollectionViewBase.itemRecyclingEvent, view, holder.getAdapterPosition(), view.bindingContext, holder);
|
172
159
|
}
|
173
160
|
}));
|
174
|
-
|
175
|
-
|
161
|
+
nativeView.setRecyclerListener(recyclerListener);
|
162
|
+
nativeView.setRecycledViewPool(this.recycledViewPool);
|
176
163
|
// nativeView.owner = new WeakRef(this);
|
177
164
|
// nativeView.sizeChangedListener = new com.nativescript.collectionview.SizeChangedListener({
|
178
165
|
// onSizeChanged: (w, h, oldW, oldH) => this.onSizeChanged(w, h),
|
179
166
|
// });
|
180
167
|
// const orientation = this._getLayoutManagarOrientation();
|
181
168
|
// initGridLayoutManager();
|
169
|
+
let layoutManager;
|
182
170
|
if (CollectionViewBase.layoutStyles[this.layoutStyle]) {
|
183
|
-
|
171
|
+
layoutManager = CollectionViewBase.layoutStyles[this.layoutStyle].createLayout(this);
|
184
172
|
}
|
185
173
|
else {
|
186
|
-
|
174
|
+
layoutManager = new com.nativescript.collectionview.PreCachingGridLayoutManager(this._context, 1);
|
187
175
|
// layoutManager = new PreCachingGridLayoutManager(this._context, 1);
|
188
176
|
// (layoutManager as any).owner = new WeakRef(this);
|
189
177
|
}
|
190
178
|
// this.spanSize
|
191
|
-
|
192
|
-
|
179
|
+
nativeView.setLayoutManager(layoutManager);
|
180
|
+
nativeView.layoutManager = layoutManager;
|
181
|
+
nativeView.sizeChangedListener = new com.nativescript.collectionview.SizeChangedListener({
|
193
182
|
onSizeChanged() { },
|
194
183
|
onMeasure: () => this.updateInnerSize()
|
195
184
|
});
|
196
185
|
this.spanSize = this._getSpanSize;
|
197
|
-
|
198
|
-
//
|
199
|
-
//
|
200
|
-
|
201
|
-
|
186
|
+
const animator = new com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator();
|
187
|
+
// Change animations are enabled by default since support-v7-recyclerview v22.
|
188
|
+
// Need to disable them when using animation indicator.
|
189
|
+
animator.setSupportsChangeAnimations(false);
|
190
|
+
nativeView.setItemAnimator(animator);
|
202
191
|
this.refresh();
|
203
192
|
}
|
204
193
|
disposeNativeView() {
|
@@ -208,17 +197,18 @@ export class CollectionView extends CollectionViewBase {
|
|
208
197
|
// return true;
|
209
198
|
// });
|
210
199
|
// this._realizedItems.clear();
|
211
|
-
this.
|
212
|
-
|
200
|
+
const nativeView = this.nativeViewProtected;
|
201
|
+
nativeView.setRecyclerListener(null);
|
202
|
+
nativeView.setRecycledViewPool(null);
|
213
203
|
this.recycledViewPoolDisposeListener = null;
|
214
204
|
this.recycledViewPool = null;
|
215
|
-
if (
|
216
|
-
this.
|
217
|
-
|
205
|
+
if (nativeView.scrollListener) {
|
206
|
+
this.nativeView.removeOnScrollListener(nativeView.scrollListener);
|
207
|
+
nativeView.scrollListener = null;
|
218
208
|
this._nScrollListener = null;
|
219
209
|
}
|
220
|
-
|
221
|
-
|
210
|
+
nativeView.sizeChangedListener = null;
|
211
|
+
nativeView.layoutManager = null;
|
222
212
|
this._listViewAdapter = null;
|
223
213
|
this._itemTouchHelper = null;
|
224
214
|
this._simpleItemTouchCallback = null;
|
@@ -262,27 +252,24 @@ export class CollectionView extends CollectionViewBase {
|
|
262
252
|
}
|
263
253
|
attachScrollListener() {
|
264
254
|
if (this._scrollOrLoadMoreChangeCount > 0 && this.isLoaded) {
|
265
|
-
|
266
|
-
|
267
|
-
}
|
268
|
-
if (!this.android.scrollListener) {
|
255
|
+
const nativeView = this.nativeViewProtected;
|
256
|
+
if (!nativeView.scrollListener) {
|
269
257
|
this._nScrollListener = new com.nativescript.collectionview.OnScrollListener.Listener({
|
270
258
|
onScrollStateChanged: this.onScrollStateChanged.bind(this),
|
271
259
|
onScrolled: this.onScrolled.bind(this)
|
272
260
|
});
|
273
|
-
|
274
|
-
|
261
|
+
const scrollListener = new com.nativescript.collectionview.OnScrollListener(this._nScrollListener);
|
262
|
+
nativeView.addOnScrollListener(scrollListener);
|
263
|
+
nativeView.scrollListener = scrollListener;
|
275
264
|
}
|
276
265
|
}
|
277
266
|
}
|
278
267
|
detachScrollListener() {
|
279
268
|
if (this._scrollOrLoadMoreChangeCount === 0 && this.isLoaded) {
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
this.android.removeOnScrollListener(this.android.scrollListener);
|
285
|
-
this.android.scrollListener = null;
|
269
|
+
const nativeView = this.nativeViewProtected;
|
270
|
+
if (nativeView.scrollListener) {
|
271
|
+
this.nativeView.removeOnScrollListener(nativeView.scrollListener);
|
272
|
+
nativeView.scrollListener = null;
|
286
273
|
this._nScrollListener = null;
|
287
274
|
}
|
288
275
|
}
|
@@ -320,10 +307,7 @@ export class CollectionView extends CollectionViewBase {
|
|
320
307
|
const lastVisibleItemPos = layoutManager['findLastCompletelyVisibleItemPosition']();
|
321
308
|
const loadMoreItemIndex = this.items.length - this.loadMoreThreshold;
|
322
309
|
if (lastVisibleItemPos === loadMoreItemIndex) {
|
323
|
-
this.notify({
|
324
|
-
eventName: CollectionViewBase.loadMoreItemsEvent,
|
325
|
-
object: this
|
326
|
-
});
|
310
|
+
this.notify({ eventName: CollectionViewBase.loadMoreItemsEvent });
|
327
311
|
}
|
328
312
|
}
|
329
313
|
else if (layoutManager['findLastCompletelyVisibleItemPositions'] && layoutManager['getSpanCount']) {
|
@@ -337,10 +321,7 @@ export class CollectionView extends CollectionViewBase {
|
|
337
321
|
}
|
338
322
|
const loadMoreItemIndex = this.items.length - this.loadMoreThreshold;
|
339
323
|
if (lastVisibleItemPos >= loadMoreItemIndex) {
|
340
|
-
this.notify({
|
341
|
-
eventName: CollectionViewBase.loadMoreItemsEvent,
|
342
|
-
object: this
|
343
|
-
});
|
324
|
+
this.notify({ eventName: CollectionViewBase.loadMoreItemsEvent });
|
344
325
|
}
|
345
326
|
}
|
346
327
|
}
|
@@ -375,10 +356,10 @@ export class CollectionView extends CollectionViewBase {
|
|
375
356
|
}
|
376
357
|
//@ts-ignore
|
377
358
|
get android() {
|
378
|
-
return this.
|
359
|
+
return this.nativeView;
|
379
360
|
}
|
380
361
|
get layoutManager() {
|
381
|
-
return this.
|
362
|
+
return this.nativeViewProtected && this.nativeViewProtected.layoutManager;
|
382
363
|
}
|
383
364
|
_getViewLayoutParams() {
|
384
365
|
if (this.isHorizontal()) {
|
@@ -398,21 +379,21 @@ export class CollectionView extends CollectionViewBase {
|
|
398
379
|
}
|
399
380
|
setNativePoolSize(key, nativeIndex) {
|
400
381
|
if (this.desiredPoolSize.has(key)) {
|
401
|
-
this.
|
382
|
+
this.nativeViewProtected.getRecycledViewPool().setMaxRecycledViews(nativeIndex, this.desiredPoolSize.get(key));
|
402
383
|
}
|
403
384
|
else {
|
404
385
|
if (this.defaultPoolSize >= 0) {
|
405
|
-
this.
|
386
|
+
this.nativeViewProtected.getRecycledViewPool().setMaxRecycledViews(nativeIndex, this.defaultPoolSize);
|
406
387
|
}
|
407
388
|
}
|
408
389
|
}
|
409
390
|
setPoolSizes() {
|
410
|
-
if (!this.
|
391
|
+
if (!this.nativeViewProtected || !this.templateTypeNumberString) {
|
411
392
|
return;
|
412
393
|
}
|
413
394
|
this.desiredPoolSize.forEach((v, k) => {
|
414
395
|
if (this.templateTypeNumberString.has(k)) {
|
415
|
-
this.
|
396
|
+
this.nativeViewProtected.getRecycledViewPool().setMaxRecycledViews(this.templateTypeNumberString.get(k), v);
|
416
397
|
}
|
417
398
|
});
|
418
399
|
}
|
@@ -474,9 +455,7 @@ export class CollectionView extends CollectionViewBase {
|
|
474
455
|
}
|
475
456
|
}
|
476
457
|
[nestedScrollingEnabledProperty.setNative](value) {
|
477
|
-
|
478
|
-
this.android.setNestedScrollingEnabled(value);
|
479
|
-
}
|
458
|
+
this.nativeViewProtected.setNestedScrollingEnabled(value);
|
480
459
|
}
|
481
460
|
[extraLayoutSpaceProperty.setNative](value) {
|
482
461
|
const layoutManager = this.layoutManager;
|
@@ -485,9 +464,7 @@ export class CollectionView extends CollectionViewBase {
|
|
485
464
|
}
|
486
465
|
}
|
487
466
|
[itemViewCacheSizeProperty.setNative](value) {
|
488
|
-
|
489
|
-
this.android.setItemViewCacheSize(value);
|
490
|
-
}
|
467
|
+
this.nativeViewProtected.setItemViewCacheSize(value);
|
491
468
|
}
|
492
469
|
[scrollBarIndicatorVisibleProperty.getDefault]() {
|
493
470
|
return true;
|
@@ -496,14 +473,14 @@ export class CollectionView extends CollectionViewBase {
|
|
496
473
|
this.updateScrollBarVisibility(value);
|
497
474
|
}
|
498
475
|
updateScrollBarVisibility(value) {
|
499
|
-
if (!this.
|
476
|
+
if (!this.nativeViewProtected) {
|
500
477
|
return;
|
501
478
|
}
|
502
479
|
if (this.orientation === 'horizontal') {
|
503
|
-
this.
|
480
|
+
this.nativeViewProtected.setHorizontalScrollBarEnabled(value);
|
504
481
|
}
|
505
482
|
else {
|
506
|
-
this.
|
483
|
+
this.nativeViewProtected.setVerticalScrollBarEnabled(value);
|
507
484
|
}
|
508
485
|
}
|
509
486
|
enumerateViewHolders(cb) {
|
@@ -534,11 +511,12 @@ export class CollectionView extends CollectionViewBase {
|
|
534
511
|
}
|
535
512
|
}
|
536
513
|
onReorderLongPress(motionEvent) {
|
537
|
-
|
514
|
+
const collectionView = this.nativeViewProtected;
|
515
|
+
if (!collectionView) {
|
538
516
|
return;
|
539
517
|
}
|
540
|
-
const view =
|
541
|
-
const viewHolder = view != null ?
|
518
|
+
const view = collectionView.findChildViewUnder(motionEvent.getX(), motionEvent.getY());
|
519
|
+
const viewHolder = view != null ? collectionView.getChildViewHolder(view) : null;
|
542
520
|
if (viewHolder) {
|
543
521
|
this.startViewHolderDragging(viewHolder.getAdapterPosition(), viewHolder);
|
544
522
|
}
|
@@ -552,9 +530,6 @@ export class CollectionView extends CollectionViewBase {
|
|
552
530
|
super._reorderItemInSource(oldPosition, newPosition, false);
|
553
531
|
}
|
554
532
|
[reorderLongPressEnabledProperty.setNative](value) {
|
555
|
-
if (!this.android) {
|
556
|
-
return;
|
557
|
-
}
|
558
533
|
if (value) {
|
559
534
|
if (!this._longPressGesture) {
|
560
535
|
this._longPressGesture = new androidx.core.view.GestureDetectorCompat(this._context, new LongPressGestureListenerImpl(new WeakRef(this)));
|
@@ -569,25 +544,22 @@ export class CollectionView extends CollectionViewBase {
|
|
569
544
|
onRequestDisallowInterceptTouchEvent: (disallowIntercept) => { }
|
570
545
|
});
|
571
546
|
}
|
572
|
-
this.
|
547
|
+
this.nativeViewProtected.addOnItemTouchListener(this._itemTouchListerner);
|
573
548
|
}
|
574
549
|
else {
|
575
550
|
if (this._itemTouchListerner) {
|
576
|
-
this.
|
551
|
+
this.nativeViewProtected.removeOnItemTouchListener(this._itemTouchListerner);
|
577
552
|
}
|
578
553
|
}
|
579
554
|
}
|
580
555
|
[reorderingEnabledProperty.setNative](value) {
|
581
|
-
if (!this.android) {
|
582
|
-
return;
|
583
|
-
}
|
584
556
|
if (value) {
|
585
557
|
if (!this._simpleItemTouchCallback) {
|
586
558
|
const ItemTouchHelper = androidx.recyclerview.widget.ItemTouchHelper;
|
587
559
|
this._simpleItemTouchCallback = new SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.START | ItemTouchHelper.END, 0);
|
588
560
|
this._simpleItemTouchCallback.owner = new WeakRef(this);
|
589
561
|
this._itemTouchHelper = new androidx.recyclerview.widget.ItemTouchHelper(this._simpleItemTouchCallback);
|
590
|
-
this._itemTouchHelper.attachToRecyclerView(this.
|
562
|
+
this._itemTouchHelper.attachToRecyclerView(this.nativeViewProtected);
|
591
563
|
}
|
592
564
|
}
|
593
565
|
}
|
@@ -610,7 +582,7 @@ export class CollectionView extends CollectionViewBase {
|
|
610
582
|
this.refresh();
|
611
583
|
}
|
612
584
|
setOnLayoutChangeListener() {
|
613
|
-
if (this.
|
585
|
+
if (this.nativeViewProtected) {
|
614
586
|
const owner = this;
|
615
587
|
this.layoutChangeListenerIsSet = true;
|
616
588
|
this.layoutChangeListener =
|
@@ -625,7 +597,7 @@ export class CollectionView extends CollectionViewBase {
|
|
625
597
|
}
|
626
598
|
}
|
627
599
|
});
|
628
|
-
this.
|
600
|
+
this.nativeViewProtected.addOnLayoutChangeListener(this.layoutChangeListener);
|
629
601
|
}
|
630
602
|
}
|
631
603
|
_updateSpanCount() {
|
@@ -754,7 +726,8 @@ export class CollectionView extends CollectionViewBase {
|
|
754
726
|
});
|
755
727
|
}
|
756
728
|
refreshVisibleItems() {
|
757
|
-
|
729
|
+
const view = this.nativeViewProtected;
|
730
|
+
if (!view) {
|
758
731
|
return;
|
759
732
|
}
|
760
733
|
const ids = Array.from(this._viewHolders)
|
@@ -764,7 +737,8 @@ export class CollectionView extends CollectionViewBase {
|
|
764
737
|
this._listViewAdapter.notifyItemRangeChanged(ids[0], ids[ids.length - 1] - ids[0] + 1);
|
765
738
|
}
|
766
739
|
isItemAtIndexVisible(index) {
|
767
|
-
|
740
|
+
const view = this.nativeViewProtected;
|
741
|
+
if (!view) {
|
768
742
|
return false;
|
769
743
|
}
|
770
744
|
const layoutManager = this.layoutManager;
|
@@ -776,9 +750,10 @@ export class CollectionView extends CollectionViewBase {
|
|
776
750
|
return false;
|
777
751
|
}
|
778
752
|
refresh() {
|
779
|
-
if (!this.
|
753
|
+
if (!this.nativeViewProtected) {
|
780
754
|
return;
|
781
755
|
}
|
756
|
+
const view = this.nativeViewProtected;
|
782
757
|
if (!this.isLoaded) {
|
783
758
|
this._isDataDirty = true;
|
784
759
|
return;
|
@@ -787,67 +762,65 @@ export class CollectionView extends CollectionViewBase {
|
|
787
762
|
this._lastLayoutKey = this._innerWidth + '_' + this._innerHeight;
|
788
763
|
let adapter = this._listViewAdapter;
|
789
764
|
if (!adapter) {
|
790
|
-
adapter = this._listViewAdapter = this.createComposedAdapter();
|
765
|
+
adapter = this._listViewAdapter = this.createComposedAdapter(this.nativeViewProtected);
|
791
766
|
adapter.setHasStableIds(!!this._itemIdGenerator);
|
792
|
-
|
767
|
+
view.setAdapter(adapter);
|
793
768
|
}
|
794
|
-
else if (!
|
795
|
-
|
769
|
+
else if (!view.getAdapter()) {
|
770
|
+
view.setAdapter(adapter);
|
796
771
|
}
|
797
772
|
this._updateSpanCount();
|
798
773
|
adapter.notifyDataSetChanged();
|
799
|
-
|
800
|
-
eventName: CollectionViewBase.dataPopulatedEvent,
|
801
|
-
object: this
|
802
|
-
};
|
803
|
-
this.notify(args);
|
774
|
+
this.notify({ eventName: CollectionViewBase.dataPopulatedEvent });
|
804
775
|
}
|
805
776
|
//@ts-ignore
|
806
777
|
get scrollOffset() {
|
807
|
-
|
778
|
+
const view = this.nativeViewProtected;
|
779
|
+
if (!view) {
|
808
780
|
return 0;
|
809
781
|
}
|
810
|
-
return (this.isHorizontal() ?
|
782
|
+
return (this.isHorizontal() ? view.computeHorizontalScrollOffset() : view.computeVerticalScrollOffset()) / Utils.layout.getDisplayDensity();
|
811
783
|
}
|
812
784
|
get verticalOffsetX() {
|
813
|
-
|
785
|
+
const view = this.nativeViewProtected;
|
786
|
+
if (!view) {
|
814
787
|
return 0;
|
815
788
|
}
|
816
|
-
return
|
789
|
+
return view.computeHorizontalScrollOffset() / Utils.layout.getDisplayDensity();
|
817
790
|
}
|
818
791
|
get verticalOffsetY() {
|
819
|
-
|
792
|
+
const view = this.nativeViewProtected;
|
793
|
+
if (!view) {
|
820
794
|
return 0;
|
821
795
|
}
|
822
|
-
return
|
796
|
+
return view.computeVerticalScrollOffset() / Utils.layout.getDisplayDensity();
|
823
797
|
}
|
824
798
|
scrollToIndex(index, animated = true) {
|
825
|
-
if (!this.
|
799
|
+
if (!this.nativeViewProtected) {
|
826
800
|
return;
|
827
801
|
}
|
828
802
|
if (animated) {
|
829
|
-
this.
|
803
|
+
this.nativeViewProtected.smoothScrollToPosition(index);
|
830
804
|
}
|
831
805
|
else {
|
832
|
-
this.
|
806
|
+
this.nativeViewProtected.scrollToPosition(index);
|
833
807
|
}
|
834
808
|
}
|
835
809
|
_setPadding(newPadding) {
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
createComposedAdapter() {
|
810
|
+
const nativeView = this.nativeViewProtected;
|
811
|
+
const padding = {
|
812
|
+
top: nativeView.getPaddingTop(),
|
813
|
+
right: nativeView.getPaddingRight(),
|
814
|
+
bottom: nativeView.getPaddingBottom(),
|
815
|
+
left: nativeView.getPaddingLeft()
|
816
|
+
};
|
817
|
+
// tslint:disable-next-line:prefer-object-spread
|
818
|
+
const newValue = Object.assign(padding, newPadding);
|
819
|
+
nativeView.setClipToPadding(false);
|
820
|
+
nativeView.setPadding(newValue.left, newValue.top, newValue.right, newValue.bottom);
|
821
|
+
this.updateInnerSize();
|
822
|
+
}
|
823
|
+
createComposedAdapter(recyclerView) {
|
851
824
|
const adapter = new com.nativescript.collectionview.Adapter();
|
852
825
|
adapter.adapterInterface = new com.nativescript.collectionview.AdapterInterface({
|
853
826
|
getItemId: this.getItemId.bind(this),
|
@@ -895,7 +868,7 @@ export class CollectionView extends CollectionViewBase {
|
|
895
868
|
const selector = this._itemTemplateSelector;
|
896
869
|
const dataItem = this.getItemAtIndex(position);
|
897
870
|
if (dataItem) {
|
898
|
-
selectorType = selector(dataItem, position, this.items);
|
871
|
+
selectorType = selector.call(this, dataItem, position, this.items);
|
899
872
|
}
|
900
873
|
}
|
901
874
|
return this.templateKeyToNativeItem(selectorType);
|
@@ -997,28 +970,25 @@ export class CollectionView extends CollectionViewBase {
|
|
997
970
|
}
|
998
971
|
this._viewHolders.add(holder);
|
999
972
|
if (Trace.isEnabled()) {
|
1000
|
-
CLog(CLogTypes.log, 'onCreateViewHolder', this.
|
973
|
+
CLog(CLogTypes.log, 'onCreateViewHolder', viewType, this.getKeyByValue(viewType));
|
1001
974
|
}
|
1002
975
|
return holder;
|
1003
976
|
}
|
977
|
+
notifyForItemAtIndex(eventName, view, index, bindingContext, native) {
|
978
|
+
const args = { eventName, object: this, index, view, ios: native, bindingContext };
|
979
|
+
this.notify(args);
|
980
|
+
return args;
|
981
|
+
}
|
1004
982
|
onBindViewHolder(holder, position) {
|
1005
983
|
if (Trace.isEnabled()) {
|
1006
984
|
CLog(CLogTypes.log, 'onBindViewHolder', position);
|
1007
985
|
}
|
1008
986
|
let view = holder.view;
|
1009
|
-
const bindingContext = this._prepareItem(view, position);
|
1010
987
|
const isNonSync = holder['defaultItemView'] === true;
|
1011
|
-
holder['position'] = position;
|
1012
988
|
view = isNonSync ? view.content : view;
|
1013
|
-
const
|
1014
|
-
|
1015
|
-
|
1016
|
-
object: this,
|
1017
|
-
view,
|
1018
|
-
bindingContext,
|
1019
|
-
android: holder
|
1020
|
-
};
|
1021
|
-
this.notify(args);
|
989
|
+
const bindingContext = this._prepareItem(view, position);
|
990
|
+
holder['position'] = position;
|
991
|
+
const args = this.notifyForItemAtIndex(CollectionViewBase.itemLoadingEvent, view, position, bindingContext, holder);
|
1022
992
|
if (isNonSync && args.view !== view) {
|
1023
993
|
view = args.view;
|
1024
994
|
// the view has been changed on the event handler
|
@@ -1044,14 +1014,13 @@ export class CollectionView extends CollectionViewBase {
|
|
1044
1014
|
if (height || !view.height) {
|
1045
1015
|
view.height = Utils.layout.toDeviceIndependentPixels(height);
|
1046
1016
|
}
|
1047
|
-
if (this.hasListeners(CollectionViewBase.displayItemEvent)) {
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
}
|
1017
|
+
// if (this.hasListeners(CollectionViewBase.displayItemEvent) ) {
|
1018
|
+
// this.notify<CollectionViewItemDisplayEventData>({
|
1019
|
+
// eventName: CollectionViewBase.displayItemEvent,
|
1020
|
+
// index:position,
|
1021
|
+
// object: this,
|
1022
|
+
// });
|
1023
|
+
// }
|
1055
1024
|
if (Trace.isEnabled()) {
|
1056
1025
|
CLog(CLogTypes.log, 'onBindViewHolder done ', position);
|
1057
1026
|
}
|