mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-06 03:50:19 +02:00
possible fix for NPE in 1.9.5
This commit is contained in:
parent
411de48080
commit
9f90ace124
3 changed files with 13 additions and 21 deletions
|
@ -442,6 +442,16 @@ public final class FBReader extends Activity implements ZLApplicationWindow {
|
||||||
if (getZLibrary().DisableButtonLightsOption.getValue()) {
|
if (getZLibrary().DisableButtonLightsOption.getValue()) {
|
||||||
setButtonLight(false);
|
setButtonLight(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCollection().bindToService(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()));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -449,16 +459,6 @@ public final class FBReader extends Activity implements ZLApplicationWindow {
|
||||||
|
|
||||||
PopupPanel.restoreVisibilities(myFBReaderApp);
|
PopupPanel.restoreVisibilities(myFBReaderApp);
|
||||||
ApiServerImplementation.sendEvent(this, ApiListener.EVENT_READ_MODE_OPENED);
|
ApiServerImplementation.sendEvent(this, ApiListener.EVENT_READ_MODE_OPENED);
|
||||||
|
|
||||||
getCollection().bindToService(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()));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,11 +25,9 @@ import java.util.*;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.filesystem.*;
|
import org.geometerplus.zlibrary.core.filesystem.*;
|
||||||
import org.geometerplus.zlibrary.core.image.ZLImage;
|
import org.geometerplus.zlibrary.core.image.ZLImage;
|
||||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
|
||||||
import org.geometerplus.zlibrary.core.util.MiscUtil;
|
import org.geometerplus.zlibrary.core.util.MiscUtil;
|
||||||
import org.geometerplus.zlibrary.core.util.RationalNumber;
|
import org.geometerplus.zlibrary.core.util.RationalNumber;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.Paths;
|
|
||||||
import org.geometerplus.fbreader.bookmodel.BookReadingException;
|
import org.geometerplus.fbreader.bookmodel.BookReadingException;
|
||||||
import org.geometerplus.fbreader.formats.*;
|
import org.geometerplus.fbreader.formats.*;
|
||||||
import org.geometerplus.fbreader.sort.TitledEntity;
|
import org.geometerplus.fbreader.sort.TitledEntity;
|
||||||
|
@ -157,12 +155,6 @@ public class Book extends TitledEntity {
|
||||||
final int index = fileName.lastIndexOf('.');
|
final int index = fileName.lastIndexOf('.');
|
||||||
setTitle(index > 0 ? fileName.substring(0, index) : fileName);
|
setTitle(index > 0 ? fileName.substring(0, index) : fileName);
|
||||||
}
|
}
|
||||||
final String demoPathPrefix = Paths.mainBookDirectory() + "/Demos/";
|
|
||||||
if (File.getPath().startsWith(demoPathPrefix)) {
|
|
||||||
final String demoTag = ZLResource.resource("library").getResource("demo").getValue();
|
|
||||||
setTitle(getTitle() + " (" + demoTag + ")");
|
|
||||||
addTag(demoTag);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadLists(BooksDatabase database) {
|
void loadLists(BooksDatabase database) {
|
||||||
|
|
|
@ -114,7 +114,7 @@ public class BookCollection extends AbstractBookCollection {
|
||||||
}
|
}
|
||||||
|
|
||||||
book = myDatabase.loadBook(id);
|
book = myDatabase.loadBook(id);
|
||||||
if (book == null || !book.File.exists()) {
|
if (book == null || book.File == null || !book.File.exists()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
book.loadLists(myDatabase);
|
book.loadLists(myDatabase);
|
||||||
|
@ -130,7 +130,7 @@ public class BookCollection extends AbstractBookCollection {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileInfoSet fileInfos = new FileInfoSet(myDatabase, physicalFile);
|
final FileInfoSet fileInfos = new FileInfoSet(myDatabase, physicalFile);
|
||||||
if (fileInfos.check(physicalFile, physicalFile != bookFile)) {
|
if (fileInfos.check(physicalFile, physicalFile != bookFile)) {
|
||||||
// loaded from db
|
// loaded from db
|
||||||
addBook(book, false);
|
addBook(book, false);
|
||||||
|
@ -358,7 +358,7 @@ public class BookCollection extends AbstractBookCollection {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Book getRecentBook(int index) {
|
public Book getRecentBook(int index) {
|
||||||
List<Long> recentIds = myDatabase.loadRecentBookIds();
|
final List<Long> recentIds = myDatabase.loadRecentBookIds();
|
||||||
return recentIds.size() > index ? getBookById(recentIds.get(index)) : null;
|
return recentIds.size() > index ? getBookById(recentIds.get(index)) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue