当前位置: 首页>>代码示例>>Java>>正文


Java Book.getCoverImage方法代码示例

本文整理汇总了Java中nl.siegmann.epublib.domain.Book.getCoverImage方法的典型用法代码示例。如果您正苦于以下问题:Java Book.getCoverImage方法的具体用法?Java Book.getCoverImage怎么用?Java Book.getCoverImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nl.siegmann.epublib.domain.Book的用法示例。


在下文中一共展示了Book.getCoverImage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readEpubMetadata

import nl.siegmann.epublib.domain.Book; //导入方法依赖的package包/类
private void readEpubMetadata(final String filename, final File f, final EBook ebk) {
    ebk.addFileType("epub");
    ebk.setBook_title(f.getName().substring(0, f.getName().length() - 5));
    ebk.setFull_file_dir_name(ebk.getFile_dir() + File.separator + ebk.getBook_title());
    long flen = f.length();
    if (flen < 24500000) {
        try {
            InputStream epubInputStream = new FileInputStream(filename);
            Book book = erdr.readEpub(epubInputStream);

            ebk.addAuthors(book.getMetadata().getAuthors());
            ebk.setBook_title(book.getTitle());
            Resource cvrImg = book.getCoverImage();
            if (cvrImg != null) {
                ebk.setCoverImageFromBitmap(BitmapFactory.decodeStream(cvrImg.getInputStream()));
            }
            epubInputStream.close();
        } catch (IOException e) {
            BookLibApplication.e(LOG_TAG + "Failed to read epub details from [" + filename + "] " + e.getMessage());
        } catch (NullPointerException npe) {
            BookLibApplication.e(LOG_TAG + "NullPointerException reading epub details from [" + filename + "] " + npe.getMessage());
        }
    } else {
        BookLibApplication.d(LOG_TAG + "Skipping Large epub [filename: " + filename + ", size: " + f.length() + "]");
    }
}
 
开发者ID:mrspaceman,项目名称:ebookmgr,代码行数:27,代码来源:LibraryScanner.java

示例2: generateCoverPage

import nl.siegmann.epublib.domain.Book; //导入方法依赖的package包/类
private String generateCoverPage(Book book) {
	
	String centerpiece;
	
	//Else we construct a basic front page with title and author.
	if ( book.getCoverImage() == null ) {												
		centerpiece = "<center><h1>" + (book.getTitle() != null ? book.getTitle(): "Book without a title") + "</h1>";
		
		if ( ! book.getMetadata().getAuthors().isEmpty() ) {						
			for ( Author author: book.getMetadata().getAuthors() ) {							
				centerpiece += "<h3>" + author.getFirstname() + " " + author.getLastname() + "</h3>";
			}
		} else {
			centerpiece += "<h3>Unknown author</h3>";
		}

           centerpiece += "</center>";

	} else {
		//If the book has a cover image, we display that
		centerpiece = "<img src='" + book.getCoverImage().getHref() + "'>";
	}		
	
	return "<html><body>" + centerpiece + "</body></html>";
}
 
开发者ID:benjamarle,项目名称:typhon,代码行数:26,代码来源:TyphonSpine.java

示例3: RBook

import nl.siegmann.epublib.domain.Book; //导入方法依赖的package包/类
/**
 * Create an {@link RBook} from a {@link SuperBook}.
 * <p>
 * {@link SuperBook}s are guaranteed to have a non-null, non-empty path, title, and author.
 * @param superBook The {@link SuperBook} to use.
 */
public RBook(SuperBook superBook) {
    // Fill in data from SuperBook.
    this.relPath = superBook.getPath();
    this.hash = superBook.getHash();

    // Fill in data from Book file.
    Book book = superBook.getBook();
    this.title = book.getTitle().getValue();
    this.author = DataUtils.getFirstAuthor(book);
    this.desc = DataUtils.getFirstDesc(book);
    this.subjects = DataUtils.concatDEList(book.getMetadata().getSubjects(), LIST_SEP);
    this.types = DataUtils.concatDEList(book.getMetadata().getTypes(), LIST_SEP);
    this.format = book.getMetadata().getFormat();
    this.language = DataUtils.concatDEList(book.getMetadata().getLanguages(), LIST_SEP);
    this.publisher = DataUtils.getFirstPublisher(book);
    Identifier identifier = Identifier.getBookIdIdentifier(book.getMetadata().getIdentifiers());
    this.bookId = identifier == null ? null : identifier.toString();
    this.createDate = DataUtils.getFirstBookDate(book, nl.siegmann.epublib.domain.Date.Event.CREATION);
    this.pubDate = DataUtils.getFirstBookDate(book, nl.siegmann.epublib.domain.Date.Event.PUBLICATION);
    this.modDate = DataUtils.getFirstBookDate(book, nl.siegmann.epublib.domain.Date.Event.MODIFICATION);
    this.numChaps = book.getTableOfContents().getAllUniqueResources().size();
    if (book.getCoverImage() != null) {
        try {
            // Get the cover image and store it.
            DataUtils.saveStreamAsCoverImage(book.getCoverImage().getInputStream(), relPath);
            hasCoverImage = true;
        } catch (IOException e) {
            e.printStackTrace();
            hasCoverImage = false;
        }
    } else hasCoverImage = false;

    // Fill in other data.
    this.lastImportDate = Calendar.getInstance().getTime();
    this.lastModifiedDate = lastImportDate;
    this.lastReadDate = null;
    this.isInRecents = false;
    this.rating = 0;
    this.isNew = true;
    this.isUpdated = false;
    this.uniqueId = UniqueIdFactory.getInstance().nextId(RBook.class);
}
 
开发者ID:bkromhout,项目名称:Minerva,代码行数:49,代码来源:RBook.java

示例4: storeBook

import nl.siegmann.epublib.domain.Book; //导入方法依赖的package包/类
@Override
public void storeBook(String fileName, Book book, boolean updateLastRead, boolean copyFile) throws IOException {
	
	File bookFile = new File(fileName);
	
	boolean hasBook = hasBook(bookFile.getName());
	
	if ( hasBook && !updateLastRead ) {
		return;
	} else if ( hasBook ) {
		helper.updateLastRead(bookFile.getName(), -1);
		return;
	}				
	
	Metadata metaData = book.getMetadata();
   	
   	String authorFirstName = "Unknown author";
   	String authorLastName = "";
   	
   	if ( metaData.getAuthors().size() > 0 ) {
   		authorFirstName = metaData.getAuthors().get(0).getFirstname();
   		authorLastName = metaData.getAuthors().get(0).getLastname();
   	}
   	
   	Option<byte[]> thumbNail = none();
   	
   	try {
   		if ( book.getCoverImage() != null && book.getCoverImage().getSize() < MAX_COVER_SIZE ) {    			
   			thumbNail = resizeImage(book.getCoverImage().getData());
   			book.getCoverImage().close();
   		}
   	} catch (IOException | OutOfMemoryError e) {
   		//If the image resource is too big, just import without a cover.
   	}
	
   	String description = "";
   	
   	if ( ! metaData.getDescriptions().isEmpty() ) {
   		description = metaData.getDescriptions().get(0);
   	}
   	
   	String title = book.getTitle();
   	
   	if ( title.trim().length() == 0 ) {    		
		title = fileName.substring( fileName.lastIndexOf('/') + 1 );
	}		
   	
	if ( copyFile ) {

		Option<File> copiedFile = copyToLibrary(fileName, authorLastName + ", " + authorFirstName, title );

		if ( ! isEmpty(copiedFile) ) {
			bookFile = copiedFile.unsafeGet();
		}
	}
   	
	this.helper.storeNewBook(bookFile.getAbsolutePath(),
			authorFirstName, authorLastName, title,
			description, thumbNail.unsafeGet(),
               updateLastRead);
	
}
 
开发者ID:benjamarle,项目名称:typhon,代码行数:63,代码来源:SqlLiteLibraryService.java


注:本文中的nl.siegmann.epublib.domain.Book.getCoverImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。