Commit 33043854c8390e62d0af69a5264f73397a387308
1 parent
977b3347
upload libs mosby3 mvp
Showing
7 changed files
with
16 additions
and
58 deletions
app/src/main/java/com/cnlive/libs/demo/mvptest/frame/ILaunchView.java
app/src/main/java/com/cnlive/libs/demo/mvptest/frame/presenter/LaunchPresenter.java
| @@ -11,7 +11,7 @@ import com.cnlive.libs.demo.data.network.testapi.ApiRequest; | @@ -11,7 +11,7 @@ import com.cnlive.libs.demo.data.network.testapi.ApiRequest; | ||
| 11 | import com.cnlive.libs.demo.data.network.testapi.ApiService; | 11 | import com.cnlive.libs.demo.data.network.testapi.ApiService; |
| 12 | import com.cnlive.libs.demo.mvptest.frame.ILaunchView; | 12 | import com.cnlive.libs.demo.mvptest.frame.ILaunchView; |
| 13 | import com.cnlive.libs.demo.mvptest.frame.view.LaunchView; | 13 | import com.cnlive.libs.demo.mvptest.frame.view.LaunchView; |
| 14 | -import com.hannesdorfmann.mosby.mvp.MvpBasePresenter; | 14 | +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; |
| 15 | 15 | ||
| 16 | import io.reactivex.disposables.Disposable; | 16 | import io.reactivex.disposables.Disposable; |
| 17 | 17 |
cnlive/build.gradle
| @@ -29,7 +29,10 @@ dependencies { | @@ -29,7 +29,10 @@ dependencies { | ||
| 29 | compile fileTree(include: ['*.jar'], dir: 'libs') | 29 | compile fileTree(include: ['*.jar'], dir: 'libs') |
| 30 | 30 | ||
| 31 | //MVP | 31 | //MVP |
| 32 | - compile 'com.hannesdorfmann.mosby:mvp:2.0.1' | 32 | + compile 'com.hannesdorfmann.mosby3:mvp:3.0.4' |
| 33 | + compile 'com.hannesdorfmann.mosby3:viewstate:3.0.4' | ||
| 34 | + compile 'com.hannesdorfmann.mosby3:mvp-lce:3.0.4' | ||
| 35 | + compile 'com.hannesdorfmann.mosby3:mvp-nullobject-presenter:3.0.4' | ||
| 33 | //GSON | 36 | //GSON |
| 34 | compile 'com.google.code.gson:gson:2.7' | 37 | compile 'com.google.code.gson:gson:2.7' |
| 35 | //RxJava | 38 | //RxJava |
cnlive/src/main/java/com/cnlive/libs/base/activity/MvpActivity.java
| @@ -4,15 +4,15 @@ import android.os.Bundle; | @@ -4,15 +4,15 @@ import android.os.Bundle; | ||
| 4 | import android.support.annotation.NonNull; | 4 | import android.support.annotation.NonNull; |
| 5 | 5 | ||
| 6 | import com.cnlive.libs.base.util.ReflectUtil; | 6 | import com.cnlive.libs.base.util.ReflectUtil; |
| 7 | -import com.hannesdorfmann.mosby.mvp.MvpPresenter; | ||
| 8 | -import com.hannesdorfmann.mosby.mvp.MvpView; | 7 | +import com.hannesdorfmann.mosby3.mvp.MvpPresenter; |
| 8 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | ||
| 9 | 9 | ||
| 10 | /** | 10 | /** |
| 11 | * MVP Databinding Base Activity | 11 | * MVP Databinding Base Activity |
| 12 | * @param <V> MVP View {@link MvpView} | 12 | * @param <V> MVP View {@link MvpView} |
| 13 | * @param <P> MVP Presenter {@link MvpPresenter} | 13 | * @param <P> MVP Presenter {@link MvpPresenter} |
| 14 | */ | 14 | */ |
| 15 | -public abstract class MvpActivity<V extends MvpView, P extends MvpPresenter<V>> extends com.hannesdorfmann.mosby.mvp.MvpActivity<V, P> { | 15 | +public abstract class MvpActivity<V extends MvpView, P extends MvpPresenter<V>> extends com.hannesdorfmann.mosby3.mvp.MvpActivity<V, P> { |
| 16 | 16 | ||
| 17 | public V view; | 17 | public V view; |
| 18 | 18 |
cnlive/src/main/java/com/cnlive/libs/base/activity/MvpBindingActivity.java
| @@ -6,9 +6,8 @@ import android.os.Bundle; | @@ -6,9 +6,8 @@ import android.os.Bundle; | ||
| 6 | import android.support.annotation.NonNull; | 6 | import android.support.annotation.NonNull; |
| 7 | 7 | ||
| 8 | import com.cnlive.libs.base.util.ReflectUtil; | 8 | import com.cnlive.libs.base.util.ReflectUtil; |
| 9 | -import com.hannesdorfmann.mosby.mvp.MvpActivity; | ||
| 10 | -import com.hannesdorfmann.mosby.mvp.MvpPresenter; | ||
| 11 | -import com.hannesdorfmann.mosby.mvp.MvpView; | 9 | +import com.hannesdorfmann.mosby3.mvp.MvpPresenter; |
| 10 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | ||
| 12 | 11 | ||
| 13 | /** | 12 | /** |
| 14 | * MVP Databinding Base Activity | 13 | * MVP Databinding Base Activity |
| @@ -19,7 +18,6 @@ import com.hannesdorfmann.mosby.mvp.MvpView; | @@ -19,7 +18,6 @@ import com.hannesdorfmann.mosby.mvp.MvpView; | ||
| 19 | */ | 18 | */ |
| 20 | public abstract class MvpBindingActivity<V extends MvpView, P extends MvpPresenter<V>, D, T extends ViewDataBinding> extends MvpActivity<V, P> { | 19 | public abstract class MvpBindingActivity<V extends MvpView, P extends MvpPresenter<V>, D, T extends ViewDataBinding> extends MvpActivity<V, P> { |
| 21 | 20 | ||
| 22 | - public V view; | ||
| 23 | public T binding; | 21 | public T binding; |
| 24 | public D data; | 22 | public D data; |
| 25 | 23 | ||
| @@ -30,31 +28,11 @@ public abstract class MvpBindingActivity<V extends MvpView, P extends MvpPresent | @@ -30,31 +28,11 @@ public abstract class MvpBindingActivity<V extends MvpView, P extends MvpPresent | ||
| 30 | ReflectUtil.invoke(binding, "setData", getViewData()); | 28 | ReflectUtil.invoke(binding, "setData", getViewData()); |
| 31 | } | 29 | } |
| 32 | 30 | ||
| 33 | - protected abstract int getLayoutId(); | ||
| 34 | - | ||
| 35 | protected D initLayoutData() { | 31 | protected D initLayoutData() { |
| 36 | return ReflectUtil.instance(2, this); | 32 | return ReflectUtil.instance(2, this); |
| 37 | } | 33 | } |
| 38 | 34 | ||
| 39 | @NonNull | 35 | @NonNull |
| 40 | - public V createView() { | ||
| 41 | - return ReflectUtil.instance(0, this.getClass(), this); | ||
| 42 | - } | ||
| 43 | - | ||
| 44 | - @NonNull | ||
| 45 | - @Override | ||
| 46 | - public P createPresenter() { | ||
| 47 | - return ReflectUtil.instance(1, this); | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - @NonNull | ||
| 51 | - @Override | ||
| 52 | - public V getMvpView() { | ||
| 53 | - if (view == null) view = createView(); | ||
| 54 | - return view; | ||
| 55 | - } | ||
| 56 | - | ||
| 57 | - @NonNull | ||
| 58 | public D getViewData() { | 36 | public D getViewData() { |
| 59 | if(data == null) data = initLayoutData(); | 37 | if(data == null) data = initLayoutData(); |
| 60 | return data; | 38 | return data; |
cnlive/src/main/java/com/cnlive/libs/base/fragment/MvpBindingFragment.java
| @@ -10,9 +10,8 @@ import android.view.View; | @@ -10,9 +10,8 @@ import android.view.View; | ||
| 10 | import android.view.ViewGroup; | 10 | import android.view.ViewGroup; |
| 11 | 11 | ||
| 12 | import com.cnlive.libs.base.util.ReflectUtil; | 12 | import com.cnlive.libs.base.util.ReflectUtil; |
| 13 | -import com.hannesdorfmann.mosby.mvp.MvpFragment; | ||
| 14 | -import com.hannesdorfmann.mosby.mvp.MvpPresenter; | ||
| 15 | -import com.hannesdorfmann.mosby.mvp.MvpView; | 13 | +import com.hannesdorfmann.mosby3.mvp.MvpPresenter; |
| 14 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | ||
| 16 | 15 | ||
| 17 | /** | 16 | /** |
| 18 | * MVP Databinding Base Fragment | 17 | * MVP Databinding Base Fragment |
| @@ -23,7 +22,6 @@ import com.hannesdorfmann.mosby.mvp.MvpView; | @@ -23,7 +22,6 @@ import com.hannesdorfmann.mosby.mvp.MvpView; | ||
| 23 | */ | 22 | */ |
| 24 | public abstract class MvpBindingFragment<V extends MvpView, P extends MvpPresenter<V>, D, T extends ViewDataBinding> extends MvpFragment<V, P> { | 23 | public abstract class MvpBindingFragment<V extends MvpView, P extends MvpPresenter<V>, D, T extends ViewDataBinding> extends MvpFragment<V, P> { |
| 25 | 24 | ||
| 26 | - public V view; | ||
| 27 | public T binding; | 25 | public T binding; |
| 28 | public D data; | 26 | public D data; |
| 29 | 27 | ||
| @@ -35,32 +33,11 @@ public abstract class MvpBindingFragment<V extends MvpView, P extends MvpPresent | @@ -35,32 +33,11 @@ public abstract class MvpBindingFragment<V extends MvpView, P extends MvpPresent | ||
| 35 | return binding.getRoot(); | 33 | return binding.getRoot(); |
| 36 | } | 34 | } |
| 37 | 35 | ||
| 38 | - protected abstract int getLayoutId(); | ||
| 39 | - | ||
| 40 | protected D initLayoutData() { | 36 | protected D initLayoutData() { |
| 41 | return ReflectUtil.instance(2, this); | 37 | return ReflectUtil.instance(2, this); |
| 42 | } | 38 | } |
| 43 | 39 | ||
| 44 | @NonNull | 40 | @NonNull |
| 45 | - public V createView() { | ||
| 46 | - return ReflectUtil.instance(0, this.getClass(), this); | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | - @NonNull | ||
| 50 | - @Override | ||
| 51 | - public P createPresenter() { | ||
| 52 | - return ReflectUtil.instance(1, this); | ||
| 53 | - } | ||
| 54 | - | ||
| 55 | - @NonNull | ||
| 56 | - @Override | ||
| 57 | - public V getMvpView() { | ||
| 58 | - if (view == null) view = createView(); | ||
| 59 | - return view; | ||
| 60 | - } | ||
| 61 | - | ||
| 62 | - | ||
| 63 | - @NonNull | ||
| 64 | public D getViewData() { | 41 | public D getViewData() { |
| 65 | if(data == null) data = initLayoutData(); | 42 | if(data == null) data = initLayoutData(); |
| 66 | return data; | 43 | return data; |
cnlive/src/main/java/com/cnlive/libs/base/fragment/MvpFragment.java
| @@ -8,8 +8,8 @@ import android.view.View; | @@ -8,8 +8,8 @@ import android.view.View; | ||
| 8 | import android.view.ViewGroup; | 8 | import android.view.ViewGroup; |
| 9 | 9 | ||
| 10 | import com.cnlive.libs.base.util.ReflectUtil; | 10 | import com.cnlive.libs.base.util.ReflectUtil; |
| 11 | -import com.hannesdorfmann.mosby.mvp.MvpPresenter; | ||
| 12 | -import com.hannesdorfmann.mosby.mvp.MvpView; | 11 | +import com.hannesdorfmann.mosby3.mvp.MvpPresenter; |
| 12 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | ||
| 13 | 13 | ||
| 14 | /** | 14 | /** |
| 15 | * MVP Databinding Base Fragment | 15 | * MVP Databinding Base Fragment |
| @@ -17,7 +17,7 @@ import com.hannesdorfmann.mosby.mvp.MvpView; | @@ -17,7 +17,7 @@ import com.hannesdorfmann.mosby.mvp.MvpView; | ||
| 17 | * @param <V> MVP View {@link MvpView} | 17 | * @param <V> MVP View {@link MvpView} |
| 18 | * @param <P> MVP Presenter {@link MvpPresenter} | 18 | * @param <P> MVP Presenter {@link MvpPresenter} |
| 19 | */ | 19 | */ |
| 20 | -public abstract class MvpFragment<V extends MvpView, P extends MvpPresenter<V>> extends com.hannesdorfmann.mosby.mvp.MvpFragment<V, P> { | 20 | +public abstract class MvpFragment<V extends MvpView, P extends MvpPresenter<V>> extends com.hannesdorfmann.mosby3.mvp.MvpFragment<V, P> { |
| 21 | 21 | ||
| 22 | public V view; | 22 | public V view; |
| 23 | 23 |