implements IModel {
13 |
14 | private int code = 200;
15 | private String message;
16 | private T data;
17 | private String version = "1.0";
18 | private String mobile = "android";
19 |
20 | public final static int ERROR = 401;
21 | public final static int SUCCESS = 200;
22 | public final static int FAIL = 500;
23 | public final static int TOKENFAIL = 1000;
24 | public final static String KEY = "czx12345";
25 |
26 | public int getCode() {
27 | return code;
28 | }
29 |
30 | public void setCode(int code) {
31 | this.code = code;
32 | }
33 |
34 | public String getMessage() {
35 | return message;
36 | }
37 |
38 | public void setMessage(String message) {
39 | this.message = message;
40 | }
41 |
42 | public T getData() {
43 | return data;
44 | }
45 |
46 | public void setData(T data) {
47 | this.data = data;
48 | }
49 |
50 | public void setEncryptData(T t){
51 | String mData = new Gson().toJson(t);
52 | try {
53 | if(mData != null && !mData.equals("")){
54 | this.data = (T) CDESCrypt.encryptString(mData, KEY);
55 | }else{
56 | this.data = t;
57 | }
58 | } catch (Exception e) {
59 | e.printStackTrace();
60 | }
61 | }
62 |
63 | public String getVersion() {
64 | return version;
65 | }
66 |
67 | public void setVersion(String version) {
68 | this.version = version;
69 | }
70 |
71 | public String getMobile() {
72 | return mobile;
73 | }
74 |
75 | public void setMobile(String mobile) {
76 | this.mobile = mobile;
77 | }
78 |
79 | @Override
80 | public boolean isNull() {
81 | return false;
82 | }
83 |
84 | @Override
85 | public boolean isAuthError() {
86 | return getCode() == TOKENFAIL;
87 | }
88 |
89 | @Override
90 | public boolean isBizError() {
91 | return false;
92 | }
93 |
94 | @Override
95 | public String getErrorMsg() {
96 | return null;
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/app/src/main/java/com/suke/czx/demo/base/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.suke.czx.demo.base;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 |
7 | import com.google.gson.Gson;
8 | import com.suke.czx.demo.App;
9 | import com.suke.czx.demo.AppConstant;
10 | import com.suke.czx.demo.AppSetting;
11 | import com.suke.czx.demo.model.user.UserEntity;
12 | import com.suke.czx.demo.widget.AlertView;
13 |
14 | import java.util.HashMap;
15 | import cn.droidlover.xdroidmvp.mvp.XActivity;
16 | import cn.droidlover.xdroidmvp.net.NetError;
17 |
18 | /**
19 | * Created by czx on 2017/5/13.
20 | */
21 |
22 | public abstract class BaseActivity extends XActivity {
23 |
24 | public UserEntity result = null;
25 | private P mPresenter;
26 | public HashMap staffInfo = null;
27 |
28 | @Override
29 | protected void onCreate(@Nullable Bundle savedInstanceState) {
30 | App.addActivity(this);
31 | super.onCreate(savedInstanceState);
32 | }
33 |
34 | @Override
35 | public P newP() {
36 | return mPresenter;
37 | }
38 |
39 | public P getmPresenter(){
40 | return (P) getP();
41 | }
42 |
43 | public UserEntity getUserInfo(){
44 | String user_info = AppSetting.Initial(context).getStringPreferences(AppConstant.USER_INFO);
45 | if(user_info!=null && !user_info.equals("")){
46 | Gson json = new Gson();
47 | result = json.fromJson(user_info,UserEntity.class);
48 | }
49 | return result;
50 | }
51 |
52 | public void showSuccessForResult(){
53 | Intent intent = new Intent();
54 | //通过Intent对象返回结果,调用setResult方法
55 | setResult(RESULT_OK,intent);
56 | finish();//结束当前的activity的生命周期
57 | }
58 |
59 | public void showAlert(String msg){
60 | AlertView.showTip(context,msg);
61 | }
62 |
63 | public void showError(NetError error) {
64 | if (error != null) {
65 | switch (error.getType()) {
66 | case NetError.ParseError:
67 | AlertView.showTip(context,"数据解析异常!");
68 | break;
69 |
70 | case NetError.AuthError:
71 | AlertView.showTip(context,"用户验证过期或已在它端登录");
72 | break;
73 |
74 | case NetError.NoConnectError:
75 | AlertView.showTip(context,"网络无连接!");
76 | break;
77 |
78 | case NetError.OtherError:
79 | AlertView.showTip(context,"服务器繁忙!");
80 | break;
81 | }
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/app/src/main/java/com/suke/czx/demo/base/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package com.suke.czx.demo.base;
2 |
3 | import android.content.Intent;
4 |
5 | import com.google.gson.Gson;
6 | import com.suke.czx.demo.AppConstant;
7 | import com.suke.czx.demo.AppSetting;
8 | import com.suke.czx.demo.model.user.UserEntity;
9 |
10 |
11 | import java.util.HashMap;
12 |
13 | import cn.droidlover.xdroidmvp.mvp.IPresent;
14 | import cn.droidlover.xdroidmvp.mvp.XFragment;
15 |
16 | /**
17 | * Created by czx on 2017/11/13.
18 | */
19 |
20 | public abstract class BaseFragment extends XFragment
{
21 |
22 | public UserEntity result = null;
23 | public HashMap staffInfo = null;
24 |
25 | public UserEntity getUserInfo(){
26 | String user_info = AppSetting.Initial(context).getStringPreferences(AppConstant.USER_INFO);
27 | if(user_info!=null && !user_info.equals("")){
28 | Gson json = new Gson();
29 | result = json.fromJson(user_info,UserEntity.class);
30 | }
31 | return result;
32 | }
33 |
34 |
35 | public void showSuccessForResult(){
36 | Intent intent = new Intent();
37 | //通过Intent对象返回结果,调用setResult方法
38 | context.setResult(context.RESULT_OK,intent);
39 | context.finish();//结束当前的activity的生命周期
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/com/suke/czx/demo/base/BaseLazyFragment.java:
--------------------------------------------------------------------------------
1 | package com.suke.czx.demo.base;
2 |
3 | import com.google.gson.Gson;
4 | import com.suke.czx.demo.AppConstant;
5 | import com.suke.czx.demo.AppSetting;
6 | import com.suke.czx.demo.model.user.UserEntity;
7 |
8 | import cn.droidlover.xdroidmvp.mvp.IPresent;
9 | import cn.droidlover.xdroidmvp.mvp.XLazyFragment;
10 |
11 | /**
12 | * Created by czx on 2017/11/13.
13 | */
14 |
15 | public abstract class BaseLazyFragment extends XLazyFragment
{
16 |
17 | public UserEntity result = null;
18 |
19 | public UserEntity getUserInfo(){
20 | String user_info = AppSetting.Initial(context).getStringPreferences(AppConstant.USER_INFO);
21 | if(user_info!=null && !user_info.equals("")){
22 | Gson json = new Gson();
23 | result = json.fromJson(user_info,UserEntity.class);
24 | }
25 | return result;
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/com/suke/czx/demo/interceptor/DataInterceptor.java:
--------------------------------------------------------------------------------
1 | package com.suke.czx.demo.interceptor;
2 |
3 | import com.google.gson.Gson;
4 | import com.suke.czx.crypt.CDESCrypt;
5 | import com.suke.czx.demo.App;
6 | import com.suke.czx.demo.AppConstant;
7 | import com.suke.czx.demo.AppSetting;
8 | import com.suke.czx.demo.base.AppBaseResult;
9 | import com.suke.czx.demo.model.user.TokenEntity;
10 | import java.io.IOException;
11 | import okhttp3.Interceptor;
12 | import okhttp3.MediaType;
13 | import okhttp3.Request;
14 | import okhttp3.Response;
15 | import okhttp3.ResponseBody;
16 |
17 | /**
18 | * Created by czx on 2017/4/27.
19 | */
20 |
21 | public class DataInterceptor implements Interceptor {
22 |
23 | @Override
24 | public Response intercept(Chain chain) throws IOException {
25 | Request request = chain.request();
26 | String requestUrl = request.url().toString();
27 | String responseBody = "";
28 | Request.Builder requestBuilder = request.newBuilder();
29 | String userToken = AppSetting.Initial(App.getContext()).getStringPreferences(AppConstant.USER_TOKEN);
30 | if(userToken != null){
31 | TokenEntity tokenEntity = new Gson().fromJson(userToken,TokenEntity.class);
32 | if(tokenEntity != null){
33 | requestBuilder.addHeader("token", tokenEntity.getToken());
34 | }
35 | }
36 |
37 | Response response = chain.proceed(requestBuilder.build());
38 | String context = response.body().string();
39 | if(requestUrl.contains("?")){
40 | responseBody = context;
41 | }else{
42 | AppBaseResult appBaseResult = new Gson().fromJson(context,AppBaseResult.class);
43 | try {
44 | Object data = appBaseResult.getData();
45 | if(data != null && !data.toString().equals("")){
46 | responseBody = "{\"code\":"+appBaseResult.getCode()+",\"message\":\""+appBaseResult.getMessage()+"\",\"data\":"+CDESCrypt.decryptString(new Gson().toJson(data),AppBaseResult.KEY)+"}";
47 | }else{
48 | responseBody = "{\"code\":"+appBaseResult.getCode()+",\"message\":\""+appBaseResult.getMessage()+"\",\"data\":null}";
49 | }
50 | } catch (Exception e) {
51 | e.printStackTrace();
52 | }
53 | }
54 |
55 | MediaType mediaType = response.body().contentType();
56 | return response.newBuilder().body(ResponseBody.create(mediaType, responseBody)).build();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/java/com/suke/czx/demo/kit/AppKit.java:
--------------------------------------------------------------------------------
1 | package com.suke.czx.demo.kit;
2 |
3 | import android.content.ClipData;
4 | import android.content.ClipboardManager;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.net.Uri;
8 | import android.widget.Toast;
9 |
10 | import java.io.IOException;
11 |
12 | import okhttp3.MediaType;
13 | import okhttp3.Request;
14 | import okio.Buffer;
15 |
16 | /**
17 | * Created by wanglei on 2016/12/11.
18 | */
19 |
20 | public class AppKit {
21 |
22 | public static void copyToClipBoard(Context context, String text) {
23 | ClipboardManager cm = (ClipboardManager) context.getSystemService(
24 | Context.CLIPBOARD_SERVICE);
25 | cm.setPrimaryClip(ClipData.newPlainText("xdroid_copy", text));
26 | Toast.makeText(context, "复制成功", Toast.LENGTH_SHORT).show();
27 | }
28 |
29 | public static void openInBrowser(Context context, String url) {
30 | Intent intent = new Intent();
31 | intent.setAction(Intent.ACTION_VIEW);
32 | Uri uri = Uri.parse(url);
33 | intent.setData(uri);
34 | if (intent.resolveActivity(context.getPackageManager()) != null) {
35 | context.startActivity(intent);
36 | } else {
37 | Toast.makeText(context, "打开失败了,没有可打开的应用", Toast.LENGTH_SHORT).show();
38 | }
39 | }
40 |
41 | public static void shareText(Context context, String shareText) {
42 | Intent intent = new Intent(Intent.ACTION_SEND);
43 | intent.setType("text/plain");
44 | intent.putExtra(Intent.EXTRA_SUBJECT, "分享");
45 | intent.putExtra(Intent.EXTRA_TEXT, shareText);
46 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
47 | context.startActivity(Intent.createChooser(intent, "分享"));
48 | }
49 |
50 | public static void shareImage(Context context, Uri uri) {
51 | Intent shareIntent = new Intent();
52 | shareIntent.setAction(Intent.ACTION_SEND);
53 | shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
54 | shareIntent.setType("image/jpeg");
55 | context.startActivity(Intent.createChooser(shareIntent, "分享图片"));
56 | }
57 |
58 | public static boolean isText(MediaType mediaType) {
59 | if (mediaType.type() != null && mediaType.type().equals("text")) {
60 | return true;
61 | }
62 | if (mediaType.subtype() != null) {
63 | if (mediaType.subtype().equals("json") ||
64 | mediaType.subtype().equals("xml") ||
65 | mediaType.subtype().equals("html") ||
66 | mediaType.subtype().equals("webviewhtml")
67 | )
68 | return true;
69 | }
70 | return false;
71 | }
72 |
73 | public static String bodyToString(final Request request) {
74 | try {
75 | final Request copy = request.newBuilder().build();
76 | final Buffer buffer = new Buffer();
77 | copy.body().writeTo(buffer);
78 | return buffer.readUtf8();
79 | } catch (final IOException e) {
80 | return "something error when show requestBody.";
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/app/src/main/java/com/suke/czx/demo/model/user/TokenEntity.java:
--------------------------------------------------------------------------------
1 | package com.suke.czx.demo.model.user;
2 |
3 | import java.io.Serializable;
4 | import java.util.Date;
5 |
6 |
7 | /**
8 | * 用户Token
9 | *
10 | * @author czx
11 | * @email object_czx@163.com
12 | * @date 2017-03-23 15:22:07
13 | */
14 | public class TokenEntity implements Serializable {
15 | private static final long serialVersionUID = 1L;
16 |
17 | //用户ID
18 | private String userId;
19 | //token
20 | private String token;
21 | //过期时间
22 | private Date expireTime;
23 | //更新时间
24 | private Date updateTime;
25 |
26 | private long expire;
27 |
28 | public long getExpire() {
29 | return expire;
30 | }
31 |
32 | public void setExpire(long expire) {
33 | this.expire = expire;
34 | }
35 |
36 | /**
37 | * 设置:用户ID
38 | */
39 | public void setUserId(String userId) {
40 | this.userId = userId;
41 | }
42 | /**
43 | * 获取:用户ID
44 | */
45 | public String getUserId() {
46 | return userId;
47 | }
48 | /**
49 | * 设置:token
50 | */
51 | public void setToken(String token) {
52 | this.token = token;
53 | }
54 | /**
55 | * 获取:token
56 | */
57 | public String getToken() {
58 | return token;
59 | }
60 | /**
61 | * 设置:过期时间
62 | */
63 | public void setExpireTime(Date expireTime) {
64 | this.expireTime = expireTime;
65 | }
66 | /**
67 | * 获取:过期时间
68 | */
69 | public Date getExpireTime() {
70 | return expireTime;
71 | }
72 | /**
73 | * 设置:更新时间
74 | */
75 | public void setUpdateTime(Date updateTime) {
76 | this.updateTime = updateTime;
77 | }
78 | /**
79 | * 获取:更新时间
80 | */
81 | public Date getUpdateTime() {
82 | return updateTime;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/app/src/main/java/com/suke/czx/demo/model/user/UserEntity.java:
--------------------------------------------------------------------------------
1 | package com.suke.czx.demo.model.user;
2 |
3 | import java.io.Serializable;
4 | import java.util.Date;
5 |
6 |
7 | /**
8 | * 用户表
9 | *
10 | * @author czx
11 | * @email object_czx@163.com
12 | * @date 2018-01-26 16:33:18
13 | */
14 | public class UserEntity implements Serializable {
15 | private static final long serialVersionUID = 1L;
16 |
17 | //用户id
18 | private Long userId;
19 | //用户名
20 | private String username;
21 | //手机号
22 | private String mobile;
23 | //密码
24 | private String password;
25 | //创建时间
26 | private Date createTime;
27 |
28 | //token
29 | private String token;
30 |
31 | private long expire;
32 |
33 | public String getToken() {
34 | return token;
35 | }
36 |
37 | public void setToken(String token) {
38 | this.token = token;
39 | }
40 |
41 | public long getExpire() {
42 | return expire;
43 | }
44 |
45 | public void setExpire(long expire) {
46 | this.expire = expire;
47 | }
48 |
49 | /**
50 | * 设置:用户id
51 | */
52 | public void setUserId(Long userId) {
53 | this.userId = userId;
54 | }
55 | /**
56 | * 获取:用户id
57 | */
58 | public Long getUserId() {
59 | return userId;
60 | }
61 | /**
62 | * 设置:用户名
63 | */
64 | public void setUsername(String username) {
65 | this.username = username;
66 | }
67 | /**
68 | * 获取:用户名
69 | */
70 | public String getUsername() {
71 | return username;
72 | }
73 | /**
74 | * 设置:手机号
75 | */
76 | public void setMobile(String mobile) {
77 | this.mobile = mobile;
78 | }
79 | /**
80 | * 获取:手机号
81 | */
82 | public String getMobile() {
83 | return mobile;
84 | }
85 | /**
86 | * 设置:密码
87 | */
88 | public void setPassword(String password) {
89 | this.password = password;
90 | }
91 | /**
92 | * 获取:密码
93 | */
94 | public String getPassword() {
95 | return password;
96 | }
97 | /**
98 | * 设置:创建时间
99 | */
100 | public void setCreateTime(Date createTime) {
101 | this.createTime = createTime;
102 | }
103 | /**
104 | * 获取:创建时间
105 | */
106 | public Date getCreateTime() {
107 | return createTime;
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/app/src/main/java/com/suke/czx/demo/net/Api.java:
--------------------------------------------------------------------------------
1 | package com.suke.czx.demo.net;
2 |
3 | import com.suke.czx.demo.AppConstant;
4 |
5 | import cn.droidlover.xdroidmvp.net.XApi;
6 |
7 | /**
8 | * Created by czx on 2018/1/29.
9 | */
10 |
11 | public class Api {
12 |
13 | private static Service service;
14 |
15 | public static Service getService() {
16 | if (service == null) {
17 | synchronized (Api.class) {
18 | if (service == null) {
19 | service = XApi.getInstance().getRetrofit(AppConstant.DEBUG_URL, true).create(Service.class);
20 | }
21 | }
22 | }
23 | return service;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/suke/czx/demo/net/Service.java:
--------------------------------------------------------------------------------
1 | package com.suke.czx.demo.net;
2 |
3 | import com.suke.czx.demo.base.AppBaseResult;
4 | import com.suke.czx.demo.model.user.UserEntity;
5 |
6 | import io.reactivex.Flowable;
7 | import retrofit2.http.Body;
8 | import retrofit2.http.POST;
9 |
10 | /**
11 | * Created by czx on 2018/1/29.
12 | */
13 |
14 | public interface Service {
15 |
16 | @POST("app/login")
17 | Flowable> login(@Body AppBaseResult appBaseResult);
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/suke/czx/demo/present/user/LoginPresent.java:
--------------------------------------------------------------------------------
1 | package com.suke.czx.demo.present.user;
2 |
3 | import com.suke.czx.demo.base.AppBaseResult;
4 | import com.suke.czx.demo.model.user.UserEntity;
5 | import com.suke.czx.demo.net.Api;
6 | import com.suke.czx.demo.ui.LoginActivity;
7 | import java.util.HashMap;
8 | import cn.droidlover.xdroidmvp.mvp.XPresent;
9 | import cn.droidlover.xdroidmvp.net.ApiSubscriber;
10 | import cn.droidlover.xdroidmvp.net.NetError;
11 | import cn.droidlover.xdroidmvp.net.XApi;
12 |
13 | /**
14 | * Created by czx on 2018/1/12.
15 | */
16 |
17 | public class LoginPresent extends XPresent {
18 |
19 | public void login(HashMap hashMap){
20 | AppBaseResult appBaseResult = new AppBaseResult();
21 | appBaseResult.setEncryptData(hashMap);
22 | Api.getService().login(appBaseResult)
23 | .compose(XApi.>getApiTransformer())
24 | .compose(XApi.>getScheduler())
25 | .subscribe(new ApiSubscriber>() {
26 | @Override
27 | protected void onFail(NetError error) {
28 | getV().showError(error);
29 | }
30 |
31 | @Override
32 | public void onNext(AppBaseResult result) {
33 | if(result.getCode() == AppBaseResult.SUCCESS){
34 | getV().showSuccess(result.getData());
35 | }else{
36 | getV().showAlert(result.getMessage());
37 | }
38 | }
39 | });
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/com/suke/czx/demo/utils/PageUtils.java:
--------------------------------------------------------------------------------
1 | package com.suke.czx.demo.utils;
2 |
3 | import java.io.Serializable;
4 | import java.util.List;
5 |
6 | /**
7 | * 分页工具类
8 | *
9 | * @author czx
10 | * @email object_czx@163.com
11 | * @date 2016年11月4日 下午12:59:00
12 | */
13 | public class PageUtils implements Serializable {
14 | private static final long serialVersionUID = 1L;
15 | //总记录数
16 | private int totalCount;
17 | //每页记录数
18 | private int pageSize;
19 | //总页数
20 | private int totalPage;
21 | //当前页数
22 | private int currPage;
23 | //列表数据
24 | private List list;
25 |
26 | /**
27 | * 分页
28 | * @param list 列表数据
29 | * @param totalCount 总记录数
30 | * @param pageSize 每页记录数
31 | * @param currPage 当前页数
32 | */
33 | public PageUtils(List list, int totalCount, int pageSize, int currPage) {
34 | this.list = list;
35 | this.totalCount = totalCount;
36 | this.pageSize = pageSize;
37 | this.currPage = currPage;
38 | this.totalPage = (int)Math.ceil((double)totalCount/pageSize);
39 | }
40 |
41 | public int getTotalCount() {
42 | return totalCount;
43 | }
44 |
45 | public void setTotalCount(int totalCount) {
46 | this.totalCount = totalCount;
47 | }
48 |
49 | public int getPageSize() {
50 | return pageSize;
51 | }
52 |
53 | public void setPageSize(int pageSize) {
54 | this.pageSize = pageSize;
55 | }
56 |
57 | public int getTotalPage() {
58 | return totalPage;
59 | }
60 |
61 | public void setTotalPage(int totalPage) {
62 | this.totalPage = totalPage;
63 | }
64 |
65 | public int getCurrPage() {
66 | return currPage;
67 | }
68 |
69 | public void setCurrPage(int currPage) {
70 | this.currPage = currPage;
71 | }
72 |
73 | public List getList() {
74 | return list;
75 | }
76 |
77 | public void setList(List list) {
78 | this.list = list;
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/app/src/main/java/com/suke/czx/demo/widget/AlertView.java:
--------------------------------------------------------------------------------
1 | package com.suke.czx.demo.widget;
2 |
3 | import android.app.Activity;
4 |
5 | import com.suke.czx.demo.R;
6 | import com.tapadoo.alerter.Alerter;
7 |
8 | /**
9 | * Created by czx on 2018/1/29.
10 | */
11 |
12 | public class AlertView {
13 |
14 | public static void showTip(Activity activity, String msg){
15 | Alerter.create(activity)
16 | //.setTitle("系统提示")
17 | .setText(msg)
18 | .setIcon(R.drawable.alerter_ic_notifications)
19 | .setBackgroundColorRes(R.color.colorPrimary) // or setBackgroundColorInt(Color.CYAN)
20 | .show();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/suke/czx/demo/widget/DialogLoading.java:
--------------------------------------------------------------------------------
1 | package com.suke.czx.demo.widget;
2 |
3 | import android.app.Dialog;
4 | import android.content.Context;
5 | import android.os.Bundle;
6 | import android.view.Gravity;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.Window;
10 | import android.widget.TextView;
11 |
12 | import com.suke.czx.demo.R;
13 |
14 |
15 | /**
16 | * Created by czx on 2017/4/10.
17 | */
18 |
19 | public class DialogLoading extends Dialog{
20 |
21 | private Context context;
22 | private String text_value;
23 |
24 | public DialogLoading(Context context){
25 | super(context, R.style.record_voice_dialog_loading);
26 | this.context = context;
27 | }
28 |
29 | public DialogLoading(Context context, String text){
30 | super(context, R.style.record_voice_dialog_loading);
31 | this.context = context;
32 | this.text_value = text;
33 | }
34 |
35 | @Override
36 | protected void onCreate(Bundle savedInstanceState) {
37 | super.onCreate(savedInstanceState);
38 | init();
39 | }
40 |
41 | public void init(){
42 | LayoutInflater inflater = LayoutInflater.from(context);
43 | View view = inflater.inflate(R.layout.layout_dialog_loading, null);
44 | setContentView(view);
45 | setCanceledOnTouchOutside(false);
46 |
47 | TextView textView = (TextView) view.findViewById(R.id.text_value);
48 | if(text_value != null){
49 | textView.setText(text_value);
50 | }
51 | Window window = getWindow();
52 | window.setGravity(Gravity.CENTER);
53 | }
54 |
55 | public String getText_value() {
56 | return text_value;
57 | }
58 |
59 | public void setText_value(String text_value) {
60 | this.text_value = text_value;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/java/com/suke/czx/demo/widget/StateView.java:
--------------------------------------------------------------------------------
1 | package com.suke.czx.demo.widget;
2 |
3 | import android.content.Context;
4 | import android.text.TextUtils;
5 | import android.util.AttributeSet;
6 | import android.widget.LinearLayout;
7 | import android.widget.TextView;
8 |
9 | import butterknife.BindView;
10 | import com.suke.czx.demo.R;
11 | import cn.droidlover.xdroidmvp.kit.KnifeKit;
12 |
13 | /**
14 | * Created by wanglei on 2016/12/31.
15 | */
16 |
17 | public class StateView extends LinearLayout {
18 |
19 | @BindView(R.id.tv_msg)
20 | TextView tvMsg;
21 |
22 | public StateView(Context context) {
23 | super(context);
24 | setupView(context);
25 | }
26 |
27 | public StateView(Context context, AttributeSet attrs) {
28 | super(context, attrs);
29 | setupView(context);
30 | }
31 |
32 | public StateView(Context context, AttributeSet attrs, int defStyleAttr) {
33 | super(context, attrs, defStyleAttr);
34 | setupView(context);
35 | }
36 |
37 | private void setupView(Context context) {
38 | inflate(context, R.layout.view_state, this);
39 | KnifeKit.bind(this);
40 | }
41 |
42 | public void setMsg(String msg) {
43 | if (!TextUtils.isEmpty(msg)) {
44 | tvMsg.setText(msg);
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/dialog_alert_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/item_part_touch.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/loading_dialog_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_arrow_white_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_keyboard_arrow_right_green_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_person_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_save_white_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_share_white_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/item_part_touch.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/view_border.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
12 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/view_shadow.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
11 |
12 |
13 |
14 |
15 |
16 | -
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
19 |
20 |
29 |
30 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_dialog_loading.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
23 |
24 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_upkeep_admin_management_popup_window.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
24 |
25 |
33 |
34 |
35 |
36 |
50 |
51 |
59 |
60 |
61 |
62 |
77 |
78 |
86 |
87 |
88 |
89 |
103 |
104 |
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/view_loading.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/view_state.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/view_toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/view_toolbar_defined.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
17 |
18 |
24 |
25 |
32 |
33 |
40 |
41 |
45 |
46 |
47 |
53 |
54 |
62 |
63 |
64 |
72 |
73 |
77 |
78 |
79 |
87 |
88 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_web.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yzcheng90/x-android/f3b87065a4ca2b6dd31463f8302109ea9bc0a6d5/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yzcheng90/x-android/f3b87065a4ca2b6dd31463f8302109ea9bc0a6d5/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/back_btn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yzcheng90/x-android/f3b87065a4ca2b6dd31463f8302109ea9bc0a6d5/app/src/main/res/mipmap-xhdpi/back_btn.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yzcheng90/x-android/f3b87065a4ca2b6dd31463f8302109ea9bc0a6d5/app/src/main/res/mipmap-xhdpi/ic_error.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yzcheng90/x-android/f3b87065a4ca2b6dd31463f8302109ea9bc0a6d5/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/xdroid_logo_128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yzcheng90/x-android/f3b87065a4ca2b6dd31463f8302109ea9bc0a6d5/app/src/main/res/mipmap-xhdpi/xdroid_logo_128.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yzcheng90/x-android/f3b87065a4ca2b6dd31463f8302109ea9bc0a6d5/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yzcheng90/x-android/f3b87065a4ca2b6dd31463f8302109ea9bc0a6d5/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 | #0ba25d
4 | #098049
5 | #ffffff
6 |
7 | #ffffff
8 | #c2c1c1
9 | #e9e9e9
10 | #000000
11 | #666666
12 |
13 | #000000
14 | #87000000
15 | #38000000
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 18sp
4 | 10sp
5 | 16sp
6 | 15sp
7 | 12sp
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | x-android
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | apply from: "conf.gradle"
3 |
4 | buildscript {
5 | repositories {
6 | jcenter()
7 | google()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.0.0'
11 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | flatDir {
21 | dirs 'libs'
22 | }
23 | jcenter()
24 | maven { url "https://jitpack.io" }
25 | mavenCentral()
26 | google()
27 | }
28 | }
29 |
30 | task clean(type: Delete) {
31 | delete rootProject.buildDir
32 | }
33 |
--------------------------------------------------------------------------------
/conf.gradle:
--------------------------------------------------------------------------------
1 | ext {
2 |
3 | android = [
4 | compileSdkVersion: 26,
5 | buildToolsVersion: "26.0.2",
6 |
7 | minSdkVersion : 17,
8 | targetSdkVersion : 25,
9 |
10 | versionCode : 1,
11 | versionName : '1.0.0',
12 |
13 | VSupportSdk : '25.3.1',
14 | VRetrofitSdk : "2.2.0",
15 | VOkhttp : "3.4.2",
16 | VRxlifecycle : "2.0.1"
17 | ]
18 | dependencies = [
19 | "appcompat-v7" : "com.android.support:appcompat-v7:${android["VSupportSdk"]}",
20 | "support-v4" : "com.android.support:support-v4:${android["VSupportSdk"]}",
21 | "design" : "com.android.support:design:${android["VSupportSdk"]}",
22 | "annotations" : "com.android.support:support-annotations:${android["VSupportSdk"]}",
23 | "recyclerview-v7" : "com.android.support:recyclerview-v7:${android["VSupportSdk"]}",
24 |
25 | "butterknife" : "com.jakewharton:butterknife:8.4.0",
26 | "butterknife-apt" : "com.jakewharton:butterknife-compiler:8.4.0",
27 | "eventbus" : "org.greenrobot:eventbus:3.0.0",
28 | "glide" : "com.github.bumptech.glide:glide:3.7.0",
29 | "picasso" : "com.squareup.picasso:picasso:2.5.2",
30 | "xrecyclerview" : "com.github.limedroid:ARecyclerView:v1.1.5",
31 | "avi-loading" : "com.wang.avi:library:1.0.2",
32 |
33 | "gson" : "com.google.code.gson:gson:2.6.2",
34 | "rxandroid" : "io.reactivex.rxjava2:rxandroid:2.0.1",
35 | "rxjava" : "io.reactivex.rxjava2:rxjava:2.0.1",
36 | "retrofit" : "com.squareup.retrofit2:retrofit:${android["VRetrofitSdk"]}",
37 | "retrofit-converter-gson" : "com.squareup.retrofit2:converter-gson:${android["VRetrofitSdk"]}",
38 | "retrofit-adapter-rxjava" : "com.squareup.retrofit2:adapter-rxjava2:${android["VRetrofitSdk"]}",
39 | "okhttp3-logging-interceptor": "com.squareup.okhttp3:logging-interceptor:${android["VOkhttp"]}",
40 | "okhttp3" : "com.squareup.okhttp3:okhttp:${android["VOkhttp"]}",
41 | "rxlifecycle" : "com.trello.rxlifecycle2:rxlifecycle:${android["VRxlifecycle"]}",
42 | "rxlifecycle-android" : "com.trello.rxlifecycle2:rxlifecycle-android:${android["VRxlifecycle"]}",
43 | "rxlifecycle-components" : "com.trello.rxlifecycle2:rxlifecycle-components:${android["VRxlifecycle"]}",
44 | "rxpermissions" : "com.tbruyelle.rxpermissions2:rxpermissions:0.9.3@aar",
45 |
46 | "canary-debug" : "com.squareup.leakcanary:leakcanary-android:1.4-beta2",
47 | "canary-release" : "com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2",
48 | ]
49 |
50 | }
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yzcheng90/x-android/f3b87065a4ca2b6dd31463f8302109ea9bc0a6d5/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
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.1-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 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | #Fri Jan 26 17:36:20 CST 2018
11 | ndk.dir=E\:\\soft\\sdk\\ndk-bundle
12 | sdk.dir=E\:\\soft\\sdk
13 |
--------------------------------------------------------------------------------
/mvp/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 |
4 | group = 'com.github.limedroid'
5 |
6 | android {
7 | compileSdkVersion rootProject.ext.android.compileSdkVersion
8 | buildToolsVersion rootProject.ext.android.buildToolsVersion
9 |
10 | defaultConfig {
11 | minSdkVersion rootProject.ext.android.minSdkVersion
12 | targetSdkVersion rootProject.ext.android.targetSdkVersion
13 | versionCode rootProject.ext.android.versionCode
14 | versionName rootProject.ext.android.versionName
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | compile fileTree(dir: 'libs', include: ['*.jar'])
26 | compile rootProject.ext.dependencies["appcompat-v7"]
27 | compile rootProject.ext.dependencies["support-v4"]
28 | compile rootProject.ext.dependencies["design"]
29 | compile rootProject.ext.dependencies["annotations"]
30 | compile rootProject.ext.dependencies["recyclerview-v7"]
31 |
32 | compile rootProject.ext.dependencies["xrecyclerview"]
33 | compile rootProject.ext.dependencies["butterknife"]
34 | compile rootProject.ext.dependencies["glide"]
35 | compile rootProject.ext.dependencies["eventbus"]
36 |
37 | compile rootProject.ext.dependencies["gson"]
38 | compile rootProject.ext.dependencies["rxandroid"]
39 | compile rootProject.ext.dependencies["rxjava"]
40 | compile rootProject.ext.dependencies["retrofit"]
41 | compile rootProject.ext.dependencies["retrofit-converter-gson"]
42 | compile rootProject.ext.dependencies["retrofit-adapter-rxjava"]
43 | compile rootProject.ext.dependencies["okhttp3"]
44 |
45 | compile rootProject.ext.dependencies["rxlifecycle"]
46 | compile rootProject.ext.dependencies["rxlifecycle-android"]
47 | compile rootProject.ext.dependencies["rxlifecycle-components"]
48 | compile rootProject.ext.dependencies["rxpermissions"]
49 | }
50 |
51 | tasks.withType(JavaCompile) {
52 | options.encoding = "UTF-8"
53 | }
54 |
55 | task sourcesJar(type: Jar) {
56 | from android.sourceSets.main.java.srcDirs
57 | classifier = 'sources'
58 | }
59 |
60 | artifacts {
61 | archives sourcesJar
62 | }
63 |
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-ARecyclerView.pro:
--------------------------------------------------------------------------------
1 | ##ARecyclerView:v1.1.5
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-avi-loading.pro:
--------------------------------------------------------------------------------
1 | #com.wang.avi:library:1.0.2
2 |
3 | -keep class com.wang.avi.** { *; }
4 | -keep class com.wang.avi.indicators.** { *; }
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-butterknife.pro:
--------------------------------------------------------------------------------
1 | #butterknife 8.4.0
2 | -keep class butterknife.** { *; }
3 | -dontwarn butterknife.internal.**
4 | -keep class **$$ViewBinder { *; }
5 |
6 | -keepclasseswithmembernames class * {
7 | @butterknife.* ;
8 | }
9 |
10 | -keepclasseswithmembernames class * {
11 | @butterknife.* ;
12 | }
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-canary-debug.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yzcheng90/x-android/f3b87065a4ca2b6dd31463f8302109ea9bc0a6d5/mvp/proguard-pro/proguard-canary-debug.pro
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-canary-release.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yzcheng90/x-android/f3b87065a4ca2b6dd31463f8302109ea9bc0a6d5/mvp/proguard-pro/proguard-canary-release.pro
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-constraint-layout.pro:
--------------------------------------------------------------------------------
1 | #constraint-layout:1.0.2
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-design.pro:
--------------------------------------------------------------------------------
1 |
2 | -dontwarn android.support.design.**
3 | -keep class android.support.design.** { *; }
4 | -keep interface android.support.design.** { *; }
5 |
6 |
7 | -dontwarn android.support.design.internal.**
8 | -keep class android.support.design.internal.** { *; }
9 | -keep interface android.support.design.internal.** { *; }
10 |
11 |
12 | -dontwarn android.support.design.widget.**
13 | -keep class android.support.design.widget.** { *; }
14 | -keep interface android.support.design.widget.** { *; }
15 |
16 |
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-eventbus-3.pro:
--------------------------------------------------------------------------------
1 | ## EventBus3 specific rules ##
2 | # http://greenrobot.org/eventbus/documentation/proguard/
3 |
4 | -keepattributes *Annotation*
5 | -keepclassmembers class ** {
6 | @org.greenrobot.eventbus.Subscribe ;
7 | }
8 | -keep enum org.greenrobot.eventbus.ThreadMode { *; }
9 |
10 | # Only required if you use AsyncExecutor
11 | -keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
12 | (java.lang.Throwable);
13 | }
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-eventbus.pro:
--------------------------------------------------------------------------------
1 | #eventbus:3.0.0
2 | ## EventBus3 specific rules ##
3 | # http://greenrobot.org/eventbus/documentation/proguard/
4 |
5 | -keepattributes *Annotation*
6 | -keepclassmembers class ** {
7 | @org.greenrobot.eventbus.Subscribe ;
8 | }
9 | -keep enum org.greenrobot.eventbus.ThreadMode { *; }
10 |
11 | # Only required if you use AsyncExecutor
12 | -keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
13 | (java.lang.Throwable);
14 | }
15 |
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-glide.pro:
--------------------------------------------------------------------------------
1 | # Glide3.7 specific rules #
2 | # https://github.com/bumptech/glide/wiki/Configuration#keeping-a-glidemodule
3 |
4 |
5 | -keep public class * implements com.bumptech.glide.module.GlideModule
6 | -keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
7 | **[] $VALUES;
8 | public *;
9 | }
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-google-gson.pro:
--------------------------------------------------------------------------------
1 | ##com.google.code.gson:gson:2.6.2
2 |
3 | ## GSON 2.6.2 specific rules ##
4 |
5 | # Gson uses generic type information stored in a class file when working with fields. Proguard
6 | # removes such information by default, so configure it to keep all of it.
7 | -keepattributes Signature
8 |
9 | # For using GSON @Expose annotation
10 | -keepattributes *Annotation*
11 |
12 | -keepattributes EnclosingMethod
13 |
14 | # Gson specific classes
15 | -keep class sun.misc.Unsafe { *; }
16 | -keep class com.google.gson.stream.** { *; }
17 |
18 |
19 | # Application classes that will be serialized/deserialized over Gson
20 | #-keep class com.google.gson.examples.android.model.** { *; }
21 | #这是google官方的proguard的文档,请注意倒数第二行,class 后方到**签名的
22 | #这一段包名应该是你所有的java bean 定义的目录(所以自己在写代码时,应该把java bean 单独放在一个包中)
23 |
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-okhttp3-logging-interceptor.pro:
--------------------------------------------------------------------------------
1 | #constraint-layout:1.0.2
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-okhttp3.pro:
--------------------------------------------------------------------------------
1 | #com.squareup.okhttp3:okhttp V3.4.2
2 |
3 | -keepattributes Signature
4 | -keepattributes *Annotation*
5 | -keep class okhttp3.** { *; }
6 | -keep interface okhttp3.** { *; }
7 | -dontwarn okhttp3.**
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-picasso.pro:
--------------------------------------------------------------------------------
1 | ##picasso 2.5.2
2 | ## Square Picasso specific rules ##
3 | ## https://square.github.io/picasso/ ##
4 |
5 | -dontwarn com.squareup.okhttp.**
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-proguard-design.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yzcheng90/x-android/f3b87065a4ca2b6dd31463f8302109ea9bc0a6d5/mvp/proguard-pro/proguard-proguard-design.pro
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-recyclerview-v7.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yzcheng90/x-android/f3b87065a4ca2b6dd31463f8302109ea9bc0a6d5/mvp/proguard-pro/proguard-recyclerview-v7.pro
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-retrofit-adapter-rxjava.pro:
--------------------------------------------------------------------------------
1 | #retrofit2.adapter.rxjava
2 |
3 | -keep class retrofit2.adapter.rxjava.** { *; }
4 | -keep interface retrofit2.adapter.rxjava.** { *; }
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-retrofit-converter-gson.pro:
--------------------------------------------------------------------------------
1 | #retrofit-converters-gson
2 | -keep class retrofit2.converter.gson.** { *; }
3 | -keep interface retrofit2.converter.gson.** { *; }
4 |
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-retrofit.pro:
--------------------------------------------------------------------------------
1 | # Retrofit 2.X
2 | ## https://square.github.io/retrofit/ ##
3 |
4 | -dontwarn retrofit2.**
5 | -keep class retrofit2.** { *; }
6 | -keepattributes Signature
7 | -keepattributes Exceptions
8 |
9 | # Platform used when running on Java 8 VMs. Will not be used at runtime.
10 | -dontwarn retrofit2.Platform$Java8
11 |
12 | -keepclasseswithmembers class * {
13 | @retrofit2.http.* ;
14 | }
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-rxandroid.pro:
--------------------------------------------------------------------------------
1 | #io.reactivex:rxandroid:1.2.1
2 |
3 | -keep class rx.android.** { *; }
4 | -keep interface rx.android.** { *; }
5 |
6 | -keep class rx.android.plugins.** { *; }
7 | -keep interface rx.android.plugins.** { *; }
8 |
9 | -keep class rx.android.schedulers.** { *; }
10 | -keep interface rx.android.schedulers.** { *; }
11 |
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-rxjava.pro:
--------------------------------------------------------------------------------
1 | #io.reactivex:rxjava:1.1.6
2 |
3 | -dontwarn sun.misc.**
4 |
5 | -keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
6 | long producerIndex;
7 | long consumerIndex;
8 | }
9 |
10 | -keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
11 | rx.internal.util.atomic.LinkedQueueNode producerNode;
12 | }
13 |
14 | -keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef {
15 | rx.internal.util.atomic.LinkedQueueNode consumerNode;
16 | }
17 |
18 | -dontnote rx.internal.util.PlatformDependent
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-rxlifecycle-android.pro:
--------------------------------------------------------------------------------
1 | #com.trello:rxlifecycle
2 |
3 |
4 | -keep class com.trello.rxlifecycle.android.** { *; }
5 | -keep interface com.trello.rxlifecycle.android.** { *; }
6 |
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-rxlifecycle-components.pro:
--------------------------------------------------------------------------------
1 | -keep class com.trello.rxlifecycle.components.** { *; }
2 | -keep interface com.trello.rxlifecycle.components.** { *; }
3 |
4 |
5 | -keep class com.trello.rxlifecycle.components.support.** { *; }
6 | -keep interface com.trello.rxlifecycle.components.support.** { *; }
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-rxlifecycle.pro:
--------------------------------------------------------------------------------
1 | #com.trello:rxlifecycle
2 |
3 |
4 | -keep class com.trello.rxlifecycle.** { *; }
5 | -keep interface com.trello.rxlifecycle.** { *; }
6 |
7 |
8 | -keep class com.trello.rxlifecycle.internal.** { *; }
9 | -keep interface com.trello.rxlifecycle.internal.** { *; }
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-rxpermissions.pro:
--------------------------------------------------------------------------------
1 | #rxpermissions com.tbruyelle.rxpermissions:rxpermissions:0.9.1
2 |
3 | -keep class com.tbruyelle.rxpermissions.** { *; }
4 | -keep interface com.tbruyelle.rxpermissions.** { *; }
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-self.pro:
--------------------------------------------------------------------------------
1 | # ------------------------------- 自定义区 -------------------------------
2 |
3 |
4 | -keepattributes Signature
5 | -keepattributes *Annotation*
6 | -keep class cn.droidlover.xdroidmvp.** { *; }
7 | -keep interface cn.droidlover.xdroidmvp.** { *; }
8 | -dontwarn cn.droidlover.xdroidmvp.**
9 |
10 | # ------------------------------- 自定义区 end -------------------------------
11 |
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-support-v4.pro:
--------------------------------------------------------------------------------
1 | #support.v4
2 | -dontwarn android.support.v4.**
3 | -dontwarn **CompatHoneycomb
4 | -dontwarn **CompatHoneycombMR2
5 | -dontwarn **CompatCreatorHoneycombMR2
6 | -keep interface android.support.v4.app.** { *; }
7 | -keep class android.support.v4.** { *; }
8 | -keep public class * extends android.support.v4.**
9 | -keep public class * extends android.app.Fragment
10 |
11 |
--------------------------------------------------------------------------------
/mvp/proguard-pro/proguard-support-v7-appcompat.pro:
--------------------------------------------------------------------------------
1 |
2 | -keep public class android.support.v7.widget.** { *; }
3 | -keep public class android.support.v7.internal.widget.** { *; }
4 | -keep public class android.support.v7.internal.view.menu.** { *; }
5 |
6 | -keep public class * extends android.support.v4.view.ActionProvider {
7 | public (android.content.Context);
8 | }
9 |
--------------------------------------------------------------------------------
/mvp/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Proguard
2 |
3 | -basedirectory proguard-pro
4 |
5 | -include proguard-normal.pro
6 |
7 | -include proguard-self.pro
8 |
9 | -include proguard-ARecyclerView.pro
10 |
11 | -include proguard-avi-loading.pro
12 |
13 | -include proguard-butterknife.pro
14 |
15 | -include proguard-canary-debug.pro
16 |
17 | -include proguard-canary-release.pro
18 |
19 | -include proguard-constraint-layout.pro
20 |
21 | -include proguard-design.pro
22 |
23 | -include proguard-eventbus-3.pro
24 |
25 | -include proguard-eventbus.pro
26 |
27 | -include proguard-glide.pro
28 |
29 | -include proguard-google-gson.pro
30 |
31 | -include proguard-okhttp3-logging-interceptor.pro
32 |
33 | -include proguard-okhttp3.pro
34 |
35 | -include proguard-picasso.pro
36 |
37 | -include proguard-proguard-design.pro
38 |
39 | -include proguard-recyclerview-v7.pro
40 |
41 | -include proguard-retrofit-adapter-rxjava.pro
42 |
43 | -include proguard-retrofit-converter-gson.pro
44 |
45 | -include proguard-retrofit.pro
46 |
47 | -include proguard-rxandroid.pro
48 |
49 | -include proguard-rxjava.pro
50 |
51 | -include proguard-rxlifecycle-android.pro
52 |
53 | -include proguard-rxlifecycle-components.pro
54 |
55 | -include proguard-rxlifecycle.pro
56 |
57 | -include proguard-rxpermissions.pro
58 |
59 | -include proguard-support-v4.pro
60 |
61 | -include proguard-support-v7-appcompat.pro
62 |
63 |
64 |
--------------------------------------------------------------------------------
/mvp/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/mvp/src/main/java/cn/droidlover/xdroidmvp/XDroidConf.java:
--------------------------------------------------------------------------------
1 | package cn.droidlover.xdroidmvp;
2 |
3 | import cn.droidlover.xdroidmvp.imageloader.ILoader;
4 | import cn.droidlover.xdroidmvp.kit.Kits;
5 | import cn.droidlover.xdroidmvp.router.Router;
6 |
7 | /**
8 | * Created by wanglei on 2016/12/4.
9 | */
10 |
11 | public class XDroidConf {
12 | // #log
13 | public static boolean LOG = true;
14 | public static String LOG_TAG = "XDroid";
15 |
16 | // #cache
17 | public static String CACHE_SP_NAME = "config";
18 | public static String CACHE_DISK_DIR = "cache";
19 |
20 | // #router
21 | public static int ROUTER_ANIM_ENTER = Router.RES_NONE;
22 | public static int ROUTER_ANIM_EXIT = Router.RES_NONE;
23 |
24 | // #imageloader
25 | public static int IL_LOADING_RES = ILoader.Options.RES_NONE;
26 | public static int IL_ERROR_RES = ILoader.Options.RES_NONE;
27 |
28 | // #dev model
29 | public static boolean DEV = true;
30 |
31 | /**
32 | * config log
33 | *
34 | * @param log
35 | * @param logTag
36 | */
37 | public static void configLog(boolean log, String logTag) {
38 | LOG = log;
39 | if (!Kits.Empty.check(logTag)) {
40 | LOG_TAG = logTag;
41 | }
42 | }
43 |
44 | /**
45 | * conf cache
46 | *
47 | * @param spName
48 | * @param diskDir
49 | */
50 | public static void configCache(String spName, String diskDir) {
51 | if (!Kits.Empty.check(spName)) {
52 | CACHE_SP_NAME = spName;
53 | }
54 | if (!Kits.Empty.check(diskDir)) {
55 | CACHE_DISK_DIR = diskDir;
56 | }
57 | }
58 |
59 | /**
60 | * config dev
61 | *
62 | * @param isDev
63 | */
64 | public static void devMode(boolean isDev) {
65 | DEV = isDev;
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/mvp/src/main/java/cn/droidlover/xdroidmvp/base/ListItemCallback.java:
--------------------------------------------------------------------------------
1 | package cn.droidlover.xdroidmvp.base;
2 |
3 | /**
4 | * Created by wanglei on 2016/12/1.
5 | */
6 |
7 | public abstract class ListItemCallback {
8 |
9 | public void onItemClick(int position, T model, int tag) {}
10 |
11 | public void onItemLongClick(int position, T model, int tag) {}
12 | }
13 |
--------------------------------------------------------------------------------
/mvp/src/main/java/cn/droidlover/xdroidmvp/base/SimpleListAdapter.java:
--------------------------------------------------------------------------------
1 | package cn.droidlover.xdroidmvp.base;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * Created by wanglei on 2016/12/1.
11 | */
12 |
13 | public abstract class SimpleListAdapter extends XListAdapter {
14 |
15 | public SimpleListAdapter(Context context) {
16 | super(context);
17 | }
18 |
19 | public SimpleListAdapter(Context context, ListItemCallback callback) {
20 | super(context, callback);
21 | }
22 |
23 | public SimpleListAdapter(Context context, List data) {
24 | super(context, data);
25 | }
26 |
27 | @Override
28 | public View getView(int position, View convertView, ViewGroup parent) {
29 | H holder = null;
30 | T item = data.get(position);
31 |
32 | if (convertView == null) {
33 | convertView = View.inflate(context, getLayoutId(), null);
34 | holder = newViewHolder(convertView);
35 |
36 | convertView.setTag(holder);
37 | } else {
38 | holder = (H) convertView.getTag();
39 | }
40 |
41 | convert(holder, item, position);
42 |
43 | return convertView;
44 | }
45 |
46 | protected abstract H newViewHolder(View convertView);
47 |
48 | protected abstract int getLayoutId();
49 |
50 | protected abstract void convert(H holder, T item, int position);
51 | }
52 |
--------------------------------------------------------------------------------
/mvp/src/main/java/cn/droidlover/xdroidmvp/base/SimpleRecAdapter.java:
--------------------------------------------------------------------------------
1 | package cn.droidlover.xdroidmvp.base;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | import cn.droidlover.xrecyclerview.RecyclerAdapter;
10 |
11 | /**
12 | * Created by wanglei on 2016/11/29.
13 | */
14 |
15 | public abstract class SimpleRecAdapter extends RecyclerAdapter {
16 |
17 | public SimpleRecAdapter(Context context) {
18 | super(context);
19 | }
20 |
21 | @Override
22 | public F onCreateViewHolder(ViewGroup parent, int viewType) {
23 | View view = LayoutInflater.from(parent.getContext()).inflate(getLayoutId(), parent, false);
24 | return newViewHolder(view);
25 | }
26 |
27 | public abstract F newViewHolder(View itemView);
28 |
29 | public abstract int getLayoutId();
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/mvp/src/main/java/cn/droidlover/xdroidmvp/base/XFragmentAdapter.java:
--------------------------------------------------------------------------------
1 | package cn.droidlover.xdroidmvp.base;
2 |
3 | import android.support.v4.app.Fragment;
4 | import android.support.v4.app.FragmentManager;
5 | import android.support.v4.app.FragmentPagerAdapter;
6 |
7 | import java.util.ArrayList;
8 | import java.util.List;
9 |
10 | /**
11 | * Created by wanglei on 2016/12/10.
12 | */
13 |
14 | public class XFragmentAdapter extends FragmentPagerAdapter {
15 | private List fragmentList = new ArrayList<>();
16 | private String[] titles;
17 |
18 | public XFragmentAdapter(FragmentManager fm, List fragmentList, String[] titles) {
19 | super(fm);
20 | this.fragmentList.clear();
21 | this.fragmentList.addAll(fragmentList);
22 | this.titles = titles;
23 | }
24 |
25 | @Override
26 | public CharSequence getPageTitle(int position) {
27 | if (titles != null && titles.length > position) {
28 | return titles[position];
29 | }
30 | return "";
31 | }
32 |
33 | @Override
34 | public Fragment getItem(int position) {
35 | return fragmentList.get(position);
36 | }
37 |
38 | @Override
39 | public int getCount() {
40 | return fragmentList.size();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/mvp/src/main/java/cn/droidlover/xdroidmvp/base/XListAdapter.java:
--------------------------------------------------------------------------------
1 | package cn.droidlover.xdroidmvp.base;
2 |
3 | import android.content.Context;
4 | import android.graphics.drawable.Drawable;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.BaseAdapter;
8 |
9 | import java.util.ArrayList;
10 | import java.util.Arrays;
11 | import java.util.List;
12 |
13 | /**
14 | * Created by wanglei on 2016/12/1.
15 | */
16 |
17 | public abstract class XListAdapter extends BaseAdapter {
18 | protected List data = new ArrayList();
19 | private ListItemCallback callback;
20 | protected Context context;
21 |
22 | public XListAdapter(Context context) {
23 | this.context = context;
24 | }
25 |
26 | public XListAdapter(Context context, ListItemCallback callback) {
27 | this(context);
28 | this.callback = callback;
29 | }
30 |
31 | public XListAdapter(Context context, List data) {
32 | this.context = context;
33 | this.data.clear();
34 | this.data.addAll(data);
35 | notifyDataSetChanged();
36 | }
37 |
38 | public void setData(List data) {
39 | if (data != null) {
40 | this.data.clear();
41 | this.data.addAll(data);
42 | } else {
43 | this.data.clear();
44 | }
45 | notifyDataSetChanged();
46 | }
47 |
48 |
49 | public void setData(T[] data) {
50 | if (data != null && data.length > 0) {
51 | setData(Arrays.asList(data));
52 | }
53 | }
54 |
55 |
56 | public void addData(List data) {
57 | if (data != null && data.size() > 0) {
58 | if (this.data == null) {
59 | this.data = new ArrayList();
60 | }
61 | this.data.addAll(data);
62 | notifyDataSetChanged();
63 | }
64 | }
65 |
66 |
67 | public void addData(T[] data) {
68 | addData(Arrays.asList(data));
69 | }
70 |
71 | public void removeElement(T element) {
72 | if (data.contains(element)) {
73 | data.remove(element);
74 | notifyDataSetChanged();
75 | }
76 | }
77 |
78 | public void removeElement(int position) {
79 | if (data != null && data.size() > position) {
80 | data.remove(position);
81 | notifyDataSetChanged();
82 | }
83 | }
84 |
85 | public void removeElements(List elements) {
86 | if (data != null && elements != null && elements.size() > 0
87 | && data.size() >= elements.size()) {
88 |
89 | for (T element : elements) {
90 | if (data.contains(element)) {
91 | data.remove(element);
92 | }
93 | }
94 |
95 | notifyDataSetChanged();
96 | }
97 | }
98 |
99 | public void removeElements(T[] elements) {
100 | if (elements != null && elements.length > 0) {
101 | removeElements(Arrays.asList(elements));
102 | }
103 | }
104 |
105 | public void updateElement(T element, int position) {
106 | if (position >= 0 && data.size() > position) {
107 | data.remove(position);
108 | data.add(position, element);
109 | notifyDataSetChanged();
110 | }
111 | }
112 |
113 | public void addElement(T element) {
114 | if (element != null) {
115 | if (this.data == null) {
116 | this.data = new ArrayList();
117 | }
118 | data.add(element);
119 | notifyDataSetChanged();
120 | }
121 | }
122 |
123 | public void clearData() {
124 | if (this.data != null) {
125 | this.data.clear();
126 | notifyDataSetChanged();
127 | }
128 | }
129 |
130 | protected void visible(boolean flag, View view) {
131 | if (flag)
132 | view.setVisibility(View.VISIBLE);
133 | }
134 |
135 |
136 | protected void gone(boolean flag, View view) {
137 | if (flag)
138 | view.setVisibility(View.GONE);
139 | }
140 |
141 | protected void inVisible(View view) {
142 | view.setVisibility(View.INVISIBLE);
143 | }
144 |
145 |
146 | protected Drawable getDrawable(int resId) {
147 | return context.getResources().getDrawable(resId);
148 | }
149 |
150 |
151 | protected String getString(int resId) {
152 | return context.getResources().getString(resId);
153 | }
154 |
155 |
156 | protected int getColor(int resId) {
157 | return context.getResources().getColor(resId);
158 | }
159 |
160 |
161 | public List getDataSource() {
162 | return data;
163 | }
164 |
165 | public void setCallback(ListItemCallback callback) {
166 | this.callback = callback;
167 | }
168 |
169 | public ListItemCallback getCallback() {
170 | return callback;
171 | }
172 |
173 |
174 | public int getSize() {
175 | return data == null ? 0 : data.size();
176 | }
177 |
178 | @Override
179 | public int getCount() {
180 | return data == null || data.isEmpty() ? 0 : data.size();
181 | }
182 |
183 | @Override
184 | public Object getItem(int position) {
185 | return data != null ? data.get(position) : null;
186 | }
187 |
188 | @Override
189 | public long getItemId(int position) {
190 | return position;
191 | }
192 |
193 | @Override
194 | public abstract View getView(int position, View convertView,
195 | ViewGroup parent);
196 |
197 |
198 | }
199 |
--------------------------------------------------------------------------------
/mvp/src/main/java/cn/droidlover/xdroidmvp/cache/DiskCache.java:
--------------------------------------------------------------------------------
1 | package cn.droidlover.xdroidmvp.cache;
2 |
3 | import android.content.Context;
4 | import android.os.Environment;
5 | import android.text.TextUtils;
6 |
7 | import java.io.File;
8 | import java.io.IOException;
9 | import java.util.Calendar;
10 | import java.util.regex.Matcher;
11 | import java.util.regex.Pattern;
12 |
13 | import cn.droidlover.xdroidmvp.XDroidConf;
14 | import cn.droidlover.xdroidmvp.kit.Codec;
15 | import cn.droidlover.xdroidmvp.kit.Kits;
16 |
17 | /**
18 | * Created by wanglei on 2016/11/28.
19 | */
20 |
21 | public class DiskCache implements ICache {
22 | private DiskLruCache cache;
23 |
24 | static String TAG_CACHE = "=====createTime{createTime_v}expireMills{expireMills_v}";
25 | static String REGEX = "=====createTime\\{(\\d{1,})\\}expireMills\\{(-?\\d{1,})\\}";
26 | private Pattern compile;
27 |
28 | public static final long NO_CACHE = -1L;
29 |
30 | private static DiskCache instance;
31 |
32 | private DiskCache(Context context) {
33 | compile = Pattern.compile(REGEX);
34 | try {
35 | File cacheDir = getDiskCacheDir(context, getCacheDir());
36 | if (!cacheDir.exists()) {
37 | cacheDir.mkdirs();
38 | }
39 | cache = DiskLruCache.open(cacheDir, Kits.Package.getVersionCode(context), 1, 10 * 1024 * 1024); //10M
40 | } catch (IOException e) {
41 | e.printStackTrace();
42 | }
43 | }
44 |
45 | public static DiskCache getInstance(Context context) {
46 | if (instance == null) {
47 | synchronized (DiskCache.class) {
48 | if (instance == null) {
49 | instance = new DiskCache(context.getApplicationContext());
50 | }
51 | }
52 | }
53 | return instance;
54 | }
55 |
56 | public void put(String key, String value) {
57 | put(key, value, NO_CACHE);
58 | }
59 |
60 | public void put(String key, String value, long expireMills) {
61 | if (TextUtils.isEmpty(key) || TextUtils.isEmpty(value)) return;
62 |
63 | String name = getMd5Key(key);
64 | try {
65 | if (!TextUtils.isEmpty(get(name))) { //如果存在,先删除
66 | cache.remove(name);
67 | }
68 |
69 | DiskLruCache.Editor editor = cache.edit(name);
70 | StringBuilder content = new StringBuilder(value);
71 | content.append(TAG_CACHE.replace("createTime_v", "" + Calendar.getInstance().getTimeInMillis()).replace("expireMills_v", "" + expireMills));
72 | editor.set(0, content.toString());
73 | editor.commit();
74 | } catch (IOException e) {
75 | e.printStackTrace();
76 | }
77 | }
78 |
79 | @Override
80 | public void put(String key, Object value) {
81 | put(key, value != null ? value.toString() : null, NO_CACHE);
82 | }
83 |
84 |
85 | public String get(String key) {
86 | try {
87 | String md5Key = getMd5Key(key);
88 | DiskLruCache.Snapshot snapshot = cache.get(md5Key);
89 | if (snapshot != null) {
90 | String content = snapshot.getString(0);
91 |
92 | if (!TextUtils.isEmpty(content)) {
93 | Matcher matcher = compile.matcher(content);
94 | long createTime = 0;
95 | long expireMills = 0;
96 | while (matcher.find()) {
97 | createTime = Long.parseLong(matcher.group(1));
98 | expireMills = Long.parseLong(matcher.group(2));
99 | }
100 | int index = content.indexOf("=====createTime");
101 |
102 | if ((createTime + expireMills > Calendar.getInstance().getTimeInMillis())
103 | || expireMills == NO_CACHE) {
104 | return content.substring(0, index);
105 | } else {
106 | //过期
107 | cache.remove(md5Key); //删除
108 | }
109 | }
110 | }
111 |
112 | } catch (Exception e) {
113 | e.printStackTrace();
114 | }
115 | return null;
116 | }
117 |
118 | public void remove(String key) {
119 | try {
120 | cache.remove(getMd5Key(key));
121 | } catch (Exception e) {
122 | e.printStackTrace();
123 | }
124 | }
125 |
126 | public boolean contains(String key) {
127 | try {
128 | DiskLruCache.Snapshot snapshot = cache.get(getMd5Key(key));
129 | return snapshot != null;
130 | } catch (IOException e) {
131 | e.printStackTrace();
132 | }
133 | return false;
134 | }
135 |
136 | public void clear() {
137 | try {
138 | cache.delete();
139 | } catch (IOException e) {
140 | e.printStackTrace();
141 | }
142 | }
143 |
144 | public static String getMd5Key(String key) {
145 | return Codec.MD5.getMessageDigest(key.getBytes());
146 | }
147 |
148 | private static File getDiskCacheDir(Context context, String dirName) {
149 | String cachePath;
150 | if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
151 | || !Environment.isExternalStorageRemovable()) {
152 | cachePath = context.getExternalCacheDir().getPath();
153 | } else {
154 | cachePath = context.getCacheDir().getPath();
155 | }
156 | return new File(cachePath + File.separator + dirName);
157 | }
158 |
159 | private String getCacheDir() {
160 | return XDroidConf.CACHE_DISK_DIR;
161 | }
162 |
163 |
164 | }
165 |
--------------------------------------------------------------------------------
/mvp/src/main/java/cn/droidlover/xdroidmvp/cache/ICache.java:
--------------------------------------------------------------------------------
1 | package cn.droidlover.xdroidmvp.cache;
2 |
3 | /**
4 | * Created by wanglei on 2016/11/27.
5 | */
6 |
7 | public interface ICache {
8 | void put(String key, Object value);
9 |
10 | Object get(String key);
11 |
12 | void remove(String key);
13 |
14 | boolean contains(String key);
15 |
16 | void clear();
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/mvp/src/main/java/cn/droidlover/xdroidmvp/cache/MemoryCache.java:
--------------------------------------------------------------------------------
1 | package cn.droidlover.xdroidmvp.cache;
2 |
3 | import android.support.v4.util.LruCache;
4 | import android.text.TextUtils;
5 |
6 | /**
7 | * Created by wanglei on 2016/11/28.
8 | */
9 |
10 | public class MemoryCache implements ICache {
11 |
12 | private LruCache cache;
13 | private static MemoryCache instance;
14 |
15 | private MemoryCache() {
16 | int maxMemory = (int) Runtime.getRuntime().maxMemory();
17 | int cacheSize = maxMemory / 8;
18 | cache = new LruCache(cacheSize);
19 |
20 | }
21 |
22 | public static MemoryCache getInstance() {
23 | if (instance == null) {
24 | synchronized (MemoryCache.class) {
25 | if (instance == null) {
26 | instance = new MemoryCache();
27 | }
28 | }
29 | }
30 | return instance;
31 | }
32 |
33 |
34 | @Override
35 | public synchronized void put(String key, Object value) {
36 | if (TextUtils.isEmpty(key)) return;
37 |
38 | if (cache.get(key) != null) {
39 | cache.remove(key);
40 | }
41 | cache.put(key, value);
42 | }
43 |
44 | @Override
45 | public Object get(String key) {
46 | return cache.get(key);
47 | }
48 |
49 | public synchronized T get(String key, Class clazz) {
50 | try {
51 | return (T) cache.get(key);
52 | } catch (Exception e) {
53 | e.printStackTrace();
54 | }
55 | return null;
56 | }
57 |
58 | @Override
59 | public void remove(String key) {
60 | if (cache.get(key) != null) {
61 | cache.remove(key);
62 | }
63 | }
64 |
65 | @Override
66 | public boolean contains(String key) {
67 | return cache.get(key) != null;
68 | }
69 |
70 | @Override
71 | public void clear() {
72 | cache.evictAll();
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/mvp/src/main/java/cn/droidlover/xdroidmvp/cache/SharedPref.java:
--------------------------------------------------------------------------------
1 | package cn.droidlover.xdroidmvp.cache;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 |
6 | import cn.droidlover.xdroidmvp.XDroidConf;
7 |
8 | /**
9 | * Created by wanglei on 2016/11/27.
10 | */
11 |
12 | public class SharedPref implements ICache {
13 |
14 | private static SharedPreferences sharedPreferences;
15 | private static SharedPreferences.Editor editor;
16 |
17 | static final String SP_NAME = XDroidConf.CACHE_SP_NAME;
18 |
19 | private static SharedPref instance;
20 |
21 | private SharedPref(Context context) {
22 | sharedPreferences = context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
23 | editor = sharedPreferences.edit();
24 | }
25 |
26 | public static SharedPref getInstance(Context context) {
27 | if (instance == null) {
28 | synchronized (SharedPref.class) {
29 | if (instance == null) {
30 | instance = new SharedPref(context.getApplicationContext());
31 | }
32 | }
33 | }
34 | return instance;
35 | }
36 |
37 | @Override
38 | public void remove(String key) {
39 | editor.remove(key);
40 | editor.apply();
41 | }
42 |
43 |
44 | @Override
45 | public boolean contains(String key) {
46 | return sharedPreferences.contains(key);
47 | }
48 |
49 | @Override
50 | public void clear() {
51 | editor.clear().apply();
52 | }
53 |
54 |
55 | public void putInt(String key, int value) {
56 | editor.putInt(key, value);
57 | editor.apply();
58 | }
59 |
60 | public int getInt(String key, int defValue) {
61 | return sharedPreferences.getInt(key, defValue);
62 | }
63 |
64 | public void putLong(String key, Long value) {
65 | editor.putLong(key, value);
66 | editor.apply();
67 | }
68 |
69 | public long getLong(String key, long defValue) {
70 | return sharedPreferences.getLong(key, defValue);
71 | }
72 |
73 |
74 | public void putBoolean(String key, Boolean value) {
75 | editor.putBoolean(key, value);
76 | editor.apply();
77 | }
78 |
79 | public boolean getBoolean(String key, boolean defValue) {
80 | return sharedPreferences.getBoolean(key, defValue);
81 | }
82 |
83 |
84 | public void putString(String key, String value) {
85 | editor.putString(key, value);
86 | editor.apply();
87 | }
88 |
89 | public String getString(String key, String defValue) {
90 | return sharedPreferences.getString(key, defValue);
91 | }
92 |
93 | @Override
94 | public Object get(String key) {
95 | return null;
96 | }
97 |
98 | @Override
99 | public void put(String key, Object value) {
100 |
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/mvp/src/main/java/cn/droidlover/xdroidmvp/event/BusProvider.java:
--------------------------------------------------------------------------------
1 | package cn.droidlover.xdroidmvp.event;
2 |
3 | /**
4 | * Created by wanglei on 2016/12/22.
5 | */
6 |
7 | public class BusProvider {
8 |
9 | private static RxBusImpl bus;
10 |
11 | public static RxBusImpl getBus() {
12 | if (bus == null) {
13 | synchronized (BusProvider.class) {
14 | if (bus == null) {
15 | bus = RxBusImpl.get();
16 | }
17 | }
18 | }
19 | return bus;
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/mvp/src/main/java/cn/droidlover/xdroidmvp/event/IBus.java:
--------------------------------------------------------------------------------
1 | package cn.droidlover.xdroidmvp.event;
2 |
3 | /**
4 | * Created by wanglei on 2016/12/22.
5 | */
6 |
7 | public interface IBus {
8 |
9 | void register(Object object);
10 | void unregister(Object object);
11 | void post(IEvent event);
12 | void postSticky(IEvent event);
13 |
14 |
15 | interface IEvent {
16 | int getTag();
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/mvp/src/main/java/cn/droidlover/xdroidmvp/event/RxBusImpl.java:
--------------------------------------------------------------------------------
1 | package cn.droidlover.xdroidmvp.event;
2 |
3 |
4 | import io.reactivex.Flowable;
5 | import io.reactivex.processors.FlowableProcessor;
6 | import io.reactivex.processors.PublishProcessor;
7 |
8 | /**
9 | * Created by wanglei on 2016/12/22.
10 | */
11 |
12 | public class RxBusImpl implements IBus {
13 |
14 | private FlowableProcessor