• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SpineReference类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



SpineReference类属于nl.siegmann.epublib.domain包,在下文中一共展示了SpineReference类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onBindViewHolder

import nl.siegmann.epublib.domain.SpineReference; //导入依赖的package包/类
@Override
public void onBindViewHolder(ChapterViewHolder holder, int position) {

    CompositeDisposable compositeDisposable = new CompositeDisposable();

    holder.binding.webview.loadUrl(BLANK_URL);
    holder.binding.webview.setUrlInterceptor(strategy.urlInterceptor);

    SpineReference spineReference = epub.getBook().getSpine().getSpineReferences().get(position);
    holder.binding.webview.loadEpubPage(epub, spineReference, epubView.getSettings());

    Bridge bridge = new Bridge();
    holder.binding.webview.setInternalBridge(bridge);

    handleLocation(position, holder.binding.webview);

    bridge.xPath()
            .doOnNext(xPath -> {
                EpubLocation location = EpubLocation.fromXPath(strategy.getCurrentChapter(), xPath);
                strategy.setCurrentLocation(location);
            })
            .subscribeWith(new BaseDisposableObserver<>())
            .addTo(compositeDisposable);
}
 
开发者ID:smartmobilefactory,项目名称:EpubReaderAndroid,代码行数:25,代码来源:ChapterAdapter.java


示例2: displayEpub

import nl.siegmann.epublib.domain.SpineReference; //导入依赖的package包/类
@Override
public void displayEpub(final Epub epub, EpubLocation location) {
    if (location instanceof EpubLocation.ChapterLocation) {
        int chapter = ((EpubLocation.ChapterLocation) location).chapter();
        SpineReference spineReference = epub.getBook().getSpine().getSpineReferences().get(chapter);
        binding.webview.loadEpubPage(epub, spineReference, epubView.getSettings());
        setCurrentChapter(chapter);
    }

    binding.webview.gotoLocation(location);
    binding.webview.setUrlInterceptor(url -> epubView.shouldOverrideUrlLoading(url));
    binding.webview.bindToSettings(settings);

    InternalEpubBridge bridge = new InternalEpubBridge();
    binding.webview.setInternalBridge(bridge);

    bridge.xPath().subscribe(xPath -> {
        setCurrentLocation(EpubLocation.fromXPath(getCurrentChapter(), xPath));
    });

    VerticalContentBinderHelper.bind(binding);
}
 
开发者ID:smartmobilefactory,项目名称:EpubReaderAndroid,代码行数:23,代码来源:SingleChapterVerticalEpubDisplayStrategy.java


示例3: getHtml

import nl.siegmann.epublib.domain.SpineReference; //导入依赖的package包/类
private static String getHtml(Epub epub, SpineReference reference, EpubViewSettings settings) throws IOException {

        InputStream inputStream = epub.getResourceContent(reference.getResource());

        String rawHtml;
        try {
            rawHtml = new String(IOUtil.toByteArray(inputStream), "UTF-8");
        } finally {
            inputStream.close();
        }

        String injectBeforeBody = buildLibraryInternalInjections()
                + injectJavascriptConstants(epub, reference)
                + buildCustomCssString(settings)
                + injectJavascriptStartCode(settings);

        String injectAfterBody = buildCustomScripsString(settings);

        // add custom scripts at the end of the body
        // this makes sure the dom tree is already present when the scripts are executed
        rawHtml = rawHtml.replaceFirst("<body>", "<body>" + injectBeforeBody);
        rawHtml = rawHtml.replaceFirst("</body>", injectAfterBody + "</body>");

        return rawHtml;
    }
 
开发者ID:smartmobilefactory,项目名称:EpubReaderAndroid,代码行数:26,代码来源:EpubDisplayHelper.java


示例4: checkSpineReferences

import nl.siegmann.epublib.domain.SpineReference; //导入依赖的package包/类
private static List<SpineReference> checkSpineReferences(Spine spine) {
	List<SpineReference> result = new ArrayList<SpineReference>(spine.size());
	Resource previousResource = null;
	for(SpineReference spineReference: spine.getSpineReferences()) {
		if(spineReference.getResource() == null
				|| StringUtils.isBlank(spineReference.getResource().getHref())) {
			continue;
		}
		if(previousResource == null
				|| spineReference.getResource() == null
				|| ( ! (spineReference.getResource().getHref().equals(previousResource.getHref())))) {
			result.add(spineReference);
		}
		previousResource = spineReference.getResource();
	}
	return result;
}
 
开发者ID:DASAR,项目名称:epublib-android,代码行数:18,代码来源:SectionHrefSanityCheckBookProcessor.java


示例5: generateSpineFromResources

import nl.siegmann.epublib.domain.SpineReference; //导入依赖的package包/类
/**
 * Creates a spine out of all resources in the resources.
 * The generated spine consists of all XHTML pages in order of their href.
 * 
 * @param resources
 * @return a spine created out of all resources in the resources.
 */
private static Spine generateSpineFromResources(Resources resources) {
	Spine result = new Spine();
	List<String> resourceHrefs = new ArrayList<String>();
	resourceHrefs.addAll(resources.getAllHrefs());
	Collections.sort(resourceHrefs, String.CASE_INSENSITIVE_ORDER);
	for (String resourceHref: resourceHrefs) {
		Resource resource = resources.getByHref(resourceHref);
		if (resource.getMediaType() == MediatypeService.NCX) {
			result.setTocResource(resource);
		} else if (resource.getMediaType() == MediatypeService.XHTML) {
			result.addSpineReference(new SpineReference(resource));
		}
	}
	return result;
}
 
开发者ID:DASAR,项目名称:epublib-android,代码行数:23,代码来源:PackageDocumentReader.java


示例6: EPubReaderAdapter

import nl.siegmann.epublib.domain.SpineReference; //导入依赖的package包/类
public EPubReaderAdapter(FragmentManager fm, List<SpineReference> spineReferences,
                         Book book, String epubFilename, boolean isSmilAvilable) {
    super(fm);
    this.mSpineReferences = spineReferences;
    this.mBook = book;
    this.mEpubFileName = epubFilename;
    this.mIsSmilAvailable = isSmilAvilable;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:EPubReaderAdapter.java


示例7: loadEpubPage

import nl.siegmann.epublib.domain.SpineReference; //导入依赖的package包/类
public void loadEpubPage(Epub epub, SpineReference spineReference, EpubViewSettings settings) {
    if (settings == null) {
        return;
    }
    loadEpubCompositeDisposable.clear();
    settings.anySettingHasChanged()
            // reload html when some settings changed
            .filter(setting -> setting == EpubViewSettings.Setting.CUSTOM_FILES)
            .startWith(EpubViewSettings.Setting.CUSTOM_FILES)
            .flatMap(setting -> EpubDisplayHelper.loadHtmlData(this, epub, spineReference, settings)
                    .toObservable())
            .subscribeWith(new BaseDisposableObserver<>())
            .addTo(loadEpubCompositeDisposable);
}
 
开发者ID:smartmobilefactory,项目名称:EpubReaderAndroid,代码行数:15,代码来源:EpubWebView.java


示例8: getView

import nl.siegmann.epublib.domain.SpineReference; //导入依赖的package包/类
@Override
public View getView(int position, ViewGroup parent) {
    CompositeDisposable compositeDisposable = chapterDisposables.get(position);
    if (compositeDisposable == null) {
        chapterDisposables.append(position, new CompositeDisposable());
        compositeDisposable = chapterDisposables.get(position);
    }

    ItemEpubVerticalContentBinding binding = ItemEpubVerticalContentBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);

    binding.webview.setUrlInterceptor(strategy.urlInterceptor);

    SpineReference spineReference = epub.getBook().getSpine().getSpineReferences().get(position);
    binding.webview.loadEpubPage(epub, spineReference, epubView.getSettings());

    handleLocation(position, binding.webview);

    binding.webview.bindToSettings(epubView.getSettings());

    InternalEpubBridge bridge = new InternalEpubBridge();
    binding.webview.setInternalBridge(bridge);

    bridge.xPath()
            .doOnNext(xPath -> {
                EpubLocation location = EpubLocation.fromXPath(strategy.getCurrentChapter(), xPath);
                chapterLocations.append(position, location);
                strategy.setCurrentLocation(location);
            })
            .subscribeWith(new BaseDisposableObserver<>())
            .addTo(compositeDisposable);

    compositeDisposable.add(VerticalContentBinderHelper.bind(binding));

    return binding.root;
}
 
开发者ID:smartmobilefactory,项目名称:EpubReaderAndroid,代码行数:36,代码来源:PagerAdapter.java


示例9: loadHtmlData

import nl.siegmann.epublib.domain.SpineReference; //导入依赖的package包/类
@CheckResult
public static Completable loadHtmlData(WebView webView, Epub epub, SpineReference spineReference, EpubViewSettings settings) {

    WeakReference<WebView> webViewWeakReference = new WeakReference<>(webView);

    return Single.fromCallable(() -> EpubDisplayHelper.getHtml(epub, spineReference, settings))
            .doOnSubscribe(disposable -> {
                webViewWeakReference.get().setTag(spineReference);
            })
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .doOnSuccess(html -> {

                WebView webViewReference = webViewWeakReference.get();

                if (webViewReference == null) {
                    return;
                }

                boolean isAttachedToWindow = true;
                if (Build.VERSION.SDK_INT >= 19) {
                    isAttachedToWindow = webViewReference.isAttachedToWindow();
                }
                if (webViewReference.getTag() == spineReference && isAttachedToWindow) {
                    String basePath = Uri.fromFile(epub.getOpfPath()).toString() + "//";
                    webViewReference.loadDataWithBaseURL(
                            basePath,
                            html,
                            "text/html",
                            "UTF-8",
                            "about:chapter"
                    );
                }
            })
            .toCompletable();
}
 
开发者ID:smartmobilefactory,项目名称:EpubReaderAndroid,代码行数:37,代码来源:EpubDisplayHelper.java


示例10: injectJavascriptConstants

import nl.siegmann.epublib.domain.SpineReference; //导入依赖的package包/类
private static String injectJavascriptConstants(Epub epub, SpineReference reference) {
    int chapterPosition = getChapterPosition(epub, reference);

    return "<script type=\"text/javascript\">\n"
            + "var epubChapter = {\n"
            + " index: " + chapterPosition + ",\n"
            + " id: \"" + reference.getResource().getId() + "\",\n"
            + " href: \"" + reference.getResource().getHref() + "\",\n"
            + " title: \"" + reference.getResource().getTitle() + "\"\n"
            + "}\n"
            + "</script>\n";
}
 
开发者ID:smartmobilefactory,项目名称:EpubReaderAndroid,代码行数:13,代码来源:EpubDisplayHelper.java


示例11: getChapterPosition

import nl.siegmann.epublib.domain.SpineReference; //导入依赖的package包/类
private static int getChapterPosition(Epub epub, SpineReference reference) {
    List<SpineReference> spineReferences = epub.getBook().getSpine().getSpineReferences();
    for (int i = 0; i < spineReferences.size(); i++) {
        SpineReference spineReference = spineReferences.get(i);
        //noinspection StringEquality
        if (spineReference.getResourceId() == reference.getResourceId()) {
            return i;
        }
        if (spineReference.getResourceId().equals(reference.getResourceId())) {
            return i;
        }
    }
    return 0;
}
 
开发者ID:smartmobilefactory,项目名称:EpubReaderAndroid,代码行数:15,代码来源:EpubDisplayHelper.java


示例12: getSpinePositionForTocReference

import nl.siegmann.epublib.domain.SpineReference; //导入依赖的package包/类
/**
 * @return -1 if toc position not found
 */
public int getSpinePositionForTocReference(TOCReference tocReference) {
    List<SpineReference> spineReferences = getBook().getSpine().getSpineReferences();
    for (int i = 0; i < spineReferences.size(); i++) {
        SpineReference spineReference = spineReferences.get(i);
        if (tocReference.getResourceId().equals(spineReference.getResourceId())) {
            return i;
        }
    }
    return -1;
}
 
开发者ID:smartmobilefactory,项目名称:EpubReaderAndroid,代码行数:14,代码来源:Epub.java


示例13: getTocPositionForSpineReference

import nl.siegmann.epublib.domain.SpineReference; //导入依赖的package包/类
/**
 * @return -1 if spine position not found
 */
public int getTocPositionForSpineReference(SpineReference spineReference) {
    List<SpineReference> spineReferences = getBook().getSpine().getSpineReferences();
    for (int i = 0; i < spineReferences.size(); i++) {
        SpineReference spineReference2 = spineReferences.get(i);
        if (spineReference2.getResourceId().equals(spineReference.getResourceId())) {
            return getTocPositionForSpinePosition(i);
        }
    }
    return -1;
}
 
开发者ID:smartmobilefactory,项目名称:EpubReaderAndroid,代码行数:14,代码来源:Epub.java


示例14: shouldOverrideUrlLoading

import nl.siegmann.epublib.domain.SpineReference; //导入依赖的package包/类
public boolean shouldOverrideUrlLoading(String url) {

        if (url.startsWith(Uri.fromFile(epub.getLocation()).toString())) {
            // internal chapter change url
            List<SpineReference> spineReferences = epub.getBook().getSpine().getSpineReferences();
            for (int i = 0; i < spineReferences.size(); i++) {
                SpineReference spineReference = spineReferences.get(i);
                if (url.endsWith(spineReference.getResource().getHref())) {
                    gotoLocation(EpubLocation.fromChapter(i));
                    return true;
                }
            }
            // chapter not found
            // can not open the url
            return true;
        }

        if (urlInterceptor != null && urlInterceptor.shouldOverrideUrlLoading(url)) {
            return true;
        }

        try {
            // try to open url with external app
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(url));
            getContext().startActivity(intent);
        } catch (Exception e) {
            // ignore
        }

        // we never want to load a new url in the same webview
        return true;
    }
 
开发者ID:smartmobilefactory,项目名称:EpubReaderAndroid,代码行数:34,代码来源:EpubView.java


示例15: writeSpineItems

import nl.siegmann.epublib.domain.SpineReference; //导入依赖的package包/类
/**
 * List all spine references
 * @throws IOException 
 * @throws IllegalStateException 
 * @throws IllegalArgumentException 
 */
private static void writeSpineItems(Spine spine, XmlSerializer serializer) throws IllegalArgumentException, IllegalStateException, IOException {
	for(SpineReference spineReference: spine.getSpineReferences()) {
		serializer.startTag(NAMESPACE_OPF, OPFTags.itemref);
		serializer.attribute(EpubWriter.EMPTY_NAMESPACE_PREFIX, OPFAttributes.idref, spineReference.getResourceId());
		if (! spineReference.isLinear()) {
			serializer.attribute(EpubWriter.EMPTY_NAMESPACE_PREFIX, OPFAttributes.linear, OPFValues.no);
		}
		serializer.endTag(NAMESPACE_OPF, OPFTags.itemref);
	}
}
 
开发者ID:DASAR,项目名称:epublib-android,代码行数:17,代码来源:PackageDocumentWriter.java


示例16: EpubManipulator

import nl.siegmann.epublib.domain.SpineReference; //导入依赖的package包/类
public EpubManipulator(String fileName, String folder, int spineIndex,
		int language, Context theContext) throws Exception {
	List<String> spineElements;
	List<SpineReference> spineList;

	if (context == null) {
		context = theContext;
	}

	this.fs = new FileInputStream(fileName);
	this.book = (new EpubReader()).readEpub(fs);
	this.fileName = fileName;
	this.decompressedFolder = folder;

	Spine spine = book.getSpine();
	spineList = spine.getSpineReferences();
	this.currentSpineElementIndex = spineIndex;
	this.currentLanguage = language;
	spineElements = new ArrayList<String>();
	pages(spineList, spineElements);
	this.pageCount = spineElements.size();
	this.spineElementPaths = new String[spineElements.size()];

	pathOPF = getPathOPF(location + folder);

	for (int i = 0; i < spineElements.size(); ++i) {
		// TODO: is there a robust path joiner in the java libs?
		this.spineElementPaths[i] = "file://" + location + folder + "/"
				+ pathOPF + "/" + spineElements.get(i);
	}
	goToPage(spineIndex);
}
 
开发者ID:pettarin,项目名称:epub3reader,代码行数:33,代码来源:EpubManipulator.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java UnionType类代码示例发布时间:2022-05-23
下一篇:
Java RuntimeReferencePropertyInfo类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap