public void updateMetaUi() { Book book = mSpritzer.getBook(); Metadata meta = book.getMetadata(); Author author = meta.getAuthors().get(0); int curChapter = mSpritzer.getCurrentChapter(); mAuthorView.setText(author.getFirstname() + " " + author.getLastname()); mTitleView.setText(meta.getFirstTitle()); String chapterText; if (book.getSpine().getResource(curChapter).getTitle() == null || book.getSpine().getResource(curChapter).getTitle().trim().compareTo("") == 0) { chapterText = String.format("Chapter %d", curChapter); } else { chapterText = book.getSpine().getResource(curChapter).getTitle(); } int startSpan = chapterText.length(); chapterText = String.format( "%s %s m left", chapterText, (mSpritzer.getMinutesRemainingInQueue() == 0) ? "<1" : String.valueOf(mSpritzer.getMinutesRemainingInQueue())); int endSpan = chapterText.length(); Spannable spanRange = new SpannableString(chapterText); TextAppearanceSpan tas = new TextAppearanceSpan(mChapterView.getContext(), R.style.MinutesToGo); spanRange.setSpan(tas, startSpan, endSpan, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); mChapterView.setText(spanRange); mProgress.setMax(mSpritzer.getMaxChapter()); mProgress.setProgress(curChapter); }
public void feedEpubToSpritzer(Uri epubPath) { if (mSpritzer == null) { mSpritzer = new EpubSpritzer(mSpritzView, epubPath); mSpritzer.setEventBus(mBus); } else { mSpritzer.setEpubPath(epubPath); } updateMetaUi(); }
@Override public void onStart() { super.onStart(); mBus = new Bus(ThreadEnforcer.ANY); mBus.register(this); if (mSpritzer == null) { mSpritzView.setText(getActivity().getString(R.string.select_epub)); } else { mSpritzer.setEventBus(mBus); mSpritzer.swapTextView(mSpritzView); if (!mSpritzer.isPlaying()) { updateMetaUi(); showMetaUi(true); } } }
@Override public void onStop() { super.onStop(); if (mSpritzer != null) { Log.i(TAG, "saving state"); mSpritzer.saveState(); } }
@Override public void onStart() { super.onStart(); mBus = new Bus(ThreadEnforcer.ANY); mBus.register(this); if (mSpritzer == null) { mSpritzer = new EpubSpritzer(mSpritzView); if (mSpritzer.getBook() == null) { mSpritzView.setText(getString(R.string.select_epub)); } else { // EpubSpritzer loaded the last book being reads updateMetaUi(); showMetaUi(true); } } else { mSpritzer.setEventBus(mBus); mSpritzer.swapTextView(mSpritzView); if (!mSpritzer.isPlaying()) { updateMetaUi(); showMetaUi(true); } } }