(final String bookURL)
| 1232 | } |
| 1233 | |
| 1234 | public final Book openBook(final String bookURL) |
| 1235 | throws IOException, BookException { |
| 1236 | |
| 1237 | //#debug |
| 1238 | AlbiteMIDlet.LOGGER.log("Opening book..."); |
| 1239 | |
| 1240 | /* |
| 1241 | * If the book is already open, no need to load it again |
| 1242 | */ |
| 1243 | if (isBookOpen(bookURL)) { |
| 1244 | mode = MODE_PAGE_READING; |
| 1245 | return currentBook; |
| 1246 | } |
| 1247 | |
| 1248 | /* |
| 1249 | * try to open the book |
| 1250 | */ |
| 1251 | //#debug |
| 1252 | AlbiteMIDlet.LOGGER.log("Trying to open..."); |
| 1253 | Book newBook = null; |
| 1254 | |
| 1255 | newBook = Book.open(bookURL); |
| 1256 | |
| 1257 | /* |
| 1258 | * All was OK, let's close current book |
| 1259 | */ |
| 1260 | closeBook(); |
| 1261 | |
| 1262 | currentBook = newBook; |
| 1263 | |
| 1264 | //#if !(TinyMode || TinyModeExport || LightMode || LightModeExport) |
| 1265 | /* |
| 1266 | * load hyphenator according to book language |
| 1267 | */ |
| 1268 | loadHyphenator(currentBook.getLanguage()); |
| 1269 | //#endif |
| 1270 | /* |
| 1271 | * Reset the Toc |
| 1272 | */ |
| 1273 | app.resetToc(); |
| 1274 | |
| 1275 | /* |
| 1276 | * Go to position and effectively reflow chapter |
| 1277 | */ |
| 1278 | goToPosition(currentBook.getCurrentChapter(), |
| 1279 | currentBook.getCurrentChapterPosition()); |
| 1280 | |
| 1281 | mode = MODE_PAGE_READING; |
| 1282 | |
| 1283 | return currentBook; |
| 1284 | } |
| 1285 | |
| 1286 | private void closeBook() { |
| 1287 | if (isBookOpen()) { |
no test coverage detected