bduncavage / PullToRefresharp

A pull-to-refresh library for Android in C#
38 stars 78 forks source link

Crash - with list is in startup view and touching screen upon startup #10

Open robin-raymond opened 10 years ago

robin-raymond commented 10 years ago

Android (Galaxy S4)

Crashed on:

        public override bool OnInterceptTouchEvent(MotionEvent ev)
        {
           ...
            if (ev.ActionMasked == MotionEventActions.Down && ContentView.IsAtTop

-and-

        public override bool OnTouchEvent(MotionEvent e)
        {
                    ...
                    last_touch_y = ContentView.IsAtTop ? (int)e.RawY : -1;

There's a race condition where the content view is not set before the touch events arrive, i.e. the "OnGlobalLayout" gets called after the touch events arrive if you are touching the list view while the screen is still loading/rendering.

        public void OnGlobalLayout()
        {
                ...
                if (content_view_res_id > 0) {
                    ContentView = (IPullToRefresharpWrappedView)FindViewById<View>(content_view_res_id);
                } else {
                    ContentView = (IPullToRefresharpWrappedView)GetChildAt(1);
                }
bduncavage commented 10 years ago

Can yo make a pull request for that fix? I'll merge it in then.