wzgiceman / rxjavaretrofitdemo-string-master Goto Github PK
View Code? Open in Web Editor NEWRxjava+ReTrofit+okHttp终极封装(String方案)
Home Page: http://blog.csdn.net/column/details/13297.html
License: MIT License
Rxjava+ReTrofit+okHttp终极封装(String方案)
Home Page: http://blog.csdn.net/column/details/13297.html
License: MIT License
楼主,我使用你这一个的时候,使用Gson的时候,包以下错误
Expected a string but was BEGIN_OBJECT
查阅了相关资料,知道是Gson不支持将Object对象的直接转化为String,请问您楼主有什么比较好的解决方法吗,谢谢
public class BaseResultEntity {
// 判断标示
private int ret;
// 提示信息
private String msg;
//显示数据(用户需要关心的数据)
private String data;
}
我用ReactNative怎么办,人家要用ReactActivity。而且有的组件只是个View而已,获取activity麻烦,只有context
看了你的博客,String方案中BaseResultEntity取消泛型,但项目源码里面加了泛型,是这样更好吗?
项目中有上百个接口,就需要写对应多个像SubjectPostApi这样的类,是不是有点臃肿了?我修改了用反射的方法去做,请求时只用这一个类即可,但是感觉不太好,有没有其他方法去优化?
HttpManager
OkHttpClient.Builder builder = new OkHttpClient.Builder();
**builder.addInterceptor(new CacheInterceptor());**
给okhttp添加拦截器后,就获取不到数据了
有网、没网 都提示:错误:无缓存。
取消okhttp拦截器后,还是提示:错误:无缓存。
重新安装 一样
else
换个手机不加拦截器运行 就可以获取到数据。。
java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread.
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:59)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:153)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:267)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.NoClassDefFoundError: okhttp3.internal.http.HttpEngine
at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:219)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at com.wzgiceman.rxretrofitlibrary.retrofit_rx.http.cookie.CookieInterceptor.intercept(CookieInterceptor.java:36)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185)
at okhttp3.RealCall.execute(RealCall.java:69)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:174)
import com.wzgiceman.rxretrofitlibrary.retrofit_rx.http.cookie.DaoMaster;
import com.wzgiceman.rxretrofitlibrary.retrofit_rx.http.cookie.DaoSession;
没有这个东西
大佬 你这个什么时候升级到 Rxjava Rxandroid 到2.0 啊
/*rxjava2.x版本*/
api 'io.reactivex.rxjava2:rxjava:2.2.7'
api 'io.reactivex.rxjava2:rxandroid:2.1.1'
/*rxlifecycle依赖的是rxjava1.x版本*/
//api 'com.trello:rxlifecycle:1.0'
//api 'com.trello:rxlifecycle-components:1.0'
/*rxlifecycle依赖的是rxjava2.x版本*/
api 'com.trello.rxlifecycle2:rxlifecycle:2.2.2'
api 'com.trello.rxlifecycle2:rxlifecycle-android-lifecycle:2.2.2'
/*adapter-rxjava依赖的是rxjava1.x版本,adapter-rxjava2依赖的是rxjava2.x版本*/
api 'com.squareup.retrofit2:retrofit:2.5.0'
//api 'com.squareup.retrofit2:adapter-rxjava:2.5.0'
api 'com.squareup.retrofit2:adapter-rxjava2:2.5.0'
api 'com.squareup.retrofit2:converter-scalars:2.5.0'
api 'com.squareup.retrofit2:converter-gson:2.5.0'
rt!保存、添加、删除?怎么做呢
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.