概述
将 RBReader 与 Mupdf代码进行整合后,将UI进行二次封装。
1.界面更加美观 类似主流阅读器界面风格
2.引用更加方便 实现0代码加入
使用步骤
- 1.修改包名
将 FBReaderIntents 类中的 DEFAULT_PACKAGE 的值 改为主程序的包名(包路径为: org.geometerplus.android.fbreader.api; )
- 2.进行重新编译
gradle markeJar
- 3.将 library下aar 放到项目libs下
compile(name: 'fBReader-release', ext: 'aar')
- 4.应用 AppApplication 中初始化阅读器组件
ZLAndroidApplication.init(this);
bookInit(this);
public static void bookInit(Context context) {
if (bs == null) {
bs = new BookCollectionShadow(); bs.bindToService(context, null);
}
}
- **5.跳阅读器页面 **
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