@@ -147,35 +147,52 @@ export abstract class CollectionViewBase extends View implements CollectionViewD
147147
148148 public abstract refresh ( ) ;
149149 public abstract scrollToIndex ( index : number , animated : boolean ) ;
150-
151- _onSizeChanged ( ) {
152- super . _onSizeChanged ( ) ;
153- this . onSizeChanged ( this . getMeasuredWidth ( ) , this . getMeasuredHeight ( ) ) ;
154- }
155- @profile
156- public onSizeChanged ( measuredWidth : number , measuredHeight : number ) {
157- let changed = false ;
158- this . _innerWidth = measuredWidth - this . effectivePaddingLeft - this . effectivePaddingRight ;
150+ public onLayout ( left : number , top : number , right : number , bottom : number ) {
151+ super . onLayout ( left , top , right , bottom ) ;
152+ this . _innerWidth = this . getMeasuredWidth ( ) - this . effectivePaddingLeft - this . effectivePaddingRight ;
159153 if ( this . colWidth ) {
160154 const newValue = PercentLength . toDevicePixels ( this . colWidth , autoEffectiveColWidth , this . _innerWidth ) ; // We cannot use 0 for auto as it throws for android.
161155 if ( newValue !== this . _effectiveColWidth ) {
162156 this . _effectiveColWidth = newValue ;
163- changed = true ;
164157 }
165158 }
166159
167- this . _innerHeight = measuredHeight - this . effectivePaddingTop - this . effectivePaddingBottom ;
160+ this . _innerHeight = this . getMeasuredHeight ( ) - this . effectivePaddingTop - this . effectivePaddingBottom ;
168161 if ( this . rowHeight ) {
169162 const newValue = PercentLength . toDevicePixels ( this . rowHeight , autoEffectiveRowHeight , this . _innerHeight ) ;
170163 if ( newValue !== this . _effectiveRowHeight ) {
171164 this . _effectiveRowHeight = newValue ;
172- changed = true ;
173165 }
174166 }
175- if ( changed ) {
176- this . refresh ( ) ;
177- }
178167 }
168+ // _onSizeChanged() {
169+ // super._onSizeChanged();
170+ // this.onSizeChanged(this.getMeasuredWidth(), this.getMeasuredHeight());
171+ // }
172+ // @profile
173+ // public onSizeChanged(measuredWidth: number, measuredHeight: number) {
174+ // let changed = false;
175+ // this._innerWidth = measuredWidth - this.effectivePaddingLeft - this.effectivePaddingRight;
176+ // if (this.colWidth) {
177+ // const newValue = PercentLength.toDevicePixels(this.colWidth, autoEffectiveColWidth, this._innerWidth); // We cannot use 0 for auto as it throws for android.
178+ // if (newValue !== this._effectiveColWidth) {
179+ // this._effectiveColWidth = newValue;
180+ // changed = true;
181+ // }
182+ // }
183+
184+ // this._innerHeight = measuredHeight - this.effectivePaddingTop - this.effectivePaddingBottom;
185+ // if (this.rowHeight) {
186+ // const newValue = PercentLength.toDevicePixels(this.rowHeight, autoEffectiveRowHeight, this._innerHeight);
187+ // if (newValue !== this._effectiveRowHeight) {
188+ // this._effectiveRowHeight = newValue;
189+ // changed = true;
190+ // }
191+ // }
192+ // if (changed) {
193+ // this.refresh();
194+ // }
195+ // }
179196 // public onLayout(left: number, top: number, right: number, bottom: number) {
180197 // super.onLayout(left, top, right, bottom);
181198 // }
@@ -214,6 +231,7 @@ export abstract class CollectionViewBase extends View implements CollectionViewD
214231 spanCount = Math . max ( Math . floor ( this . _innerWidth / this . _effectiveColWidth ) , 1 ) || 1 ;
215232 }
216233 }
234+ console . log ( 'computeSpanCount' , this . _innerWidth , this . _innerHeight , this . _effectiveRowHeight , this . _effectiveColWidth , spanCount ) ;
217235 return spanCount ;
218236 }
219237 public _onRowHeightPropertyChanged ( oldValue : PercentLength , newValue : PercentLength ) {
@@ -380,7 +398,7 @@ export abstract class CollectionViewBase extends View implements CollectionViewD
380398 _isDataDirty = false ;
381399 onLoaded ( ) {
382400 super . onLoaded ( ) ;
383- if ( this . _isDataDirty ) {
401+ if ( this . _isDataDirty && this . _effectiveColWidth !== undefined && this . _effectiveRowHeight !== undefined ) {
384402 this . refresh ( ) ;
385403 }
386404 }
@@ -422,7 +440,9 @@ export const colWidthProperty = new Property<CollectionViewBase, PercentLength>(
422440 equalityComparer : PercentLength . equals ,
423441 valueConverter : PercentLength . parse ,
424442 valueChanged : ( target , oldValue , newValue ) => {
425- target . _effectiveColWidth = PercentLength . toDevicePixels ( newValue , autoEffectiveColWidth , target . _innerWidth ) ;
443+ if ( target . _innerWidth !== 0 ) {
444+ target . _effectiveColWidth = PercentLength . toDevicePixels ( newValue , autoEffectiveColWidth , target . _innerWidth ) ;
445+ }
426446 target . _onColWidthPropertyChanged ( oldValue , newValue ) ;
427447 } ,
428448} ) ;
0 commit comments