Android

Android_开源阅读器

2019-10-28  本文已影响0人  卢融霜

概述

将 RBReader 与 Mupdf代码进行整合后,将UI进行二次封装。

1.界面更加美观 类似主流阅读器界面风格
2.引用更加方便 实现0代码加入

使用步骤

将 FBReaderIntents 类中的 DEFAULT_PACKAGE 的值 改为主程序的包名(包路径为: org.geometerplus.android.fbreader.api; )

 gradle markeJar
compile(name: 'fBReader-release', ext: 'aar')
 ZLAndroidApplication.init(this);
 bookInit(this);

public static void bookInit(Context context) {
    if (bs == null) {
          bs = new BookCollectionShadow(); bs.bindToService(context, null);
     }
 }
public void openBook(Context context, String filePath, String type) {
   if (bs == null) {
     bs = new BookCollectionShadow();
     bs.bindToService(context, null);
    }

    File file = new File(filePath);
    if (file.exists()) {
        Book book = bs.getBookByFile(filePath);
        if (type.equalsIgnoreCase("TXT") || type.equalsIgnoreCase("EPUB")) {
            //跳转阅读器
            FBReader.openBookActivity(context, book, null);
        } else if (type.equalsIgnoreCase("PDF")) {
            //跳转PDF阅读器
            Uri uri = Uri.parse(filePath);
            Intent intent = new Intent(context, MuPDFActivity.class);
            intent.setAction(Intent.ACTION_VIEW);
            intent.setData(uri);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent);
        }
    }
}


源码:

https://github.com/lurongshuang/FBReader-Mupdf_library
1.png 2.png 3.png 4.png 5.png 6.png 7.png 8.png 9.png 10.png
上一篇下一篇

猜你喜欢

热点阅读