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

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.view.ViewGroup.dispatchTouchEvent(android.view.MotionEvent)' on a null object reference #239

Closed
ngokhongkn opened this issue Jul 10, 2018 · 6 comments

Comments

@ngokhongkn
Copy link

07-10 08:43:55.768 32514-32514/de.zweidenker.rheinwerk_reader E/AndroidRuntime: FATAL EXCEPTION: main
Process: de.zweidenker.rheinwerk_reader, PID: 32514
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.view.ViewGroup.dispatchTouchEvent(android.view.MotionEvent)' on a null object reference
at com.folioreader.view.FolioWebView.computeHorizontalScroll(FolioWebView.java:121)
at com.folioreader.view.FolioWebView.onTouchEvent(FolioWebView.java:108)
at android.view.View.dispatchTouchEvent(View.java:10779)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2859)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2535)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2492)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2492)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2492)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2492)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2492)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2492)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2492)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2492)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2492)
at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:582)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1885)
at android.app.Activity.dispatchTouchEvent(Activity.java:3240)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:71)

@udfvirus
Copy link

Add to FolioWebView.java if (webViewPager! = Null) webViewPager.dispatchTouchEvent (event);

@hrishikesh-kadam
Copy link
Contributor

hrishikesh-kadam commented Jul 11, 2018

@ngokhongkn Can you please share EPUB file with us so that we can investigate?

@javavirys the solution you proposed would not make the Horizontal scrolling feature work. It would be helpful if you can share EPUB file with us.

This generally happens when JS Horizontal pagination code doesn't give callback to Java code -

function postInitHorizontalDirection() {
var htmlElement = document.getElementsByTagName('html')[0];
var bodyElement = document.getElementsByTagName('body')[0];
var bodyStyle = bodyElement.currentStyle || window.getComputedStyle(bodyElement);
var paddingTop = parseInt(bodyStyle.paddingTop, 10);
var paddingRight = parseInt(bodyStyle.paddingRight, 10);
var paddingBottom = parseInt(bodyStyle.paddingBottom, 10);
var paddingLeft = parseInt(bodyStyle.paddingLeft, 10);
var clientWidth = document.documentElement.clientWidth;
var scrollWidth = document.documentElement.scrollWidth;
//console.log("-> document.documentElement.offsetWidth = " + document.documentElement.offsetWidth);
if (scrollWidth > clientWidth
&& scrollWidth > document.documentElement.offsetWidth) {
scrollWidth += paddingRight;
}
var newBodyWidth = scrollWidth - (paddingLeft + paddingRight);
window.scrollWidth = scrollWidth;
htmlElement.style.width = scrollWidth + 'px';
bodyElement.style.width = newBodyWidth + 'px';
// pageCount deliberately rounded instead of ceiling to avoid any unexpected error
var pageCount = Math.round(scrollWidth / clientWidth);
var pageCountFloat = scrollWidth / clientWidth;
if (pageCount != pageCountFloat) {
console.warn("-> pageCount = " + pageCount + ", pageCountFloat = " + pageCountFloat
+ ", Something wrong in pageCount calculation");
}
//console.log("-> scrollWidth = " + scrollWidth);
//console.log("-> newBodyWidth = " + newBodyWidth);
//console.log("-> pageCount = " + pageCount);
FolioPageFragment.setHorizontalPageCount(pageCount);
}

@SuppressWarnings("unused")
@JavascriptInterface
public void setHorizontalPageCount(int horizontalPageCount) {
Log.v(LOG_TAG, "-> setHorizontalPageCount = " + horizontalPageCount
+ " -> " + spineItem.originalHref);
mWebview.setHorizontalPageCount(horizontalPageCount);
}

public void setHorizontalPageCount(int horizontalPageCount) {
this.horizontalPageCount = horizontalPageCount;
handler.post(new Runnable() {
@Override
public void run() {
if (webViewPager == null)
webViewPager = ((View) getParent()).findViewById(R.id.webViewPager);
webViewPager.setHorizontalPageCount(FolioWebView.this.horizontalPageCount);
}
});
}

@udfvirus
Copy link

Here's the epub
pub.zip

@hrishikesh-kadam
Copy link
Contributor

@javavirys I am unable to reproduce the issue.
Can you please give me exact steps?

@ngokhongkn
Copy link
Author

Hi everybody
When I switch very fast, this error occurs.
In my project, I use folioreader to open each html page and not use it to open the epub.
thanks everyone. I fixed it by check null

@hrishikesh-kadam
Copy link
Contributor

@mahavir155 I think this bug still exists due to the limitation of nanohttpd. Fast swiping between chapters leads to some connection problem between client and server.

Let's keep it open.

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

4 participants