FolioReader / FolioReader-Android

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

how save the ReadLocator? #399

Open pppppbbbbb opened 4 years ago

pppppbbbbb commented 4 years ago

@Override public void saveReadLocator(ReadLocator readLocator) { Log.i(LOG_TAG, "-> saveReadLocator -> " + readLocator.toJson());

    /*ReadLocator has toJson() method which gives JSON in following format - 
    {
        bookId : string,
        href : string,
        created : integer,
        locations : {
            cfi : string
        }
    }
    You can save this last read position in your local or remote db*/
}

this fun don't run

pppppbbbbb commented 4 years ago

"Uncaught ReferenceError: DOMRect is not defined", source: file:///android_asset/js/Bridge.js (865)

pppppbbbbb commented 4 years ago

return new DOMRect(rectJson.x, rectJson.y, rectJson.width, rectJson.height);

pppppbbbbb commented 4 years ago

function constructDOMRect(rectJsonString) { var rectJson = JSON.parse(rectJsonString); var drect = {top:rectJson.y, right:rectJson.x+rectJson.width, bottom:rectJson.y+rectJson.height,left:rectJson.x}; return drect; }

I rewrite this fun can save ReadLocator;

marvoceo commented 4 years ago

How were you able to fix it?

pppppbbbbb commented 4 years ago

How were you able to fix it?

rewrite JS function constructDOMRect(rectJsonString) {}

pppppbbbbb commented 4 years ago

do you have a sample code you can send me?

assets/Bridge.js --->rewrited

function constructDOMRect(rectJsonString) { var rectJson = JSON.parse(rectJsonString); var drect = {top:rectJson.y, right:rectJson.x+rectJson.width, bottom:rectJson.y+rectJson.height,left:rectJson.x}; return drect; }

marvoceo commented 4 years ago

Thanks. Much appreciated.

pppppbbbbb commented 4 years ago

Thanks. Much appreciated.

you're welcome , Is the problem solved?

marvoceo commented 4 years ago

noo, still not working

marvoceo commented 4 years ago

Still not getting any output from: @Override public void saveReadLocator(ReadLocator readLocator) { Log.i(LOG_TAG, "-> saveReadLocator -> " + readLocator.toJson());

}
marvoceo commented 4 years ago

What I have done so far:

  1. Created a file known as Bridge.js in the assets folder.(this is because I have included the Folio Reader Library in my gradle file)
  2. Copied the original Bridge.js from the FolioReader Library
  3. Made the change you had suggested.

Still getting zero output form the method: @override public void saveReadLocator(ReadLocator readLocator) { Log.i(LOG_TAG, "-> saveReadLocator -> " + readLocator.toJson());

}

pppppbbbbb commented 4 years ago

can you give me your email? I'll send you the FolioReader lib. but I change something. The lib is used locally. src/folioreaderlib

y-ziane commented 3 years ago

can you give me your email? I'll send you the FolioReader lib. but I change something. The lib is used locally. src/folioreaderlib.

can you help me too, I'm stuck, cant get it to work :(

pppppbbbbb commented 3 years ago

can you give me your email? I'll send you the FolioReader lib. but I change something. The lib is used locally. src/folioreaderlib.

can you help me too, I'm stuck, cant get it to work :(

find the .js file rewirte this funtion

function constructDOMRect(rectJsonString) { var rectJson = JSON.parse(rectJsonString); var drect = {top:rectJson.y, right:rectJson.x+rectJson.width, bottom:rectJson.y+rectJson.height,left:rectJson.x}; return drect; }

pppppbbbbb commented 3 years ago

can you give me your email? I'll send you the FolioReader lib. but I change something. The lib is used locally. src/folioreaderlib.

can you help me too, I'm stuck, cant get it to work :(

source: file:///android_asset/js/Bridge.js (865)