@@ -60,7 +60,7 @@ export class Pager extends PagerBase {
60
60
private _pageListener : any ;
61
61
// used to store viewHolder and thus their corresponding Views
62
62
// used to "destroy" cells when possible
63
- _viewHolders = new Set < WeakRef < PagerViewHolder > > ( ) ;
63
+ _viewHolders = new Set < PagerViewHolder > ( ) ;
64
64
public _childrenViewsType = new Map < number , View > ( ) ;
65
65
public _realizedTemplates = new Map < string , Map < android . view . View , View > > ( ) ;
66
66
lastEvent = 0 ;
@@ -164,9 +164,8 @@ export class Pager extends PagerBase {
164
164
165
165
private enumerateViewHolders < T = any > ( cb : ( v : PagerViewHolder ) => T ) {
166
166
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 ) {
170
169
result = cb ( v ) ;
171
170
if ( result ) {
172
171
return result ;
@@ -331,7 +330,12 @@ export class Pager extends PagerBase {
331
330
} ;
332
331
disposeViewHolderViews ( ) {
333
332
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 ( ) ;
335
339
} ) ;
336
340
this . _viewHolders = new Set ( ) ;
337
341
}
@@ -841,12 +845,14 @@ function initPagerRecyclerAdapter() {
841
845
} else {
842
846
sp [ PLACEHOLDER ] = true ;
843
847
}
844
- owner . _addView ( sp ) ;
848
+ sp . _setupAsRootView ( owner . _context ) ;
849
+ sp . _isAddedToNativeVisualTree = true ;
850
+ sp . callLoaded ( ) ;
845
851
sp . nativeView . setLayoutParams ( new android . view . ViewGroup . LayoutParams ( android . view . ViewGroup . LayoutParams . MATCH_PARENT , android . view . ViewGroup . LayoutParams . MATCH_PARENT ) ) ;
846
852
847
853
initPagerViewHolder ( ) ;
848
854
const holder = new PagerViewHolder ( new WeakRef ( sp ) , new WeakRef ( owner ) ) ;
849
- owner . _viewHolders . add ( new WeakRef ( holder ) ) ;
855
+ owner . _viewHolders . add ( holder ) ;
850
856
return holder ;
851
857
}
852
858
@@ -988,14 +994,14 @@ function initStaticPagerStateAdapter() {
988
994
} else {
989
995
sp [ PLACEHOLDER ] = true ;
990
996
}
991
- owner . _addView ( sp ) ;
992
-
997
+ sp . _setupAsRootView ( owner . _context ) ;
998
+ sp . _isAddedToNativeVisualTree = true ;
999
+ sp . callLoaded ( ) ;
993
1000
sp . nativeView . setLayoutParams ( new android . view . ViewGroup . LayoutParams ( android . view . ViewGroup . LayoutParams . MATCH_PARENT , android . view . ViewGroup . LayoutParams . MATCH_PARENT ) ) ;
994
1001
995
-
996
1002
initPagerViewHolder ( ) ;
997
1003
const holder = new PagerViewHolder ( new WeakRef ( sp ) , new WeakRef ( owner ) ) ;
998
- owner . _viewHolders . add ( new WeakRef ( holder ) ) ;
1004
+ owner . _viewHolders . add ( holder ) ;
999
1005
return holder ;
1000
1006
}
1001
1007
0 commit comments