-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix(android): fragments in children of header/footerview #12524
Conversation
specifically allow to add a MapView ("ti.map") inside headerView of Ti.UI.ListView fix TIMOB-28376
Tests:
|
👍 for the community! should be the same here I guess: https://github.com/appcelerator/titanium_mobile/blob/b6436261f78d53f37c6ddcb461c612345f96e493/android/modules/ui/src/java/ti/modules/titanium/ui/widget/tableview/TableViewHolder.java#L538 |
@m1ga Updated! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FR Passed, tested using the test cases above.
Test Environment
MacOS Big Sur: 11.1 Beta 1
Xcode: 12.2 Beta
Java Version: 1.8.0_242
Android NDK: 21.3.6528147
Node.js: 12.18.1
""NPM":"5.0.0","CLI":"8.1.1""
iPhone 8 14.2
The backport to
Check the run for full details # Fetch latest updates from GitHub
git fetch
# Check out the target branch
git checkout 10_0_X
# Make sure it's up to date
git pull
# Check out your branch
git checkout -b backport-12524-to-10_0_X
# Apply the commits from the PR
curl -s https://github.com/appcelerator/titanium_mobile/commit/896e25485fdda00f4f396b16bb5486a74681e52e.patch | git am -3 --ignore-whitespace
curl -s https://github.com/appcelerator/titanium_mobile/commit/ecc0d57281161c18054f4ad0a0c8de64530255fa.patch | git am -3 --ignore-whitespace
curl -s https://github.com/appcelerator/titanium_mobile/commit/ed3cf84a3261775954faceda40af68a1bb97aa7e.patch | git am -3 --ignore-whitespace
curl -s https://github.com/appcelerator/titanium_mobile/commit/936eb59192e195fba995603d09d552fa7c90392c.patch | git am -3 --ignore-whitespace
curl -s https://github.com/appcelerator/titanium_mobile/commit/1eceea723c1ffc64997e7b13bb6885347d652ee8.patch | git am -3 --ignore-whitespace
curl -s https://github.com/appcelerator/titanium_mobile/commit/bc3e78ac58339c1f729c78a0f5ee84179a62699b.patch | git am -3 --ignore-whitespace
curl -s https://github.com/appcelerator/titanium_mobile/commit/a2e7d885df1d136c06d082669d9274aab36dc90d.patch | git am -3 --ignore-whitespace
# Push it to GitHub
git push --set-upstream origin backport-12524-to-10_0_X Then, create a pull request where the |
…/footerview (#12524) specifically allow to add a MapView ("ti.map") inside headerView of Ti.UI.ListView Fixes TIMOB-28376
} | ||
if (hasPropertyAndNotNull(TiC.PROPERTY_FOOTER_VIEW)) { | ||
final TiViewProxy footerProxy = (TiViewProxy) getProperty(TiC.PROPERTY_FOOTER_VIEW); | ||
footerProxy.releaseViews(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@drauggres Quick question as you fixed this one and https://jira.appcelerator.org/browse/TIMOB-28583 now popped up for us: When comparing the changes, you release the views and set the activity for list headers / footers, but you don't set the activity for list section headers / footers. Is this maybe the missing piece to prevent further crashes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi. The original commit I made is here:
NetrisTV@f9c1912
IIRC the problem here is that the proxies in Titanium receive an Activity
at the creation time from the currently open Window
, which may not be the Window
where they will be added to later.
We should set the activity for any child views to the same as the parent.
I'm not sure about .releaseViews()
part, I didn't write it. This is probably for the case where you are moving a view from one parent to another. I don't know if this is really necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, thank you! So you would recommedn to add the setActivity
here as well? And I am wondering if a workaround then may be to wait for the window to be opened!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but you don't set the activity for list section headers / footers
Just checked the code, we call setActivity
in this case too:
https://github.com/appcelerator/titanium_mobile/blob/2dad43e47e6db455ce6d9f852082ab766bfd81d8/android/modules/ui/src/java/ti/modules/titanium/ui/widget/listview/ListSectionProxy.java#L350-L365
In theory it is possible to have a "wrong" Activity
stored in the parent proxy. We don't really know the right one before it is being added to a Window
.
I think we should override ListViewProxy.add
to call setActivity
for its header/footer and every section (and their headers/footers).
https://github.com/appcelerator/titanium_mobile/blob/2dad43e47e6db455ce6d9f852082ab766bfd81d8/android/titanium/src/java/org/appcelerator/titanium/proxy/TiViewProxy.java#L581
UPD: And this is probably not correct, we should always update activity:
https://github.com/appcelerator/titanium_mobile/blob/2dad43e47e6db455ce6d9f852082ab766bfd81d8/android/titanium/src/java/org/appcelerator/titanium/proxy/TiViewProxy.java#L616-L617
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I am wondering if a workaround then may be to wait for the window to be opened!
just tried that and it doesn't work.
Btw: it just happens with a map, a normal view inside the footerView works fine. And if your footerView is visible directly it works with a map too.
It starts some map parts
I/Google Maps Android API: Google Play services package version: 214815044
I/Google Maps Android API: Google Play services maps renderer version(legacy): 203115000
before it crashs. So perhaps we have to search in ti.map?
Also it will crash when the map is inside a normal template item/row.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can get it to work when I call mapView.add(require('ti.map').createView());
when the footer view is visible.
So as a workaround @hansemannn you could add #13095 and use the scrolling
event to get the firstVisibleItemIndex
all the time and check if that is near the bottom and add the mapview to the view.
Not sure if there is an event of the footerView so you'll know that it is created by the recyclerview
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's really hard to do in the quite extended environment we're using it here. It really has to be a ti.map thing then. Not sure where to look then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hansemannn there is an easier workaround:
const mapView = Ti.UI.createView({
height: 200
});
mapView.addEventListener("postlayout", postLay);
function postLay() {
mapView.add(require('ti.map').createView());
mapView.removeEventListener("postlayout", postLay)
}
// footerView: mapView
add a "loading..." text into the mapView
and you're fine 😉 Works in my test app.
Also found some older issues with map view fragments in other fragments:
https://jira.appcelerator.org/browse/TIMOB-18244
https://jira.appcelerator.org/browse/TIMOB-18876
Tested fragmentOnly: true
but it will only show an empty view, no map.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting - will test that on Monday as the first thing. Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All credits to @drauggres!
JIRA:
https://jira.appcelerator.org/browse/TIMOB-28376
MapView Test:
ListView Dark/Light Switch Test:
ListViewHeaderViewTest.js
attached to TIMOB-28376 on Android 10 or higher.TableView Dark/Light Switch Test:
TableViewHeaderLabelTest.js
attached to TIMOB-28376 on Android 10 or higher.