Topener / nl.fokkezb.pullToRefresh

Widget to implement a table pull-to-refresh header in Titanium Alloy
184 stars 60 forks source link

Uncaught Error in Android 6.0.1 #63

Closed riveraser closed 7 years ago

riveraser commented 8 years ago

screenshot_20160713-154834

Hi there, I got this issue when trying on my phone... I use Titanium SDK 5.2.0 /// Funny thing is that this works perfectly on my emulators..

This is my code:

  <Widget id="ptr" src="nl.fokkezb.pullToRefresh" onRelease="myRefresher">
        <ListView id="listView" defaultItemTemplate="template" onItemclick="onItemClick">
            <Templates>
                    <ItemTemplate name="template" class="itemContenedor" >
                        <View>
                            <ImageView bindId="imgNota" class="imagenLista" defaultImage="/images/imgDefault.jpg"  />
                        </View>
                        <View class="contenedorTitulo" >
                            <Label bindId="title" id="title" /> 
                        </View>
                    </ItemTemplate>
                </Templates>
                <Widget id="listWidgetNotas" src="nl.fokkezb.infiniteScroll" onEnd="listLoader" />
                <ListSection id="section" dataCollection="notasHome" >
                    <ListItem notaid:id="{id}" title:text="{titulonota}" imgNota:image="{imageintro}" />
                </ListSection>
            </ListView>
        </Widget>
FokkeZB commented 8 years ago

The widget should wrap the ListView, not be a child of it. Please follow the steps in the readme:

https://github.com/FokkeZB/nl.fokkezb.pullToRefresh#usage

riveraser commented 8 years ago

Widget is the main element and the listview is inside the widget as you can see in the code I pasted..

....

Maybe you saw the Infiniti Scroller widget inside the list view....

FokkeZB commented 8 years ago

Sorry, indeed.

I've never seen this error before. It seems to be related to the setRefreshing code: https://github.com/FokkeZB/nl.fokkezb.pullToRefresh/blob/master/nl.fokkezb.pullToRefresh/controllers/widget.js#L79-L93

Could you play a little with different devices/emulators, leaving out init functions etc to see if you can narrow down perhaps?

riveraser commented 8 years ago

Full log here:

[WARN] : W/System.err: android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. [WARN] : W/System.err: at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:6024) [WARN] : W/System.err: at android.view.ViewRootImpl.invalidateChildInParent(ViewRootImpl.java:853) [WARN] : W/System.err: at android.view.ViewGroup.invalidateChild(ViewGroup.java:4320) [WARN] : W/System.err: at android.view.View.invalidate(View.java:10935) [WARN] : W/System.err: at android.view.View.invalidateParentIfNeeded(View.java:11021) [WARN] : W/System.err: at android.view.View.clearAnimation(View.java:16804) [WARN] : W/System.err: at android.support.v4.widget.SwipeRefreshLayout.startScaleDownAnimation(SwipeRefreshLayout.java:434) [WARN] : W/System.err: at android.support.v4.widget.SwipeRefreshLayout.setRefreshing(SwipeRefreshLayout.java:420) [WARN] : W/System.err: at android.support.v4.widget.SwipeRefreshLayout.setRefreshing(SwipeRefreshLayout.java:373) [WARN] : W/System.err: at com.rkam.swiperefreshlayout.SwipeRefresh.setRefreshing(SwipeRefresh.java:78) [WARN] : W/System.err: at com.rkam.swiperefreshlayout.SwipeRefreshProxy.setRefreshing(SwipeRefreshProxy.java:26) [WARN] : W/System.err: at org.appcelerator.kroll.runtime.v8.V8Object.nativeCallProperty(Native Method) [WARN] : W/System.err: at org.appcelerator.kroll.runtime.v8.V8Object.callProperty(V8Object.java:73) [WARN] : W/System.err: at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1155) [WARN] : W/System.err: at android.os.Handler.dispatchMessage(Handler.java:98) [WARN] : W/System.err: at android.os.Looper.loop(Looper.java:136) [WARN] : W/System.err: at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:118) [ERROR] : TiExceptionHandler: (main) [25066,128741] ----- Titanium Javascript Runtime Error ----- [ERROR] : TiExceptionHandler: (main) [0,128741] - In undefined:25,24 [ERROR] : TiExceptionHandler: (main) [0,128741] - Message: Uncaught Error: Only the original thread that created a view hierarchy can touch its views. [ERROR] : TiExceptionHandler: (main) [0,128741] - Source: refreshControl.setRefreshing(false); [ERROR] : V8Exception: Exception occurred at undefined:25: Uncaught Error: Only the original thread that created a view hierarchy can touch its views. [WARN] : EGL_genymotion: eglSurfaceAttrib not implemented

FokkeZB commented 8 years ago

It looks like an error in the module. Could you try without the widget (following the instructions of the module) and report it there?

Topener commented 8 years ago

@riveraser have you tried @FokkeZB's comment?

fnando521 commented 7 years ago

The error occurs in widget.js:

refreshControl.setRefreshing(false);

Commenting this line out no longer causes the error, however, the loading indicator is never dimissed

FokkeZB commented 7 years ago

That seems like a module issue then. It could also depend on the module for you are using. I originally made it to work with https://github.com/iskugor/Ti.SwipeRefreshLayout#set-refreshing but some people also use e.g. http://gitt.io/component/com.rkam.swiperefreshlayout.

Please play around with these module forks and report the bug at the relevant repo if neither of them work.

hansemannn commented 7 years ago

Fixed it, the issue was related to the UI-thread.

FokkeZB commented 7 years ago