| 205 | } |
| 206 | |
| 207 | protected void loadDocument(final OnException onException) { |
| 208 | worker.add(new Worker.Task() { |
| 209 | int chapterCount = 0; |
| 210 | int pageCount = 0; |
| 211 | public void work() { |
| 212 | chapterCount = doc.countChapters(); |
| 213 | pageCount = doc.countPages(); |
| 214 | if (acceleratorPath != null) |
| 215 | doc.saveAccelerator(acceleratorPath); |
| 216 | } |
| 217 | public void run() { |
| 218 | callback.onChapterCountChange(chapterCount); |
| 219 | callback.onPageCountChange(pageCount); |
| 220 | loadOutline(onException); |
| 221 | refreshMetadata(onException); |
| 222 | if (currentPage != null) |
| 223 | gotoLocation(currentPage, onException); |
| 224 | else |
| 225 | gotoFirstPage(onException); |
| 226 | } |
| 227 | public void exception(Throwable t) { |
| 228 | if (onException != null) |
| 229 | onException.run(t); |
| 230 | } |
| 231 | }); |
| 232 | } |
| 233 | |
| 234 | public void relayoutDocument(final int width, final int height, final int em, final OnException onException) { |
| 235 | worker.add(new Worker.Task() { |