Skip to content

Commit 7a33ae0

Browse files
committed
fix(android): regression fix
1 parent 6d18cc2 commit 7a33ae0

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/ui-pager/index.android.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class Pager extends PagerBase {
6060
private _pageListener: any;
6161
// used to store viewHolder and thus their corresponding Views
6262
// used to "destroy" cells when possible
63-
_viewHolders = new Set<WeakRef<PagerViewHolder>>();
63+
_viewHolders = new Set<PagerViewHolder>();
6464
public _childrenViewsType = new Map<number, View>();
6565
public _realizedTemplates = new Map<string, Map<android.view.View, View>>();
6666
lastEvent = 0;
@@ -164,9 +164,8 @@ export class Pager extends PagerBase {
164164

165165
private enumerateViewHolders<T = any>(cb: (v: PagerViewHolder) => T) {
166166
let result: T, v: PagerViewHolder;
167-
for (let it = this._viewHolders.values(), cellItemView: WeakRef<PagerViewHolder> = null; (cellItemView = it.next().value); ) {
168-
v = cellItemView?.get();
169-
if (v) {
167+
for (let it = this._viewHolders.values(), cellItemView: PagerViewHolder = null; (cellItemView = it.next().value); ) {
168+
if (cellItemView) {
170169
result = cb(v);
171170
if (result) {
172171
return result;
@@ -331,7 +330,12 @@ export class Pager extends PagerBase {
331330
};
332331
disposeViewHolderViews() {
333332
this.enumerateViewHolders((v) => {
334-
this._removeViewCore(v.view);
333+
const view = v.view;
334+
if (view && view.isLoaded) {
335+
view.callUnloaded();
336+
}
337+
view._isAddedToNativeVisualTree = false;
338+
view._tearDownUI();
335339
});
336340
this._viewHolders = new Set();
337341
}
@@ -841,12 +845,14 @@ function initPagerRecyclerAdapter() {
841845
} else {
842846
sp[PLACEHOLDER] = true;
843847
}
844-
owner._addView(sp);
848+
sp._setupAsRootView(owner._context);
849+
sp._isAddedToNativeVisualTree = true;
850+
sp.callLoaded();
845851
sp.nativeView.setLayoutParams(new android.view.ViewGroup.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT));
846852

847853
initPagerViewHolder();
848854
const holder = new PagerViewHolder(new WeakRef(sp), new WeakRef(owner));
849-
owner._viewHolders.add(new WeakRef(holder));
855+
owner._viewHolders.add(holder);
850856
return holder;
851857
}
852858

@@ -988,14 +994,14 @@ function initStaticPagerStateAdapter() {
988994
} else {
989995
sp[PLACEHOLDER] = true;
990996
}
991-
owner._addView(sp);
992-
997+
sp._setupAsRootView(owner._context);
998+
sp._isAddedToNativeVisualTree = true;
999+
sp.callLoaded();
9931000
sp.nativeView.setLayoutParams(new android.view.ViewGroup.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT));
9941001

995-
9961002
initPagerViewHolder();
9971003
const holder = new PagerViewHolder(new WeakRef(sp), new WeakRef(owner));
998-
owner._viewHolders.add(new WeakRef(holder));
1004+
owner._viewHolders.add(holder);
9991005
return holder;
10001006
}
10011007

0 commit comments

Comments
 (0)