use of org.geometerplus.fbreader.bookmodel.BookModel in project FBReaderJ by geometer.
the class FBReader method onResume.
@Override
protected void onResume() {
super.onResume();
myStartTimer = true;
Config.Instance().runOnConnect(new Runnable() {
public void run() {
SyncOperations.enableSync(FBReader.this, myFBReaderApp.SyncOptions);
final int brightnessLevel = getZLibrary().ScreenBrightnessLevelOption.getValue();
if (brightnessLevel != 0) {
getViewWidget().setScreenBrightness(brightnessLevel);
} else {
setScreenBrightnessAuto();
}
if (getZLibrary().DisableButtonLightsOption.getValue()) {
setButtonLight(false);
}
getCollection().bindToService(FBReader.this, new Runnable() {
public void run() {
final BookModel model = myFBReaderApp.Model;
if (model == null || model.Book == null) {
return;
}
onPreferencesUpdate(myFBReaderApp.Collection.getBookById(model.Book.getId()));
}
});
}
});
registerReceiver(myBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
IsPaused = false;
myResumeTimestamp = System.currentTimeMillis();
if (OnResumeAction != null) {
final Runnable action = OnResumeAction;
OnResumeAction = null;
action.run();
}
registerReceiver(mySyncUpdateReceiver, new IntentFilter(FBReaderIntents.Event.SYNC_UPDATED));
SetScreenOrientationAction.setOrientation(this, getZLibrary().getOrientationOption().getValue());
if (myCancelIntent != null) {
final Intent intent = myCancelIntent;
myCancelIntent = null;
getCollection().bindToService(this, new Runnable() {
public void run() {
runCancelAction(intent);
}
});
return;
} else if (myOpenBookIntent != null) {
final Intent intent = myOpenBookIntent;
myOpenBookIntent = null;
getCollection().bindToService(this, new Runnable() {
public void run() {
openBook(intent, null, true);
}
});
} else if (myFBReaderApp.getCurrentServerBook(null) != null) {
getCollection().bindToService(this, new Runnable() {
public void run() {
myFBReaderApp.useSyncInfo(true, myNotifier);
}
});
} else if (myFBReaderApp.Model == null && myFBReaderApp.ExternalBook != null) {
getCollection().bindToService(this, new Runnable() {
public void run() {
myFBReaderApp.openBook(myFBReaderApp.ExternalBook, null, null, myNotifier);
}
});
} else {
getCollection().bindToService(this, new Runnable() {
public void run() {
myFBReaderApp.useSyncInfo(true, myNotifier);
}
});
}
PopupPanel.restoreVisibilities(myFBReaderApp);
ApiServerImplementation.sendEvent(this, ApiListener.EVENT_READ_MODE_OPENED);
}
use of org.geometerplus.fbreader.bookmodel.BookModel in project FBReaderJ by geometer.
the class TestFB2Reader method testImageSize.
public void testImageSize() {
BookModel model = new BookModel(myDirectory + "image.fb2");
new FB2Reader(model).read();
ZLImage image = model.getImageMap().getImage("cover.jpg");
ZLImageData imageData = ZLImageManager.getInstance().getImageData(image);
ZLSwingPaintContext paint = new ZLSwingPaintContext();
assertTrue(paint.imageHeight(imageData) == 277);
assertTrue(paint.imageWidth(imageData) == 200);
}
use of org.geometerplus.fbreader.bookmodel.BookModel in project FBReaderJ by geometer.
the class TestFB2Reader method testAnnotationBeforeBodyParagraph.
public void testAnnotationBeforeBodyParagraph() {
BookModel bookModel = new BookModel(myDirectory + "annotation_before.fb2");
new FB2Reader(bookModel).read();
ZLTextModel model = bookModel.getBookTextModel();
assertEquals(model.getParagraph(1).getKind(), ZLTextParagraph.Kind.END_OF_SECTION_PARAGRAPH);
}
use of org.geometerplus.fbreader.bookmodel.BookModel in project FBReaderJ by geometer.
the class TestFB2Reader method testNotesSimple.
public void testNotesSimple() {
BookModel model = new BookModel(myDirectory + "simple_notes.fb2");
new FB2Reader(model).read();
assertNotNull(model.getFootnoteModel("1"));
}
use of org.geometerplus.fbreader.bookmodel.BookModel in project FBReaderJ by geometer.
the class TestFB2Reader method testImage.
/* public void testPnvs() {
FB2Reader reader = new FB2Reader("M:/Books/pnvs.fb2");
reader.read();
}
*/
public void testImage() {
BookModel model = new BookModel(myDirectory + "image.fb2");
new FB2Reader(model).read();
byte[] image = (model.getImageMap().getImage("cover.jpg")).byteData();
try {
BufferedImage img = ImageIO.read(new ByteArrayInputStream(image));
ImageIO.write(img, "jpg", new File(myDirectory + "img.jpg"));
} catch (IOException e) {
fail();
}
}
Aggregations