@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515***************************************************************************** */
1616
17+ import { ContentView } from "ui/content-view" ;
1718import { KeyedTemplate , Length , View } from "ui/core/view" ;
1819import * as utils from "utils/utils" ;
1920
@@ -363,7 +364,11 @@ function initGridViewAdapter() {
363364 public onCreateViewHolder ( parent : android . view . ViewGroup , viewType : number ) : android . support . v7 . widget . RecyclerView . ViewHolder {
364365 const owner = this . owner . get ( ) ;
365366 const template = owner . _itemTemplatesInternal [ viewType ] ;
366- const view = template . createView ( ) ;
367+ let view = template . createView ( ) ;
368+
369+ if ( ! view ) {
370+ view = new ContentView ( ) ;
371+ }
367372
368373 owner . _addView ( view ) ;
369374
@@ -374,15 +379,19 @@ function initGridViewAdapter() {
374379
375380 public onBindViewHolder ( vh : GridViewCellHolder , index : number ) {
376381 const owner = this . owner . get ( ) ;
377-
378- owner . notify < GridItemEventData > ( {
382+ const args : GridItemEventData = {
379383 eventName : GridViewBase . itemLoadingEvent ,
380384 object : owner ,
381385 index,
382386 view : vh . view ,
383387 android : vh ,
384388 ios : undefined ,
385- } ) ;
389+ } ;
390+ owner . notify ( args ) ;
391+
392+ if ( vh . view !== args . view && vh . view instanceof ContentView ) {
393+ vh . view . content = args . view ;
394+ }
386395
387396 if ( owner . orientation === "horizontal" ) {
388397 vh . view . width = utils . layout . toDeviceIndependentPixels ( owner . _effectiveColWidth ) ;
0 commit comments