概述
將 RBReader 與 Mupdf代碼進(jìn)行整合后浴滴,將UI進(jìn)行二次封裝副瀑。
1.界面更加美觀 類似主流閱讀器界面風(fēng)格
2.引用更加方便 實(shí)現(xiàn)0代碼加入
使用步驟
- 1.修改包名
將 FBReaderIntents 類中的 DEFAULT_PACKAGE 的值 改為主程序的包名(包路徑為: org.geometerplus.android.fbreader.api; )
- 2.進(jìn)行重新編譯
gradle markeJar
- 3.將 library下aar 放到項(xiàng)目libs下
compile(name: 'fBReader-release', ext: 'aar')
- 4.應(yīng)用 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")) {
//跳轉(zhuǎn)閱讀器
FBReader.openBookActivity(context, book, null);
} else if (type.equalsIgnoreCase("PDF")) {
//跳轉(zhuǎn)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