android 下载网络pdf文件后并显示
Demo下载地址:https://download.csdn.net/download/as425017946/10664926
1.基本思路:
打开网络pdf 思路整体还是来源与图片的加载。
android中加载网络图片的框架有很多个。如image-laoder, fresco、glide等,首先都是从内存中找图片,如果内存中没有,接着从本地找,本地没有在从网络下载。
android中加载pdf也是类似,首先从本地找pdf文件,如果本地存在该pdf文件,直接打开,如果本地不存在,将该pdf文件下载到本地在打开。
下载文件用到了retrofit2的库,已经封装到android_pdf中了。
2.依赖android_pdf库方法
2.1 在项目的gradle中增加如下代码:
compile 'com.lidong.pdf:android_pdf:1.0.1'
2.2 一句代码就可以加载网络pdf。
pdfView.fileFromLocalStorage(this,this,this,fileUrl,fileName); //设置pdf文件地址
2.3对fileFromLocalStorage(this,this,this,fileUrl,fileName)的解析
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
- OnPageChangeListener onPageChangeListener :翻页回调
- OnLoadCompleteListener onLoadCompleteListener:加载完成的回调
- OnDrawListener:页面绘制的回调
- String fileUrl : 文件的网络地址
- String fileName 文件名称
3.使用android_pdf库方法
3.1写一个布局文件
?
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
3.2在MainActivity中加载
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
更多相关文章
- Android(安卓)在安装完成界面,点击打开应用程序。在应用程序点击h
- Android(安卓)init进程——源码分析
- Android(安卓)Studio Error:前言中不允许有内容。
- Android(安卓)上传头像(文件)到服务器
- Mac android 环境配置
- Android(安卓)根文件系统启动过程。
- Android进程系列第六篇---LowmemoryKiller机制分析(上)
- Android(安卓)基础
- NPM 和webpack 的基础使用
随机推荐
- Android(安卓)编译中的LOCAL_SDK_VERSION
- Android新特性-RecyclerView之基础篇
- 使用Android(安卓)studio3.6的java api方
- Android学习笔记:通过Android之Service实
- android:dkplayer中ijkplayer延迟长的问题
- 第一次运行Android(安卓)Studio
- android 网络编程 HttpGet类和HttpPost类
- android 文件合并打包 Error:Execution f
- Android(安卓)Fragment和FragmentActivit
- Android(安卓)Sudio 开发环境配置