Android_开源阅读器
2019-10-28 本文已影响0人
卢融霜
概述
将 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
![](https://img.haomeiwen.com/i17878874/0b14f0a301077fca.png)
![](https://img.haomeiwen.com/i17878874/ba647ab0b9228b43.png)
![](https://img.haomeiwen.com/i17878874/a15ca39d9f611137.png)
![](https://img.haomeiwen.com/i17878874/f9d87319ab88bb35.png)
![](https://img.haomeiwen.com/i17878874/aa257f3edb71b64e.png)
![](https://img.haomeiwen.com/i17878874/a5f5929ff1bc0e75.png)
![](https://img.haomeiwen.com/i17878874/5bc07e1dd063a00b.png)
![](https://img.haomeiwen.com/i17878874/73c2124114d27703.png)
![](https://img.haomeiwen.com/i17878874/ccc37d20dcc93bed.png)
![](https://img.haomeiwen.com/i17878874/7b0bb30f699ac28b.png)