Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-25503] Android: Fix CardView template compatibility #10045

Merged
merged 4 commits into from
May 18, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,21 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto

public TiUICardView(final TiViewProxy proxy)
{
// we create the view after the properties are processed
super(proxy);

// generate native view
if (this.nativeView == null) {
processProperties(getProxy().getProperties());
}
}

public TiUICardViewLayout getLayout()
{
View nativeView = getNativeView();
return ((TiCardView) nativeView).layout;
if (nativeView != null) {
return ((TiCardView) nativeView).layout;
}
return null;
}

@Override
Expand Down
49 changes: 49 additions & 0 deletions tests/Resources/ti.ui.listview.addontest.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,53 @@ describe('Titanium.UI.ListView', function () {
window.add(listView);
window.open();
});

it.android('listView with Ti.UI.Android.CardView', function (finish) {
var win = Ti.UI.createWindow({
backgroundColor: 'gray'
}),
listView = Ti.UI.createListView({
templates: {
test: {
childTemplates: [{
type: 'Ti.UI.Android.CardView',
childTemplates: [{
type: 'Ti.UI.Label',
bindId: 'label',
properties: {
color: 'black',
bindId: 'label'
}
}],
properties: {
width: Ti.UI.FILL,
height: Ti.UI.SIZE,
cardUseCompatPadding: true,
backgroundColor: 'white',
layout: 'vertical'
}
}]
}
},
defaultItemTemplate: 'test'
}),
section = Ti.UI.createListSection(),
items = [];

['A', 'B', 'C'].forEach((item) => items.push({
label: { text: item },
template: 'test'
}));

section.setItems(items);
listView.setSections([ section ]);

// should not crash after drawing listView
win.addEventListener('postlayout', function () {
finish();
});

win.add(listView);
win.open();
});
});