Skip to content

Commit

Permalink
fix(android): fragments in children of list view and tableview header…
Browse files Browse the repository at this point in the history
…/footerview (#12524)

specifically allow to add a MapView ("ti.map") inside headerView of Ti.UI.ListView

Fixes TIMOB-28376
  • Loading branch information
hansemannn authored and sgtcoolguy committed Mar 11, 2021
1 parent 5a8acaa commit ef5c95d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -648,23 +648,6 @@ public void releaseViews()
{
this.holder = null;

final KrollDict properties = getProperties();

if (properties.containsKeyAndNotNull(TiC.PROPERTY_HEADER_VIEW)) {
final TiViewProxy header = (TiViewProxy) properties.get(TiC.PROPERTY_HEADER_VIEW);

if (header.getParent() == this) {
header.releaseViews();
}
}
if (properties.containsKeyAndNotNull(TiC.PROPERTY_FOOTER_VIEW)) {
final TiViewProxy footer = (TiViewProxy) properties.get(TiC.PROPERTY_FOOTER_VIEW);

if (footer.getParent() == this) {
footer.releaseViews();
}
}

super.releaseViews();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,20 @@ public void release()
@Override
public void releaseViews()
{
// Release all section item views.
for (final ListItemProxy item : this.items) {

// Release all section item views.
item.releaseViews();
}

// Release header/footer views.
if (hasPropertyAndNotNull(TiC.PROPERTY_HEADER_VIEW)) {
final TiViewProxy headerProxy = (TiViewProxy) getProperty(TiC.PROPERTY_HEADER_VIEW);
headerProxy.releaseViews();
}
if (hasPropertyAndNotNull(TiC.PROPERTY_FOOTER_VIEW)) {
final TiViewProxy footerProxy = (TiViewProxy) getProperty(TiC.PROPERTY_FOOTER_VIEW);
footerProxy.releaseViews();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ private void setHeaderFooter(TiViewProxy listViewProxy,
return;
}

final Context context = this.itemView.getContext();

// Handle `header` and `footer`.
if (updateHeader) {
if (properties.containsKeyAndNotNull(TiC.PROPERTY_HEADER_TITLE)) {
Expand All @@ -325,6 +327,11 @@ private void setHeaderFooter(TiViewProxy listViewProxy,

// Handle header view.
final TiViewProxy headerProxy = (TiViewProxy) properties.get(TiC.PROPERTY_HEADER_VIEW);
if ((context instanceof Activity) && (headerProxy.getActivity() != context)) {
headerProxy.releaseViews();
headerProxy.setActivity((Activity) context);
}

final TiUIView view = headerProxy.getOrCreateView();
if (view != null) {
final View headerView = view.getOuterView();
Expand Down Expand Up @@ -354,6 +361,11 @@ private void setHeaderFooter(TiViewProxy listViewProxy,

// Handle footer view.
final TiViewProxy footerProxy = (TiViewProxy) properties.get(TiC.PROPERTY_FOOTER_VIEW);
if ((context instanceof Activity) && (footerProxy.getActivity() != context)) {
footerProxy.releaseViews();
footerProxy.setActivity((Activity) context);
}

final TiUIView view = footerProxy.getOrCreateView();
if (view != null) {
final View footerView = view.getOuterView();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,8 @@ private void setHeaderFooter(TiViewProxy tableViewProxy,
return;
}

final Context context = this.itemView.getContext();

// Handle `header` and `footer`.
if (updateHeader) {

Expand All @@ -536,8 +538,12 @@ private void setHeaderFooter(TiViewProxy tableViewProxy,

// Handle header view.
final TiViewProxy headerProxy = (TiViewProxy) properties.get(TiC.PROPERTY_HEADER_VIEW);
final TiUIView view = headerProxy.getOrCreateView();
if ((context instanceof Activity) && (headerProxy.getActivity() != context)) {
headerProxy.releaseViews();
headerProxy.setActivity((Activity) context);
}

final TiUIView view = headerProxy.getOrCreateView();
if (view != null) {
final View headerView = view.getOuterView();

Expand Down Expand Up @@ -574,8 +580,12 @@ private void setHeaderFooter(TiViewProxy tableViewProxy,

// Handle footer view.
final TiViewProxy footerProxy = (TiViewProxy) properties.get(TiC.PROPERTY_FOOTER_VIEW);
final TiUIView view = footerProxy.getOrCreateView();
if ((context instanceof Activity) && (footerProxy.getActivity() != context)) {
footerProxy.releaseViews();
footerProxy.setActivity((Activity) context);
}

final TiUIView view = footerProxy.getOrCreateView();
if (view != null) {
final View footerView = view.getOuterView();

Expand Down

0 comments on commit ef5c95d

Please sign in to comment.