/** * When checking a book contains a chapter SwordBook returns false if verse 0 is not in the chapter so this method compensates for that * * This can be removed if SwordBook.contains is converted to be containsAnyOf as discussed in JS-273 */ private boolean bookContainsAnyOf(Book book, Key key) { if (book.contains(key)) { return true; } for (Key aKey : key) { if (book.contains(aKey)) { return true; } } return false; } }
@Override public void setCurrentDocument(Book doc) { Log.d(TAG, "Set current doc to "+doc); Book prevDoc = currentDocument; if (!doc.equals(currentDocument) && !shareKeyBetweenDocs && getKey()!=null && !doc.contains(getKey())) { doSetKey(null); } localSetCurrentDocument(doc); // try to clear memory to prevent OutOfMemory errors if (!currentDocument.equals(prevDoc)) { Activator.deactivate(prevDoc); } }
private boolean isVerseInBook(Book document, Versification v11n, BibleBook bibleBook, int chapter, int verseNo ) { Verse verse = new Verse(v11n, bibleBook, chapter, verseNo); // no content for specified verse implies this verse clearly is not in this document if (!document.contains(verse)) { return false; } // IBT Synodal documents sometimes return stub data for missing verses in dc books e.g. <chapter eID="gen7" osisID="1Esd.1"/> if (isProbablyIBTDocument(document, v11n) && isProbablyEmptyVerseInDocument(document, verse)) { // it is just IBT dummy empty verse content return false; } return true; }
private void computeScope() { if (inScope == null) { Key all = book.getGlobalKeyList(); inScope = book.createEmptyKeyList(); outScope = book.createEmptyKeyList(); for (Key key : all) { if (book.contains(key)) { inScope.addAll(key); } else { outScope.addAll(key); } } } }
/** This is only called after the very first bible download to attempt to ensure the first page is not 'Verse not found' * go through a list of default verses until one is found in the first/only book installed */ public void setFirstUseDefaultVerse() { try { Versification versification = getCurrentPageManager().getCurrentBible().getVersification(); Verse[] defaultVerses = new Verse[] { new Verse(versification, BibleBook.JOHN,3,16), new Verse(versification, BibleBook.GEN,1,1), new Verse(versification, BibleBook.PS,1,1)}; List<Book> bibles = swordDocumentFacade.getBibles(); if (bibles.size()==1) { Book bible = bibles.get(0); for (Verse verse : defaultVerses) { if (bible.contains(verse)) { getCurrentPageManager().getCurrentBible().setKey(verse); return; } } } } catch (Exception e) { Log.e(TAG, "Verse error"); } }