Skip to content

Commit a0cc9cc

Browse files
committed
fix android angular simple template
1 parent 40115ec commit a0cc9cc

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

demo-ng/app/app.ios.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
@import 'node_modules/nativescript-theme-core/scss/light';
22
@import 'node_modules/nativescript-theme-core/scss/index';
33
@import 'node_modules/nativescript-theme-core/scss/platforms/index.ios';
4+
5+
.odd {
6+
background-color: #cecece;
7+
}

grid-view.android.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
***************************************************************************** */
1616

17+
import { ContentView } from "ui/content-view";
1718
import { KeyedTemplate, Length, View } from "ui/core/view";
1819
import * 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

Comments
 (0)