Android: onMarker event not fired when postlayout event set
PietroGranati opened this issue · 14 comments
I have searched and made sure there are no existing issues for the issue I am filing
- I have searched the existing issues
Description
Hello everyone, I have encountered a bug, I have a ListView with onMarker event set on creation in Alloy.
When you open the view I load the data in the listview and use the setMarker method to launch the update and append data to the list.
Everything was working fine until I put the first loading data on a postlayout event in the container view like this:
function loadView() { $.bodyView.removeEventListener('postlayout', loadView); loadNote(); }
On iOS everything is working fine, on Android it stops the marker event to fire
Expected Behavior
The makerk event should fire
Actual behavior
The marker is not firing
Reproducible sample
/
Steps to reproduce
Create an alloy view with postlayout event ad a listview inside with marker event
In the controller add the code for post layout with the removal code for postlayout
Platform
Android
SDK version you are using
9.3.2
Alloy version you are using
No response
can you check it in a recent SDK. 9.3.2 is very old and even if there was an error in that version it won't be fixed.
and a side note: I've #13095 because I had trouble with the markers too. I've used them for lazy loading and especially on very fast scrolls not all makers fired. With the continuousUpdate
event I can check firstVisibleItemIndex
during scrolling and not only when the direction changes. Its in 11.1.1
I was trying on 11.1.1 too, but maybe yesterday I got the cache dirty, today on 11.1.1 it's working fine.
On fast scrolling I got the same result as you, maybe the setMarker isn't fast enough
The error from the log:
java.lang.NullPointerException: Attempt to read from field 'android.graphics.Rect androidx.recyclerview.widget.RecyclerView$LayoutParams.mDecorInsets' on a null object reference in method 'int androidx.recyclerview.widget.RecyclerView$LayoutManager.getLeftDecorationWidth(android.view.View)'
any other lines with Titanium classes in that error?
Sure:
[ERROR] InputEventReceiver: Exception dispatching input event. [ERROR] E/MessageQueue-JNI: Exception in MessageQueue callback: handleReceiveCallback [ERROR] E/MessageQueue-JNI: java.lang.NullPointerException: Attempt to read from field 'android.graphics.Rect androidx.recyclerview.widget.RecyclerView$LayoutParams.mDecorInsets' on a null object reference in method 'int androidx.recyclerview.widget.RecyclerView$LayoutManager.getLeftDecorationWidth(android.view.View)' [ERROR] E/MessageQueue-JNI: at androidx.recyclerview.widget.RecyclerView$LayoutManager.getLeftDecorationWidth(RecyclerView.java:9757) [ERROR] E/MessageQueue-JNI: at androidx.recyclerview.widget.RecyclerView$LayoutManager.getDecoratedLeft(RecyclerView.java:9650) [ERROR] E/MessageQueue-JNI: at androidx.recyclerview.widget.RecyclerView$LayoutManager$1.getChildStart(RecyclerView.java:7611) [ERROR] E/MessageQueue-JNI: at androidx.recyclerview.widget.ViewBoundsCheck.isViewWithinBoundFlags(ViewBoundsCheck.java:249) [ERROR] E/MessageQueue-JNI: at androidx.recyclerview.widget.RecyclerView$LayoutManager.isViewPartiallyVisible(RecyclerView.java:9946) [ERROR] E/MessageQueue-JNI: at ti.modules.titanium.ui.widget.listview.ListViewProxy.handleMarker(ListViewProxy.java:461) [ERROR] E/MessageQueue-JNI: at ti.modules.titanium.ui.widget.listview.ListViewAdapter.onBindViewHolder(ListViewAdapter.java:107) [ERROR] E/MessageQueue-JNI: at ti.modules.titanium.ui.widget.listview.ListViewAdapter.onBindViewHolder(ListViewAdapter.java:23) [ERROR] E/MessageQueue-JNI: at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:7065) [ERROR] E/MessageQueue-JNI: at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:7107) [ERROR] E/MessageQueue-JNI: at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:6012) [ERROR] E/MessageQueue-JNI: at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6279) [ERROR] E/MessageQueue-JNI: at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6118) [ERROR] E/MessageQueue-JNI: at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6114) [ERROR] E/MessageQueue-JNI: at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2303) [ERROR] E/MessageQueue-JNI: at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1627) [ERROR] E/MessageQueue-JNI: at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1587) [ERROR] E/MessageQueue-JNI: at androidx.recyclerview.widget.LinearLayoutManager.scrollBy(LinearLayoutManager.java:1391) [ERROR] E/MessageQueue-JNI: at androidx.recyclerview.widget.LinearLayoutManager.scrollVerticallyBy(LinearLayoutManager.java:1128) [ERROR] E/MessageQueue-JNI: at androidx.recyclerview.widget.RecyclerView.scrollStep(RecyclerView.java:1841) [ERROR] E/MessageQueue-JNI: at androidx.recyclerview.widget.RecyclerView.scrollByInternal(RecyclerView.java:1940) [ERROR] E/MessageQueue-JNI: at androidx.recyclerview.widget.RecyclerView.onTouchEvent(RecyclerView.java:3391) [ERROR] E/MessageQueue-JNI: at android.view.View.dispatchTouchEvent(View.java:15076) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3917) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3581) [ERROR] E/MessageQueue-JNI: at ti.modules.titanium.ui.widget.listview.TiNestedRecyclerView.dispatchTouchEvent(TiNestedRecyclerView.java:110) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923) [ERROR] E/MessageQueue-JNI: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597) [ERROR] E/MessageQueue-JNI: at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:1016) [ERROR] E/MessageQueue-JNI: at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1962) [ERROR] E/MessageQueue-JNI: at android.app.Activity.dispatchTouchEvent(Activity.java:4265) [ERROR] E/MessageQueue-JNI: at androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:69) [ERROR] E/MessageQueue-JNI: at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:974) [ERROR] E/MessageQueue-JNI: at android.view.View.dispatchPointerEvent(View.java:15335) [ERROR] E/MessageQueue-JNI: at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:7815) [ERROR] E/MessageQueue-JNI: at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:7588) [ERROR] E/MessageQueue-JNI: at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6922) [ERROR] E/MessageQueue-JNI: at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:6979) [ERROR] E/MessageQueue-JNI: at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:6945) [ERROR] E/MessageQueue-JNI: at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:7143) [ERROR] E/MessageQueue-JNI: at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:6953) [ERROR] E/MessageQueue-JNI: at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:7200) [ERROR] E/MessageQueue-JNI: at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6926) [ERROR] E/MessageQueue-JNI: at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:6979) [ERROR] E/MessageQueue-JNI: at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:6945) [ERROR] E/MessageQueue-JNI: at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:6953) [ERROR] E/MessageQueue-JNI: at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6926) [ERROR] E/MessageQueue-JNI: at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:10400) [ERROR] E/MessageQueue-JNI: at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:10248) [ERROR] E/MessageQueue-JNI: at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:10204) [ERROR] E/MessageQueue-JNI: at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:10532) [ERROR] E/MessageQueue-JNI: at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:259) [ERROR] E/MessageQueue-JNI: at android.os.MessageQueue.nativePollOnce(Native Method) [ERROR] E/MessageQueue-JNI: at android.os.MessageQueue.next(MessageQueue.java:335) [ERROR] E/MessageQueue-JNI: at android.os.Looper.loopOnce(Looper.java:186) [ERROR] E/MessageQueue-JNI: at android.os.Looper.loop(Looper.java:313) [ERROR] E/MessageQueue-JNI: at android.app.ActivityThread.main(ActivityThread.java:8669) [ERROR] E/MessageQueue-JNI: at java.lang.reflect.Method.invoke(Native Method) [ERROR] E/MessageQueue-JNI: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) [ERROR] E/MessageQueue-JNI: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
but that is with 9.3.1 again, correct?
The isVisible
check is different in SDK >= 11
Yeah I've a new version in developing using sdk 11 but trying to fixing the sdk 9 in production now
if you want to patch your 9.3.x then have a look at the current implementation:
https://github.com/tidev/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/widget/listview/ListViewProxy.java#L662
and move that over to 9.x. It's the last line in Ti, the other classes its going in are native classes. So have to make the check in that line
It's possible that I cannot find the file in 9.3.2 ?
I've linked it above: https://github.com/tidev/titanium_mobile/blob/9_3_X/android/modules/ui/src/java/ti/modules/titanium/ui/widget/listview/ListViewProxy.java#L461
thats the 9.3.x branch
Yep I saw it maybe is my fault but if I go to the folder in OSX where are stored the SDKs I cannot find the lines your're pointing, I will check
you have to build a custom SDK for Android, you can't just change the lines in an existing SDK
Ok so I were understanding it right, sorry for the misunderstood