├── LICENSE ├── README.md ├── app ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── cn │ │ └── droidlover │ │ └── xdroidmvp │ │ └── demo │ │ ├── App.java │ │ ├── adapter │ │ ├── GanhuoAdapter.java │ │ ├── GirlAdapter.java │ │ └── HomeAdapter.java │ │ ├── kit │ │ └── AppKit.java │ │ ├── model │ │ ├── BaseModel.java │ │ └── GankResults.java │ │ ├── net │ │ ├── Api.java │ │ └── GankService.java │ │ ├── present │ │ └── PBasePager.java │ │ ├── ui │ │ ├── AboutActivity.java │ │ ├── BasePagerFragment.java │ │ ├── GanhuoFragment.java │ │ ├── GirlFragment.java │ │ ├── HomeFragment.java │ │ ├── MainActivity.java │ │ └── WebActivity.java │ │ └── widget │ │ └── StateView.java │ └── res │ ├── drawable-v21 │ └── item_part_touch.xml │ ├── drawable │ ├── ic_arrow_white_24dp.xml │ ├── ic_keyboard_arrow_right_green_24dp.xml │ ├── ic_person_black_24dp.xml │ ├── ic_save_white_24dp.xml │ ├── ic_share_white_24dp.xml │ ├── item_part_touch.xml │ ├── view_border.xml │ └── view_shadow.xml │ ├── layout │ ├── activity_about.xml │ ├── activity_main.xml │ ├── activity_web.xml │ ├── adapter_ganhuo.xml │ ├── adapter_girl.xml │ ├── adapter_home.xml │ ├── fragment_base_pager.xml │ ├── view_loading.xml │ ├── view_state.xml │ └── view_toolbar.xml │ ├── menu │ ├── menu_main.xml │ └── menu_web.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ ├── ic_error.png │ ├── ic_launcher.png │ └── xdroid_logo_128.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ ├── android_icon.png │ ├── ic_launcher.png │ ├── ios_icon.png │ ├── js_icon.png │ ├── other_icon.png │ └── video_icon.jpg │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── art ├── XdroidMvp_total.png ├── snapshot_1.png └── snapshot_2.png ├── build.gradle ├── conf.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── mvp.png ├── mvp ├── build.gradle ├── proguard-pro │ ├── proguard-ARecyclerView.pro │ ├── proguard-avi-loading.pro │ ├── proguard-butterknife.pro │ ├── proguard-canary-debug.pro │ ├── proguard-canary-release.pro │ ├── proguard-constraint-layout.pro │ ├── proguard-design.pro │ ├── proguard-eventbus-3.pro │ ├── proguard-eventbus.pro │ ├── proguard-glide.pro │ ├── proguard-google-gson.pro │ ├── proguard-normal.pro │ ├── proguard-okhttp3-logging-interceptor.pro │ ├── proguard-okhttp3.pro │ ├── proguard-picasso.pro │ ├── proguard-proguard-design.pro │ ├── proguard-recyclerview-v7.pro │ ├── proguard-retrofit-adapter-rxjava.pro │ ├── proguard-retrofit-converter-gson.pro │ ├── proguard-retrofit.pro │ ├── proguard-rxandroid.pro │ ├── proguard-rxjava.pro │ ├── proguard-rxlifecycle-android.pro │ ├── proguard-rxlifecycle-components.pro │ ├── proguard-rxlifecycle.pro │ ├── proguard-rxpermissions.pro │ ├── proguard-self.pro │ ├── proguard-support-v4.pro │ └── proguard-support-v7-appcompat.pro ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── cn │ │ └── droidlover │ │ └── xdroidmvp │ │ ├── XDroidConf.java │ │ ├── base │ │ ├── ListItemCallback.java │ │ ├── SimpleListAdapter.java │ │ ├── SimpleRecAdapter.java │ │ ├── XFragmentAdapter.java │ │ └── XListAdapter.java │ │ ├── cache │ │ ├── DiskCache.java │ │ ├── DiskLruCache.java │ │ ├── ICache.java │ │ ├── MemoryCache.java │ │ └── SharedPref.java │ │ ├── event │ │ ├── BusProvider.java │ │ ├── IBus.java │ │ └── RxBusImpl.java │ │ ├── imageloader │ │ ├── GlideLoader.java │ │ ├── ILFactory.java │ │ ├── ILoader.java │ │ └── LoadCallback.java │ │ ├── kit │ │ ├── Codec.java │ │ ├── Kits.java │ │ ├── KnifeKit.java │ │ └── SimpleCallback.java │ │ ├── log │ │ ├── LogFormat.java │ │ ├── XLog.java │ │ └── XPrinter.java │ │ ├── mvp │ │ ├── IPresent.java │ │ ├── IView.java │ │ ├── LazyFragment.java │ │ ├── VDelegate.java │ │ ├── VDelegateBase.java │ │ ├── XActivity.java │ │ ├── XFragment.java │ │ ├── XLazyFragment.java │ │ └── XPresent.java │ │ ├── net │ │ ├── ApiSubscriber.java │ │ ├── Https.java │ │ ├── IModel.java │ │ ├── LogInterceptor.java │ │ ├── NetError.java │ │ ├── NetProvider.java │ │ ├── RequestHandler.java │ │ ├── XApi.java │ │ ├── XInterceptor.java │ │ ├── cookie │ │ │ ├── CookieJarImpl.java │ │ │ ├── CookieStore.java │ │ │ ├── HasCookieStore.java │ │ │ ├── MemoryCookieStore.java │ │ │ ├── PersistentCookieStore.java │ │ │ └── SerializableHttpCookie.java │ │ └── progress │ │ │ ├── ProRequestBody.java │ │ │ ├── ProResponseBody.java │ │ │ ├── ProgressHelper.java │ │ │ └── ProgressListener.java │ │ └── router │ │ ├── Router.java │ │ ├── RouterCallback.java │ │ └── SimpleRouterCallback.java │ └── res │ └── values │ └── strings.xml ├── settings.gradle ├── test ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── cn │ │ └── droidlover │ │ └── xdroidmvp │ │ └── test │ │ ├── ImageLoaderTest.java │ │ ├── base │ │ ├── AListAdapter.java │ │ ├── BRecAdapter.java │ │ ├── CListAdapter.java │ │ └── DRecAdapter.java │ │ ├── mvp │ │ ├── PermissionActivity.java │ │ ├── UiDelegateActivity.java │ │ ├── multi_p │ │ │ ├── BActivity.java │ │ │ ├── CActivity.java │ │ │ ├── ICommonV.java │ │ │ └── PMulti.java │ │ ├── no_p │ │ │ └── NoPActivity.java │ │ └── single_p │ │ │ ├── PSingle.java │ │ │ └── SinglePActivity.java │ │ ├── router │ │ ├── EndActivity.java │ │ └── StartActivity.java │ │ └── rxbus │ │ ├── LoginEvent.java │ │ └── RxBusActivity.java │ └── res │ ├── layout │ └── item_single.xml │ └── values │ └── strings.xml └── xdroid_logo_128.png /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 WangLei 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #XDroidMvp 轻量级的Android MVP快速开发框架 2 | 3 | ## 概述 4 | 5 |
6 |
7 |
16 |
17 |
54 |
55 |
187 |
188 |
191 |
192 |
{ 11 | void bindUI(View rootView); 12 | 13 | void bindEvent(); 14 | 15 | void initData(Bundle savedInstanceState); 16 | 17 | int getOptionsMenuId(); 18 | 19 | int getLayoutId(); 20 | 21 | boolean useEventBus(); 22 | 23 | P newP(); 24 | } 25 | -------------------------------------------------------------------------------- /mvp/src/main/java/cn/droidlover/xdroidmvp/mvp/VDelegate.java: -------------------------------------------------------------------------------- 1 | package cn.droidlover.xdroidmvp.mvp; 2 | 3 | import android.view.View; 4 | 5 | /** 6 | * Created by wanglei on 2016/12/29. 7 | */ 8 | 9 | public interface VDelegate { 10 | void resume(); 11 | 12 | void pause(); 13 | 14 | void destory(); 15 | 16 | void visible(boolean flag, View view); 17 | void gone(boolean flag, View view); 18 | void inVisible(View view); 19 | 20 | void toastShort(String msg); 21 | void toastLong(String msg); 22 | } 23 | -------------------------------------------------------------------------------- /mvp/src/main/java/cn/droidlover/xdroidmvp/mvp/VDelegateBase.java: -------------------------------------------------------------------------------- 1 | package cn.droidlover.xdroidmvp.mvp; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | import android.widget.Toast; 6 | 7 | /** 8 | * Created by wanglei on 2016/12/29. 9 | */ 10 | 11 | public class VDelegateBase implements VDelegate { 12 | 13 | private Context context; 14 | 15 | private VDelegateBase(Context context) { 16 | this.context = context; 17 | } 18 | 19 | public static VDelegate create(Context context) { 20 | return new VDelegateBase(context); 21 | } 22 | 23 | 24 | @Override 25 | public void resume() { 26 | 27 | } 28 | 29 | @Override 30 | public void pause() { 31 | 32 | } 33 | 34 | @Override 35 | public void destory() { 36 | 37 | } 38 | 39 | @Override 40 | public void visible(boolean flag, View view) { 41 | if (flag) view.setVisibility(View.VISIBLE); 42 | } 43 | 44 | @Override 45 | public void gone(boolean flag, View view) { 46 | if (flag) view.setVisibility(View.GONE); 47 | } 48 | 49 | @Override 50 | public void inVisible(View view) { 51 | view.setVisibility(View.INVISIBLE); 52 | } 53 | 54 | @Override 55 | public void toastShort(String msg) { 56 | Toast.makeText(context, msg, Toast.LENGTH_SHORT).show(); 57 | } 58 | 59 | @Override 60 | public void toastLong(String msg) { 61 | Toast.makeText(context, msg, Toast.LENGTH_LONG).show(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /mvp/src/main/java/cn/droidlover/xdroidmvp/mvp/XActivity.java: -------------------------------------------------------------------------------- 1 | package cn.droidlover.xdroidmvp.mvp; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.view.Menu; 7 | import android.view.View; 8 | 9 | import com.tbruyelle.rxpermissions2.RxPermissions; 10 | import com.trello.rxlifecycle2.components.support.RxAppCompatActivity; 11 | 12 | import butterknife.Unbinder; 13 | import cn.droidlover.xdroidmvp.XDroidConf; 14 | import cn.droidlover.xdroidmvp.event.BusProvider; 15 | import cn.droidlover.xdroidmvp.kit.KnifeKit; 16 | 17 | /** 18 | * Created by wanglei on 2016/12/29. 19 | */ 20 | 21 | public abstract class XActivity
extends RxAppCompatActivity implements IView
{ 22 | 23 | private VDelegate vDelegate; 24 | private P p; 25 | protected Activity context; 26 | 27 | private RxPermissions rxPermissions; 28 | 29 | private Unbinder unbinder; 30 | 31 | 32 | @Override 33 | protected void onCreate(@Nullable Bundle savedInstanceState) { 34 | super.onCreate(savedInstanceState); 35 | context = this; 36 | 37 | getP(); 38 | 39 | if (getLayoutId() > 0) { 40 | setContentView(getLayoutId()); 41 | bindUI(null); 42 | bindEvent(); 43 | } 44 | initData(savedInstanceState); 45 | 46 | } 47 | 48 | @Override 49 | public void bindUI(View rootView) { 50 | unbinder = KnifeKit.bind(this); 51 | } 52 | 53 | protected VDelegate getvDelegate() { 54 | if (vDelegate == null) { 55 | vDelegate = VDelegateBase.create(context); 56 | } 57 | return vDelegate; 58 | } 59 | 60 | protected P getP() { 61 | if (p == null) { 62 | p = newP(); 63 | } 64 | if (p != null) { 65 | if (!p.hasV()) { 66 | p.attachV(this); 67 | } 68 | } 69 | return p; 70 | } 71 | 72 | @Override 73 | protected void onStart() { 74 | super.onStart(); 75 | if (useEventBus()) { 76 | BusProvider.getBus().register(this); 77 | } 78 | } 79 | 80 | 81 | @Override 82 | protected void onResume() { 83 | super.onResume(); 84 | getvDelegate().resume(); 85 | } 86 | 87 | 88 | @Override 89 | protected void onPause() { 90 | super.onPause(); 91 | getvDelegate().pause(); 92 | } 93 | 94 | @Override 95 | public boolean useEventBus() { 96 | return false; 97 | } 98 | 99 | @Override 100 | protected void onDestroy() { 101 | super.onDestroy(); 102 | if (useEventBus()) { 103 | BusProvider.getBus().unregister(this); 104 | } 105 | if (getP() != null) { 106 | getP().detachV(); 107 | } 108 | getvDelegate().destory(); 109 | p = null; 110 | vDelegate = null; 111 | } 112 | 113 | @Override 114 | public boolean onCreateOptionsMenu(Menu menu) { 115 | if (getOptionsMenuId() > 0) { 116 | getMenuInflater().inflate(getOptionsMenuId(), menu); 117 | } 118 | return super.onCreateOptionsMenu(menu); 119 | } 120 | 121 | protected RxPermissions getRxPermissions() { 122 | rxPermissions = new RxPermissions(this); 123 | rxPermissions.setLogging(XDroidConf.DEV); 124 | return rxPermissions; 125 | } 126 | 127 | @Override 128 | public int getOptionsMenuId() { 129 | return 0; 130 | } 131 | 132 | @Override 133 | public void bindEvent() { 134 | 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /mvp/src/main/java/cn/droidlover/xdroidmvp/mvp/XFragment.java: -------------------------------------------------------------------------------- 1 | package cn.droidlover.xdroidmvp.mvp; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.os.Bundle; 6 | import android.support.annotation.Nullable; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | 11 | import com.tbruyelle.rxpermissions2.RxPermissions; 12 | import com.trello.rxlifecycle2.components.support.RxFragment; 13 | 14 | import butterknife.Unbinder; 15 | import cn.droidlover.xdroidmvp.XDroidConf; 16 | import cn.droidlover.xdroidmvp.event.BusProvider; 17 | import cn.droidlover.xdroidmvp.kit.KnifeKit; 18 | 19 | /** 20 | * Created by wanglei on 2016/12/29. 21 | */ 22 | 23 | public abstract class XFragment
extends RxFragment implements IView
{ 24 | 25 | private VDelegate vDelegate; 26 | private P p; 27 | protected Activity context; 28 | private View rootView; 29 | protected LayoutInflater layoutInflater; 30 | 31 | private RxPermissions rxPermissions; 32 | 33 | private Unbinder unbinder; 34 | 35 | 36 | @Nullable 37 | @Override 38 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 39 | layoutInflater = inflater; 40 | if (rootView == null && getLayoutId() > 0) { 41 | rootView = inflater.inflate(getLayoutId(), null); 42 | bindUI(rootView); 43 | } else { 44 | ViewGroup viewGroup = (ViewGroup) rootView.getParent(); 45 | if (viewGroup != null) { 46 | viewGroup.removeView(rootView); 47 | } 48 | } 49 | 50 | return rootView; 51 | } 52 | 53 | 54 | @Override 55 | public void onActivityCreated(@Nullable Bundle savedInstanceState) { 56 | super.onActivityCreated(savedInstanceState); 57 | getP(); 58 | 59 | if (useEventBus()) { 60 | BusProvider.getBus().register(this); 61 | } 62 | bindEvent(); 63 | initData(savedInstanceState); 64 | } 65 | 66 | @Override 67 | public void bindUI(View rootView) { 68 | unbinder = KnifeKit.bind(this, rootView); 69 | } 70 | 71 | protected VDelegate getvDelegate() { 72 | if (vDelegate == null) { 73 | vDelegate = VDelegateBase.create(context); 74 | } 75 | return vDelegate; 76 | } 77 | 78 | protected P getP() { 79 | if (p == null) { 80 | p = newP(); 81 | } 82 | if (p != null) { 83 | if (!p.hasV()) { 84 | p.attachV(this); 85 | } 86 | } 87 | return p; 88 | } 89 | 90 | @Override 91 | public void onAttach(Context context) { 92 | super.onAttach(context); 93 | if (context instanceof Activity) { 94 | this.context = (Activity) context; 95 | } 96 | } 97 | 98 | @Override 99 | public void onDetach() { 100 | super.onDetach(); 101 | context = null; 102 | } 103 | 104 | @Override 105 | public boolean useEventBus() { 106 | return false; 107 | } 108 | 109 | 110 | @Override 111 | public void onDestroyView() { 112 | super.onDestroyView(); 113 | if (useEventBus()) { 114 | BusProvider.getBus().unregister(this); 115 | } 116 | if (getP() != null) { 117 | getP().detachV(); 118 | } 119 | getvDelegate().destory(); 120 | 121 | p = null; 122 | vDelegate = null; 123 | } 124 | 125 | protected RxPermissions getRxPermissions() { 126 | rxPermissions = new RxPermissions(getActivity()); 127 | rxPermissions.setLogging(XDroidConf.DEV); 128 | return rxPermissions; 129 | } 130 | 131 | @Override 132 | public int getOptionsMenuId() { 133 | return 0; 134 | } 135 | 136 | @Override 137 | public void bindEvent() { 138 | 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /mvp/src/main/java/cn/droidlover/xdroidmvp/mvp/XLazyFragment.java: -------------------------------------------------------------------------------- 1 | package cn.droidlover.xdroidmvp.mvp; 2 | 3 | import android.os.Bundle; 4 | import android.view.View; 5 | 6 | import com.tbruyelle.rxpermissions2.RxPermissions; 7 | 8 | import butterknife.Unbinder; 9 | import cn.droidlover.xdroidmvp.XDroidConf; 10 | import cn.droidlover.xdroidmvp.event.BusProvider; 11 | import cn.droidlover.xdroidmvp.kit.KnifeKit; 12 | 13 | /** 14 | * Created by wanglei on 2017/1/26. 15 | */ 16 | 17 | public abstract class XLazyFragment
18 | extends LazyFragment implements IView
{
19 |
20 | private VDelegate vDelegate;
21 | private P p;
22 |
23 | private RxPermissions rxPermissions;
24 | private Unbinder unbinder;
25 |
26 | @Override
27 | protected void onCreateViewLazy(Bundle savedInstanceState) {
28 | super.onCreateViewLazy(savedInstanceState);
29 |
30 | getP();
31 |
32 | if (getLayoutId() > 0) {
33 | setContentView(getLayoutId());
34 | bindUI(getRealRootView());
35 | }
36 | if (useEventBus()) {
37 | BusProvider.getBus().register(this);
38 | }
39 | bindEvent();
40 | initData(savedInstanceState);
41 | }
42 |
43 | @Override
44 | public void bindUI(View rootView) {
45 | unbinder = KnifeKit.bind(this, rootView);
46 | }
47 |
48 | @Override
49 | public void bindEvent() {
50 |
51 | }
52 |
53 |
54 | public VDelegate getvDelegate() {
55 | if (vDelegate == null) {
56 | vDelegate = VDelegateBase.create(context);
57 | }
58 | return vDelegate;
59 | }
60 |
61 | protected P getP() {
62 | if (p == null) {
63 | p = newP();
64 | }
65 | if (p != null) {
66 | if (!p.hasV()) {
67 | p.attachV(this);
68 | }
69 | }
70 | return p;
71 | }
72 |
73 | @Override
74 | protected void onDestoryLazy() {
75 | super.onDestoryLazy();
76 | if (useEventBus()) {
77 | BusProvider.getBus().unregister(this);
78 | }
79 | if (getP() != null) {
80 | getP().detachV();
81 | }
82 | getvDelegate().destory();
83 |
84 | p = null;
85 | vDelegate = null;
86 | }
87 |
88 |
89 | protected RxPermissions getRxPermissions() {
90 | rxPermissions = new RxPermissions(getActivity());
91 | rxPermissions.setLogging(XDroidConf.DEV);
92 | return rxPermissions;
93 | }
94 |
95 |
96 | @Override
97 | public int getOptionsMenuId() {
98 | return 0;
99 | }
100 |
101 |
102 | @Override
103 | public boolean useEventBus() {
104 | return false;
105 | }
106 |
107 |
108 | }
109 |
--------------------------------------------------------------------------------
/mvp/src/main/java/cn/droidlover/xdroidmvp/mvp/XPresent.java:
--------------------------------------------------------------------------------
1 | package cn.droidlover.xdroidmvp.mvp;
2 |
3 | import java.lang.ref.WeakReference;
4 |
5 | /**
6 | * Created by wanglei on 2016/12/29.
7 | */
8 |
9 | public class XPresent