FolioReader / FolioReader-Android

A Java ePub reader and parser framework for Android.
BSD 3-Clause "New" or "Revised" License
2.25k stars 720 forks source link

Not supporting all types epub ? #159

Closed devendroid closed 6 years ago

devendroid commented 6 years ago

Its not supporting all epubs i checked with some of the epubs that's opening by iBook and calibre but not showing or getting crashed in FR, What is criteria to show epub by FR ?

One of them this epub is not showing contents !

Error Log:

Error: java.lang.NullPointerException : Attempt to invoke virtual method 'java.lang.String org.readium.r2_streamer.model.publication.link.Link.getTypeLink()' on a null object reference                                                                           
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String org.readium.r2_streamer.model.publication.link.Link.getTypeLink()' on a null object reference
at org.readium.r2_streamer.server.handler.ResourceHandler.get(ResourceHandler.java:65)
at fi.iki.elonen.router.RouterNanoHTTPD$UriResource.process(RouterNanoHTTPD.java:384)
at fi.iki.elonen.router.RouterNanoHTTPD$UriRouter.process(RouterNanoHTTPD.java:596)
at fi.iki.elonen.router.RouterNanoHTTPD.serve(RouterNanoHTTPD.java:671)
at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
at java.lang.Thread.run(Thread.java:818)

java.io.FileNotFoundException: http://127.0.0.1:8080/hindi1/OEBPS/Text/Chapter%201.html
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:238)
at com.folioreader.ui.base.HtmlTask.doInBackground(HtmlTask.java:38)
at com.folioreader.ui.base.HtmlTask.doInBackground(HtmlTask.java:22)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
vikasrairajput commented 6 years ago

Hey, i resolved this issue In HtmlTask class remove space in string String strUrl = urls[0]; String withoutSpace= strUrl.replaceAll("\u0020", "%20"); try { URL url = new URL(withoutSpace); URLConnection urlConnection = url.openConnection(); InputStream inputStream = urlConnection.getInputStream(); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, AppUtil.charsetNameForURLConnection(urlConnection))); StringBuilder stringBuilder = new StringBuilder(); String line; while ((line = bufferedReader.readLine()) != null) { stringBuilder.append(line); } return stringBuilder.toString(); } catch (IOException e) { Log.e(TAG, "HtmlTask failed", e); } return null; }

devendroid commented 6 years ago

@vikasrairajput thanks for your comment, but my issue did not resolved, did you check my given epub file, is this showing at your end ?

vikasrairajput commented 6 years ago

sorry,your epub also not working on my side..

hrishikesh-kadam commented 6 years ago

@devsideal This bug has been fixed in r2-streamer-java v0.1.3 - https://github.com/readium/r2-streamer-java/commit/3f613515a5967e148660cf45c11461acad5284a6

And integreated this version of r2-streamer-java in v0.3.5 of FolioReader. Also you can use v0.3.6 which makes FolioReader as a Singleton.

@mahavir155 @GautamChibde We can close this issue.