Comments (6)
这个是关于retrofit及okhttp的扩展实现,百度搜索很多
from mvparms.
@WooYu 刚刚看了下,大多数做法是自定义一个 Interceptor, 你将这个 Interceptor,在WeApplication中通过GlobeConfigModule.addInterceptor(),传进来就可以了,旧版本使用 WeApplication 中的 getInterceptors() 方法,教程很多难度应该不大
from mvparms.
在你说的位置进行拦截,那不所有的请求都会被拦截了
from mvparms.
@WooYu Okhttp的整个实现都建立在了,Interceptor上,它内部也是使用几个Interceptor对请求进行封装,请求服务器,返回数据,所以你使用Interceptor,并不一定要将所有请求拦截,如果不符合你的条件你不拦截也不处理就可以了,这并不会对后续的请求有什么影响,Android中的事件分发机制,也是使用了责任链模式,你不处理那就不拦截就可以了,不会对后面的事件有什么影响
from mvparms.
from mvparms.
@WooYu 那我给你个意见,在 Interceptor 中可以拿到所有请求的header和参数,你可以在上传文件请求接口中添加一个用来区别其他请求接口的header,然后使用这个 Interceptor 判断是否含有这个 header 即可
from mvparms.
Related Issues (20)
- 依赖远程2.5.2版本,不通过 HOT 4
- 配置多个GlobalConfiguration 时可能产生的问题
- 远程依赖2.5.2网络请求报错
- baseUrl未更改 HOT 2
- 如果想切换多个retrofit实例,怎么改?
- 什么时候推MVVMArms
- 当前项目依赖的aar包与远程以来的arms 有冲突,请问要怎么处理
- 这个项目还维护吗?
- android 11的是否开始适配了,分区存储哦
- androidStudio 4.1.1无法使用快速创建模板,templates文件夹没有了,官方不支持 HOT 13
- demo混淆后,提示Binary XML file line #24: Binary XML file line #24: Error inflating class LinearLayout HOT 2
- ActivityLifecycle中使用@Inject获取的mAppManager为空
- 请教作者一个问题 HOT 1
- ButterKnife过时,被Google弃用
- 这个项目只适合新手 HOT 6
- mModel偶发性空指针,接入腾讯Bugly检测到很多次 HOT 6
- Android 4.3报错误 HOT 3
- 建议
- Program type already present: com.jess.xinghuo.base.BaseFragment_MembersInjector HOT 3
- MVP
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mvparms.