@nativescript-community/ui-collectionview 5.1.9 → 5.3.0
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/CHANGELOG.md +17 -0
- package/index-common.d.ts +3 -5
- package/index-common.js +101 -24
- package/index-common.js.map +1 -1
- package/index.android.d.ts +16 -6
- package/index.android.js +211 -101
- package/index.android.js.map +1 -1
- package/index.d.ts +5 -1
- package/index.ios.d.ts +6 -2
- package/index.ios.js +14 -2
- package/index.ios.js.map +1 -1
- package/package.json +2 -2
- package/platforms/android/AndroidManifest.xml +1 -1
- package/platforms/android/include.gradle +4 -3
- package/platforms/android/java/com/nativescript/collectionview/GridLayoutManager.java +9 -0
- package/platforms/android/java/com/nativescript/collectionview/OverlapDecoration.java +22 -0
- package/platforms/android/java/com/nativescript/collectionview/RecyclerView.java +33 -0
- package/platforms/android/java/com/nativescript/collectionview/SizeChangedListener.java +2 -1
- package/platforms/android/java/com/nativescript/collectionview/SmoothScroller.java +21 -0
- package/react/index.d.ts +5 -5
- package/svelte/index.d.ts +0 -1
- package/typings/android.d.ts +19 -2
- package/typings/android.wasabeef.d.ts +843 -0
- package/vue3/component.d.ts +1 -1
- package/vue3/component.js +16 -9
- package/vue3/component.js.map +1 -1
- package/angular/collectionview-comp.d.ts +0 -82
- package/angular/index.d.ts +0 -8
package/index.android.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
+
var _a, _b;
|
1
2
|
/* eslint-disable no-redeclare */
|
2
|
-
import { ChangeType, ContentView, CoreTypes, Property, ProxyViewContainer, Trace, Utils, View, ViewBase, booleanConverter, paddingBottomProperty, paddingLeftProperty, paddingRightProperty, paddingTopProperty, profile } from '@nativescript/core';
|
3
|
-
import { reorderLongPressEnabledProperty, reorderingEnabledProperty, reverseLayoutProperty, scrollBarIndicatorVisibleProperty } from '.';
|
3
|
+
import { ChangeType, ContentView, CoreTypes, Length, Property, ProxyViewContainer, Trace, Utils, View, ViewBase, booleanConverter, paddingBottomProperty, paddingLeftProperty, paddingRightProperty, paddingTopProperty, profile } from '@nativescript/core';
|
4
|
+
import { itemOverlapProperty, reorderLongPressEnabledProperty, reorderingEnabledProperty, reverseLayoutProperty, scrollBarIndicatorVisibleProperty } from '.';
|
4
5
|
import { CLog, CLogTypes, CollectionViewBase, ListViewViewTypes, isScrollEnabledProperty, orientationProperty } from './index-common';
|
5
6
|
export * from './index-common';
|
6
7
|
var SimpleCallback = /** @class */ (function (_super) {
|
@@ -12,13 +13,14 @@ var SimpleCallback = /** @class */ (function (_super) {
|
|
12
13
|
return global.__native(_this);
|
13
14
|
}
|
14
15
|
SimpleCallback.prototype.onMove = function (recyclerview, viewHolder, target) {
|
16
|
+
var _a;
|
15
17
|
var startPosition = viewHolder.getAdapterPosition();
|
16
18
|
var endPosition = target.getAdapterPosition();
|
17
19
|
if (this.startPosition === -1) {
|
18
20
|
this.startPosition = startPosition;
|
19
21
|
}
|
20
22
|
this.endPosition = endPosition;
|
21
|
-
var owner = this.owner
|
23
|
+
var owner = (_a = this.owner) === null || _a === void 0 ? void 0 : _a.get();
|
22
24
|
if (owner) {
|
23
25
|
owner._reorderItemInSource(startPosition, endPosition);
|
24
26
|
return true;
|
@@ -26,6 +28,7 @@ var SimpleCallback = /** @class */ (function (_super) {
|
|
26
28
|
return false;
|
27
29
|
};
|
28
30
|
SimpleCallback.prototype.onSelectedChanged = function (viewHolder, state) {
|
31
|
+
var _a;
|
29
32
|
if (viewHolder) {
|
30
33
|
if (this.startPosition === -1) {
|
31
34
|
this.startPosition = viewHolder.getAdapterPosition();
|
@@ -33,7 +36,7 @@ var SimpleCallback = /** @class */ (function (_super) {
|
|
33
36
|
}
|
34
37
|
if (!viewHolder) {
|
35
38
|
// this is where we identify the end of the drag and call the end event
|
36
|
-
var owner = this.owner
|
39
|
+
var owner = (_a = this.owner) === null || _a === void 0 ? void 0 : _a.get();
|
37
40
|
if (this.endPosition === -1) {
|
38
41
|
this.endPosition = this.startPosition;
|
39
42
|
}
|
@@ -65,7 +68,8 @@ var LongPressGestureListenerImpl = /** @class */ (function (_super) {
|
|
65
68
|
return global.__native(_this);
|
66
69
|
}
|
67
70
|
LongPressGestureListenerImpl.prototype.onLongPress = function (motionEvent) {
|
68
|
-
var
|
71
|
+
var _a;
|
72
|
+
var owner = (_a = this._owner) === null || _a === void 0 ? void 0 : _a.get();
|
69
73
|
if (owner) {
|
70
74
|
owner.onReorderLongPress(motionEvent);
|
71
75
|
}
|
@@ -84,6 +88,11 @@ const nestedScrollingEnabledProperty = new Property({
|
|
84
88
|
defaultValue: true,
|
85
89
|
valueConverter: booleanConverter
|
86
90
|
});
|
91
|
+
export var SnapPosition;
|
92
|
+
(function (SnapPosition) {
|
93
|
+
SnapPosition[SnapPosition["START"] = 0] = "START";
|
94
|
+
SnapPosition[SnapPosition["END"] = 1] = "END";
|
95
|
+
})(SnapPosition || (SnapPosition = {}));
|
87
96
|
export class CollectionView extends CollectionViewBase {
|
88
97
|
constructor() {
|
89
98
|
super(...arguments);
|
@@ -98,10 +107,30 @@ export class CollectionView extends CollectionViewBase {
|
|
98
107
|
this.scrolling = false;
|
99
108
|
this.needsScrollStartEvent = false;
|
100
109
|
this.animateItemUpdate = false;
|
110
|
+
this.mInPropertiesSet = false;
|
111
|
+
this.mShouldUpdateInnerSize = false;
|
112
|
+
this.mShouldUpdateSpanCount = false;
|
113
|
+
this.mShouldRefresh = false;
|
101
114
|
this.defaultPoolSize = 10;
|
102
115
|
this.desiredPoolSize = new Map();
|
103
116
|
this.isDragging = false;
|
104
117
|
this._layedOut = false;
|
118
|
+
this.bindedViewHolders = new Set();
|
119
|
+
}
|
120
|
+
onResumeNativeUpdates() {
|
121
|
+
// {N} suspends properties update on `_suspendNativeUpdates`. So we only need to do this in onResumeNativeUpdates
|
122
|
+
this.mInPropertiesSet = true;
|
123
|
+
super.onResumeNativeUpdates();
|
124
|
+
this.mInPropertiesSet = false;
|
125
|
+
if (this.mShouldUpdateInnerSize) {
|
126
|
+
this.updateInnerSize();
|
127
|
+
}
|
128
|
+
if (this.mShouldUpdateSpanCount) {
|
129
|
+
this.updateSpanCount();
|
130
|
+
}
|
131
|
+
if (this.mShouldRefresh) {
|
132
|
+
this.refresh();
|
133
|
+
}
|
105
134
|
}
|
106
135
|
createNativeView() {
|
107
136
|
// storing the class in a property for reuse in the future cause a materializing which is pretty slow!
|
@@ -121,55 +150,59 @@ export class CollectionView extends CollectionViewBase {
|
|
121
150
|
return recyclerView;
|
122
151
|
}
|
123
152
|
initNativeView() {
|
124
|
-
this.setOnLayoutChangeListener();
|
125
153
|
super.initNativeView();
|
126
154
|
const nativeView = this.nativeViewProtected;
|
127
|
-
this.recycledViewPool
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
this._viewHolders
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
view.
|
155
|
+
if (!this.recycledViewPool) {
|
156
|
+
this.recycledViewPool = new com.nativescript.collectionview.RecycledViewPool();
|
157
|
+
this.recycledViewPoolDisposeListener = new com.nativescript.collectionview.RecycledViewPool.ViewPoolListener({
|
158
|
+
onViewHolderDisposed: (holder) => {
|
159
|
+
if (Trace.isEnabled()) {
|
160
|
+
CLog(CLogTypes.log, 'onViewHolderDisposed', holder);
|
161
|
+
}
|
162
|
+
if (this._viewHolders) {
|
163
|
+
this._viewHolders.delete(holder);
|
164
|
+
}
|
165
|
+
const isNonSync = holder['defaultItemView'] === true;
|
166
|
+
const view = isNonSync ? holder.view.content : holder.view;
|
167
|
+
this.notifyForItemAtIndex(CollectionViewBase.itemDisposingEvent, view, holder.getAdapterPosition(), view.bindingContext, holder);
|
168
|
+
if (view && view.isLoaded) {
|
169
|
+
view.callUnloaded();
|
170
|
+
}
|
171
|
+
view._isAddedToNativeVisualTree = false;
|
172
|
+
//@ts-ignore
|
173
|
+
view.parent = null;
|
174
|
+
view._tearDownUI();
|
141
175
|
}
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
176
|
+
});
|
177
|
+
this.recycledViewPool.mListener = this.recycledViewPoolDisposeListener;
|
178
|
+
}
|
179
|
+
if (Trace.isEnabled() || this.hasListeners(CollectionViewBase.itemRecyclingEvent)) {
|
180
|
+
const recyclerListener = (this.recyclerListener = new androidx.recyclerview.widget.RecyclerView.RecyclerListener({
|
181
|
+
onViewRecycled: (holder) => {
|
182
|
+
if (Trace.isEnabled()) {
|
183
|
+
CLog(CLogTypes.log, 'onViewRecycled', this, nativeView, holder);
|
184
|
+
}
|
185
|
+
const isNonSync = holder['defaultItemView'] === true;
|
186
|
+
const view = isNonSync ? holder.view.content : holder.view;
|
187
|
+
this.notifyForItemAtIndex(CollectionViewBase.itemRecyclingEvent, view, holder.getAdapterPosition(), view.bindingContext, holder);
|
153
188
|
}
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
}
|
158
|
-
}));
|
159
|
-
nativeView.setRecyclerListener(recyclerListener);
|
189
|
+
}));
|
190
|
+
nativeView.setRecyclerListener(recyclerListener);
|
191
|
+
}
|
160
192
|
nativeView.setRecycledViewPool(this.recycledViewPool);
|
161
|
-
// nativeView.owner = new WeakRef(this);
|
162
|
-
// nativeView.sizeChangedListener = new com.nativescript.collectionview.SizeChangedListener({
|
163
|
-
// onSizeChanged: (w, h, oldW, oldH) => this.onSizeChanged(w, h),
|
164
|
-
// });
|
165
|
-
// const orientation = this._getLayoutManagarOrientation();
|
166
|
-
// initGridLayoutManager();
|
167
193
|
let layoutManager;
|
168
194
|
if (CollectionViewBase.layoutStyles[this.layoutStyle]) {
|
169
195
|
layoutManager = CollectionViewBase.layoutStyles[this.layoutStyle].createLayout(this);
|
170
196
|
}
|
171
197
|
else {
|
172
198
|
layoutManager = new com.nativescript.collectionview.PreCachingGridLayoutManager(this._context, 1);
|
199
|
+
if (this.hasListeners(CollectionView.layoutCompletedEvent)) {
|
200
|
+
layoutManager.layoutCompletedListener = new com.nativescript.collectionview.GridLayoutManager.LayoutCompletedListener({
|
201
|
+
onLayoutCompleted: () => {
|
202
|
+
this.notify({ eventName: CollectionView.layoutCompletedEvent });
|
203
|
+
}
|
204
|
+
});
|
205
|
+
}
|
173
206
|
// layoutManager = new PreCachingGridLayoutManager(this._context, 1);
|
174
207
|
// (layoutManager as any).owner = new WeakRef(this);
|
175
208
|
}
|
@@ -177,19 +210,13 @@ export class CollectionView extends CollectionViewBase {
|
|
177
210
|
nativeView.setLayoutManager(layoutManager);
|
178
211
|
nativeView.layoutManager = layoutManager;
|
179
212
|
nativeView.sizeChangedListener = new com.nativescript.collectionview.SizeChangedListener({
|
180
|
-
|
213
|
+
onLayout: (changed, left, top, right, bottom) => changed && this.onLayout(left, top, right, bottom),
|
181
214
|
onMeasure: () => this.updateInnerSize()
|
182
215
|
});
|
183
216
|
this.spanSize = this._getSpanSize;
|
184
|
-
const animator = new com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator();
|
185
|
-
// Change animations are enabled by default since support-v7-recyclerview v22.
|
186
|
-
// Need to disable them when using animation indicator.
|
187
|
-
animator.setSupportsChangeAnimations(false);
|
188
|
-
nativeView.setItemAnimator(animator);
|
189
217
|
this.refresh();
|
190
218
|
}
|
191
219
|
disposeNativeView() {
|
192
|
-
// clear the cache
|
193
220
|
// this.eachChildView((view) => {
|
194
221
|
// view.parent._removeView(view);
|
195
222
|
// return true;
|
@@ -211,15 +238,13 @@ export class CollectionView extends CollectionViewBase {
|
|
211
238
|
this._itemTouchHelper = null;
|
212
239
|
this._simpleItemTouchCallback = null;
|
213
240
|
this.disposeViewHolderViews();
|
214
|
-
this._hlayoutParams = null;
|
215
|
-
this._vlayoutParams = null;
|
216
241
|
this.clearTemplateTypes();
|
217
242
|
super.disposeNativeView();
|
218
243
|
}
|
219
244
|
onLoaded() {
|
220
245
|
super.onLoaded();
|
221
246
|
this.attachScrollListener();
|
222
|
-
this.refresh();
|
247
|
+
// this.refresh();
|
223
248
|
}
|
224
249
|
getViewForItemAtIndex(index) {
|
225
250
|
return this.enumerateViewHolders((v) => (v.getAdapterPosition() === index ? v.view : undefined));
|
@@ -423,6 +448,16 @@ export class CollectionView extends CollectionViewBase {
|
|
423
448
|
[paddingLeftProperty.setNative](value) {
|
424
449
|
this._setPadding({ left: this.effectivePaddingLeft });
|
425
450
|
}
|
451
|
+
[itemOverlapProperty.setNative](value) {
|
452
|
+
if (!this.decorator) {
|
453
|
+
this.decorator = new com.nativescript.collectionview.OverlapDecoration();
|
454
|
+
this.nativeViewProtected.addItemDecoration(this.decorator);
|
455
|
+
}
|
456
|
+
this.decorator.top = Length.toDevicePixels(value[0], 0);
|
457
|
+
this.decorator.right = Length.toDevicePixels(value[1], 0);
|
458
|
+
this.decorator.bottom = Length.toDevicePixels(value[2], 0);
|
459
|
+
this.decorator.left = Length.toDevicePixels(value[3], 0);
|
460
|
+
}
|
426
461
|
[orientationProperty.getDefault]() {
|
427
462
|
return 'vertical';
|
428
463
|
}
|
@@ -527,7 +562,7 @@ export class CollectionView extends CollectionViewBase {
|
|
527
562
|
// we will call events only at then end
|
528
563
|
super._reorderItemInSource(oldPosition, newPosition, false);
|
529
564
|
}
|
530
|
-
[reorderLongPressEnabledProperty.setNative](value) {
|
565
|
+
[_a = reorderLongPressEnabledProperty.setNative](value) {
|
531
566
|
if (value) {
|
532
567
|
if (!this._longPressGesture) {
|
533
568
|
this._longPressGesture = new androidx.core.view.GestureDetectorCompat(this._context, new LongPressGestureListenerImpl(new WeakRef(this)));
|
@@ -550,7 +585,7 @@ export class CollectionView extends CollectionViewBase {
|
|
550
585
|
}
|
551
586
|
}
|
552
587
|
}
|
553
|
-
[reorderingEnabledProperty.setNative](value) {
|
588
|
+
[_b = reorderingEnabledProperty.setNative](value) {
|
554
589
|
if (value) {
|
555
590
|
if (!this._simpleItemTouchCallback) {
|
556
591
|
const ItemTouchHelper = androidx.recyclerview.widget.ItemTouchHelper;
|
@@ -579,26 +614,12 @@ export class CollectionView extends CollectionViewBase {
|
|
579
614
|
super.onItemTemplatesChanged(oldValue, newValue); // TODO: update current template with the new one
|
580
615
|
this.refresh();
|
581
616
|
}
|
582
|
-
|
583
|
-
if (this.
|
584
|
-
|
585
|
-
|
586
|
-
this.layoutChangeListener =
|
587
|
-
this.layoutChangeListener ||
|
588
|
-
new android.view.View.OnLayoutChangeListener({
|
589
|
-
onLayoutChange(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) {
|
590
|
-
if (left !== oldLeft || top !== oldTop || right !== oldRight || bottom !== oldBottom) {
|
591
|
-
owner.onLayout(left, top, right, bottom);
|
592
|
-
if (owner.hasListeners(View.layoutChangedEvent)) {
|
593
|
-
owner._raiseLayoutChangedEvent();
|
594
|
-
}
|
595
|
-
}
|
596
|
-
}
|
597
|
-
});
|
598
|
-
this.nativeViewProtected.addOnLayoutChangeListener(this.layoutChangeListener);
|
617
|
+
updateSpanCount() {
|
618
|
+
if (this.mInPropertiesSet) {
|
619
|
+
this.mShouldUpdateSpanCount = true;
|
620
|
+
return;
|
599
621
|
}
|
600
|
-
|
601
|
-
_updateSpanCount() {
|
622
|
+
this.mShouldUpdateSpanCount = false;
|
602
623
|
const layoutManager = this.layoutManager;
|
603
624
|
if (layoutManager && layoutManager['setSpanCount']) {
|
604
625
|
const newValue = (this.currentSpanCount = this.computeSpanCount());
|
@@ -609,20 +630,28 @@ export class CollectionView extends CollectionViewBase {
|
|
609
630
|
}
|
610
631
|
}
|
611
632
|
updateInnerSize() {
|
612
|
-
|
613
|
-
|
633
|
+
if (this.mInPropertiesSet) {
|
634
|
+
this.mShouldUpdateInnerSize = true;
|
635
|
+
return false;
|
636
|
+
}
|
637
|
+
this.mShouldUpdateInnerSize = false;
|
638
|
+
const result = super.updateInnerSize();
|
639
|
+
if (result) {
|
640
|
+
this.updateSpanCount();
|
641
|
+
}
|
642
|
+
return result;
|
614
643
|
}
|
615
644
|
_onColWidthPropertyChanged(oldValue, newValue) {
|
616
|
-
this.
|
645
|
+
this.updateSpanCount();
|
617
646
|
super._onColWidthPropertyChanged(oldValue, newValue);
|
618
647
|
}
|
619
648
|
_onRowHeightPropertyChanged(oldValue, newValue) {
|
620
|
-
this.
|
649
|
+
this.updateSpanCount();
|
621
650
|
super._onRowHeightPropertyChanged(oldValue, newValue);
|
622
651
|
}
|
623
652
|
onLayout(left, top, right, bottom) {
|
624
653
|
this._layedOut = true;
|
625
|
-
super.onLayout(left, top, right, bottom);
|
654
|
+
// super.onLayout(left, top, right, bottom);
|
626
655
|
const p = CollectionViewBase.plugins[this.layoutStyle];
|
627
656
|
if (p && p.onLayout) {
|
628
657
|
p.onLayout(this, left, top, right, bottom);
|
@@ -728,9 +757,7 @@ export class CollectionView extends CollectionViewBase {
|
|
728
757
|
if (!view) {
|
729
758
|
return;
|
730
759
|
}
|
731
|
-
const ids = Array.from(this.
|
732
|
-
.map((s) => s['position'])
|
733
|
-
.filter((s) => s !== null)
|
760
|
+
const ids = Array.from(this.bindedViewHolders)
|
734
761
|
.sort((a, b) => a - b);
|
735
762
|
this._listViewAdapter.notifyItemRangeChanged(ids[0], ids[ids.length - 1] - ids[0] + 1);
|
736
763
|
}
|
@@ -748,26 +775,33 @@ export class CollectionView extends CollectionViewBase {
|
|
748
775
|
return false;
|
749
776
|
}
|
750
777
|
refresh() {
|
751
|
-
if (
|
778
|
+
if (this.mInPropertiesSet) {
|
779
|
+
this.mShouldRefresh = true;
|
752
780
|
return;
|
753
781
|
}
|
782
|
+
this.mShouldRefresh = false;
|
754
783
|
const view = this.nativeViewProtected;
|
755
|
-
if (!
|
756
|
-
this._isDataDirty = true;
|
784
|
+
if (!view) {
|
757
785
|
return;
|
758
786
|
}
|
787
|
+
// seems like we refresh sooner
|
788
|
+
// not sure why it was needed before and not now.
|
789
|
+
// if (!this.isLoaded || this._innerWidth === 0 || this._innerHeight === 0) {
|
790
|
+
// this._isDataDirty = true;
|
791
|
+
// return;
|
792
|
+
// }
|
759
793
|
this._isDataDirty = false;
|
760
794
|
this._lastLayoutKey = this._innerWidth + '_' + this._innerHeight;
|
761
795
|
let adapter = this._listViewAdapter;
|
762
796
|
if (!adapter) {
|
763
|
-
adapter = this._listViewAdapter = this.createComposedAdapter(
|
797
|
+
adapter = this._listViewAdapter = this.createComposedAdapter(view);
|
764
798
|
adapter.setHasStableIds(!!this._itemIdGenerator);
|
765
799
|
view.setAdapter(adapter);
|
766
800
|
}
|
767
801
|
else if (!view.getAdapter()) {
|
768
802
|
view.setAdapter(adapter);
|
769
803
|
}
|
770
|
-
this.
|
804
|
+
this.updateSpanCount();
|
771
805
|
adapter.notifyDataSetChanged();
|
772
806
|
this.notify({ eventName: CollectionViewBase.dataPopulatedEvent });
|
773
807
|
}
|
@@ -793,13 +827,13 @@ export class CollectionView extends CollectionViewBase {
|
|
793
827
|
}
|
794
828
|
return view.computeVerticalScrollOffset() / Utils.layout.getDisplayDensity();
|
795
829
|
}
|
796
|
-
scrollToIndex(index, animated = true) {
|
830
|
+
scrollToIndex(index, animated = true, snap = SnapPosition.START) {
|
797
831
|
const view = this.nativeViewProtected;
|
798
832
|
if (!view) {
|
799
833
|
return;
|
800
834
|
}
|
801
835
|
if (animated) {
|
802
|
-
view.smoothScrollToPosition(index);
|
836
|
+
view.smoothScrollToPosition(index, snap);
|
803
837
|
}
|
804
838
|
else {
|
805
839
|
view.scrollToPosition(index);
|
@@ -914,15 +948,15 @@ export class CollectionView extends CollectionViewBase {
|
|
914
948
|
}
|
915
949
|
return this.templateTypeNumberString.get(key);
|
916
950
|
}
|
917
|
-
nativeItemToTemplateKey(item) {
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
}
|
951
|
+
// public nativeItemToTemplateKey(item: number): string {
|
952
|
+
// let result: string;
|
953
|
+
// this.templateTypeNumberString?.forEach((value, key, map) => {
|
954
|
+
// if (value === item) {
|
955
|
+
// result = key;
|
956
|
+
// }
|
957
|
+
// }, this);
|
958
|
+
// return result;
|
959
|
+
// }
|
926
960
|
disposeViewHolderViews() {
|
927
961
|
this.enumerateViewHolders((v) => {
|
928
962
|
const view = v.view;
|
@@ -942,6 +976,7 @@ export class CollectionView extends CollectionViewBase {
|
|
942
976
|
return this.templateStringTypeNumber.get(viewType);
|
943
977
|
}
|
944
978
|
onCreateViewHolder(parent, viewType) {
|
979
|
+
const start = Date.now();
|
945
980
|
let view = this.getViewForViewType(ListViewViewTypes.ItemView, this.getKeyByValue(viewType));
|
946
981
|
const isNonSync = view === undefined;
|
947
982
|
// dont create unecessary StackLayout if template.createView returns. Will happend when not using Vue or angular
|
@@ -982,7 +1017,7 @@ export class CollectionView extends CollectionViewBase {
|
|
982
1017
|
}
|
983
1018
|
this._viewHolders.add(holder);
|
984
1019
|
if (Trace.isEnabled()) {
|
985
|
-
CLog(CLogTypes.log, 'onCreateViewHolder', viewType, this.getKeyByValue(viewType));
|
1020
|
+
CLog(CLogTypes.log, 'onCreateViewHolder', this, this.nativeView, viewType, this.getKeyByValue(viewType), holder, Date.now() - start, 'ms');
|
986
1021
|
}
|
987
1022
|
return holder;
|
988
1023
|
}
|
@@ -992,14 +1027,19 @@ export class CollectionView extends CollectionViewBase {
|
|
992
1027
|
return args;
|
993
1028
|
}
|
994
1029
|
onBindViewHolder(holder, position) {
|
1030
|
+
const start = Date.now();
|
995
1031
|
if (Trace.isEnabled()) {
|
996
|
-
CLog(CLogTypes.log, 'onBindViewHolder', position);
|
1032
|
+
CLog(CLogTypes.log, 'onBindViewHolder', this, this.nativeView, position, holder, holder.view);
|
997
1033
|
}
|
998
1034
|
let view = holder.view;
|
999
1035
|
const isNonSync = holder['defaultItemView'] === true;
|
1000
1036
|
view = isNonSync ? view.content : view;
|
1001
1037
|
const bindingContext = this._prepareItem(view, position);
|
1038
|
+
if (holder['position'] !== undefined) {
|
1039
|
+
this.bindedViewHolders.delete(holder['position']);
|
1040
|
+
}
|
1002
1041
|
holder['position'] = position;
|
1042
|
+
this.bindedViewHolders.add(holder['position']);
|
1003
1043
|
const args = this.notifyForItemAtIndex(CollectionViewBase.itemLoadingEvent, view, position, bindingContext, holder);
|
1004
1044
|
if (isNonSync && args.view !== view) {
|
1005
1045
|
view = args.view;
|
@@ -1034,13 +1074,14 @@ export class CollectionView extends CollectionViewBase {
|
|
1034
1074
|
// });
|
1035
1075
|
// }
|
1036
1076
|
if (Trace.isEnabled()) {
|
1037
|
-
CLog(CLogTypes.log, 'onBindViewHolder done ', position);
|
1077
|
+
CLog(CLogTypes.log, 'onBindViewHolder done ', position, Date.now() - start, 'ms');
|
1038
1078
|
}
|
1039
1079
|
}
|
1040
1080
|
onViewRecycled(holder) {
|
1041
1081
|
holder['position'] = null;
|
1042
1082
|
}
|
1043
1083
|
}
|
1084
|
+
CollectionView.layoutCompletedEvent = 'layoutCompleted';
|
1044
1085
|
CollectionView.DEFAULT_TEMPLATE_VIEW_TYPE = 0;
|
1045
1086
|
CollectionView.CUSTOM_TEMPLATE_ITEM_TYPE = 1;
|
1046
1087
|
__decorate([
|
@@ -1049,12 +1090,81 @@ __decorate([
|
|
1049
1090
|
__decorate([
|
1050
1091
|
profile
|
1051
1092
|
], CollectionView.prototype, "initNativeView", null);
|
1093
|
+
__decorate([
|
1094
|
+
profile
|
1095
|
+
], CollectionView.prototype, "disposeNativeView", null);
|
1096
|
+
__decorate([
|
1097
|
+
profile
|
1098
|
+
], CollectionView.prototype, "onLoaded", null);
|
1099
|
+
__decorate([
|
1100
|
+
profile
|
1101
|
+
], CollectionView.prototype, "attachScrollListener", null);
|
1102
|
+
__decorate([
|
1103
|
+
profile
|
1104
|
+
], CollectionView.prototype, "setNativePoolSize", null);
|
1105
|
+
__decorate([
|
1106
|
+
profile
|
1107
|
+
], CollectionView.prototype, "setPoolSizes", null);
|
1108
|
+
__decorate([
|
1109
|
+
profile
|
1110
|
+
], CollectionView.prototype, _a, null);
|
1111
|
+
__decorate([
|
1112
|
+
profile
|
1113
|
+
], CollectionView.prototype, _b, null);
|
1114
|
+
__decorate([
|
1115
|
+
profile
|
1116
|
+
], CollectionView.prototype, "onItemViewLoaderChanged", null);
|
1117
|
+
__decorate([
|
1118
|
+
profile
|
1119
|
+
], CollectionView.prototype, "onItemTemplateSelectorChanged", null);
|
1120
|
+
__decorate([
|
1121
|
+
profile
|
1122
|
+
], CollectionView.prototype, "onItemTemplateChanged", null);
|
1123
|
+
__decorate([
|
1124
|
+
profile
|
1125
|
+
], CollectionView.prototype, "onItemTemplatesChanged", null);
|
1126
|
+
__decorate([
|
1127
|
+
profile
|
1128
|
+
], CollectionView.prototype, "updateSpanCount", null);
|
1129
|
+
__decorate([
|
1130
|
+
profile
|
1131
|
+
], CollectionView.prototype, "updateInnerSize", null);
|
1132
|
+
__decorate([
|
1133
|
+
profile
|
1134
|
+
], CollectionView.prototype, "_onColWidthPropertyChanged", null);
|
1135
|
+
__decorate([
|
1136
|
+
profile
|
1137
|
+
], CollectionView.prototype, "_onRowHeightPropertyChanged", null);
|
1138
|
+
__decorate([
|
1139
|
+
profile
|
1140
|
+
], CollectionView.prototype, "onLayout", null);
|
1052
1141
|
__decorate([
|
1053
1142
|
profile
|
1054
1143
|
], CollectionView.prototype, "refresh", null);
|
1144
|
+
__decorate([
|
1145
|
+
profile
|
1146
|
+
], CollectionView.prototype, "_setPadding", null);
|
1147
|
+
__decorate([
|
1148
|
+
profile
|
1149
|
+
], CollectionView.prototype, "createComposedAdapter", null);
|
1150
|
+
__decorate([
|
1151
|
+
profile
|
1152
|
+
], CollectionView.prototype, "clearTemplateTypes", null);
|
1153
|
+
__decorate([
|
1154
|
+
profile
|
1155
|
+
], CollectionView.prototype, "getItemViewType", null);
|
1156
|
+
__decorate([
|
1157
|
+
profile
|
1158
|
+
], CollectionView.prototype, "templateKeyToNativeItem", null);
|
1159
|
+
__decorate([
|
1160
|
+
profile
|
1161
|
+
], CollectionView.prototype, "disposeViewHolderViews", null);
|
1055
1162
|
__decorate([
|
1056
1163
|
profile
|
1057
1164
|
], CollectionView.prototype, "onCreateViewHolder", null);
|
1165
|
+
__decorate([
|
1166
|
+
profile
|
1167
|
+
], CollectionView.prototype, "notifyForItemAtIndex", null);
|
1058
1168
|
__decorate([
|
1059
1169
|
profile
|
1060
1170
|
], CollectionView.prototype, "onBindViewHolder", null);
|