Life is a fucking movie. 😈 😈 😈 😈 😈 😈
人生如戏。
🎨 A new Android MVP architecture (此框架旨在解决传统 MVP 类和接口太多, 并且 Presenter 和 View 通过接口通信过于繁琐, 重用 Presenter 代价太大等问题).
License: Apache License 2.0
假如现在有3个Presenter,这3个Presenter都有一个网络请求的方法用来请求数据。现在的情况是每个Presenter都要写这个方法,怎么写一个通用的Presenter,请大佬指教?
我看了你所有的源码,看见你框架中使用默认的适配器,但是你适配器中兵没有增查改等操作,而且你的数据也是通过构造器传进去的。如果此时我想移除适配器中的某条数据或者是像适配器中添加某个特定位置的数据,你这边都没法操作适配器。
@OverRide
public void initData(@nullable Bundle savedInstanceState) {
mPresenter.requestGetToken(Message.obtain(MainActivity.this, new Object[]{true}));
}
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.art.client.android/com.art.client.android.mvp.ui.activity.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.art.client.android.mvp.presenter.MainPresenter.requestGetToken(me.jessyan.art.mvp.Message)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.art.client.android.mvp.presenter.MainPresenter.requestGetToken(me.jessyan.art.mvp.Message)' on a null object reference
at com.art.client.android.mvp.ui.activity.MainActivity.initData(MainActivity.java:27)
at me.jessyan.art.base.BaseActivity.onCreate(BaseActivity.java:84)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void me.jessyan.art.mvp.IView.showMessage(java.lang.String)' on a null object reference at me.jessyan.mvpart.demo.mvp.presenter.UserPresenter$1.onRequestPermissionFailureWithAskNeverAgain(UserPresenter.java:94) at me.jessyan.art.utils.PermissionUtil$1.onNext(PermissionUtil.java:98) at me.jessyan.art.utils.PermissionUtil$1.onNext(PermissionUtil.java:87)
应该是跟Arms一样的
我看整个项目代码结构基本一致,只是减少基础库类的引用吗?对mvp 分层这些有区别吗,最近也在做代码重构,比较纠结MVVM 架构还是MVP 架构
super(appComponent.repositoryManager().createRepository(UserRepository.class)); 这句报错,请问有遇到的吗?
Retrofit Code by Kotlin:
@POST("/xxx/xxxxx/add")
suspend fun newPatQuestionAdd(@Body request: AddProblem): BaseBean<QuestionAddBean?>
the param "request" have some fields, one of the field contains String %28%29%u704C%u5357%u9EBB%u5C06
, this fied lead to crash, as follow:
Crash Report:
E java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape (%) pattern : %u7
at java.net.URLDecoder.decode(URLDecoder.java:178)
at me.jessyan.art.http.log.RequestInterceptor.parseParams(RequestInterceptor.java:173)
at me.jessyan.art.http.log.RequestInterceptor.intercept(RequestInterceptor.java:50)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
Thanks.
EventBus的事件没有View的Message对象,如何对View进行操作?
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object me.jessyan.art.mvp.IRepositoryManager.createRetrofitService(java.lang.Class)' on a null object reference;
打开APP点物理返回退出APP再次打开 报这个错误
如题,继承你的BaseApplication后如果获取这个全局的上下文?请指点谢谢
使用MVPArt框架提交POST请求,服务器收到的request中的body为空
1.日志是打印了http heard body
2.但是GlobalHttpHandlerImpl类中的onHttpRequestBefore方法request参数的body是空
如果收到给request添加body,请求可以成功
是不是我的Repository代码有问题,以下是部分代码,请帮忙看下,谢谢
model service的代码:
/**
* 用户注册
*
* @param user
* @return
*/
@post("home/userRegister.do")
Observable<BaseResponse> register(@Body UserInfo user);
Repository的代码:
public Observable<BaseResponse<RegisterInfo>> register(String account, String verifyCode) {
UserInfo info = new UserInfo();
info.setAccount(account);
info.setVerificationCode(verifyCode);
return mManager.createRetrofitService(UserCenterService.class).register(info);
}
GlobalConfiguration配置类增加了以下代码
//通用拦截器添加header
okhttpBuilder.addInterceptor(chain -> {
String timestamp = new SimpleDateFormat("yyyyMMddHHmmss", Locale.getDefault()).format(new Date());
Request request = chain.request().newBuilder()
.addHeader("Content-Type", "application/json")
.addHeader("deviceNo", Global.DEVICE_NO)
.addHeader("deviceType", Global.DEVICE_TYPE)
.addHeader("time", timestamp)
.addHeader("token", EncodeUtils.md5(EncodeUtils.md5(Global.DEVICE_NO + Global.SECRET_KEY) + timestamp))
.addHeader("student", "")
.build();
return chain.proceed(request);
});
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.