getDataSubscriber() {
41 | return observeForever;
42 | }
43 |
44 | @Override
45 | public void retryData() {
46 | setLoadData(1);
47 | }
48 |
49 | /***
50 | * 列表加载分页数据
51 | *
52 | * @param pager 分页 等于1 刷新
53 | ***/
54 | public void setLoadData(int pager) {
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/Aac-data-module/src/main/java/com/aac/expansion/data/AacDataActivity.java:
--------------------------------------------------------------------------------
1 | package com.aac.expansion.data;
2 |
3 |
4 | import android.support.annotation.CallSuper;
5 | import android.support.annotation.NonNull;
6 | import android.view.View;
7 | import com.aac.expansion.ener.ViewGetDataListener;
8 | import com.aac.module.ui.AacActivity;
9 | import com.helper.loadviewhelper.load.LoadViewHelper;
10 |
11 | /**
12 | * author yangc
13 | * date 2017/8/14
14 | * E-Mail:yangchaojiang@outlook.com
15 | * Deprecated: Activity数据父类
16 | */
17 |
18 | public abstract class AacDataActivity extends AacActivity
implements ViewGetDataListener {
19 | private LoadViewHelper helper;
20 |
21 | @CallSuper
22 | @Override
23 | public void onDestroy() {
24 | super.onDestroy();
25 | if (helper != null) {
26 | helper.onDestroy();
27 | }
28 | }
29 |
30 | /***
31 | *父类调用方法,用于切换
32 | * **/
33 | void setBaseData(@NonNull M data) {
34 | if (helper != null) {
35 | helper.showContent();
36 | }
37 | setData(data);
38 | }
39 |
40 |
41 | /***
42 | *父类调用方法,用于切换
43 | * **/
44 | @Override
45 | public void setError(Throwable e) {
46 | if (helper != null) {
47 | helper.showError();
48 | }
49 | }
50 |
51 | @Override
52 | public LoadViewHelper getViewLoadHelper() {
53 | return helper;
54 | }
55 |
56 | @Override
57 | public void showLoadView() {
58 | if (helper != null) {
59 | helper.showLoading();
60 | }
61 | }
62 |
63 | @Override
64 | public void initLoadHelper(@NonNull View view) {
65 | helper = new LoadViewHelper(view);
66 | helper.showLoading();
67 | helper.setListener(() -> getPresenter().retryData());
68 | }
69 |
70 | @Override
71 | public void showErrorView() {
72 | if (helper != null) {
73 | helper.showError();
74 | }
75 | }
76 |
77 | @Override
78 | public void showContentView() {
79 | if (helper != null) {
80 | helper.showContent();
81 | }
82 | }
83 | /***
84 | * 数据返回
85 | * @param data data
86 | * **/
87 | public abstract void setData(@NonNull M data);
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/Aac-data-module/src/main/java/com/aac/expansion/data/AacDataFPresenter.java:
--------------------------------------------------------------------------------
1 | package com.aac.expansion.data;
2 |
3 |
4 | import android.arch.lifecycle.Observer;
5 | import android.support.annotation.NonNull;
6 |
7 | import com.aac.expansion.ener.PostDataListener;
8 | import com.aac.module.ui.AacFragmentPresenter;
9 |
10 | /**
11 | * author yangc
12 | * date 2017/8/14
13 | * E-Mail:yangchaojiang@outlook.com
14 | * Deprecated: Fragment数据业务
15 | */
16 |
17 | public abstract class AacDataFPresenter extends AacFragmentPresenter implements PostDataListener {
18 |
19 | private Observer observeForever = m -> {
20 | if (m != null) {
21 | postData(m);
22 | } else {
23 | postError(new Throwable(new NullPointerException()));
24 | }
25 | };
26 |
27 | @Override
28 | public void postData(@NonNull M m) {
29 | getView().setBaseData(m);
30 | }
31 |
32 | @Override
33 | public void postError(Throwable e) {
34 | getView().setError(e);
35 |
36 | }
37 |
38 | @Override
39 | public void retryData() {
40 |
41 | }
42 | /**
43 | * 返回订阅数据
44 | *
45 | * @return Observer
46 | ***/
47 | public Observer getDataSubscriber() {
48 | return observeForever;
49 | }
50 |
51 | /**
52 | * 当视图初始化并且对用户可见的时候去真正的加载数据
53 | */
54 | protected abstract void lazyLoad();
55 |
56 | /**
57 | * 当视图已经对用户不可见并且加载过数据,如果需要在切换到其他页面时停止加载数据,可以覆写此方法
58 | */
59 | protected void stopLoad() {
60 | }
61 | /***
62 | * 列表加载分页数据
63 | *
64 | * @param pager 分页 等于1 刷新
65 | ***/
66 | public void setLoadData(int pager){}
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/Aac-data-module/src/main/java/com/aac/expansion/data/AacDataFragment.java:
--------------------------------------------------------------------------------
1 | package com.aac.expansion.data;
2 |
3 | import android.support.annotation.CallSuper;
4 | import android.support.annotation.NonNull;
5 | import android.view.View;
6 |
7 | import com.aac.expansion.ener.ViewGetDataListener;
8 | import com.aac.module.ui.AacFragment;
9 | import com.helper.loadviewhelper.load.LoadViewHelper;
10 |
11 | /**
12 | * Created by yangc on 2017/8/14.
13 | * E-Mail:yangchaojiang@outlook.com
14 | * Deprecated: Fragment 数据view
15 | */
16 |
17 | public abstract class AacDataFragment extends AacFragment
implements ViewGetDataListener {
18 | private LoadViewHelper helper;
19 | private boolean isInit = false;
20 | private boolean isLoad = false;
21 |
22 | @CallSuper
23 | @Override
24 | public void onDestroy() {
25 | super.onDestroy();
26 | if (helper != null) {
27 | helper.onDestroy();
28 | }
29 | }
30 |
31 | /***
32 | * 父类调用方法,用于切换
33 | **/
34 | void setBaseData(@NonNull M data) {
35 | showContentView();
36 | setData(data);
37 | }
38 |
39 | @Override
40 | public void setError(Throwable e) {
41 | showErrorView();
42 | }
43 |
44 | /**
45 | * 视图是否已经对用户可见,系统的方法
46 | */
47 | @CallSuper
48 | @Override
49 | public void setUserVisibleHint(boolean isVisibleToUser) {
50 | super.setUserVisibleHint(isVisibleToUser);
51 | if (setOpenLazyLoad()) {
52 | isCanLoadData();
53 | }
54 | }
55 |
56 | /**
57 | * 是否可以加载数据
58 | * 可以加载数据的条件:
59 | * 1.视图已经初始化
60 | * 2.视图对用户可见
61 | */
62 | protected void isCanLoadData() {
63 | if (!isInit) {
64 | return;
65 | }
66 | if (getUserVisibleHint()) {
67 | if (!isLoad) {
68 | isLoad = true;
69 | getPresenter().lazyLoad();
70 | }else {
71 | showContentView();
72 | }
73 | } else {
74 | if (isLoad) {
75 | getPresenter().stopLoad();
76 | }
77 | }
78 | }
79 |
80 | /**
81 | * 开启懒加载
82 | *
83 | * @return setOpenLazyLoad true 开启 false
84 | **/
85 | protected boolean setOpenLazyLoad() {
86 | return false;
87 | }
88 |
89 | @Override
90 | public LoadViewHelper getViewLoadHelper() {
91 | return helper;
92 | }
93 |
94 | @Override
95 | public void initLoadHelper(@NonNull View view) {
96 | if (!isInit) {
97 | helper = new LoadViewHelper(view);
98 | helper.showLoading();
99 | helper.setListener(() -> {
100 | getViewLoadHelper().showLoading();
101 | getPresenter().retryData();
102 | });
103 | }
104 | }
105 |
106 | @Override
107 | public void showErrorView() {
108 |
109 | if (helper != null) {
110 | helper.showError();
111 | }
112 | }
113 |
114 | @Override
115 | public void showContentView() {
116 | if (helper != null) {
117 | helper.showContent();
118 | }
119 | }
120 |
121 | @Override
122 | public void showLoadView() {
123 | if (helper != null) {
124 | helper.showLoading();
125 | }
126 | }
127 |
128 | /***
129 | * 数据返回
130 | * @param data data
131 | * **/
132 | protected abstract void setData(@NonNull M data);
133 | }
134 |
--------------------------------------------------------------------------------
/Aac-data-module/src/main/java/com/aac/expansion/ener/PostDataListener.java:
--------------------------------------------------------------------------------
1 | package com.aac.expansion.ener;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 |
6 | /**
7 | * author yangc
8 | * date 2017/12/28
9 | * E-Mail:yangchaojiang@outlook.com
10 | * Deprecated:
11 | */
12 |
13 | public interface PostDataListener {
14 |
15 | /***
16 | * 手动发布数据
17 | * @param m 数据
18 | *
19 | **/
20 | void postData(@NonNull M m);
21 | /**
22 | * 手动发布错误
23 | *
24 | * @param e e
25 | */
26 | void postError(Throwable e);
27 | /**
28 | * 点击重试加载
29 | **/
30 | void retryData();
31 |
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/Aac-data-module/src/main/java/com/aac/expansion/ener/ViewGetDataListener.java:
--------------------------------------------------------------------------------
1 | package com.aac.expansion.ener;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.view.View;
5 |
6 | import com.helper.loadviewhelper.load.LoadViewHelper;
7 |
8 | /**
9 | * Created by yangc on 2017/9/15.
10 | * E-Mail:yangchaojiang@outlook.com
11 | * Deprecated: 数据view 接口
12 | */
13 |
14 |
15 | public interface ViewGetDataListener {
16 |
17 | LoadViewHelper getViewLoadHelper();
18 |
19 | /***
20 | * 错误处理
21 | *
22 | * @param e 错误
23 | **/
24 | void setError(Throwable e);
25 |
26 | /***
27 | * 显示加载中布局
28 | * @param contentView 内容布局
29 | * ***/
30 | void initLoadHelper(@NonNull View contentView);
31 |
32 | /***
33 | * 显示加载中布局
34 | * ***/
35 | void showLoadView();
36 |
37 | /***
38 | * 显示错误布局
39 | * ***/
40 | void showErrorView();
41 |
42 | /***
43 | * 显示内容布局
44 | * ***/
45 | void showContentView();
46 | }
47 |
--------------------------------------------------------------------------------
/Aac-data-module/src/main/java/com/aac/expansion/ener/ViewGetListener.java:
--------------------------------------------------------------------------------
1 | package com.aac.expansion.ener;
2 |
3 | import android.support.annotation.LayoutRes;
4 | import android.support.v7.widget.RecyclerView;
5 |
6 | import com.chad.library.adapter.base.BaseQuickAdapter;
7 | import com.chad.library.adapter.base.BaseViewHolder;
8 |
9 | /**
10 | * Created by yangc on 2017/9/15.
11 | * E-Mail:yangchaojiang@outlook.com
12 | * Deprecated: 列表数据view 接口
13 | */
14 |
15 |
16 | public interface ViewGetListener extends ViewGetDataListener{
17 | /***
18 | * 获取当前的分页数
19 | * @return int
20 | ***/
21 | int getCurPage();
22 | /**
23 | * 获取获取最后一个示例
24 | * @return BaseQuickAdapter
25 | **/
26 | M getLastItem();
27 | /**
28 | * 获取RecyclerView
29 | * @return RecyclerView
30 | **/
31 | RecyclerView getRecyclerView();
32 |
33 | /**
34 | * 获取数据适配器实例
35 | * @return BaseQuickAdapter
36 | **/
37 | BaseQuickAdapter getAdapter();
38 |
39 | /***
40 | * 设置网格中的列数
41 | * 子类重写该方法 大于1 使用网格布局 否则L是list
42 | * @return int
43 | */
44 | int setGridSpanCount();
45 |
46 | /***
47 | * 获取item数据layoutId
48 | * @return int
49 | **/
50 | @LayoutRes
51 | int getItemLayout();
52 |
53 |
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/Aac-data-module/src/main/java/com/aac/expansion/list/AacListAPresenter.java:
--------------------------------------------------------------------------------
1 | package com.aac.expansion.list;
2 |
3 |
4 |
5 | import com.aac.expansion.data.AacDataAPresenter;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * Created by yangc on 2017/8/14.
11 | * E-Mail:yangchaojiang@outlook.com
12 | * Deprecated: 列表数据业务
13 | */
14 |
15 | public abstract class AacListAPresenter extends AacDataAPresenter>{
16 |
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/Aac-data-module/src/main/java/com/aac/expansion/list/AacListFPresenter.java:
--------------------------------------------------------------------------------
1 | package com.aac.expansion.list;
2 |
3 | import com.aac.expansion.data.AacDataFPresenter;
4 | import java.util.List;
5 |
6 | /**
7 | * Created by yangc on 2017/8/14.
8 | * E-Mail:yangchaojiang@outlook.com
9 | * Deprecated: Fragment 列表数据理处理
10 | */
11 |
12 | public abstract class AacListFPresenter extends AacDataFPresenter> {
13 |
14 |
15 |
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/Aac-data-module/src/main/java/com/aac/expansion/list/AacListFragment.java:
--------------------------------------------------------------------------------
1 | package com.aac.expansion.list;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.CallSuper;
5 | import android.support.annotation.NonNull;
6 | import android.support.annotation.Nullable;
7 | import android.support.v4.widget.SwipeRefreshLayout;
8 | import android.support.v7.widget.GridLayoutManager;
9 | import android.support.v7.widget.LinearLayoutManager;
10 | import android.support.v7.widget.RecyclerView;
11 | import android.view.View;
12 |
13 | import com.aac.expansion.R;
14 | import com.aac.expansion.data.AacDataFPresenter;
15 | import com.aac.expansion.data.AacDataFragment;
16 | import com.aac.expansion.ener.ViewGetListener;
17 | import com.chad.library.adapter.base.BaseQuickAdapter;
18 | import com.chad.library.adapter.base.BaseViewHolder;
19 |
20 | import java.lang.ref.WeakReference;
21 | import java.util.List;
22 |
23 | /**
24 | * author yangc
25 | * date 2017/8/14
26 | * E-Mail:yangchaojiang@outlook.com
27 | * Deprecated: 列表Fragment 支持懒加载, 子类重写setOpenLazyLoad方法,开启懒加载
28 | */
29 |
30 | public abstract class AacListFragment extends AacDataFragment
>
31 | implements SwipeRefreshLayout.OnRefreshListener, BaseQuickAdapter.RequestLoadMoreListener, ViewGetListener {
32 | private RecyclerView recyclerView;
33 | protected SwipeRefreshLayout swipeRefresh;
34 | private int daraPage = 1;
35 | private AacBaseQuickAdapter adapter;
36 |
37 | @CallSuper
38 | @Override
39 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
40 | super.onViewCreated(view, savedInstanceState);
41 | swipeRefresh = view.findViewById(R.id.swipeRefresh);
42 | recyclerView = view.findViewById(R.id.recyclerView);
43 | if (setGridSpanCount() <= 1) {
44 | recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
45 | } else {
46 | recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), setGridSpanCount()));
47 | }
48 | // recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
49 | swipeRefresh.setOnRefreshListener(this);
50 | swipeRefresh.setRefreshing(false);
51 | adapter = new AacBaseQuickAdapter(this);
52 | adapter.bindToRecyclerView(recyclerView);
53 | }
54 |
55 | @Override
56 | public void initLoadHelper(@NonNull View view) {
57 | super.initLoadHelper(view);
58 | adapter.setEmptyView(getViewLoadHelper().getEmptyLayoutId(),recyclerView);
59 | }
60 |
61 | @CallSuper
62 | @Override
63 | public void onDestroy() {
64 | super.onDestroy();
65 | if (adapter != null) {
66 | adapter.getData().clear();
67 | adapter.setOnLoadMoreListener(null, recyclerView);
68 |
69 | }
70 | if (swipeRefresh != null) {
71 | swipeRefresh.setRefreshing(false);
72 | swipeRefresh.setOnRefreshListener(null);
73 | }
74 | }
75 |
76 | /***
77 | * 设置数据
78 | * @param data data
79 | * **/
80 | public void setData(@NonNull List data) {
81 | if (daraPage < 2) {
82 | if (swipeRefresh.isRefreshing()) {
83 | setRefreshing(false);
84 | }
85 | adapter.getData().clear();
86 | adapter.notifyDataSetChanged();
87 | adapter.addData(data);
88 |
89 | } else {
90 | if (data.isEmpty()) {
91 | adapter.loadMoreEnd();
92 | } else {
93 | adapter.loadMoreComplete();
94 | }
95 | adapter.addData(data);
96 | }
97 |
98 | }
99 |
100 | @Override
101 | public void setError(Throwable e) {
102 | if (daraPage < 2) {
103 | if (swipeRefresh.isRefreshing()) {
104 | setRefreshing(false);
105 | }
106 | showErrorView();
107 | } else {
108 | adapter.loadMoreFail();
109 | }
110 | }
111 |
112 | public void setDaraPage(int daraPage) {
113 | this.daraPage = daraPage;
114 | }
115 |
116 | @Override
117 | public int getContentLayoutId() {
118 | return R.layout.aac_include_recycle_view;
119 | }
120 |
121 |
122 | @Override
123 | public void onRefresh() {
124 | daraPage = 1;
125 | getPresenter().setLoadData(daraPage);
126 | }
127 |
128 | @Override
129 | public void onLoadMoreRequested() {
130 | daraPage += 1;
131 | getPresenter().setLoadData(daraPage);
132 | }
133 |
134 |
135 | @Override
136 | public int getCurPage() {
137 | return daraPage;
138 | }
139 | @Nullable
140 | @Override
141 | public M getLastItem() {
142 | if (adapter.getData().isEmpty()){
143 | return null;
144 | }
145 | return adapter.getItem(adapter.getData().size()-1);
146 | }
147 | /**
148 | * 获取RecyclerView
149 | **/
150 | @Override
151 | public RecyclerView getRecyclerView() {
152 | return recyclerView;
153 | }
154 |
155 | /**
156 | * 获取数据适配器实例
157 | **/
158 | @Override
159 | public BaseQuickAdapter getAdapter() {
160 | return adapter;
161 | }
162 |
163 |
164 | /***
165 | * @param setRefreshing 是否刷新 true false 则停止
166 | **/
167 | public void setRefreshing(boolean setRefreshing) {
168 | showContentView();
169 | swipeRefresh.postDelayed(() -> {
170 | if (swipeRefresh == null) return;
171 | swipeRefresh.setRefreshing(setRefreshing);
172 | if (setRefreshing) {
173 | onRefresh();
174 | }
175 | }, 200);
176 | }
177 |
178 | /**
179 | * 是否启用分页 默认不启用
180 | *
181 | * @param enable true 启用 false 不启用
182 | */
183 | public void setStartLoadMore(boolean enable) {
184 | if (enable) {
185 | adapter.setOnLoadMoreListener(this, recyclerView);
186 | }
187 | }
188 | /****
189 | * BaseViewHolder 实现item 布局内容
190 | *
191 | * @param helper BaseViewHolder
192 | * @param item 数据
193 | **/
194 | protected abstract void convertViewHolder(BaseViewHolder helper, M item);
195 | /***
196 | * 数据式适配器
197 | ****/
198 | private class AacBaseQuickAdapter extends BaseQuickAdapter {
199 | private WeakReference weakReference;
200 |
201 | private AacBaseQuickAdapter(AacListFragment aacListFragment) {
202 | super(getItemLayout());
203 | weakReference = new WeakReference<>(aacListFragment);
204 |
205 | }
206 |
207 | @Override
208 | protected void convert(BaseViewHolder helper, M item) {
209 | if (weakReference.get() == null) return;
210 | convertViewHolder(helper, item);
211 | }
212 | }
213 |
214 |
215 | }
216 |
217 |
--------------------------------------------------------------------------------
/Aac-data-module/src/main/java/com/aac/expansion/list/AacMultiListAPresenter.java:
--------------------------------------------------------------------------------
1 | package com.aac.expansion.list;
2 |
3 |
4 |
5 | import com.aac.expansion.data.AacDataAPresenter;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * Created by yangc on 2017/8/14.
11 | * E-Mail:yangchaojiang@outlook.com
12 | * Deprecated: 列表数据业务
13 | */
14 |
15 | public abstract class AacMultiListAPresenter extends AacDataAPresenter>{
16 |
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/Aac-data-module/src/main/java/com/aac/expansion/list/AacMultiListActivity.java:
--------------------------------------------------------------------------------
1 | package com.aac.expansion.list;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.support.annotation.CallSuper;
6 | import android.support.annotation.NonNull;
7 | import android.support.annotation.Nullable;
8 | import android.support.v4.widget.SwipeRefreshLayout;
9 | import android.support.v7.widget.GridLayoutManager;
10 | import android.support.v7.widget.LinearLayoutManager;
11 | import android.support.v7.widget.RecyclerView;
12 | import android.view.View;
13 | import com.aac.expansion.R;
14 | import com.aac.expansion.data.AacDataAPresenter;
15 | import com.aac.expansion.data.AacDataActivity;
16 | import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
17 | import com.chad.library.adapter.base.BaseQuickAdapter;
18 | import java.util.List;
19 |
20 | /**
21 | * Created by yangc on 2017/8/14.
22 | * E-Mail:yangchaojiang@outlook.com
23 | * Deprecated: 数据父类
24 | */
25 |
26 | public abstract class AacMultiListActivity extends AacDataActivity
>
27 | implements SwipeRefreshLayout.OnRefreshListener, BaseQuickAdapter.RequestLoadMoreListener {
28 | protected RecyclerView recyclerView;
29 | protected SwipeRefreshLayout swipeRefresh;
30 | private BaseMultiItemQuickAdapter adapter;
31 | private int daraPage = 1;
32 |
33 | @CallSuper
34 | @Override
35 | protected void onCreate(@Nullable Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | swipeRefresh = findViewById(R.id.swipeRefresh);
38 | recyclerView = findViewById(R.id.recyclerView);
39 | if (setGridSpanCount() <= 1) {
40 | recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
41 | } else {
42 | recyclerView.setLayoutManager(new GridLayoutManager(this, setGridSpanCount()));
43 | }
44 | // recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
45 | swipeRefresh.setOnRefreshListener(this);
46 | adapter =getMultiAdapter();
47 | adapter.bindToRecyclerView(recyclerView);
48 | //检查是否满一屏,如果不满足关闭loadMore
49 | initLoadHelper(swipeRefresh);
50 | adapter.disableLoadMoreIfNotFullPage();
51 |
52 | }
53 |
54 | @CallSuper
55 | @Override
56 | public void onDestroy() {
57 | super.onDestroy();
58 | if (adapter != null) {
59 | adapter.getData().clear();
60 | adapter.setOnLoadMoreListener(null, recyclerView);
61 | }
62 | if (swipeRefresh != null) {
63 | swipeRefresh.setRefreshing(false);
64 | swipeRefresh.setOnRefreshListener(null);
65 | }
66 | }
67 |
68 | @Override
69 | public void initLoadHelper(@NonNull View view) {
70 | super.initLoadHelper(view);
71 | adapter.setEmptyView(getViewLoadHelper().getEmptyLayoutId());
72 | }
73 |
74 | @Override
75 | public void onRefresh() {
76 | daraPage = 1;
77 | getPresenter().setLoadData(daraPage);
78 | }
79 |
80 | @Override
81 | public void onLoadMoreRequested() {
82 | daraPage += 1;
83 | getPresenter().setLoadData(daraPage);
84 | }
85 |
86 | /***
87 | * 设置数据
88 | * @param data data
89 | * **/
90 | @Override
91 | public void setData(@NonNull List data) {
92 | if (daraPage < 2) {
93 | if (swipeRefresh.isRefreshing()) {
94 | setRefreshing(false);
95 | }
96 | adapter.getData().clear();
97 | adapter.notifyDataSetChanged();
98 | adapter.addData(data);
99 |
100 | } else {
101 | if (data.isEmpty()) {
102 | adapter.loadMoreEnd();
103 | } else {
104 | adapter.loadMoreComplete();
105 | }
106 | adapter.addData(data);
107 | }
108 |
109 | }
110 |
111 | /***
112 | * 错误
113 | * @param e 错误
114 | **/
115 | @Override
116 | public void setError(Throwable e) {
117 | if (daraPage < 2) {
118 | if (swipeRefresh.isRefreshing()) {
119 | setRefreshing(false);
120 | }
121 | showErrorView();
122 | } else {
123 | adapter.loadMoreFail();
124 | }
125 | }
126 |
127 | @Override
128 | public int getContentLayoutId() {
129 | return R.layout.aac_recycle_view;
130 | }
131 |
132 | public void setDaraPage(int daraPage) {
133 | this.daraPage = daraPage;
134 | }
135 |
136 | public int getCurPage() {
137 | return daraPage;
138 | }
139 |
140 | /**
141 | * 获取RecyclerView
142 | **/
143 | public RecyclerView getRecyclerView() {
144 | return recyclerView;
145 | }
146 |
147 | /***
148 | * 进入页面开启是否下拉刷新
149 | *
150 | * @param setRefreshing true 开始刷新 false 停滞
151 | **/
152 | public void setRefreshing(final boolean setRefreshing) {
153 | showContentView();
154 | swipeRefresh.postDelayed(() -> {
155 | if (swipeRefresh == null) return;
156 | swipeRefresh.setRefreshing(setRefreshing);
157 | if (setRefreshing) {
158 | onRefresh();
159 | }
160 | }, 200);
161 |
162 | }
163 | /***
164 | * 设置网格中的列数
165 | * 子类重写该方法 大于1 使用网格布局 否则L是list
166 | */
167 | public int setGridSpanCount() {
168 | return 1;
169 | }
170 |
171 | /**
172 | * 是否启用分页 默认不启用
173 | *
174 | * @param enable true 启用 false 不启用
175 | */
176 | public void setLoadMore(boolean enable) {
177 | if (enable) {
178 | adapter.setOnLoadMoreListener(this, recyclerView);
179 | }
180 | }
181 | @NonNull
182 | public abstract BaseMultiItemQuickAdapter getMultiAdapter();
183 |
184 | }
185 |
--------------------------------------------------------------------------------
/Aac-data-module/src/main/java/com/aac/expansion/list/AacMultiListFPresenter.java:
--------------------------------------------------------------------------------
1 | package com.aac.expansion.list;
2 |
3 | import com.aac.expansion.data.AacDataFPresenter;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * Created by yangc on 2017/8/14.
9 | * E-Mail:yangchaojiang@outlook.com
10 | * Deprecated: Fragment 列表数据理处理
11 | */
12 |
13 | public abstract class AacMultiListFPresenter extends AacDataFPresenter> {
14 |
15 |
16 |
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/Aac-data-module/src/main/java/com/aac/expansion/list/AacMultiListFragment.java:
--------------------------------------------------------------------------------
1 | package com.aac.expansion.list;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.CallSuper;
5 | import android.support.annotation.NonNull;
6 | import android.support.annotation.Nullable;
7 | import android.support.v4.widget.SwipeRefreshLayout;
8 | import android.support.v7.widget.GridLayoutManager;
9 | import android.support.v7.widget.LinearLayoutManager;
10 | import android.support.v7.widget.RecyclerView;
11 | import android.view.View;
12 | import com.aac.expansion.R;
13 | import com.aac.expansion.data.AacDataFPresenter;
14 | import com.aac.expansion.data.AacDataFragment;
15 | import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
16 | import com.chad.library.adapter.base.BaseQuickAdapter;
17 | import com.chad.library.adapter.base.entity.MultiItemEntity;
18 | import java.util.List;
19 |
20 | /**
21 | * author yangc
22 | * date 2017/8/14
23 | * E-Mail:yangchaojiang@outlook.com
24 | * Deprecated: 列表Fragment 支持懒加载, 子类重写setOpenLazyLoad方法,开启懒加载
25 | */
26 |
27 | public abstract class AacMultiListFragment extends AacDataFragment
>
28 | implements SwipeRefreshLayout.OnRefreshListener, BaseQuickAdapter.RequestLoadMoreListener{
29 | private RecyclerView recyclerView;
30 | protected SwipeRefreshLayout swipeRefresh;
31 | private int daraPage = 1;
32 | private BaseMultiItemQuickAdapter adapter;
33 |
34 | @CallSuper
35 | @Override
36 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
37 | super.onViewCreated(view, savedInstanceState);
38 | swipeRefresh = view.findViewById(R.id.swipeRefresh);
39 | recyclerView = view.findViewById(R.id.recyclerView);
40 | if (setGridSpanCount() <= 1) {
41 | recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
42 | } else {
43 | recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), setGridSpanCount()));
44 | }
45 | // recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
46 | swipeRefresh.setOnRefreshListener(this);
47 | swipeRefresh.setRefreshing(false);
48 | adapter = getMultiAdapter();
49 | adapter.bindToRecyclerView(recyclerView);
50 | }
51 |
52 | @Override
53 | public void initLoadHelper(@NonNull View view) {
54 | super.initLoadHelper(view);
55 | adapter.setEmptyView(getViewLoadHelper().getEmptyLayoutId(), recyclerView);
56 | }
57 |
58 | @CallSuper
59 | @Override
60 | public void onDestroy() {
61 | super.onDestroy();
62 | if (adapter != null) {
63 | adapter.getData().clear();
64 | adapter.setOnLoadMoreListener(null, recyclerView);
65 |
66 | }
67 | if (swipeRefresh != null) {
68 | swipeRefresh.setRefreshing(false);
69 | swipeRefresh.setOnRefreshListener(null);
70 | }
71 | }
72 |
73 | /***
74 | * 设置数据
75 | * @param data data
76 | * **/
77 | public void setData(@NonNull List data) {
78 | if (daraPage < 2) {
79 | if (swipeRefresh.isRefreshing()) {
80 | setRefreshing(false);
81 | }
82 | adapter.getData().clear();
83 | adapter.notifyDataSetChanged();
84 | adapter.addData(data);
85 |
86 | } else {
87 | if (data.isEmpty()) {
88 | adapter.loadMoreEnd();
89 | } else {
90 | adapter.loadMoreComplete();
91 | }
92 | adapter.addData(data);
93 | }
94 |
95 | }
96 |
97 | @Override
98 | public void setError(Throwable e) {
99 | if (daraPage < 2) {
100 | if (swipeRefresh.isRefreshing()) {
101 | setRefreshing(false);
102 | }
103 | showErrorView();
104 | } else {
105 | adapter.loadMoreFail();
106 | }
107 | }
108 |
109 | public void setDaraPage(int daraPage) {
110 | this.daraPage = daraPage;
111 | }
112 | /***
113 | * @param setRefreshing 是否刷新 true false 则停止
114 | **/
115 | public void setRefreshing(boolean setRefreshing) {
116 | showContentView();
117 | swipeRefresh.postDelayed(() -> {
118 | if (swipeRefresh == null) return;
119 | swipeRefresh.setRefreshing(setRefreshing);
120 | if (setRefreshing) {
121 | onRefresh();
122 | }
123 | }, 200);
124 | }
125 |
126 | /**
127 | * 是否启用分页 默认不启用
128 | *
129 | * @param enable true 启用 false 不启用
130 | */
131 | public void setStartLoadMore(boolean enable) {
132 | if (enable) {
133 | adapter.setOnLoadMoreListener(this, recyclerView);
134 | }
135 | }
136 | @Override
137 | public int getContentLayoutId() {
138 | return R.layout.aac_include_recycle_view;
139 | }
140 |
141 |
142 | @Override
143 | public void onRefresh() {
144 | daraPage = 1;
145 | getPresenter().setLoadData(daraPage);
146 | }
147 |
148 | @Override
149 | public void onLoadMoreRequested() {
150 | daraPage += 1;
151 | getPresenter().setLoadData(daraPage);
152 | }
153 |
154 | public int getCurPage() {
155 | return daraPage;
156 | }
157 |
158 | @Nullable
159 | public M getLastItem() {
160 | if (adapter.getData().isEmpty()) {
161 | return null;
162 | }
163 | return (M) adapter.getItem(adapter.getData().size() - 1);
164 | }
165 | /**
166 | * 获取RecyclerView
167 | **/
168 | public RecyclerView getRecyclerView() {
169 | return recyclerView;
170 | }
171 | /***
172 | * 设置网格中的列数
173 | * 子类重写该方法 大于1 使用网格布局 否则L是list
174 | */
175 | public int setGridSpanCount() {
176 | return 1;
177 | }
178 |
179 | @NonNull
180 | public abstract BaseMultiItemQuickAdapter getMultiAdapter();
181 |
182 | }
183 |
184 |
--------------------------------------------------------------------------------
/Aac-data-module/src/main/res/drawable/ic_chevron_left_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/Aac-data-module/src/main/res/layout/aac_include_recycle_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
15 |
16 |
--------------------------------------------------------------------------------
/Aac-data-module/src/main/res/layout/aac_include_toolbar_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Aac-data-module/src/main/res/layout/aac_recycle_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Aac-data-module/src/main/res/layout/aac_view_list_con_empty.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
--------------------------------------------------------------------------------
/Aac-data-module/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Aac-data-module/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AccDataModule
3 | 暂无数据
4 |
5 |
--------------------------------------------------------------------------------
/Aac-data-module/src/test/java/com/aac/expansion/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.aac.expansion;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/AacModule/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/AacModule/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'me.tatarka.retrolambda'
3 | android {
4 | compileSdkVersion project.ext.compileSdkVersion
5 | buildToolsVersion project.ext.buildToolsVersion
6 | defaultConfig {
7 | minSdkVersion project.ext.minSdkVersion
8 | targetSdkVersion project.ext.targetSdkVersion
9 | versionCode project.ext.versionCode
10 | versionName project.ext.versionName
11 |
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 |
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 |
22 | lintOptions {
23 | abortOnError false
24 | }
25 | //设置JDK1.8
26 | compileOptions {
27 | sourceCompatibility JavaVersion.VERSION_1_8
28 | targetCompatibility JavaVersion.VERSION_1_8
29 | }
30 | lintOptions {
31 | abortOnError false
32 | }
33 |
34 | }
35 |
36 | dependencies {
37 | compile fileTree(include: ['*.jar'], dir: 'libs')
38 | androidTestCompile('com.android.support.test.espresso:espresso-core:3.0.2', {
39 | exclude group: 'com.android.support', module: 'support-annotations'
40 | })
41 | testCompile 'junit:junit:4.12'
42 | def lifecycle_version = "1.1.1"
43 | // alternatively, just LiveData
44 | compile "com.android.support:appcompat-v7:${libSversion}"
45 | compile "android.arch.lifecycle:extensions:$lifecycle_version"
46 | // alternatively - just ViewModel
47 | compile "android.arch.lifecycle:viewmodel:$lifecycle_version" // use -ktx for Kotlin
48 | // alternatively - just LiveData
49 | compile "android.arch.lifecycle:livedata:$lifecycle_version"
50 | // alternatively - Lifecycles only (no ViewModel or LiveData).
51 | // Support library depends on this lightweight import
52 | compile "android.arch.lifecycle:runtime:$lifecycle_version"
53 |
54 | annotationProcessor "android.arch.lifecycle:compiler:$lifecycle_version"
55 | }
56 |
57 | apply plugin: 'com.novoda.bintray-release'
58 | ////上传到jcenter
59 | //
60 | publish {
61 | repoName="ycjiang"//仓库名
62 | userOrg = 'ycjiang'
63 | groupId = 'com.ycjiang'
64 | artifactId = 'AacModule'
65 | publishVersion = project.ext.publishVersion
66 | desc = 'Based on google Android Architecture Components package to achieve MVP rapid development framework'
67 | website = 'https://github.com/yangchaojiang/AaComponents'
68 | dryRun = false
69 | }
70 |
--------------------------------------------------------------------------------
/AacModule/src/androidTest/java/com/aac/module/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.aac.module;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.acc.module.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/AacModule/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/AacModule/src/main/java/com/aac/module/callback/ActivityLifecycleCallbacksWrapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This source is part of the
3 | * _____ ___ ____
4 | * __ / / _ \/ _ | / __/___ _______ _
5 | * / // / , _/ __ |/ _/_/ _ \/ __/ _ `/
6 | * \___/_/|_/_/ |_/_/ (_)___/_/ \_, /
7 | * /___/
8 | * repository.
9 | *
10 | * Copyright (C) 2013 Benoit 'BoD' Lubek (BoD@JRAF.org)
11 | *
12 | * Licensed under the Apache License, Version 2.0 (the "License");
13 | * you may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 | package com.aac.module.callback;
25 |
26 | import android.annotation.TargetApi;
27 | import android.app.Activity;
28 | import android.app.Application.ActivityLifecycleCallbacks;
29 | import android.os.Build;
30 | import android.os.Bundle;
31 |
32 | /**
33 | * Wraps into an {@link ActivityLifecycleCallbacks}.
34 | */
35 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
36 | public abstract class ActivityLifecycleCallbacksWrapper implements ActivityLifecycleCallbacks {
37 |
38 |
39 | @Override
40 | public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
41 | }
42 |
43 | @Override
44 | public void onActivityStarted(Activity activity) {
45 | }
46 |
47 | @Override
48 | public void onActivityResumed(Activity activity) {
49 | }
50 |
51 | @Override
52 | public void onActivityPaused(Activity activity) {
53 | }
54 |
55 | @Override
56 | public void onActivityStopped(Activity activity) {
57 | }
58 |
59 | @Override
60 | public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
61 | }
62 |
63 | @Override
64 | public void onActivityDestroyed(Activity activity) {
65 | }
66 |
67 | @Override
68 | public boolean equals(Object o) {
69 | return this==o;
70 | }
71 |
72 |
73 | @Override
74 | public int hashCode() {
75 | return this.hashCode();
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/AacModule/src/main/java/com/aac/module/model/AacAndroidViewModel.java:
--------------------------------------------------------------------------------
1 | package com.aac.module.model;
2 |
3 | import android.app.Application;
4 | import android.arch.lifecycle.AndroidViewModel;
5 |
6 | /**
7 | * Created by yangc on 2017/8/27.
8 | * E-Mail:yangchaojiang@outlook.com
9 | * Deprecated:父类view模型
10 | */
11 |
12 | public abstract class AacAndroidViewModel extends AndroidViewModel {
13 |
14 | public AacAndroidViewModel(Application application) {
15 | super(application);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/AacModule/src/main/java/com/aac/module/model/AacViewModel.java:
--------------------------------------------------------------------------------
1 | package com.aac.module.model;
2 |
3 | import android.arch.lifecycle.ViewModel;
4 |
5 | /**
6 | * Created by yangc on 2017/8/27.
7 | * E-Mail:yangchaojiang@outlook.com
8 | * Deprecated: 父类view模型
9 | */
10 |
11 | public abstract class AacViewModel extends ViewModel {
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/AacModule/src/main/java/com/aac/module/pres/RequiresPresenter.java:
--------------------------------------------------------------------------------
1 | package com.aac.module.pres;
2 |
3 | import com.aac.module.ui.AacPresenter;
4 |
5 | import java.lang.annotation.ElementType;
6 | import java.lang.annotation.Inherited;
7 | import java.lang.annotation.Retention;
8 | import java.lang.annotation.RetentionPolicy;
9 | import java.lang.annotation.Target;
10 |
11 |
12 | @Inherited
13 | @Retention(RetentionPolicy.RUNTIME)
14 | @Target(ElementType.TYPE)
15 | public @interface RequiresPresenter {
16 | Class extends AacPresenter> value();
17 | }
18 |
--------------------------------------------------------------------------------
/AacModule/src/main/java/com/aac/module/ui/AacActivity.java:
--------------------------------------------------------------------------------
1 | package com.aac.module.ui;
2 |
3 | import android.arch.lifecycle.Lifecycle;
4 | import android.arch.lifecycle.LifecycleRegistry;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.os.PersistableBundle;
8 | import android.support.annotation.CallSuper;
9 | import android.support.annotation.NonNull;
10 | import android.support.annotation.Nullable;
11 | import android.support.v7.app.AppCompatActivity;
12 | import android.support.v7.widget.Toolbar;
13 |
14 | import com.aac.module.R;
15 | import com.aac.module.utils.ContentLayoutListener;
16 |
17 | /**
18 | * Created by yangc on 2017/8/13.
19 | * E-Mail:yangchaojiang@outlook.com
20 | * Deprecated: 控制activity 控制类
21 | *
22 | * @param 与activity 订阅{@link AacPresenter }类
23 | * @see AacActivity
24 | */
25 |
26 | public abstract class AacActivity
extends AppCompatActivity implements ContentLayoutListener {
27 | private LifecycleRegistry lifecycleRegistry = new LifecycleRegistry(this);
28 | private P t = PresenterBuilder.fromViewClass(this);
29 | @CallSuper
30 | @Override
31 | protected void onCreate(@Nullable Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | if (getContentLayoutId() == 0) {
34 | throw new NullPointerException(getString(R.string.aac_layout_error_hint));
35 | }
36 | setContentView(getContentLayoutId());
37 | Toolbar toolbar = findViewById(R.id.toolbar);
38 | if (toolbar != null) {
39 | onSetToolbar(toolbar);
40 | }
41 | if (t != null) {
42 | lifecycleRegistry.addObserver(t);
43 | t.onCreateView();
44 | }
45 |
46 | }
47 | @CallSuper
48 | @Override
49 | protected void onDestroy() {
50 | super.onDestroy();
51 | lifecycleRegistry.removeObserver(t);
52 | lifecycleRegistry = null;
53 | t = null;
54 | }
55 |
56 | @CallSuper
57 | @Override
58 | public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) {
59 | super.onSaveInstanceState(outState, outPersistentState);
60 | t.onSave(outState);
61 | }
62 |
63 | @NonNull
64 | @CallSuper
65 | @Override
66 | public LifecycleRegistry getLifecycle() {
67 | return lifecycleRegistry;
68 | }
69 |
70 | @CallSuper
71 | @Override
72 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
73 | t.onResult(requestCode, resultCode, data);
74 | super.onActivityResult(requestCode, resultCode, data);
75 | }
76 |
77 | /**
78 | * 设置Toolbar如果使用了ToolBar则自动部署。没有则无影响。
79 | *
80 | * @param toolbar toolbar
81 | **/
82 | public void onSetToolbar(Toolbar toolbar) {
83 | setSupportActionBar(toolbar);
84 | toolbar.setNavigationOnClickListener((view) -> finish());
85 | assert getSupportActionBar() != null;
86 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
87 | }
88 |
89 | @Override
90 | public void setTitle(CharSequence title) {
91 | if (getSupportActionBar() != null) {
92 | getSupportActionBar().setTitle(title);
93 | }
94 | }
95 |
96 | /***
97 | * 得到对应业务处理类
98 | *
99 | * @return L
100 | **/
101 | public P getPresenter() {
102 | return t;
103 | }
104 | /**
105 | * 返回当前生命中周期状态
106 | *
107 | * @param state Lifecycle.State
108 | * @return boolean
109 | **/
110 | public boolean getState(Lifecycle.State state) {
111 | return lifecycleRegistry.getCurrentState().isAtLeast(state);
112 | }
113 |
114 | }
115 |
--------------------------------------------------------------------------------
/AacModule/src/main/java/com/aac/module/ui/AacFragment.java:
--------------------------------------------------------------------------------
1 | package com.aac.module.ui;
2 |
3 | import android.arch.lifecycle.Lifecycle;
4 | import android.arch.lifecycle.LifecycleRegistry;
5 | import android.os.Bundle;
6 | import android.support.annotation.CallSuper;
7 | import android.support.annotation.NonNull;
8 | import android.support.annotation.Nullable;
9 | import android.support.v4.app.Fragment;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 |
14 | import com.aac.module.R;
15 | import com.aac.module.utils.ContentLayoutListener;
16 |
17 | /**
18 | * Created by yangc on 2017/8/13.
19 | * E-Mail:yangchaojiang@outlook.com
20 | * Deprecated:
21 | *
22 | * @param
AacFragment 订阅{@link AacFragmentPresenter }类
23 | * @see AacFragment
24 | */
25 |
26 | public abstract class AacFragment
extends Fragment implements ContentLayoutListener {
27 | private LifecycleRegistry lifecycleRegistry = new LifecycleRegistry(this);
28 | private P t = PresenterBuilder.fromViewClass(this);
29 |
30 | @CallSuper
31 | @Override
32 | public void onCreate(@Nullable Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 | lifecycleRegistry.addObserver(t);
35 | lifecycleRegistry.markState(Lifecycle.State.CREATED);
36 | }
37 |
38 | @Nullable
39 | @Override
40 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
41 | if (getContentLayoutId() == 0) {
42 | throw new NullPointerException(getString(R.string.aac_layout_error_hint));
43 | }
44 | return inflater.inflate(getContentLayoutId(), container, false);
45 | }
46 |
47 | @CallSuper
48 | @Override
49 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
50 | t.onCreateView();
51 | super.onViewCreated(view, savedInstanceState);
52 | t.onViewCreated();
53 | }
54 |
55 | @CallSuper
56 | @Override
57 | public void onStart() {
58 | super.onStart();
59 | lifecycleRegistry.markState(Lifecycle.State.STARTED);
60 | }
61 |
62 | @CallSuper
63 | @Override
64 | public void onResume() {
65 | super.onResume();
66 | lifecycleRegistry.markState(Lifecycle.State.RESUMED);
67 | }
68 |
69 | @CallSuper
70 | @Override
71 | public void onDestroyView() {
72 | super.onDestroyView();
73 | t.onDestroyView();
74 | }
75 |
76 | @CallSuper
77 | @Override
78 | public void onDestroy() {
79 | super.onDestroy();
80 | lifecycleRegistry.markState(Lifecycle.State.DESTROYED);
81 | lifecycleRegistry.removeObserver(t);
82 | lifecycleRegistry = null;
83 | t = null;
84 | }
85 |
86 |
87 |
88 | @NonNull
89 | @Override
90 | public LifecycleRegistry getLifecycle() {
91 | return lifecycleRegistry;
92 | }
93 |
94 | /***
95 | * 得到对应业务处理类
96 | *
97 | * @return R
98 | **/
99 | public P getPresenter() {
100 | return t;
101 | }
102 |
103 | /**
104 | * 返回是否当前生命中周期状态
105 | *
106 | * @param state Lifecycle.State
107 | * @return boolean
108 | **/
109 | public boolean getState(Lifecycle.State state) {
110 | return lifecycleRegistry.getCurrentState().isAtLeast(state);
111 | }
112 |
113 | }
114 |
--------------------------------------------------------------------------------
/AacModule/src/main/java/com/aac/module/ui/AacFragmentPresenter.java:
--------------------------------------------------------------------------------
1 | package com.aac.module.ui;
2 |
3 |
4 | /**
5 | * Created by yangc on 2017/8/13.
6 | * E-Mail:yangchaojiang@outlook.com
7 | * Deprecated: Fragment业务处理控制类
8 | *
9 | * @param AacFragmentPresenter 订阅{@link AacFragment}类
10 | * @see AacFragmentPresenter
11 | */
12 |
13 |
14 | public abstract class AacFragmentPresenter extends AacPresenter {
15 |
16 |
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/AacModule/src/main/java/com/aac/module/ui/AacPresenter.java:
--------------------------------------------------------------------------------
1 | package com.aac.module.ui;
2 |
3 | import android.app.Activity;
4 | import android.arch.lifecycle.Lifecycle;
5 | import android.arch.lifecycle.LifecycleObserver;
6 | import android.arch.lifecycle.OnLifecycleEvent;
7 | import android.arch.lifecycle.ViewModel;
8 | import android.arch.lifecycle.ViewModelProvider;
9 | import android.arch.lifecycle.ViewModelProviders;
10 | import android.content.Intent;
11 | import android.os.Bundle;
12 | import android.support.annotation.NonNull;
13 | import android.support.v4.app.Fragment;
14 | import android.support.v4.app.FragmentActivity;
15 |
16 | /**
17 | * author yangc
18 | * date 2017/8/13
19 | * E-Mail:yangchaojiang@outlook.com
20 | * Deprecated: 业务处理控制类
21 | *
22 | * @param 与AacPresenter建立订阅View
23 | * @see AacPresenter
24 | */
25 |
26 | public abstract class AacPresenter implements LifecycleObserver {
27 | private Lifecycle lifecycle;
28 | private ActivityType view;
29 |
30 | @OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
31 | protected void onCreate() {
32 |
33 | }
34 |
35 | @OnLifecycleEvent(Lifecycle.Event.ON_START)
36 | protected void onStart() {
37 | }
38 |
39 | @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
40 | protected void onResume() {
41 | }
42 |
43 | @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
44 | protected void onPause() {
45 | }
46 |
47 | @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
48 | protected void onStop() {
49 | }
50 |
51 | @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
52 | protected void onDestroy() {
53 | view = null;
54 | lifecycle = null;
55 | }
56 | protected void onCreateView() {
57 |
58 | }
59 |
60 | public void onDestroyView() {
61 |
62 | }
63 |
64 | public void onViewCreated() {
65 | }
66 | protected void onResult(int requestCode, int resultCode, Intent data) {
67 |
68 | }
69 |
70 | protected void onSave(Bundle state) {
71 |
72 | }
73 |
74 | @NonNull
75 | public final ActivityType getView() {
76 | return view;
77 | }
78 |
79 | /***
80 | * 单例获取viewModel方式类型实例
81 | *
82 | * @param modelClass modelClass类型
83 | *@param ViewModelType
84 | * @return ViewModelType
85 | **/
86 | public ViewModelType getInstanceViewModel(Class modelClass) {
87 | return new ViewModelProvider.NewInstanceFactory().create(modelClass);
88 | }
89 |
90 | /***
91 | * 获取数据viewModel方式类型实例
92 | *
93 | * @param modelClass modelClass类型
94 | *@param ViewModelType
95 | * @return ViewModelType
96 | **/
97 | public ViewModelType getViewActivityModel(Class modelClass) {
98 |
99 | if (view instanceof Fragment) {
100 | return ViewModelProviders.of(((Fragment) view).getActivity()).get(modelClass);
101 | } else if (view instanceof FragmentActivity) {
102 | return ViewModelProviders.of((FragmentActivity) view).get(modelClass);
103 | } else {
104 | return getInstanceViewModel(modelClass);
105 | }
106 | }
107 |
108 | /***
109 | * 获取数据viewModel方式类型实例
110 | *
111 | * @param modelClass modelClass类型
112 | *@param ViewModelType
113 | * @return ViewModelType
114 | **/
115 | public ViewModelType getViewModel(Class modelClass) {
116 |
117 | if (view instanceof Fragment) {
118 | return ViewModelProviders.of((Fragment) view).get(modelClass);
119 | } else if (view instanceof FragmentActivity) {
120 | return ViewModelProviders.of((FragmentActivity) view).get(modelClass);
121 | } else {
122 | return getInstanceViewModel(modelClass);
123 | }
124 | }
125 |
126 | /***
127 | * 获取数据viewModel方式类型实例
128 | *
129 | * @param modelClass modelClass类型
130 | *@param ViewModelType
131 | * @return ViewModelType
132 | **/
133 | public ViewModelType getApplicationViewModel(Class modelClass) {
134 |
135 | if (view instanceof Fragment) {
136 | return new ViewModelProvider.AndroidViewModelFactory(((Fragment) view).getActivity().getApplication()).create(modelClass);
137 | } else if (view instanceof FragmentActivity) {
138 | return new ViewModelProvider.AndroidViewModelFactory(((Activity) view).getApplication()).create(modelClass);
139 | } else {
140 | return getInstanceViewModel(modelClass);
141 |
142 | }
143 | }
144 | /**
145 | * 返回是否当前生命中周期状态
146 | *
147 | * @param state Lifecycle.State
148 | * @return boolean
149 | **/
150 | public boolean isAtLeast(Lifecycle.State state) {
151 | return lifecycle.getCurrentState().isAtLeast(state);
152 | }
153 |
154 | void create(@NonNull ActivityType view) {
155 | this.view = view;
156 | }
157 |
158 |
159 | }
160 |
--------------------------------------------------------------------------------
/AacModule/src/main/java/com/aac/module/ui/AacService.java:
--------------------------------------------------------------------------------
1 | package com.aac.module.ui;
2 |
3 | import android.arch.lifecycle.LifecycleService;
4 | import android.content.Intent;
5 |
6 | /**
7 | * Created by yangc on 2017/8/13.
8 | * E-Mail:yangchaojiang@outlook.com
9 | * Deprecated:
10 | *
11 | * @see AacService
12 | */
13 |
14 |
15 | public abstract class AacService extends LifecycleService {
16 | private P t = PresenterBuilder.fromViewClass(this);
17 | @Override
18 | public void onCreate() {
19 | super.onCreate();
20 | getLifecycle().addObserver(t);
21 | }
22 | @Override
23 | public int onStartCommand(Intent intent, int flags, int startId) {
24 | return super.onStartCommand(intent, flags, startId);
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/AacModule/src/main/java/com/aac/module/ui/PresenterBuilder.java:
--------------------------------------------------------------------------------
1 | package com.aac.module.ui;
2 |
3 |
4 | import android.arch.lifecycle.LifecycleOwner;
5 | import android.support.annotation.NonNull;
6 |
7 | import com.aac.module.pres.RequiresPresenter;
8 |
9 | /**
10 | * Created by yangc on 2017/8/13.
11 | * E-Mail:yangchaojiang@outlook.com
12 | * Deprecated: java反射当前类
13 | */
14 | public class PresenterBuilder {
15 |
16 | public static PresenterType fromViewClass(@NonNull LifecycleOwner viewClass) {
17 | RequiresPresenter annotation = viewClass.getClass().getAnnotation(RequiresPresenter.class);
18 | //noinspection unchecked
19 | if (annotation == null) {
20 | return null;
21 | //throw new RuntimeException("You must declaration @RequiresPresenter for your Activity");
22 | }
23 | Class presenterClass = (Class) annotation.value();
24 | PresenterType presenter;
25 | try {
26 | presenter = presenterClass.newInstance();
27 | presenter.create(viewClass);
28 | } catch (InstantiationException e) {
29 | throw new RuntimeException("PresenterBuilder Find generic failed:"+e);
30 | } catch (IllegalAccessException e) {
31 | throw new RuntimeException("PresenterBuilder Find generic failed:"+e);
32 | }
33 | return presenter;
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/AacModule/src/main/java/com/aac/module/utils/ContentLayoutListener.java:
--------------------------------------------------------------------------------
1 | package com.aac.module.utils;
2 |
3 | import android.support.annotation.LayoutRes;
4 |
5 | /**
6 | * Created by yangc on 2017/12/2
7 | * E-Mail:yangchaojiang@outlook.com
8 | * Deprecated:
9 | */
10 |
11 | public interface ContentLayoutListener {
12 |
13 | /***
14 | * 内容布局id
15 | * @return int
16 | ***/
17 | @LayoutRes
18 | int getContentLayoutId();
19 | }
20 |
--------------------------------------------------------------------------------
/AacModule/src/main/java/com/aac/module/utils/MyFragmentManager.java:
--------------------------------------------------------------------------------
1 | package com.aac.module.utils;
2 |
3 | import android.support.annotation.IdRes;
4 | import android.support.annotation.NonNull;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v4.app.FragmentManager;
7 | import android.support.v4.app.FragmentTransaction;
8 | import java.util.ArrayList;
9 | import java.util.List;
10 | /**
11 | * Created by yangc on 2017/9/11.
12 | * E-Mail:yangchaojiang@outlook.com
13 | * Deprecated: fragment 管里类
14 | */
15 |
16 | public class MyFragmentManager {
17 | private List fragmentList;
18 | private FragmentManager fragmentManager;
19 | private int resId;
20 | /****
21 | * 初始化
22 | *
23 | * @param fragmentManager fragment 容器
24 | * @param resId 容器布局
25 | * @param data list列表数据
26 | **/
27 | public MyFragmentManager(@NonNull List data,@NonNull FragmentManager fragmentManager, @IdRes int resId) {
28 | fragmentList = new ArrayList<>();
29 | this.fragmentManager = fragmentManager;
30 | this.resId = resId;
31 | addAll(data);
32 | }
33 |
34 | /****
35 | * 初始化
36 | *
37 | * @param fragmentManager fragment 容器
38 | * @param resId 容器布局
39 | **/
40 | public MyFragmentManager(@NonNull FragmentManager fragmentManager, @IdRes int resId) {
41 | fragmentList = new ArrayList<>();
42 | this.fragmentManager = fragmentManager;
43 | this.resId = resId;
44 | }
45 |
46 | /****
47 | * 添加列表
48 | *
49 | * @param data list列表数据
50 | ***/
51 | private void addAll(List data) {
52 | fragmentList.addAll(data);
53 | FragmentTransaction b = fragmentManager.beginTransaction();
54 | for (Fragment item : fragmentList) {
55 | b.add(resId, item);
56 | }
57 | for (Fragment item : fragmentList) {
58 | b.hide(item);
59 | }
60 | b.show(fragmentList.get(0));
61 | b.commitAllowingStateLoss();
62 | }
63 | /****
64 | * 添加item
65 | *
66 | * @param fragment 添加单个
67 | ***/
68 | public void add(Fragment fragment) {
69 | fragmentList.add(fragment);
70 | }
71 | /****
72 | * 插入item
73 | *
74 | * @param index 插入索引
75 | * @param fragment item
76 | ***/
77 | public void install(int index,Fragment fragment) {
78 | fragmentList.set(index,fragment);
79 | }
80 |
81 | /***
82 | * 显示当前fragment 其他隐藏
83 | *
84 | * @param index 索引
85 | **/
86 | public void show(int index) {
87 | FragmentTransaction b = fragmentManager.beginTransaction();
88 | b.show(fragmentList.get(index));
89 | b.commitAllowingStateLoss();
90 | }
91 | /***
92 | * 显示当前fragment 其他隐藏
93 | *
94 | * @param index 索引
95 | **/
96 | public void updateShow(int index) {
97 | FragmentTransaction b = fragmentManager.beginTransaction();
98 | for (Fragment item : fragmentList) {
99 | b.hide(item);
100 | }
101 | b.show(fragmentList.get(index));
102 | b.commitAllowingStateLoss();
103 | }
104 |
105 | /***
106 | * 隐藏当前fragment
107 | *
108 | * @param index 索引
109 | **/
110 | public void hide(int index) {
111 | FragmentTransaction b = fragmentManager.beginTransaction();
112 | b.show(fragmentList.get(index));
113 | b.commitAllowingStateLoss();
114 | }
115 | /***
116 | * 隐藏当前fragment
117 | *
118 | * @param index 索引
119 | **/
120 | public void replace(int index) {
121 | FragmentTransaction b = fragmentManager.beginTransaction();
122 | b.replace(resId,fragmentList.get(index));
123 | b.commitAllowingStateLoss();
124 | }
125 | /***
126 | *获取当前Fragment 实例
127 | *
128 | *@param T
129 | * @param index 索引
130 | * @return T
131 | **/
132 | public T getItem(int index) {
133 | return (T) fragmentList.get(index);
134 | }
135 |
136 |
137 | /***
138 | * 全部隐藏当前fragment
139 | **/
140 | public void hideAll() {
141 | FragmentTransaction b = fragmentManager.beginTransaction();
142 | for (Fragment item : fragmentList) {
143 | b.hide(item);
144 | }
145 | b.commitAllowingStateLoss();
146 | }
147 |
148 | /***
149 | * 释放资源
150 | * **/
151 | public void onDestroy() {
152 | if (fragmentList != null) {
153 | fragmentList.clear();
154 | fragmentList = null;
155 | }
156 | fragmentManager = null;
157 | }
158 |
159 | }
160 |
--------------------------------------------------------------------------------
/AacModule/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/AacModule/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AccModule
3 | 没有布局文件id
4 |
5 |
--------------------------------------------------------------------------------
/AacModule/src/test/java/com/aac/module/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.aac.module;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AaComponents
2 |
3 | [  ](https://bintray.com/ycjiang/ycjiang/AacHttpDataModule/_latestVersion)
4 |
5 | 基于google Android Architecture Components 封装实现MVP快速开发框架
6 |
7 | AaComponents 是一套基于MVP模式的快速开发框架。定义了一套开发规范。
8 | 并提供了基于这套规范的Activity,Fragment,Presenter,Model等父类及控件和API等,
9 | 完成APP开发过程中大量繁琐工作。
10 |
11 | ##依赖
12 | * 1 compile 'com.ycjiang:AacDataModule:2.5.3'
13 | * 2 compile 'com.ycjiang:AacModule:2.5.3'
14 | * 3 compile 'com.ycjiang:AacRxDataModule:2.5.3'
15 | * 4 compile 'com.ycjiang:AacHttpDataModule:2.5.3'
16 | >> 注意 引用 AaDataModule 默认引用 AacModule 包, 不需要在引用在AaDataModule
17 |
18 | ```
19 | repositories {
20 | jcenter()
21 | maven { url "https://jitpack.io" }//BaseRecyclerViewAdapterHelper框架需要
22 | //3.0以下as的版本
23 | maven { url 'https://maven.google.com' }
24 | 或者 //3.0以上as的版本。下面的
25 | google();
26 |
27 |
28 | }
29 | ```
30 | ### 使用插件快速生成aac模板代码[戳我](https://github.com/yangchaojiang/AAcHelper)
31 |
32 | #### More
33 | Find more details about Matisse in [wiki](https://github.com/yangchaojiang/AaComponents/wiki)
34 |
35 | ##重复依赖
36 | 本库已经依赖了下面的库,请注意重复依赖的问题
37 |
38 | compile 'android.arch.lifecycle:extensions:1.0.0'
39 | annotationProcessor "android.arch.lifecycle:compiler:1.0.0"
40 | compile "com.android.support:appcompat-v7:${libSversion}"
41 | compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.34'
42 | compile "com.android.support:recyclerview-v7:${libSversion}"
43 | compile 'com.ycjiang:loadviewhelper:1.1.0'
44 | compile 'com.ycjiang:center-toolbar:1.0.0'
45 | //
46 | // AacHttpDataModule 内部引用
47 | compile 'com.lzy.net:okgo:3.0.4'
48 | compile 'com.lzy.net:okrx2:2.0.2'
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android-extensions'
3 | apply plugin: 'kotlin-android'
4 | apply plugin: 'kotlin-kapt'
5 | android {
6 | compileSdkVersion project.ext.compileSdkVersion
7 | buildToolsVersion project.ext.buildToolsVersion
8 | defaultConfig {
9 | minSdkVersion project.ext.minSdkVersion
10 | targetSdkVersion project.ext.targetSdkVersion
11 | versionCode project.ext.versionCode
12 | versionName project.ext.versionName
13 | applicationId "com.example.aac"
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | dataBinding {
23 | enabled = true
24 | }
25 | compileOptions {
26 | sourceCompatibility JavaVersion.VERSION_1_8
27 | targetCompatibility JavaVersion.VERSION_1_8
28 | }
29 | lintOptions {
30 | abortOnError false
31 | }
32 | }
33 |
34 | dependencies {
35 | implementation 'com.android.support.constraint:constraint-layout:1.1.2'
36 | compile fileTree(include: ['*.jar'], dir: 'libs')
37 | androidTestCompile('com.android.support.test.espresso:espresso-core:3.0.2', {
38 | exclude group: 'com.android.support', module: 'support-annotations'
39 | })
40 | compile('com.android.support:appcompat-v7:' + libSversion, {
41 | exclude group: 'com.android.support', module: 'appcompat-v7'
42 | })
43 | compile('com.android.support:support-v4:' + libSversion, {
44 | exclude group: 'com.android.support', module: 'support-v4'
45 | })
46 | compile 'com.baoyz.pullrefreshlayout:library:1.2.0'
47 | compile 'com.ycjiang:Yutils:1.2.4'
48 | testCompile 'junit:junit:4.12'
49 | compile 'com.coolerfall:android-app-daemon:1.2.0'
50 | compile 'android.arch.lifecycle:reactivestreams:1.1.1'
51 | compile 'com.lzy.net:okgo:3.0.4'
52 | compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
53 | // compile 'com.ycjiang:AacHttpDataModule:2.4.8'
54 | implementation project(':Aac-data-module-http')
55 | implementation project(':Aac-data-module-coroutines')
56 | }
57 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\SDK/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/example/aac/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.aac;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.example.aac", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/ActivityCallback.java:
--------------------------------------------------------------------------------
1 | package com.example.aac;
2 |
3 | import android.app.Activity;
4 | import android.content.res.Configuration;
5 | import android.content.res.Resources;
6 | import android.os.Bundle;
7 | import android.support.v7.app.AppCompatDelegate;
8 |
9 | import com.aac.module.callback.ActivityLifecycleCallbacksWrapper;
10 |
11 | /**
12 | * Created by yangc on 2017/8/17.
13 | * E-Mail:yangchaojiang@outlook.com
14 | * Deprecated: 周期回调
15 | */
16 | public class ActivityCallback extends ActivityLifecycleCallbacksWrapper {
17 |
18 | @Override
19 | public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
20 | super.onActivityCreated(activity, savedInstanceState);
21 | AppCompatDelegate.setCompatVectorFromResourcesEnabled(false);
22 |
23 | }
24 |
25 | @Override
26 | public void onActivityResumed(Activity activity) {
27 | super.onActivityResumed(activity);
28 | }
29 | @Override
30 | public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
31 | super.onActivitySaveInstanceState(activity, outState);
32 | }
33 |
34 | @Override
35 | public void onActivityDestroyed(Activity activity) {
36 | super.onActivityDestroyed(activity);
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/App.java:
--------------------------------------------------------------------------------
1 | package com.example.aac;
2 |
3 | import android.app.Application;
4 |
5 |
6 | /**
7 | * Created by yangc on 2017/8/17.
8 | * E-Mail:yangchaojiang@outlook.com
9 | * Deprecated:
10 | */
11 | public class App extends Application {
12 |
13 |
14 | @Override
15 | public void onCreate() {
16 | super.onCreate();
17 | registerActivityLifecycleCallbacks(new ActivityCallback());
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.java;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.app.ActionBar;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.view.View;
9 |
10 | import com.center.toolbar.TitleToolbar;
11 | import com.example.aac.R;
12 | import com.example.aac.java.coroutines.CoroutinesActivity;
13 | import com.example.aac.java.data.activity.TestDataActivity;
14 | import com.example.aac.java.data.activity.TestDataListActivity;
15 | import com.example.aac.java.data.fragment.TestFragmentActivity;
16 |
17 | public class MainActivity extends AppCompatActivity {
18 | private TitleToolbar titleToolbar;
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_main);
23 | this.titleToolbar = findViewById(R.id.toolbar);
24 | setSupportActionBar(titleToolbar);
25 | ActionBar mActionBar = getSupportActionBar();
26 | mActionBar.setDisplayOptions(mActionBar.getDisplayOptions() | ActionBar.DISPLAY_HOME_AS_UP);
27 | titleToolbar.setTitle("我的");
28 | findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
29 | @Override
30 | public void onClick(View v) {
31 | Intent intent = new Intent(MainActivity.this, TestDataActivity.class);
32 | startActivity(intent);
33 | }
34 | });
35 | findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
36 | @Override
37 | public void onClick(View v) {
38 | Intent intent = new Intent(MainActivity.this, TestDataListActivity.class);
39 | startActivity(intent);
40 | }
41 | });
42 | findViewById(R.id.button3).setOnClickListener(new View.OnClickListener() {
43 | @Override
44 | public void onClick(View v) {
45 | Intent intent = new Intent(MainActivity.this, TestFragmentActivity.class);
46 | startActivity(intent);
47 | }
48 | });
49 | findViewById(R.id.button4).setOnClickListener(new View.OnClickListener() {
50 | @Override
51 | public void onClick(View v) {
52 | Intent intent = new Intent(MainActivity.this, CoroutinesActivity.class);
53 | startActivity(intent);
54 | }
55 | });
56 | }
57 |
58 | @Override
59 | protected void onPostCreate(@Nullable Bundle savedInstanceState) {
60 | super.onPostCreate(savedInstanceState);
61 |
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/TestPresenter.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.java;
2 |
3 | import android.arch.lifecycle.LiveData;
4 | import android.util.Log;
5 |
6 | import com.aac.data.http.converter.BeanConverter;
7 | import com.aac.data.http.utils.AacUtils;
8 | import com.aac.module.ui.AacPresenter;
9 | import com.alibaba.fastjson.TypeReference;
10 | import com.lzy.okgo.model.HttpParams;
11 |
12 | import java.lang.reflect.Type;
13 | import java.util.List;
14 |
15 | import io.reactivex.Flowable;
16 |
17 | /**
18 | * Created by yangc on 2017/8/13.
19 | * E-Mail:yangchaojiang@outlook.com
20 | * Deprecated:
21 | */
22 |
23 | public class TestPresenter extends AacPresenter {
24 | public static final String TAG = "TestPresenter";
25 |
26 |
27 | @Override
28 | protected void onCreateView() {
29 | super.onCreateView();
30 | Log.d(TAG, "onCreateView");
31 | }
32 |
33 | public LiveData sss() {
34 | HttpParams httpParams = new HttpParams();
35 | return AacUtils.httpLiveGet("sss"
36 | , httpParams
37 | , new BeanConverter("-1", String.class));
38 | }
39 |
40 | public Flowable> sss2() {
41 | HttpParams params = new HttpParams();
42 | TypeReference typeReference = new TypeReference>(){};
43 | return AacUtils.httpRxGet("sss"
44 | , params
45 | , new BeanConverter<>("-1",typeReference.getType()));
46 | }
47 |
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/coroutines/CoroutinesActivity.kt:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.coroutines
2 |
3 | import android.arch.lifecycle.LiveData
4 | import android.os.Bundle
5 | import android.support.v7.app.AppCompatActivity
6 | import android.util.Log
7 | import com.aac.data.coroutines.ColourisesDataAdapter
8 | import com.aac.data.http.converter.BeanConverter
9 | import com.aac.data.http.utils.httpLivePost
10 | import com.aac.data.http.utils.httpRxGet
11 | import com.aac.data.http.utils.httpRxPost
12 | import com.example.aac.R
13 | import com.lzy.okgo.OkGo
14 | import com.lzy.okgo.model.HttpParams
15 | import com.yutils.YUtils
16 | import io.reactivex.Flowable
17 |
18 | class CoroutinesActivity : AppCompatActivity() {
19 |
20 | override fun onCreate(savedInstanceState: Bundle?){
21 | super.onCreate(savedInstanceState)
22 | YUtils.initialize(application)
23 | val data = HttpParams()
24 | data.put("test", "1233")
25 | setContentView(R.layout.activity_coroutines)
26 | /* httpRxGet("http://www.kuaidi.com/index-ajaxselectcourierinfo-1202247993797-yunda.html", data,
27 | BeanConverter("-1", DataBen::class.java))
28 | .subscribe({
29 | YUtils.Toast(it.timeused + "222222222222")
30 | }, {
31 | Log.d("CoroutinesActivity", it.message)
32 | })
33 | */
34 | OkGo.get("https://gamazavr.ru/json/search/?query=call%20of")
35 | .converter(BeanConverter("-1", DataBen::class.java))
36 | .adapt(ColourisesDataAdapter())
37 | .onSubscribe({
38 | YUtils.Toast(it.timeused + "222222222222")
39 | },{
40 | Log.d("CoroutinesActivity", it?.message)
41 | })
42 |
43 |
44 | }
45 | fun ssss(): Flowable {
46 | val data = HttpParams()
47 | return httpRxGet("http://www.kuaidi.com/index-ajaxselectcourierinfo-1202247993797-yunda.html",
48 | data,
49 | BeanConverter("-1", DataBen::class.java))
50 | }
51 |
52 | fun sssss(): LiveData {
53 | val data = HttpParams()
54 | return httpLivePost("http://www.kuaidi.com/index-ajaxselectcourierinfo-1202247993797-yunda.html",
55 | data,
56 | BeanConverter("-1", DataBen::class.java))
57 | }
58 |
59 | fun DataBean(string: String): Flowable {
60 | val params = HttpParams()
61 | params.put("string", string)
62 | return httpRxPost("sss"
63 | , params,
64 | BeanConverter("-1", DataBen::class.java))
65 |
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/coroutines/DataBen.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.coroutines;
2 |
3 | /**
4 | * author yangc
5 | * date 2018/7/5
6 | * E-Mail:yangchaojiang@outlook.com
7 | * Deprecated:
8 | */
9 | public class DataBen {
10 | private Boolean success;
11 | private String time;
12 | private String timeused;
13 |
14 | public Boolean getSuccess() {
15 | return success;
16 | }
17 |
18 | public void setSuccess(Boolean success) {
19 | this.success = success;
20 | }
21 |
22 | public String getTime() {
23 | return time;
24 | }
25 |
26 | public void setTime(String time) {
27 | this.time = time;
28 | }
29 |
30 | public String getTimeused() {
31 | return timeused;
32 | }
33 |
34 | public void setTimeused(String timeused) {
35 | this.timeused = timeused;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/activity/TesDataPresenter.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.activity;
2 |
3 | import android.util.Log;
4 |
5 | import com.aac.expansion.data.AacDataAPresenter;
6 | import com.aac.module.rx2.presenter.data.AacRxDataAPresenter;
7 | import com.example.aac.java.data.activity.bean.UserBean;
8 | import com.example.aac.java.model.TestDataViewModel;
9 |
10 |
11 | /**
12 | * Created by yangc on 2017/8/13.
13 | * E-Mail:yangchaojiang@outlook.com
14 | * Deprecated:
15 | */
16 |
17 | public class TesDataPresenter extends AacRxDataAPresenter {
18 | public static final String TAG = TesDataPresenter.class.getName();
19 | private TestDataViewModel dataViewModel;
20 |
21 | @Override
22 | public void onCreate() {
23 | super.onCreate();
24 | Log.d(TAG, "onCreate");
25 | dataViewModel = getApplicationViewModel(TestDataViewModel.class);
26 | getData();
27 | }
28 |
29 |
30 | @Override
31 | public void retryData() {
32 | getData();
33 | }
34 |
35 | public void getData() {
36 | dataViewModel.getData().observe(getView(), getDataSubscriber());
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/activity/TestDataActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.NonNull;
5 | import android.support.annotation.Nullable;
6 | import android.widget.TextView;
7 |
8 | import com.aac.expansion.data.AacDataActivity;
9 | import com.aac.module.pres.RequiresPresenter;
10 | import com.example.aac.R;
11 |
12 | /**
13 | * Created by yangc on 2017/8/14.
14 | * E-Mail:yangchaojiang@outlook.com
15 | * Deprecated:
16 | */
17 |
18 | @RequiresPresenter(TesDataPresenter.class)
19 | public class TestDataActivity extends AacDataActivity {
20 | TextView te;
21 |
22 | @Override
23 | protected void onCreate(@Nullable Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | te = findViewById(R.id.textView2);
26 | initLoadHelper(findViewById(R.id.root));
27 | getSupportActionBar().setTitle("测试");
28 | }
29 |
30 |
31 | @Override
32 | public void setData(@NonNull String data) {
33 | te.setText(data);
34 | }
35 |
36 | @Override
37 | public int getContentLayoutId() {
38 | return R.layout.test_data1_views;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/activity/TestDataListActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 |
6 | import com.aac.expansion.list.AacListActivity;
7 | import com.aac.module.pres.RequiresPresenter;
8 | import com.chad.library.adapter.base.BaseViewHolder;
9 |
10 | /**
11 | * Created by yangc on 2017/8/14.
12 | * E-Mail:yangchaojiang@outlook.com
13 | * Deprecated:
14 | */
15 |
16 | @RequiresPresenter(TestDataListPresenter.class)
17 | public class TestDataListActivity extends AacListActivity {
18 |
19 | @Override
20 | protected void onCreate(@Nullable Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setLoadMore(true);
23 | setRefreshing(true);
24 | setTitle("测试数据");
25 | }
26 |
27 | @Override
28 | public int getItemLayout() { return android.R.layout.simple_list_item_2; }
29 | @Override
30 | public void convertViewHolder(BaseViewHolder helper, String item) {
31 | helper.setText(android.R.id.text1, item);
32 | helper.setText(android.R.id.text2, item);
33 | }
34 |
35 |
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/activity/TestDataListPresenter.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.activity;
2 |
3 |
4 | import com.aac.module.rx2.presenter.list.AacRxListAPresenter;
5 | import com.example.aac.java.model.TestDataViewModel;
6 |
7 | /**
8 | * Created by yangc on 2017/8/14.
9 | * E-Mail:yangchaojiang@outlook.com
10 | * Deprecated:
11 | */
12 |
13 | public class TestDataListPresenter extends AacRxListAPresenter {
14 | private TestDataViewModel viewModel;
15 | @Override
16 | public void onCreate() {
17 | super.onCreate();
18 | viewModel = getViewModel(TestDataViewModel.class);
19 | setLoadData(1);
20 | }
21 |
22 | /***
23 | * 没有进入页面没有开启刷新需要说手动调用
24 | * **/
25 | @Override
26 | public void setLoadData(int pager) {
27 | super.setLoadData(pager);
28 | viewModel.getListData(pager).observe(getView(), getDataSubscriber());
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/activity/bean/UserBean.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.activity.bean;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | /**
7 | * Created by yangc on 2017/9/25.
8 | * E-Mail:yangchaojiang@outlook.com
9 | * Deprecated:
10 | */
11 |
12 | public class UserBean implements Parcelable {
13 |
14 | private String test;
15 |
16 | public String getTest() {
17 | return test;
18 | }
19 |
20 | public void setTest(String test) {
21 | this.test = test;
22 | }
23 |
24 | @Override
25 | public int describeContents() {
26 | return 0;
27 | }
28 |
29 | @Override
30 | public void writeToParcel(Parcel dest, int flags) {
31 | dest.writeString(this.test);
32 | }
33 |
34 | public UserBean() {
35 | }
36 |
37 | protected UserBean(Parcel in) {
38 | this.test = in.readString();
39 | }
40 |
41 | public static final Creator CREATOR = new Creator() {
42 | @Override
43 | public UserBean createFromParcel(Parcel source) {
44 | return new UserBean(source);
45 | }
46 |
47 | @Override
48 | public UserBean[] newArray(int size) {
49 | return new UserBean[size];
50 | }
51 | };
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/fragment/TestFragmentActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.fragment;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.view.View;
7 |
8 | import com.aac.module.ui.AacActivity;
9 | import com.example.aac.R;
10 | import com.example.aac.java.data.fragment.data.Test2FragmentActivity;
11 | import com.example.aac.java.data.fragment.list.TestDataFragmentActivity;
12 |
13 | /**
14 | * Created by yangc on 2017/8/27.
15 | * E-Mail:yangchaojiang@outlook.com
16 | * Deprecated:
17 | */
18 |
19 | public class TestFragmentActivity extends AacActivity {
20 | public static final String TAG = "TestDataFragmentActivity";
21 | @Override
22 | protected void onCreate(@Nullable Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | findViewById(R.id.button5).setOnClickListener(new View.OnClickListener() {
25 | @Override
26 | public void onClick(View v) {
27 | Intent intent = new Intent(TestFragmentActivity.this, Test2FragmentActivity.class);
28 | startActivity(intent);
29 |
30 | }
31 | });
32 | findViewById(R.id.button6).setOnClickListener(new View.OnClickListener() {
33 | @Override
34 | public void onClick(View v) {
35 | Intent intent = new Intent(TestFragmentActivity.this, TestDataFragmentActivity.class);
36 | startActivity(intent);
37 |
38 | }
39 | });
40 |
41 | }
42 |
43 | @Override
44 | public int getContentLayoutId() {
45 | return R.layout.test_fragmen_view;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/fragment/data/Test2FragmentActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.fragment.data;
2 |
3 | import com.aac.module.ui.AacActivity;
4 | import com.example.aac.R;
5 |
6 | /**
7 | * Created by yangc on 2017/8/15.
8 | * E-Mail:yangchaojiang@outlook.com
9 | * Deprecated: fragment 详细数据demo
10 | */
11 |
12 | public class Test2FragmentActivity extends AacActivity {
13 |
14 | @Override
15 | public int getContentLayoutId() {
16 | return R.layout.test__fragment_view;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/fragment/data/TestDataFragment.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.fragment.data;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.NonNull;
5 | import android.support.annotation.Nullable;
6 | import android.view.View;
7 | import android.widget.TextView;
8 |
9 | import com.aac.expansion.data.AacDataFragment;
10 | import com.aac.module.pres.RequiresPresenter;
11 | import com.example.aac.R;
12 |
13 | /**
14 | * Created by yangc on 2017/8/15.
15 | * E-Mail:yangchaojiang@outlook.com
16 | * Deprecated: fragment 详细数据demo
17 | */
18 | @RequiresPresenter(TestDataFragmentPresenter.class)
19 | public class TestDataFragment extends AacDataFragment {
20 |
21 | private TextView textView2;
22 |
23 | @Override
24 | public int getContentLayoutId() {
25 | return R.layout.test_data_fragment_view;
26 | }
27 | @Override
28 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
29 | super.onViewCreated(view, savedInstanceState);
30 | textView2 = view.findViewById( R.id.textView);
31 | initLoadHelper(view.findViewById(R.id.textViewlayout));
32 | }
33 | @Override
34 | public void setData(@NonNull String data) {
35 | textView2.setText(data);
36 | }
37 | @Override
38 | public void setError(Throwable e) {
39 |
40 | }
41 |
42 | @Override
43 | public void onDestroy() {
44 | super.onDestroy();
45 | }
46 |
47 | @Override
48 | protected boolean setOpenLazyLoad() {
49 | return true;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/fragment/data/TestDataFragmentPresenter.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.fragment.data;
2 |
3 |
4 | import android.util.Log;
5 |
6 | import com.aac.expansion.data.AacDataFPresenter;
7 | import com.example.aac.java.model.TestDataViewModel;
8 |
9 | /**
10 | * Created by yangc on 2017/8/15.
11 | * E-Mail:yangchaojiang@outlook.com
12 | * Deprecated:
13 | */
14 |
15 | public class TestDataFragmentPresenter extends AacDataFPresenter {
16 | public static final String TAG = "TestFragmentPresenter";
17 | private TestDataViewModel viewModel;
18 |
19 | @Override
20 | protected void onCreateView() {
21 | super.onCreateView();
22 | viewModel=getViewModel(TestDataViewModel.class);
23 | Log.d(TAG,"onCreateView");
24 |
25 | }
26 |
27 | @Override
28 | protected void lazyLoad() {
29 | Log.d(TAG,"lazyLoad");
30 | viewModel.getData().observe(getView(),getDataSubscriber());
31 |
32 | }
33 |
34 | @Override
35 | public void retryData() {
36 | lazyLoad();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/fragment/list/TestDataFragmentActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.fragment.list;
2 |
3 | import com.aac.module.ui.AacActivity;
4 | import com.example.aac.R;
5 |
6 | /**
7 | * Created by yangc on 2017/8/15.
8 | * E-Mail:yangchaojiang@outlook.com
9 | * Deprecated:
10 | */
11 |
12 | public class TestDataFragmentActivity extends AacActivity {
13 |
14 |
15 | @Override
16 | public int getContentLayoutId() {
17 | return R.layout.test_list_fragment_view;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/fragment/list/TestFragmentPresenter.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.fragment.list;
2 |
3 | import com.aac.expansion.list.AacListFPresenter;
4 | import com.example.aac.java.model.TestDataViewModel;
5 |
6 | /**
7 | * Created by yangc on 2017/8/15.
8 | * E-Mail:yangchaojiang@outlook.com
9 | * Deprecated:
10 | */
11 |
12 | public class TestFragmentPresenter extends AacListFPresenter {
13 |
14 | private TestDataViewModel viewModel;
15 | @Override
16 | protected void onCreateView() {
17 | super.onCreateView();
18 | viewModel = getViewModel(TestDataViewModel.class);
19 | }
20 | /**
21 | * 是否可以加载数据
22 | * 可以加载数据的条件:
23 | */
24 | @Override
25 | protected void lazyLoad() {
26 | viewModel.getListData(1).observe(getView(), getDataSubscriber());
27 | }
28 |
29 | @Override
30 | public void setLoadData(int pager) {
31 | viewModel.getListData(pager).observe(getView(), getDataSubscriber());
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/fragment/list/TestListFragment.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.fragment.list;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.view.View;
6 | import com.aac.expansion.list.AacListFragment;
7 | import com.aac.module.pres.RequiresPresenter;
8 | import com.chad.library.adapter.base.BaseViewHolder;
9 |
10 | /**
11 | * Created by yangc on 2017/8/15.
12 | * E-Mail:yangchaojiang@outlook.com
13 | * Deprecated:
14 | */
15 | @RequiresPresenter(TestFragmentPresenter.class)
16 | public class TestListFragment extends AacListFragment {
17 |
18 | /***
19 | * 等于1 list 大于1 GridS
20 | * **/
21 | @Override
22 | public int setGridSpanCount() {
23 | return 3;
24 | }
25 | @Override
26 | public int getItemLayout() {
27 | return android.R.layout.simple_list_item_2;
28 | }
29 | @Override
30 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
31 | super.onViewCreated(view, savedInstanceState);
32 | setStartLoadMore(true);
33 | setRefreshing(true);
34 | }
35 |
36 | @Override
37 | public void convertViewHolder(BaseViewHolder helper, String item) {
38 | helper.setText(android.R.id.text1, item);
39 | helper.setText(android.R.id.text2, item);
40 | }
41 | @Override
42 | protected boolean setOpenLazyLoad() {
43 | return false;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/multi/adapter/TestAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.multi.adapter
2 |
3 | import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
4 | import com.chad.library.adapter.base.BaseViewHolder
5 | import com.example.aac.java.data.multi.bean.Multi
6 |
7 | import java.util.ArrayList
8 |
9 | /**
10 | * Same as QuickAdapter#QuickAdapter(Context,int) but with
11 | * some initialization data.
12 | *
13 | * @param data A new list is created out of this one to avoid mutable list
14 | */
15 | class TestAdapter : BaseMultiItemQuickAdapter(ArrayList()) {
16 |
17 | init {
18 | //addItemType();
19 | }
20 | override fun convert(helper: BaseViewHolder, item: Multi) {
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/multi/bean/Multi.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.multi.bean;
2 |
3 |
4 | import android.os.Parcel;
5 | import android.os.Parcelable;
6 |
7 | import com.chad.library.adapter.base.entity.MultiItemEntity;
8 |
9 | /**
10 | * Created by yangc on 2018/10/15 11:08:53
11 | * E-Mail:yangchaojiang@outlook.com
12 | * Deprecated:
13 | **/
14 | public class Multi implements Parcelable,MultiItemEntity {
15 |
16 |
17 | protected Multi(Parcel in) {
18 | }
19 |
20 | @Override
21 | public void writeToParcel(Parcel dest, int flags) {
22 | }
23 | @Override
24 | public int describeContents() {
25 | return 0;
26 | }
27 |
28 | public static final Creator CREATOR = new Creator() {
29 | @Override
30 | public Multi createFromParcel(Parcel in) {
31 | return new Multi(in);
32 | }
33 |
34 | @Override
35 | public Multi[] newArray(int size) {
36 | return new Multi[size];
37 | }
38 | };
39 |
40 | @Override
41 | public int getItemType() {
42 | return 0;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/multi/model/MultiViewModel.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.multi.model;
2 |
3 | import com.aac.module.model.AacViewModel;
4 | /**
5 | * Created by yangc on 2018/10/15 11:08:53
6 | * E-Mail:yangchaojiang@outlook.com
7 | * Deprecated:
8 | **/
9 | public class MultiViewModel extends AacViewModel {
10 | @Override
11 | protected void onCleared() {
12 | super.onCleared();
13 | }
14 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/multi/presenter/MultiPresenter.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.multi.presenter;
2 |
3 | import com.aac.expansion.list.AacListAPresenter;
4 | import com.aac.expansion.list.AacMultiListAPresenter;
5 | import com.example.aac.java.data.multi.model.MultiViewModel;
6 | import com.example.aac.java.data.multi.ui.MultiActivity;
7 | import com.example.aac.java.data.multi.bean.Multi;
8 |
9 | /**
10 | * Created by yangc on 2018/10/15 11:08:53
11 | * E-Mail:yangchaojiang@outlook.com
12 | * Deprecated:
13 | **/
14 | public class MultiPresenter extends AacMultiListAPresenter {
15 | public static final String TAG = MultiPresenter.class.getName();
16 | private MultiViewModel mMulti;
17 | @Override
18 | public void onCreate() {
19 | super.onCreate();
20 | mMulti = getViewModel(MultiViewModel.class);
21 | }
22 |
23 | @Override
24 | public void setLoadData(int pager) {
25 | // mMulti.getListData(getView(),"id").observe(getView(),getDataSubscriber());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/multi/ui/MultiActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.multi.ui;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import com.aac.expansion.list.AacListActivity;
7 | import android.os.Bundle;
8 | import android.support.annotation.NonNull;
9 | import android.support.annotation.Nullable;
10 |
11 | import com.aac.expansion.list.AacMultiListActivity;
12 | import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
13 | import com.chad.library.adapter.base.BaseQuickAdapter;
14 | import com.chad.library.adapter.base.BaseViewHolder;
15 | import com.aac.module.pres.RequiresPresenter;
16 | import com.example.aac.R;
17 | import com.example.aac.java.data.multi.adapter.TestAdapter;
18 | import com.example.aac.java.data.multi.presenter.MultiPresenter;
19 | import com.example.aac.java.data.multi.bean.Multi;
20 |
21 | /**
22 | * Created by yangc on 2018/10/15 11:08:53
23 | * E-Mail:yangchaojiang@outlook.com
24 | * Deprecated:
25 | **/
26 | @RequiresPresenter(MultiPresenter.class)
27 | public class MultiActivity extends AacMultiListActivity {
28 | private TestAdapter mTestAdapter;
29 |
30 | public static void startActivity(Activity activity) {
31 | Intent intent = new Intent(activity,MultiActivity.class);
32 | activity.startActivity(intent);
33 | }
34 | @Override
35 | protected void onCreate(@Nullable Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | setLoadMore(true);
38 | }
39 |
40 |
41 | @Override
42 | public int setGridSpanCount() {
43 | return 3;
44 | }
45 |
46 | @NonNull
47 | @Override
48 | public TestAdapter getMultiAdapter() {
49 | return mTestAdapter;
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/test/adapter/TestAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.test.adapter
2 | import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
3 | import com.chad.library.adapter.base.BaseViewHolder
4 | import com.example.aac.java.data.test.bean.Test
5 |
6 | import java.util.ArrayList
7 |
8 | /**
9 | * Same as QuickAdapter#QuickAdapter(Context,int) but with
10 | * some initialization data.
11 | *
12 | */
13 | class TestAdapter : BaseMultiItemQuickAdapter(ArrayList()) {
14 |
15 | init {
16 | //addItemType();
17 | }
18 |
19 | override fun convert(helper: BaseViewHolder, item: Test) {
20 |
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/test/bean/Test.kt:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.test.bean
2 | import java.io.Serializable
3 | import com.chad.library.adapter.base.entity.MultiItemEntity;
4 | /**
5 | * Created by yangc on 2018/10/15 18:14:55
6 | * E-Mail:yangchaojiang@outlook.com
7 | * Deprecated:
8 | **/
9 | class Test :Serializable,MultiItemEntity {
10 | var test:String?=null
11 |
12 |
13 | override fun getItemType(): Int = 0
14 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/test/model/TestViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.test.model
2 | import com.aac.module.model.AacViewModel
3 |
4 | /**
5 | * Created by yangc on 2018/10/15 18:14:55
6 | * E-Mail:yangchaojiang@outlook.com
7 | * Deprecated:
8 | **/
9 | class TestViewModel : AacViewModel() {
10 | override fun onCleared() {
11 | super.onCleared()
12 | }
13 |
14 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/test/presenter/TestPresenter.kt:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.test.presenter
2 |
3 | import com.aac.expansion.list.AacMultiListAPresenter
4 |
5 | import com.example.aac.java.data.test.model.TestViewModel
6 | import com.example.aac.java.data.test.ui.TestActivity
7 | import com.example.aac.java.data.test.bean.Test;
8 |
9 |
10 | /**
11 | * Created by yangc on 2018/10/15 18:14:55
12 | * E-Mail:yangchaojiang@outlook.com
13 | * Deprecated:
14 | **/
15 | class TestPresenter : AacMultiListAPresenter (){
16 | private lateinit var mTest: TestViewModel
17 | public override fun onCreate() {
18 | super.onCreate()
19 | mTest = getViewModel(TestViewModel::class.java)
20 | }
21 |
22 | fun lazyLoad() {
23 | }
24 | companion object {
25 | val TAG = TestPresenter::class.java.name
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/test/ui/TestActivity.kt:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.test.ui
2 | import android.app.Activity
3 | import android.content.Intent
4 | import android.os.Bundle
5 | import com.aac.expansion.list.AacMultiListActivity
6 |
7 | import com.chad.library.adapter.base.BaseViewHolder
8 | import com.aac.module.pres.RequiresPresenter
9 | import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
10 | import com.example.aac.R
11 | import com.example.aac.java.data.test.presenter.TestPresenter
12 | import com.example.aac.java.data.test.bean.Test
13 | import com.example.aac.java.data.test.adapter.TestAdapter
14 |
15 | /**
16 | * Created by yangc on 2018/10/15 18:14:55
17 | * E-Mail:yangchaojiang@outlook.com
18 | * Deprecated:
19 | **/
20 | @RequiresPresenter(TestPresenter::class)
21 | class TestActivity : AacMultiListActivity() {
22 |
23 | private val mTestAdapter : TestAdapter = TestAdapter()
24 |
25 | override fun getMultiAdapter(): BaseMultiItemQuickAdapter = mTestAdapter
26 |
27 | override fun onCreate(savedInstanceState: Bundle?) {
28 | super.onCreate(savedInstanceState)
29 | // setLoadMore(true)
30 | }
31 |
32 | companion object {
33 | fun startActivity(activity: Activity) {
34 | val intent = Intent(activity, TestActivity::class.java)
35 | activity.startActivity(intent)
36 | }
37 | }
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/test4/adapter/Test4Adapter.kt:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.test4.adapter
2 | import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
3 | import com.chad.library.adapter.base.BaseViewHolder
4 | import com.example.aac.java.data.test4.bean.Test4
5 |
6 | import java.util.ArrayList
7 |
8 | /**
9 | * Same as QuickAdapter#QuickAdapter(Context,int) but with
10 | * some initialization data.
11 | *
12 | */
13 | class Test4Adapter : BaseMultiItemQuickAdapter(ArrayList()) {
14 |
15 | init {
16 | //addItemType();
17 | }
18 |
19 | override fun convert(helper: BaseViewHolder, item: Test4) {
20 |
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/test4/bean/Test4.kt:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.test4.bean
2 | import java.io.Serializable
3 | import com.chad.library.adapter.base.entity.MultiItemEntity;
4 | /**
5 | * Created by yangc on 2018/10/15 18:15:15
6 | * E-Mail:yangchaojiang@outlook.com
7 | * Deprecated:
8 | **/
9 | class Test4 :Serializable,MultiItemEntity {
10 | var test:String?=null
11 |
12 |
13 | override fun getItemType(): Int = 0
14 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/test4/model/Test4ViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.test4.model
2 | import com.aac.module.model.AacViewModel
3 |
4 | /**
5 | * Created by yangc on 2018/10/15 18:15:15
6 | * E-Mail:yangchaojiang@outlook.com
7 | * Deprecated:
8 | **/
9 | class Test4ViewModel : AacViewModel() {
10 | override fun onCleared() {
11 | super.onCleared()
12 | }
13 |
14 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/test4/presenter/Test4Presenter.kt:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.test4.presenter
2 |
3 | import com.aac.expansion.list.AacMultiListFPresenter
4 | import com.example.aac.java.data.test4.model.Test4ViewModel
5 | import com.example.aac.java.data.test4.ui.Test4Fragment
6 | import com.example.aac.java.data.test4.bean.Test4;
7 |
8 |
9 | /**
10 | * Created by yangc on 2018/10/15 18:15:15
11 | * E-Mail:yangchaojiang@outlook.com
12 | * Deprecated:
13 | **/
14 | class Test4Presenter : AacMultiListFPresenter (){
15 | private lateinit var mTest4: Test4ViewModel
16 | public override fun onCreate() {
17 | super.onCreate()
18 | mTest4 = getViewModel(Test4ViewModel::class.java)
19 | }
20 |
21 | override fun lazyLoad() {
22 | }
23 | companion object {
24 | val TAG = Test4Presenter::class.java.name
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/data/test4/ui/Test4Fragment.kt:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.data.test4.ui
2 | import android.os.Bundle
3 | import android.view.View
4 | import com.aac.expansion.list.AacMultiListFragment
5 | import com.chad.library.adapter.base.BaseViewHolder
6 | import com.aac.module.pres.RequiresPresenter
7 | import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
8 | import com.example.aac.R
9 | import com.example.aac.java.data.test4.presenter.Test4Presenter
10 | import com.example.aac.java.data.test4.bean.Test4
11 | import com.example.aac.java.data.test4.adapter.Test4Adapter
12 |
13 | /**
14 | * Created by yangc on 2018/10/15 18:15:14
15 | * E-Mail:yangchaojiang@outlook.com
16 | * Deprecated:
17 | **/
18 | @RequiresPresenter(Test4Presenter::class)
19 | class Test4Fragment : AacMultiListFragment() {
20 |
21 | private val mTest4Adapter : Test4Adapter = Test4Adapter()
22 |
23 | override fun getMultiAdapter(): BaseMultiItemQuickAdapter = mTest4Adapter
24 |
25 | override fun setOpenLazyLoad(): Boolean = true
26 |
27 | override fun setGridSpanCount(): Int = 1
28 |
29 | override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
30 | super.onViewCreated(view, savedInstanceState)
31 | //setStartLoadMore(true);
32 | }
33 |
34 | companion object {
35 | fun getInstance(param: String): Test4Fragment {
36 | val fragment = Test4Fragment()
37 | val bundle = Bundle()
38 | bundle.putString("param", param)
39 | fragment.arguments = bundle
40 | return fragment
41 | }
42 | }
43 |
44 | }
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/java/model/TestDataViewModel.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.java.model;
2 |
3 | import android.app.Application;
4 | import android.arch.lifecycle.AndroidViewModel;
5 | import android.arch.lifecycle.LiveData;
6 | import android.arch.lifecycle.MutableLiveData;
7 | import android.content.Context;
8 | import android.os.SystemClock;
9 | import android.util.Log;
10 |
11 |
12 | import com.alibaba.fastjson.TypeReference;
13 | import com.example.aac.java.data.activity.bean.UserBean;
14 | import com.example.aac.utils.JsonCallback;
15 | import com.lzy.okgo.OkGo;
16 | import com.lzy.okgo.callback.StringCallback;
17 | import com.lzy.okgo.model.Response;
18 |
19 | import java.util.ArrayList;
20 | import java.util.List;
21 |
22 | /**
23 | * Created by yangc on 2017/8/14.
24 | * E-Mail:yangchaojiang@outlook.com
25 | * Deprecated:
26 | */
27 |
28 | public class TestDataViewModel extends AndroidViewModel {
29 | private MutableLiveData data = new MutableLiveData<>();
30 | private MutableLiveData> listData = new MutableLiveData<>();
31 | private MutableLiveData liveData = new MutableLiveData<>();
32 | public TestDataViewModel(Application application) {
33 | super(application);
34 | Log.d("TestDataViewModel", "TestDataViewModel");
35 |
36 | }
37 |
38 | public LiveData getData() {
39 | Log.d("TestDataViewModel", data.getValue() + "");
40 | Thread s = new Thread(new Runnable() {
41 | @Override
42 | public void run() {
43 | SystemClock.sleep(1000);
44 | data.postValue(null);
45 | //data.postValue("获取数据");
46 | }
47 | });
48 | s.start();
49 | return data;
50 | }
51 |
52 |
53 | @Override
54 | protected void onCleared() {
55 | super.onCleared();
56 | Log.d("TestDataViewModel", "onCleared");
57 | }
58 |
59 | public LiveData> getListData(final int page) {
60 | Thread s = new Thread(new Runnable() {
61 | @Override
62 | public void run() {
63 | SystemClock.sleep(2000);
64 | int s = (page - 1) * 40;
65 | List list = new ArrayList<>();
66 | for (int i = s; i < 40 * page; i++) {
67 | list.add("数据:" + i);
68 | }
69 | listData.postValue(list);
70 | }
71 | });
72 | s.start();
73 | return listData;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/utils/JsonCallback.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.utils;
2 |
3 |
4 | import com.alibaba.fastjson.JSONObject;
5 | import com.alibaba.fastjson.TypeReference;
6 | import com.lzy.okgo.callback.AbsCallback;
7 | import com.lzy.okgo.request.base.Request;
8 | import com.yutils.JsonManager;
9 |
10 | import java.lang.reflect.Type;
11 |
12 | import okhttp3.Response;
13 | import okhttp3.ResponseBody;
14 |
15 | /**
16 | * Created by yangc on 2017/10/7.
17 | * E-Mail:yangchaojiang@outlook.com
18 | * Deprecated:
19 | */
20 |
21 | public abstract class JsonCallback extends AbsCallback {
22 | private Type type;
23 | private Class clazz;
24 | private String key;
25 |
26 | public JsonCallback(String key, Class clazz) {
27 | this.clazz = clazz;
28 | this.key = key;
29 | }
30 | public JsonCallback(String key, Type type) {
31 | this.type = type;
32 | this.key = key;
33 | }
34 | private JsonCallback(){
35 |
36 | }
37 | /**
38 | * 该方法是子线程处理,不能做ui相关的工作
39 | * 主要作用是解析网络返回的 response 对象,生产onSuccess回调中需要的数据对象
40 | * 这里的解析工作不同的业务逻辑基本都不一样,所以需要自己实现,以下给出的时模板代码,实际使用根据需要修改
41 | */
42 | @Override
43 | public T convertResponse(Response response) throws Throwable {
44 | // 重要的事情说三遍,不同的业务,这里的代码逻辑都不一样,如果你不修改,那么基本不可用
45 | // 重要的事情说三遍,不同的业务,这里的代码逻辑都不一样,如果你不修改,那么基本不可用
46 | // 重要的事情说三遍,不同的业务,这里的代码逻辑都不一样,如果你不修改,那么基本不可用
47 | //详细自定义的原理和文档,看这里: https://github.com/jeasonlzy/okhttp-OkGo/wiki/JsonCallback
48 | ResponseBody body = response.body();
49 | if (body == null) {
50 | return null;
51 | }
52 | JSONObject s = JsonManager.parseJsonObject(body.string());
53 | if (s.getBoolean("success")) {
54 | if (clazz!=null){
55 | return JsonManager.jsonToBean(s.get(key).toString(),clazz);
56 | }else if (type!=null){
57 | return JsonManager.jsonToBean(s.get(key).toString(),type);
58 | }else {
59 | return JsonManager.jsonToBean(body.bytes());
60 | }
61 | } else {
62 | throw new IllegalStateException(response.message());
63 | }
64 | }
65 |
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/utils/JsonCallbcakKotlin.kt:
--------------------------------------------------------------------------------
1 | package com.keba.utils
2 |
3 |
4 | import android.support.annotation.AnyThread
5 | import android.support.annotation.NonNull
6 | import com.alibaba.fastjson.JSONObject
7 | import com.lzy.okgo.callback.AbsCallback
8 | import com.yutils.JsonManager
9 | import java.lang.reflect.Type
10 | import okhttp3.Response
11 |
12 | /**
13 | * Created by yangc on 2017/10/7.
14 | * E-Mail:yangchaojiang@outlook.com
15 | * Deprecated:
16 | */
17 |
18 | abstract class JsonCallbcakKotlin : AbsCallback {
19 | private var type: Type? = null
20 | private var clazz: Class? = null
21 | private var key: String? = null
22 |
23 | constructor(@NonNull key: String, clazz: Class) {
24 | this.clazz = clazz
25 | this.key = key
26 | }
27 |
28 | constructor(@NonNull key: String, type: Type) {
29 | this.type = type
30 | this.key = key
31 | }
32 |
33 | override fun onStart(request: com.lzy.okgo.request.base.Request>?) {
34 | super.onStart(request)
35 | }
36 |
37 | /**
38 | * 该方法是子线程处理,不能做ui相关的工作
39 | * 主要作用是解析网络返回的 response 对象,生产onSuccess回调中需要的数据对象
40 | * 这里的解析工作不同的业务逻辑基本都不一样,所以需要自己实现,以下给出的时模板代码,实际使用根据需要修改
41 | */
42 | @Throws(Throwable::class)
43 | override fun convertResponse(response: Response): T? {
44 | // 重要的事情说三遍,不同的业务,这里的代码逻辑都不一样,如果你不修改,那么基本不可用
45 | // 重要的事情说三遍,不同的业务,这里的代码逻辑都不一样,如果你不修改,那么基本不可用
46 | // 重要的事情说三遍,不同的业务,这里的代码逻辑都不一样,如果你不修改,那么基本不可用
47 | //详细自定义的原理和文档,看这里: https://github.com/jeasonlzy/okhttp-OkGo/wiki/JsonCallback
48 | val body = response.body() ?: return null
49 | val s = JsonManager.parseJsonObject(body.string())
50 | return if (s.getBoolean("success")!!) {
51 | when {
52 | clazz != null -> JsonManager.jsonToBean(s[key].toString(), clazz!!)
53 | type != null -> JsonManager.jsonToBean(s[key].toString(), type!!)
54 | else -> JsonManager.jsonToBean(body.bytes())
55 | }
56 | } else {
57 | throw IllegalStateException(response.message())
58 | }
59 | }
60 |
61 | companion object {
62 | /*****
63 | * @param response 請求對象
64 | * @param type 返回实例对象类型
65 | * @param key 需要处理对象key
66 | * @return T
67 | * set TypeReference typeReference = new TypeReference() {};
68 | */
69 | @AnyThread
70 | @Throws(Exception::class)
71 | fun getBean(response: Response, type: Type, key: String): T? {
72 | val body = response.body() ?: return null
73 | val s = JsonManager.parseJsonObject(body.string())
74 | return if (s.getBoolean("success")!!) {
75 | JsonManager.jsonToBean(s?.get(key).toString(), type)
76 | } else if (!s.getBoolean("success")!!) {
77 | JsonManager.jsonToBean(body.bytes())
78 | } else {
79 | throw IllegalStateException(response.message())
80 | }
81 | }
82 |
83 | /*****
84 | * @param response 請求對象
85 | * @param clazz 返回实例对象类型
86 | * @param key 需要处理对象key
87 | * @return T
88 | */
89 | @AnyThread
90 | @Throws(Exception::class)
91 | fun getBean(response: Response, clazz: Class, key: String): T? {
92 | val body = response.body() ?: return null
93 | val s = JsonManager.parseJsonObject(body.string())
94 | return if (s.getBoolean("success")!!) {
95 | JsonManager.jsonToBean(s?.get(key).toString(), clazz)
96 | } else if (!s.getBoolean("success")!!) {
97 | JsonManager.jsonToBean(body.bytes())
98 | } else {
99 | throw IllegalStateException(response.message())
100 | }
101 | }
102 |
103 | /*****
104 | * @param response 請求對象
105 | * @param clazz 返回实例对象类型
106 | * @param key 需要处理对象key
107 | * @return T
108 | */
109 | @AnyThread
110 | @Throws(Exception::class)
111 | fun getBean(response: Response): JSONObject? {
112 | val body = response.body() ?: return null
113 | return JsonManager.parseJsonObject(body.string())
114 |
115 | }
116 |
117 | /*****
118 | * @param response 請求對象
119 | * @param clazz 返回实例对象类型
120 | * @param key 需要处理对象key
121 | * @return T
122 | */
123 | @AnyThread
124 | @Throws(Exception::class)
125 | fun getListBean(response: Response, clazz: Class, key: String): List? {
126 | val body = response.body() ?: return null
127 | val s = JsonManager.parseJsonObject(body.string())
128 | if (s.getBoolean("success")!!) {
129 | return JsonManager.jsonToList(s?.get(key).toString(), clazz)
130 | } else {
131 | throw IllegalStateException(response.message())
132 | }
133 | }
134 | }
135 |
136 | }
137 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/utils/rwar/model/RwarViewModel.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.utils.rwar.model;
2 |
3 | import com.aac.module.model.AacViewModel;
4 | /**
5 | * Created by yangc on 2018/11/27 17:29:05
6 | * E-Mail:yangchaojiang@outlook.com
7 | * Deprecated:
8 | **/
9 | public class RwarViewModel extends AacViewModel {
10 | @Override
11 | protected void onCleared() {
12 | super.onCleared();
13 | }
14 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/utils/rwar/presenter/RwarPresenter.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.utils.rwar.presenter;
2 |
3 |
4 | import com.aac.module.ui.AacPresenter;
5 | import com.example.aac.utils.rwar.model.RwarViewModel;
6 | import com.example.aac.utils.rwar.ui.RwarActivity;
7 |
8 | /**
9 | * Created by yangc on 2018/11/27 17:29:04
10 | * E-Mail:yangchaojiang@outlook.com
11 | * Deprecated:
12 | **/public class RwarPresenter extends AacPresenter {
13 |
14 | public static final String TAG = RwarPresenter.class.getName();
15 | private RwarViewModel mRwar;
16 | @Override
17 | public void onCreate() {
18 | super.onCreate();
19 | mRwar = getViewModel(RwarViewModel.class);
20 | }
21 |
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/aac/utils/rwar/ui/RwarActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.aac.utils.rwar.ui;
2 |
3 |
4 | import android.app.Activity;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.support.annotation.Nullable;
8 | import com.aac.module.ui.AacActivity;
9 | import com.aac.module.pres.RequiresPresenter;
10 | import com.example.aac.R;
11 | import com.example.aac.utils.rwar.presenter.RwarPresenter;
12 |
13 |
14 |
15 | /**
16 | * Created by yangc on 2018/11/27 17:29:04
17 | * E-Mail:yangchaojiang@outlook.com
18 | * Deprecated:
19 | **/
20 | @RequiresPresenter(RwarPresenter.class)
21 | public class RwarActivity extends AacActivity {
22 |
23 | public static void startActivity(Activity activity) {
24 | Intent intent = new Intent(activity,RwarActivity.class);
25 | activity.startActivity(intent);
26 | }
27 | @Override
28 | public int getContentLayoutId() { return R.layout.activity_rwar; }
29 |
30 | @Override
31 | protected void onCreate(@Nullable Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_coroutines.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
17 |
18 |
26 |
27 |
35 |
36 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_multi.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_rwar.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_test.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_test1.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_test2.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_test23.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_test3.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_test4.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_test5.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_test77.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_testk.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_tets6.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_test.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_test1.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_test2.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_test3.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_test4.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_test44.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_test5.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_test6.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/include_toolbar_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/test__fragment_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/test_cuutom_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
10 |
14 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/test_data1_views.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/test_data_fragment_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
15 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/test_data_list_actvity.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/test_data_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
13 |
14 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/test_fragmen_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
19 |
20 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/test_list_custom_fragment_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
12 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/test_list_fragment_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangchaojiang/AaComponents/e9175440fdc9ec8079e32121753f099690fcb178/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangchaojiang/AaComponents/e9175440fdc9ec8079e32121753f099690fcb178/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangchaojiang/AaComponents/e9175440fdc9ec8079e32121753f099690fcb178/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangchaojiang/AaComponents/e9175440fdc9ec8079e32121753f099690fcb178/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangchaojiang/AaComponents/e9175440fdc9ec8079e32121753f099690fcb178/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #e1e1e1
7 | #999999
8 | #eeeeee
9 | #ffffff
10 | #c61a04
11 | #cccccc
12 | #d81e06
13 | #b0b8b2
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | acc
3 | 忘记密码
4 | 请输入数字或字母
5 | 密码长度六位以上
6 | 登录
7 | 请输入手机号码
8 | 输入密码
9 | 注册新用户
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/test/java/com/example/aac/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.aac;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.3.0'
5 | ext.anko_version='0.10.7'
6 | repositories {
7 | jcenter()
8 | google()
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:3.1.3'
12 | classpath 'com.novoda:bintray-release:0.8.1'
13 | classpath 'me.tatarka:gradle-retrolambda:3.7.0'
14 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
15 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
16 | // NOTE: Do not place your application dependencies here; they belong
17 | // in the individual module build.gradle files
18 | }
19 | }
20 |
21 | allprojects {
22 | repositories {
23 | jcenter()
24 | maven { url "https://jitpack.io" }
25 | maven { url 'https://maven.google.com' }
26 | mavenCentral()
27 | }
28 |
29 | project.ext {
30 | compileSdkVersion=26
31 | targetSdkVersion=25
32 | buildToolsVersion='26.0.3'
33 | minSdkVersion=16
34 | versionCode = 1
35 | versionName = "1.0"
36 | libSversion="26.1.0"
37 | publishVersion="2.5.3"
38 | }
39 |
40 | //加上这些
41 | tasks.withType(Javadoc) {
42 | options {
43 | encoding "UTF-8"
44 | charSet 'UTF-8'
45 | links "http://docs.oracle.com/javase/7/docs/api/"
46 | }
47 | }
48 | }
49 |
50 | //非常重要要不它不认识你的项目.kt文件名 其中airpurgeview是你的library名
51 | tasks.getByPath(":Aac-data-module-http:releaseAndroidJavadocs").enabled = false
52 | task clean(type: Delete) {
53 | delete rootProject.buildDir
54 | }
55 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 | android.enableD8=true
19 | android.enableD8.desugaring = true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangchaojiang/AaComponents/e9175440fdc9ec8079e32121753f099690fcb178/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Nov 05 10:35:28 CST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':AacModule', ':Aac-data-module',':Aac-data-module-rx2', ':Aac-data-module-http', ':Aac-data-module-coroutines'
2 |
--------------------------------------------------------------------------------