Skip to content
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

android.view.ViewRootImpl cannot be cast to android.view.View #94

Open
KevinColemanInc opened this issue Mar 25, 2015 · 2 comments
Open

Comments

@KevinColemanInc
Copy link

Any ideas why I am I getting this error? Running version 1.5.0

  java.lang.ClassCastException: android.view.ViewRootImpl cannot be cast to android.view.View
        at com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView.onTouchEvent(ObservableRecyclerView.java:227)
        at android.view.View.dispatchTouchEvent(View.java:7706)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2210)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1945)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2068)
        at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1515)
        at android.app.Activity.dispatchTouchEvent(Activity.java:2458)
        at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2016)
        at android.view.View.dispatchPointerEvent(View.java:7886)
        at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:3947)
        at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3826)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3392)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3442)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3411)
        at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3518)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3419)
        at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3575)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3392)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3442)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3411)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3419)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3392)
        at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5532)
        at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5512)
        at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5483)
        at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5612)
        at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
        at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
        at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:176)
        at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:5585)
        at android.view.ViewRootImpl$ConsumeBatchedInputRun

edit:
seems to happen when I scroll down on a recyclerview that is smaller than the screen (aka, no scrolling necessary)

@KevinColemanInc
Copy link
Author

I grabbed the source code and I did this in ObservableRecyclerView.java:227:

  for (View v = this; v != null && v != parent; ) {
      ViewParent temp = v.getParent();
      if (temp instanceof View) {
          v = (View) temp;
          offsetX += v.getLeft() - v.getScrollX();
          offsetY += v.getTop() - v.getScrollY();
      }
      else
      {break;}
  }

and it seemed to fix it.

@mobiRic
Copy link

mobiRic commented Oct 27, 2016

I stumbled across this post when searching on the same bug. Turns out it has been around for a while, and is logged with google here:

In case that helps you guys, or any future readers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants