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

[6_1_X][TIMOB-24987] Android: Setting a custom theme's parent to "Theme.Titanium" no longer causes a recursive lookup. #9253

Merged
merged 4 commits into from
Jul 26, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 0 additions & 6 deletions android/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3355,12 +3355,6 @@ AndroidBuilder.prototype.generateTheme = function generateTheme(next) {
if (this.tiapp.fullscreen || this.tiapp['statusbar-hidden']) {
flags += '.Fullscreen';
}
if (this.tiappAndroidManifest && this.tiappAndroidManifest.application && this.tiappAndroidManifest.application.theme) {
var theme = this.tiappAndroidManifest.application.theme;
if (theme.startsWith('@style/') && theme !== '@style/Theme.Titanium') {
flags = theme.replace('@style/', '');
}
}

fs.writeFileSync(themeFile, ejs.render(fs.readFileSync(path.join(this.templatesDir, 'theme.xml')).toString(), {
flags: flags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import ti.modules.titanium.ui.ViewProxy;
import ti.modules.titanium.ui.widget.listview.TiListView.TiBaseAdapter;
import ti.modules.titanium.ui.widget.listview.TiListViewTemplate.DataItem;
import android.app.Activity;
import android.os.Message;
import android.view.View;

Expand Down Expand Up @@ -707,10 +708,16 @@ public void generateCellContent(int sectionIndex, KrollDict data, TiListViewTemp

public void generateChildContentViews(DataItem item, TiUIView parentContent, TiBaseListViewItem rootItem, boolean root) {

Activity activity = getActivity();
if (activity == null) {
return;
}

ArrayList<DataItem> childrenItem = item.getChildren();
for (int i = 0; i < childrenItem.size(); i++) {
DataItem child = childrenItem.get(i);
TiViewProxy proxy = child.getViewProxy();
proxy.setActivity(activity);
TiUIView view = proxy.createView(proxy.getActivity());
view.registerForTouch();
proxy.setView(view);
Expand Down Expand Up @@ -895,8 +902,18 @@ public boolean isFooterTitle(int pos) {
return (footerTitle != null && pos == getItemCount() - 1);
}

public void setListView(TiListView l) {
listView = new WeakReference<TiListView>(l);
public void setListView(TiListView listView) {
// Store a weak reference to the given ListView.
this.listView = new WeakReference<TiListView>(listView);

// Updates this proxy to use the given ListView's activity. Will end up using its theme.
// Note: Odds are this proxy was initialized with the previous activity upon creation.
if (listView != null) {
TiViewProxy listViewProxy = listView.getProxy();
if ((listViewProxy != null) && (listViewProxy.getActivity() != null)) {
setActivity(listViewProxy.getActivity());
}
}
}

public TiListView getListView() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ protected void processTemplates(KrollDict templates) {
}
}

public View layoutHeaderOrFooterView (TiViewProxy viewProxy) {
public View layoutHeaderOrFooterView(TiViewProxy viewProxy) {
TiUIView tiView = viewProxy.peekView();
if (tiView != null) {
TiViewProxy parentProxy = viewProxy.getParent();
Expand All @@ -838,6 +838,10 @@ public View layoutHeaderOrFooterView (TiViewProxy viewProxy) {
}
}
} else {
TiViewProxy listViewProxy = getProxy();
if ((listViewProxy != null) && (listViewProxy.getActivity() != null)) {
viewProxy.setActivity(listViewProxy.getActivity());
}
tiView = viewProxy.forceCreateView();
}
View outerView = tiView.getOuterView();
Expand Down