Coder Social home page Coder Social logo

jessyancoding / mvpart Goto Github PK

View Code? Open in Web Editor NEW
778.0 778.0 153.0 1.19 MB

🎨 A new Android MVP architecture (此框架旨在解决传统 MVP 类和接口太多, 并且 Presenter 和 View 通过接口通信过于繁琐, 重用 Presenter 代价太大等问题).

License: Apache License 2.0

Java 100.00%
android-architecture android-library architectural-patterns architecture arms mvp mvp-android mvp-architecture mvp-library mvp-pattern mvparms mvpart

mvpart's Introduction

MVPArt

Latest Stable Version Build Status Min Sdk Version License Author QQ Group

中文说明

A New Android MVP Architecture

This framework is designed to solve the traditional MVP class and interface too much, and Presenter and View communicate too complicated through the interface, reuse Presenter too much cost

Architectural

Introduction

Master Branch

Master branch is a simple framework without network layer, mainly through the four Demo introduced the framework of the ideas, features and use of methods, compact and flexible has a set of existing framework but need to refactor For MVP structure of the project, but no matter which branch you are using is strongly recommended that you first look at Master branch Demo

Complete Branch

Complete branch is a complete framework with a network layer, Retrofit as a network layer and use Dagger2 to manage all objects, mature and powerful for new projects

Notice

  • Use Template to automatically generate MVP classes

  • This framework is a lightweight framework, more suitable for small and medium-sized projects, large-scale projects please use MVPArms

  • Traditional MVP corresponds to a Presenter, and most Presenter has only one or two methods, which leads to the existence of a large number of very few tags Presenter, this framework is designed to solve the reuse Presenter need to achieve too many redundant interface method, encourage developers to write similar logic in a Presenter, constantly reuse Presenter, reduce a large number of class files

  • Of course, many different logic is written in a Presenter, although you can write a lot of classes, but behind the expansion is certainly not good, so the size of their own control, but for the outsourcing project is very useful

Download

 implementation 'me.jessyan:art:2.5.0'

 ---------------------- 以下是扩展库 ----------------------
 
 //想使用 Glide 请依赖 art-imageloader-glide 扩展库
 implementation 'me.jessyan:art-imageloader-glide:2.5.0' 
 
 //想使用 AndroidAutoLayout 请依赖 art-autolayout 扩展库
 implementation 'me.jessyan:art-autolayout:2.5.0'

About Me

License

 Copyright 2017, jessyan

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

mvpart's People

Contributors

jessyancoding avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mvpart's Issues

请问DefaultAdapter<T>是怎么来更新适配器

我看了你所有的源码,看见你框架中使用默认的适配器,但是你适配器中兵没有增查改等操作,而且你的数据也是通过构造器传进去的。如果此时我想移除适配器中的某条数据或者是像适配器中添加某个特定位置的数据,你这边都没法操作适配器。

关于复用的问题?

假如现在有3个Presenter,这3个Presenter都有一个网络请求的方法用来请求数据。现在的情况是每个Presenter都要写这个方法,怎么写一个通用的Presenter,请大佬指教?

权限拒绝会出现崩溃现象,msg中IView为空

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)

POST请求BODY为空

使用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);
});

为什么我的 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)

Demo有一个错误

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再次打开 报这个错误

URLDecoder: Illegal hex characters in escape (%) pattern : %u7

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.