From cc56fc7ef8c525b95831cc5a72e73d87b9ba8d35 Mon Sep 17 00:00:00 2001 From: wangzhenfei <179576267@qq.com> Date: Sun, 25 Jun 2017 20:18:16 +0800 Subject: [PATCH 01/47] =?UTF-8?q?=E5=AE=B6=E9=87=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 39fb081..e5a96f6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.iml +.idea .gradle /local.properties /.idea/workspace.xml From b23e6cd1d1a50702f89752ff1600e22bcd46db82 Mon Sep 17 00:00:00 2001 From: wangzhenfei <179576267@qq.com> Date: Wed, 28 Jun 2017 22:56:11 +0800 Subject: [PATCH 02/47] =?UTF-8?q?=E5=AE=B6=E9=87=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/wzf/boardgame/Test.java | 24 ++++ .../wzf/boardgame/constant/UrlService.java | 8 +- .../http/Interceptor/LoggerInterceptor.java | 2 +- .../boardgame/ui/activity/MainActivity.java | 13 +- .../wzf/boardgame/utils/MathUtilAndroid.java | 134 ++++++++++++++++++ 5 files changed, 178 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/com/wzf/boardgame/Test.java create mode 100644 app/src/main/java/com/wzf/boardgame/utils/MathUtilAndroid.java diff --git a/app/src/main/java/com/wzf/boardgame/Test.java b/app/src/main/java/com/wzf/boardgame/Test.java new file mode 100644 index 0000000..cf0a70e --- /dev/null +++ b/app/src/main/java/com/wzf/boardgame/Test.java @@ -0,0 +1,24 @@ +package com.wzf.boardgame; + +import com.wzf.boardgame.function.http.dto.request.RegisterRequestDto; +import com.wzf.boardgame.utils.JsonUtils; +import com.wzf.boardgame.utils.MathUtilAndroid; + +/** + * Created by wzf on 2017/6/28. + */ + +public class Test { + public static void main(String[] args) { + RegisterRequestDto dto = new RegisterRequestDto(); + dto.setUserId("123"); + dto.setNickname("wzf"); + dto.setSmsCode("1234"); + dto.setUserPwd("qqqqqq"); + dto.setUserMobile("18521709590"); + String befer = MathUtilAndroid.encodeAES(JsonUtils.toJson(dto)); + System.out.println(befer); + String after = MathUtilAndroid.decodeAES(befer); + System.out.println(after); + } +} diff --git a/app/src/main/java/com/wzf/boardgame/constant/UrlService.java b/app/src/main/java/com/wzf/boardgame/constant/UrlService.java index a7edf25..8d48f1a 100644 --- a/app/src/main/java/com/wzf/boardgame/constant/UrlService.java +++ b/app/src/main/java/com/wzf/boardgame/constant/UrlService.java @@ -20,7 +20,7 @@ public interface UrlService { boolean DEBUG = true; String BASE_RESOURCE = "http://192.168.2.202:8081/boxingmanager/"; - String BASE_URL = "http://192.168.2.202:8081/boxingmanager/"; + String BASE_URL = "http://106.14.215.117/BRPG/"; UrlService SERVICE = OkHttpUtils.getInstance().getUrlService(UrlService.class); @@ -38,6 +38,12 @@ public interface UrlService { //登录 @GET("test/getLogger") Observable> login(@Query("os") String os); + + //登录 + @POST("user/register") + @FormUrlEncoded + Observable> register(@Field("params") String params) + ; // // //注销 // @POST("logout") diff --git a/app/src/main/java/com/wzf/boardgame/function/http/Interceptor/LoggerInterceptor.java b/app/src/main/java/com/wzf/boardgame/function/http/Interceptor/LoggerInterceptor.java index ec5ef5f..17a2b7d 100644 --- a/app/src/main/java/com/wzf/boardgame/function/http/Interceptor/LoggerInterceptor.java +++ b/app/src/main/java/com/wzf/boardgame/function/http/Interceptor/LoggerInterceptor.java @@ -54,7 +54,7 @@ private void logForRequest(Request request) { paramsBuilder.append("---------------------request log start---------------------" + "\n"); paramsBuilder.append("method : " + request.method() + "\n"); - paramsBuilder.append("url : " + url + "----->>\n"); + paramsBuilder.append("url : " + url + "\n"); if (headers != null && headers.size() > 0) { paramsBuilder.append("===========================headers===============================\n\t\t\t"); paramsBuilder.append(headers.toString().replaceAll("\\n","\n\t\t\t")); diff --git a/app/src/main/java/com/wzf/boardgame/ui/activity/MainActivity.java b/app/src/main/java/com/wzf/boardgame/ui/activity/MainActivity.java index 07a427a..d4bcb1e 100644 --- a/app/src/main/java/com/wzf/boardgame/ui/activity/MainActivity.java +++ b/app/src/main/java/com/wzf/boardgame/ui/activity/MainActivity.java @@ -6,9 +6,12 @@ import com.wzf.boardgame.R; import com.wzf.boardgame.constant.UrlService; import com.wzf.boardgame.function.http.ResponseSubscriber; +import com.wzf.boardgame.function.http.dto.request.RegisterRequestDto; import com.wzf.boardgame.function.map.BaiDuMapManager; import com.wzf.boardgame.ui.base.BaseActivity; import com.wzf.boardgame.utils.AppDeviceInfo; +import com.wzf.boardgame.utils.JsonUtils; +import com.wzf.boardgame.utils.MathUtilAndroid; import butterknife.Bind; import butterknife.ButterKnife; @@ -39,7 +42,15 @@ public void run() { }); } }); - UrlService.SERVICE.login("123123132132") + + RegisterRequestDto dto = new RegisterRequestDto(); + dto.setUserId("123"); + dto.setNickname("wzf"); + dto.setSmsCode("1234"); + dto.setUserPwd("qqqqqq"); + dto.setUserMobile("18521709590"); + String src = MathUtilAndroid.encodeAES(JsonUtils.toJson(dto)); + UrlService.SERVICE.register(src) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(new ResponseSubscriber(this, true) { diff --git a/app/src/main/java/com/wzf/boardgame/utils/MathUtilAndroid.java b/app/src/main/java/com/wzf/boardgame/utils/MathUtilAndroid.java new file mode 100644 index 0000000..32154c2 --- /dev/null +++ b/app/src/main/java/com/wzf/boardgame/utils/MathUtilAndroid.java @@ -0,0 +1,134 @@ +package com.wzf.boardgame.utils; + + +import android.util.Base64; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; + +/** + * 算法工具类 + * + * @author chenlong 2015-12-17 + * + */ +public class MathUtilAndroid { + + /** + * AES加密公钥 + */ + private static final String AES_PUBLIC_KEY = "hdgZGsUpkBdm8Q5bZ4aLqw=="; + + public static final String ENCODING = "UTF-8"; + + /** + * 进行base64编码 + * @param input + * 要编码的数据 + * @return + * @throws Exception + */ + public static byte[] encodeBase64(byte[] input) throws Exception { + return Base64.encode(input, Base64.DEFAULT); +// Class clazz = Class.forName("com.sun.org.apache.xerces.internal.impl.dv.util.Base64"); +// Method mainMethod = clazz.getMethod("encode", byte[].class); +// mainMethod.setAccessible(true); +// Object retObj = mainMethod.invoke(null, new Object[] { input }); +// return (String) retObj; + } + + /** + * 进行base64解码 + * @param input + * 要解码的数据 + * @return + * @throws Exception + */ + public static byte[] decodeBase64(String input) throws Exception{ + return Base64.decode(input, Base64.DEFAULT); +// Class clazz=Class.forName("com.sun.org.apache.xerces.internal.impl.dv.util.Base64"); +// Method mainMethod= clazz.getMethod("decode", String.class); +// mainMethod.setAccessible(true); +// Object retObj=mainMethod.invoke(null, input); +// return (byte[])retObj; + } + + /** + * AES加密 + * @param data + * @return + * @throws Exception + */ + public static String encodeAES(String data){ + String content = null; + try { + byte[] key = decodeBase64(AES_PUBLIC_KEY); + SecretKeySpec secretKey = new SecretKeySpec(key, "AES");//恢复密钥 + Cipher cipher = Cipher.getInstance("AES");//Cipher完成加密或解密工作类 + cipher.init(Cipher.ENCRYPT_MODE, secretKey);//对Cipher初始化,解密模式 + byte[] cipherByte = cipher.doFinal(data.getBytes());//加密data + content = new String(encodeBase64(cipherByte)); + } catch (Exception e) { + e.printStackTrace(); + } + + return content; + } + + /** + * AES解密 + * @param data + * @return + * @throws Exception + */ + public static String decodeAES(String data) { + byte[] cipherByte = new byte[0];//解密data + try { + byte[] key = decodeBase64(AES_PUBLIC_KEY); + + SecretKeySpec secretKey = new SecretKeySpec(key, "AES");//恢复密钥 + Cipher cipher = Cipher.getInstance("AES");//Cipher完成加密或解密工作类 + cipher.init(Cipher.DECRYPT_MODE, secretKey);//对Cipher初始化,解密模式 + cipherByte = cipher.doFinal(decodeBase64(data)); + } catch (Exception e) { + e.printStackTrace(); + } + + return new String(cipherByte); + } + + /** + * md5加密 + * @param plainText + * @return + */ + public static String md5Encryption(String plainText) { + String re_md5 = new String(); + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + md.update(plainText.getBytes()); + byte b[] = md.digest(); + + int i; + + StringBuffer buf = new StringBuffer(""); + for (int offset = 0; offset < b.length; offset++) { + i = b[offset]; + if (i < 0) + i += 256; + if (i < 16) + buf.append("0"); + buf.append(Integer.toHexString(i)); + } + + re_md5 = buf.toString(); + + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + return re_md5; + } + +} From 8b1da6364bb8d4386c6d3ddbba7de0b7b082cf1f Mon Sep 17 00:00:00 2001 From: wangzhenfei <179576267@qq.com> Date: Wed, 28 Jun 2017 22:57:36 +0800 Subject: [PATCH 03/47] =?UTF-8?q?=E5=AE=B6=E9=87=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../http/dto/request/RegisterRequestDto.java | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 app/src/main/java/com/wzf/boardgame/function/http/dto/request/RegisterRequestDto.java diff --git a/app/src/main/java/com/wzf/boardgame/function/http/dto/request/RegisterRequestDto.java b/app/src/main/java/com/wzf/boardgame/function/http/dto/request/RegisterRequestDto.java new file mode 100644 index 0000000..46eebe2 --- /dev/null +++ b/app/src/main/java/com/wzf/boardgame/function/http/dto/request/RegisterRequestDto.java @@ -0,0 +1,62 @@ +package com.wzf.boardgame.function.http.dto.request; + +/** + * Created by wzf on 2017/6/28. + */ + +public class RegisterRequestDto { + + /** + * nickname : 昵称 + * smsCode : 5871 + * userId : 1000145 + * userPwd : 123456 + * userMobile : 13814591112 + */ + + private String nickname; + private String smsCode; + private String userId; + private String userPwd; + private String userMobile; + + public String getNickname() { + return nickname; + } + + public void setNickname(String nickname) { + this.nickname = nickname; + } + + public String getSmsCode() { + return smsCode; + } + + public void setSmsCode(String smsCode) { + this.smsCode = smsCode; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getUserPwd() { + return userPwd; + } + + public void setUserPwd(String userPwd) { + this.userPwd = userPwd; + } + + public String getUserMobile() { + return userMobile; + } + + public void setUserMobile(String userMobile) { + this.userMobile = userMobile; + } +} From 369401eb867c98f0ffda3441f543cc19e84cbaec Mon Sep 17 00:00:00 2001 From: wangzhenfei <179576267@qq.com> Date: Thu, 29 Jun 2017 10:46:20 +0800 Subject: [PATCH 04/47] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Interceptor/DecodeParamsInterceptor.java | 36 +++++++++++++++++++ .../boardgame/function/http/OkHttpUtils.java | 2 ++ .../function/http/ResponseSubscriber.java | 9 ++--- .../http/dto/request/BaseRequestDto.java | 20 +++++++++++ .../http/dto/request/RegisterRequestDto.java | 7 +++- .../http/dto/response/BaseResponse.java | 36 +++++++++---------- .../boardgame/ui/activity/MainActivity.java | 5 ++- 7 files changed, 89 insertions(+), 26 deletions(-) create mode 100644 app/src/main/java/com/wzf/boardgame/function/http/Interceptor/DecodeParamsInterceptor.java create mode 100644 app/src/main/java/com/wzf/boardgame/function/http/dto/request/BaseRequestDto.java diff --git a/app/src/main/java/com/wzf/boardgame/function/http/Interceptor/DecodeParamsInterceptor.java b/app/src/main/java/com/wzf/boardgame/function/http/Interceptor/DecodeParamsInterceptor.java new file mode 100644 index 0000000..583b904 --- /dev/null +++ b/app/src/main/java/com/wzf/boardgame/function/http/Interceptor/DecodeParamsInterceptor.java @@ -0,0 +1,36 @@ +package com.wzf.boardgame.function.http.Interceptor; + +import com.wzf.boardgame.function.http.dto.response.BaseResponse; +import com.wzf.boardgame.utils.DebugLog; +import com.wzf.boardgame.utils.JsonUtils; +import com.wzf.boardgame.utils.MathUtilAndroid; + +import java.io.IOException; + +import okhttp3.Interceptor; +import okhttp3.MediaType; +import okhttp3.Response; +import okhttp3.ResponseBody; + +/** + * @Description: + * @author: wangzhenfei + * @date: 2017-06-29 09:48 + * 对参数进行加密 + */ + +public class DecodeParamsInterceptor implements Interceptor { + @Override + public Response intercept(Chain chain) throws IOException { + Response originalResponse = chain.proceed(chain.request()); + MediaType type = originalResponse.body().contentType(); + String payload = originalResponse.body().string(); + BaseResponse baseResponse = JsonUtils.fromJSON(BaseResponse.class, payload); + DebugLog.i("OKHTTP", "----->>>> before decode response params <<<<-----\n"); + DebugLog.i("OKHTTP", JsonUtils.format(JsonUtils.toJson(baseResponse)) + "\n"); + baseResponse.setResponse(MathUtilAndroid.decodeAES(baseResponse.getResponse().toString())); + String jsonStr = JsonUtils.toJson(baseResponse); + ResponseBody responseBody = ResponseBody.create(type, jsonStr); + return originalResponse.newBuilder().body(responseBody).build(); + } +} diff --git a/app/src/main/java/com/wzf/boardgame/function/http/OkHttpUtils.java b/app/src/main/java/com/wzf/boardgame/function/http/OkHttpUtils.java index 247439b..927a35c 100644 --- a/app/src/main/java/com/wzf/boardgame/function/http/OkHttpUtils.java +++ b/app/src/main/java/com/wzf/boardgame/function/http/OkHttpUtils.java @@ -6,6 +6,7 @@ import com.wzf.boardgame.MyApplication; import com.wzf.boardgame.constant.UrlService; import com.wzf.boardgame.function.http.Interceptor.AddParamInterceptor; +import com.wzf.boardgame.function.http.Interceptor.DecodeParamsInterceptor; import com.wzf.boardgame.function.http.Interceptor.LoggerInterceptor; import com.wzf.boardgame.function.http.Interceptor.OkhttpOffLineCacheInterceptor; import com.wzf.boardgame.function.http.Interceptor.OkhttpOnLineCacheInterceptor; @@ -42,6 +43,7 @@ private OkHttpUtils() { .connectTimeout(DEFAULT_TIMEOUT, TimeUnit.SECONDS) .addInterceptor(new AddParamInterceptor())//添加头部headers .addInterceptor(new LoggerInterceptor(null, true)) + .addInterceptor(new DecodeParamsInterceptor())//解密 .addInterceptor(new OkhttpOffLineCacheInterceptor())//离线缓存 .addNetworkInterceptor(new OkhttpOnLineCacheInterceptor());//在线缓存 retrofitBuilder = new Retrofit.Builder() diff --git a/app/src/main/java/com/wzf/boardgame/function/http/ResponseSubscriber.java b/app/src/main/java/com/wzf/boardgame/function/http/ResponseSubscriber.java index 4f327ea..4831781 100644 --- a/app/src/main/java/com/wzf/boardgame/function/http/ResponseSubscriber.java +++ b/app/src/main/java/com/wzf/boardgame/function/http/ResponseSubscriber.java @@ -55,7 +55,8 @@ public final void onError(Throwable e) { dialog.dismiss(); } try { - onFailure(NET_OR_SERVER_ERROR, e.toString()); +// onFailure(NET_OR_SERVER_ERROR, e.toString()); + onFailure(NET_OR_SERVER_ERROR, "请求出了点小状况哦,请重试"); } catch (Exception e1) { e1.printStackTrace(); } @@ -64,15 +65,15 @@ public final void onError(Throwable e) { @Override public final void onNext(BaseResponse t) { if (t != null) { - if (t.getCode() == 0) { + if (t.getResultCode() == 0) { try { - onSuccess(t.getData()); + onSuccess(t.getResponse()); } catch (Exception e) { e.printStackTrace(); } } else { try { - onFailure(t.getCode(), t.getMessage()); + onFailure(t.getResultCode(), t.getMsg()); } catch (Exception e) { e.printStackTrace(); } diff --git a/app/src/main/java/com/wzf/boardgame/function/http/dto/request/BaseRequestDto.java b/app/src/main/java/com/wzf/boardgame/function/http/dto/request/BaseRequestDto.java new file mode 100644 index 0000000..f2374d1 --- /dev/null +++ b/app/src/main/java/com/wzf/boardgame/function/http/dto/request/BaseRequestDto.java @@ -0,0 +1,20 @@ +package com.wzf.boardgame.function.http.dto.request; + +import com.wzf.boardgame.utils.DebugLog; +import com.wzf.boardgame.utils.JsonUtils; +import com.wzf.boardgame.utils.MathUtilAndroid; + +/** + * @Description: + * @author: wangzhenfei + * @date: 2017-06-29 10:06 + */ + +public class BaseRequestDto { + public String toEncodeString(){ + String json = JsonUtils.toJson(this); + DebugLog.i("OKHTTP", " ----->>>> before encode params <<<<-----\n"); + DebugLog.i("OKHTTP", JsonUtils.format(json) + "\n"); + return MathUtilAndroid.encodeAES(json); + } +} diff --git a/app/src/main/java/com/wzf/boardgame/function/http/dto/request/RegisterRequestDto.java b/app/src/main/java/com/wzf/boardgame/function/http/dto/request/RegisterRequestDto.java index 46eebe2..7438ac8 100644 --- a/app/src/main/java/com/wzf/boardgame/function/http/dto/request/RegisterRequestDto.java +++ b/app/src/main/java/com/wzf/boardgame/function/http/dto/request/RegisterRequestDto.java @@ -1,10 +1,13 @@ package com.wzf.boardgame.function.http.dto.request; +import com.wzf.boardgame.utils.JsonUtils; +import com.wzf.boardgame.utils.MathUtilAndroid; + /** * Created by wzf on 2017/6/28. */ -public class RegisterRequestDto { +public class RegisterRequestDto extends BaseRequestDto{ /** * nickname : 昵称 @@ -59,4 +62,6 @@ public String getUserMobile() { public void setUserMobile(String userMobile) { this.userMobile = userMobile; } + + } diff --git a/app/src/main/java/com/wzf/boardgame/function/http/dto/response/BaseResponse.java b/app/src/main/java/com/wzf/boardgame/function/http/dto/response/BaseResponse.java index 749cfbc..f220a8b 100644 --- a/app/src/main/java/com/wzf/boardgame/function/http/dto/response/BaseResponse.java +++ b/app/src/main/java/com/wzf/boardgame/function/http/dto/response/BaseResponse.java @@ -7,40 +7,40 @@ */ public class BaseResponse { - private int code; - private String message; - private T data; + private int resultCode; + private String msg; + private T response; - public int getCode() { - return code; + public int getResultCode() { + return resultCode; } - public void setCode(int code) { - this.code = code; + public void setResultCode(int resultCode) { + this.resultCode = resultCode; } - public String getMessage() { - return message; + public String getMsg() { + return msg; } - public void setMessage(String message) { - this.message = message; + public void setMsg(String msg) { + this.msg = msg; } - public T getData() { - return data; + public T getResponse() { + return response; } - public void setData(T data) { - this.data = data; + public void setResponse(T response) { + this.response = response; } @Override public String toString() { return "BaseResponse{" + - "code=" + code + - ", message='" + message + '\'' + - ", data=" + data + + "resultCode=" + resultCode + + ", msg='" + msg + '\'' + + ", response=" + response + '}'; } } \ No newline at end of file diff --git a/app/src/main/java/com/wzf/boardgame/ui/activity/MainActivity.java b/app/src/main/java/com/wzf/boardgame/ui/activity/MainActivity.java index d4bcb1e..3b0fa75 100644 --- a/app/src/main/java/com/wzf/boardgame/ui/activity/MainActivity.java +++ b/app/src/main/java/com/wzf/boardgame/ui/activity/MainActivity.java @@ -49,8 +49,7 @@ public void run() { dto.setSmsCode("1234"); dto.setUserPwd("qqqqqq"); dto.setUserMobile("18521709590"); - String src = MathUtilAndroid.encodeAES(JsonUtils.toJson(dto)); - UrlService.SERVICE.register(src) + UrlService.SERVICE.register(dto.toEncodeString()) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(new ResponseSubscriber(this, true) { @@ -63,7 +62,7 @@ public void onSuccess(Object loginResponseDto) throws Exception { @Override public void onFailure(int code, String message) throws Exception { super.onFailure(code, message); - tv.setText(message); + showToast(message); } }); } From 2ba7890d5888d2a00b4721a493b8c968b42e7490 Mon Sep 17 00:00:00 2001 From: wangzhenfei <179576267@qq.com> Date: Fri, 30 Jun 2017 14:31:25 +0800 Subject: [PATCH 05/47] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../function/http/Interceptor/DecodeParamsInterceptor.java | 7 +++++-- .../wzf/boardgame/function/http/ResponseSubscriber.java | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/wzf/boardgame/function/http/Interceptor/DecodeParamsInterceptor.java b/app/src/main/java/com/wzf/boardgame/function/http/Interceptor/DecodeParamsInterceptor.java index 583b904..963df0f 100644 --- a/app/src/main/java/com/wzf/boardgame/function/http/Interceptor/DecodeParamsInterceptor.java +++ b/app/src/main/java/com/wzf/boardgame/function/http/Interceptor/DecodeParamsInterceptor.java @@ -1,5 +1,6 @@ package com.wzf.boardgame.function.http.Interceptor; +import com.wzf.boardgame.constant.UrlService; import com.wzf.boardgame.function.http.dto.response.BaseResponse; import com.wzf.boardgame.utils.DebugLog; import com.wzf.boardgame.utils.JsonUtils; @@ -26,8 +27,10 @@ public Response intercept(Chain chain) throws IOException { MediaType type = originalResponse.body().contentType(); String payload = originalResponse.body().string(); BaseResponse baseResponse = JsonUtils.fromJSON(BaseResponse.class, payload); - DebugLog.i("OKHTTP", "----->>>> before decode response params <<<<-----\n"); - DebugLog.i("OKHTTP", JsonUtils.format(JsonUtils.toJson(baseResponse)) + "\n"); + if(UrlService.DEBUG){ + DebugLog.i("OKHTTP", "----->>>> before decode response params <<<<-----\n"); + DebugLog.i("OKHTTP", JsonUtils.format(JsonUtils.toJson(baseResponse)) + "\n"); + } baseResponse.setResponse(MathUtilAndroid.decodeAES(baseResponse.getResponse().toString())); String jsonStr = JsonUtils.toJson(baseResponse); ResponseBody responseBody = ResponseBody.create(type, jsonStr); diff --git a/app/src/main/java/com/wzf/boardgame/function/http/ResponseSubscriber.java b/app/src/main/java/com/wzf/boardgame/function/http/ResponseSubscriber.java index 4831781..fd0ee26 100644 --- a/app/src/main/java/com/wzf/boardgame/function/http/ResponseSubscriber.java +++ b/app/src/main/java/com/wzf/boardgame/function/http/ResponseSubscriber.java @@ -17,6 +17,7 @@ */ public class ResponseSubscriber extends Subscriber> { + public static final int REQUEST_SUCCESS = 200; public static int NET_OR_SERVER_ERROR = 0X4562; private NetRequestWaitDialog dialog; private WeakReference contextWeakReference; @@ -65,7 +66,7 @@ public final void onError(Throwable e) { @Override public final void onNext(BaseResponse t) { if (t != null) { - if (t.getResultCode() == 0) { + if (t.getResultCode() == REQUEST_SUCCESS) { try { onSuccess(t.getResponse()); } catch (Exception e) { From 5da4a6daa249b4613e0ba3dedd29f3fa544153e4 Mon Sep 17 00:00:00 2001 From: wangzhenfei <179576267@qq.com> Date: Fri, 30 Jun 2017 14:32:50 +0800 Subject: [PATCH 06/47] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/wzf/boardgame/function/http/ResponseSubscriber.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/wzf/boardgame/function/http/ResponseSubscriber.java b/app/src/main/java/com/wzf/boardgame/function/http/ResponseSubscriber.java index fd0ee26..750a7ce 100644 --- a/app/src/main/java/com/wzf/boardgame/function/http/ResponseSubscriber.java +++ b/app/src/main/java/com/wzf/boardgame/function/http/ResponseSubscriber.java @@ -57,7 +57,7 @@ public final void onError(Throwable e) { } try { // onFailure(NET_OR_SERVER_ERROR, e.toString()); - onFailure(NET_OR_SERVER_ERROR, "请求出了点小状况哦,请重试"); + onFailure(NET_OR_SERVER_ERROR, "请求出了点小状况哦,请稍后重试"); } catch (Exception e1) { e1.printStackTrace(); } From 7e596cc3f526a138efc4f8f1ef3cdadcbcb1ff33 Mon Sep 17 00:00:00 2001 From: wangzhenfei <179576267@qq.com> Date: Sun, 2 Jul 2017 17:49:46 +0800 Subject: [PATCH 07/47] =?UTF-8?q?=E5=AE=B6=E9=87=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 4 + .../wzf/boardgame/constant/UrlService.java | 11 +- .../Interceptor/DecodeParamsInterceptor.java | 4 +- .../http/Interceptor/LoggerInterceptor.java | 3 +- .../function/http/ResponseSubscriber.java | 2 + .../http/dto/request/BaseRequestDto.java | 4 +- .../http/dto/request/GetSmsCodeReqDto.java | 28 +++++ .../boardgame/ui/activity/LoginActivity.java | 83 ++++++++++++++ .../boardgame/ui/activity/MainActivity.java | 70 ++++++++---- .../ui/activity/RegisterActivity.java | 108 ++++++++++++++++++ 10 files changed, 285 insertions(+), 32 deletions(-) create mode 100644 app/src/main/java/com/wzf/boardgame/function/http/dto/request/GetSmsCodeReqDto.java create mode 100644 app/src/main/java/com/wzf/boardgame/ui/activity/LoginActivity.java create mode 100644 app/src/main/java/com/wzf/boardgame/ui/activity/RegisterActivity.java diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 49589cf..86680db 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -42,6 +42,10 @@ + + > login(@Query("os") String os); - //登录 + //获取验证码 + @POST("user/smsCode") + @FormUrlEncoded + Observable> smsCode(@Field("params") String params); + + //注册 @POST("user/register") @FormUrlEncoded - Observable> register(@Field("params") String params) - ; + Observable> register(@Field("params") String params); + // // //注销 // @POST("logout") diff --git a/app/src/main/java/com/wzf/boardgame/function/http/Interceptor/DecodeParamsInterceptor.java b/app/src/main/java/com/wzf/boardgame/function/http/Interceptor/DecodeParamsInterceptor.java index 963df0f..9d1ee04 100644 --- a/app/src/main/java/com/wzf/boardgame/function/http/Interceptor/DecodeParamsInterceptor.java +++ b/app/src/main/java/com/wzf/boardgame/function/http/Interceptor/DecodeParamsInterceptor.java @@ -28,8 +28,8 @@ public Response intercept(Chain chain) throws IOException { String payload = originalResponse.body().string(); BaseResponse baseResponse = JsonUtils.fromJSON(BaseResponse.class, payload); if(UrlService.DEBUG){ - DebugLog.i("OKHTTP", "----->>>> before decode response params <<<<-----\n"); - DebugLog.i("OKHTTP", JsonUtils.format(JsonUtils.toJson(baseResponse)) + "\n"); + DebugLog.d("OKHTTP", "----->>>> before decode response params <<<<-----\n"); + DebugLog.d("OKHTTP", JsonUtils.format(JsonUtils.toJson(baseResponse)) + "\n"); } baseResponse.setResponse(MathUtilAndroid.decodeAES(baseResponse.getResponse().toString())); String jsonStr = JsonUtils.toJson(baseResponse); diff --git a/app/src/main/java/com/wzf/boardgame/function/http/Interceptor/LoggerInterceptor.java b/app/src/main/java/com/wzf/boardgame/function/http/Interceptor/LoggerInterceptor.java index 17a2b7d..c2d044c 100644 --- a/app/src/main/java/com/wzf/boardgame/function/http/Interceptor/LoggerInterceptor.java +++ b/app/src/main/java/com/wzf/boardgame/function/http/Interceptor/LoggerInterceptor.java @@ -133,9 +133,10 @@ private Response logForResponse(Response response) { } catch (Exception e) { e.printStackTrace(); } finally { - paramsBuilder.append("---------------------response log end-----------------------" + "\n"); +// paramsBuilder.append("——————————————————————————-----response log end--——————————————————————————————————---\n"); //打印参数 DebugLog.i("OKHTTP", paramsBuilder.toString()); + DebugLog.w("OKHTTP", "——————————————————————————-----response log end--——————————————————————————————————---\n"); } return response; diff --git a/app/src/main/java/com/wzf/boardgame/function/http/ResponseSubscriber.java b/app/src/main/java/com/wzf/boardgame/function/http/ResponseSubscriber.java index 750a7ce..7b4a5a8 100644 --- a/app/src/main/java/com/wzf/boardgame/function/http/ResponseSubscriber.java +++ b/app/src/main/java/com/wzf/boardgame/function/http/ResponseSubscriber.java @@ -4,6 +4,7 @@ import android.os.Looper; import com.wzf.boardgame.function.http.dto.response.BaseResponse; +import com.wzf.boardgame.utils.DebugLog; import java.lang.ref.WeakReference; @@ -57,6 +58,7 @@ public final void onError(Throwable e) { } try { // onFailure(NET_OR_SERVER_ERROR, e.toString()); + DebugLog.e("OKHTTP",e.toString()); onFailure(NET_OR_SERVER_ERROR, "请求出了点小状况哦,请稍后重试"); } catch (Exception e1) { e1.printStackTrace(); diff --git a/app/src/main/java/com/wzf/boardgame/function/http/dto/request/BaseRequestDto.java b/app/src/main/java/com/wzf/boardgame/function/http/dto/request/BaseRequestDto.java index f2374d1..1c285a4 100644 --- a/app/src/main/java/com/wzf/boardgame/function/http/dto/request/BaseRequestDto.java +++ b/app/src/main/java/com/wzf/boardgame/function/http/dto/request/BaseRequestDto.java @@ -13,8 +13,8 @@ public class BaseRequestDto { public String toEncodeString(){ String json = JsonUtils.toJson(this); - DebugLog.i("OKHTTP", " ----->>>> before encode params <<<<-----\n"); - DebugLog.i("OKHTTP", JsonUtils.format(json) + "\n"); + DebugLog.w("OKHTTP", " ——————————————————————————----->>>> before encode params <<<<--——————————————————————————————————---\n"); + DebugLog.d("OKHTTP", JsonUtils.format(json) + "\n"); return MathUtilAndroid.encodeAES(json); } } diff --git a/app/src/main/java/com/wzf/boardgame/function/http/dto/request/GetSmsCodeReqDto.java b/app/src/main/java/com/wzf/boardgame/function/http/dto/request/GetSmsCodeReqDto.java new file mode 100644 index 0000000..f2946e5 --- /dev/null +++ b/app/src/main/java/com/wzf/boardgame/function/http/dto/request/GetSmsCodeReqDto.java @@ -0,0 +1,28 @@ +package com.wzf.boardgame.function.http.dto.request; + +/** + * Created by wzf on 2017/7/2. + */ + +public class GetSmsCodeReqDto extends BaseRequestDto{ + public static final String SMS_CODE_REGISTER = "1"; + public static final String SMS_CODE_PSW = "2"; + private String userMobile; + private String codeType; + + public String getUserMobile() { + return userMobile; + } + + public void setUserMobile(String userMobile) { + this.userMobile = userMobile; + } + + public String getCodeType() { + return codeType; + } + + public void setCodeType(String codeType) { + this.codeType = codeType; + } +} diff --git a/app/src/main/java/com/wzf/boardgame/ui/activity/LoginActivity.java b/app/src/main/java/com/wzf/boardgame/ui/activity/LoginActivity.java new file mode 100644 index 0000000..83d3d19 --- /dev/null +++ b/app/src/main/java/com/wzf/boardgame/ui/activity/LoginActivity.java @@ -0,0 +1,83 @@ +package com.wzf.boardgame.ui.activity; + +import android.content.Intent; +import android.graphics.Paint; +import android.os.Bundle; +import android.view.View; +import android.widget.EditText; +import android.widget.TextView; + +import com.wzf.boardgame.R; +import com.wzf.boardgame.constant.UrlService; +import com.wzf.boardgame.function.http.ResponseSubscriber; +import com.wzf.boardgame.function.http.dto.request.GetSmsCodeReqDto; +import com.wzf.boardgame.ui.base.BaseActivity; +import com.wzf.boardgame.utils.REGX; + +import butterknife.Bind; +import butterknife.ButterKnife; +import butterknife.OnClick; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +/** + * Created by wzf on 2017/7/2. + */ + +public class LoginActivity extends BaseActivity { + @Bind(R.id.tv_center) + TextView tvCenter; + @Bind(R.id.et_phone) + EditText etPhone; + @Bind(R.id.et_psw) + EditText etPsw; + @Bind(R.id.forget_psd) + TextView forgetPsd; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_login); + ButterKnife.bind(this); + initView(); + GetSmsCodeReqDto reqDto = new GetSmsCodeReqDto(); + reqDto.setUserMobile("18521709590"); + reqDto.setCodeType(GetSmsCodeReqDto.SMS_CODE_REGISTER); + UrlService.SERVICE.smsCode(reqDto.toEncodeString()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribeOn(Schedulers.io()) + .subscribe(new ResponseSubscriber(this, true) { + @Override + public void onSuccess(Object loginResponseDto) throws Exception { + super.onSuccess(loginResponseDto); + showToast("验证码已发送"); + } + + @Override + public void onFailure(int code, String message) throws Exception { + super.onFailure(code, message); + showToast(message); + } + }); + } + + private void initView() { + tvCenter.setText("登录"); + tvCenter.setVisibility(View.VISIBLE); + etPhone.setFilters(REGX.getFilters(REGX.REGX_MOBILE_INPUT)); + forgetPsd.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG ); //中划线 + } + + @OnClick({R.id.forget_psd, R.id.to_register, R.id.btn_login}) + public void onViewClicked(View view) { + switch (view.getId()) { + case R.id.forget_psd: + break; + case R.id.to_register: + startActivity(new Intent(this, RegisterActivity.class)); + break; + case R.id.btn_login: + break; + } + } +} diff --git a/app/src/main/java/com/wzf/boardgame/ui/activity/MainActivity.java b/app/src/main/java/com/wzf/boardgame/ui/activity/MainActivity.java index 3b0fa75..02ebd1a 100644 --- a/app/src/main/java/com/wzf/boardgame/ui/activity/MainActivity.java +++ b/app/src/main/java/com/wzf/boardgame/ui/activity/MainActivity.java @@ -6,12 +6,10 @@ import com.wzf.boardgame.R; import com.wzf.boardgame.constant.UrlService; import com.wzf.boardgame.function.http.ResponseSubscriber; -import com.wzf.boardgame.function.http.dto.request.RegisterRequestDto; +import com.wzf.boardgame.function.http.dto.request.GetSmsCodeReqDto; import com.wzf.boardgame.function.map.BaiDuMapManager; import com.wzf.boardgame.ui.base.BaseActivity; import com.wzf.boardgame.utils.AppDeviceInfo; -import com.wzf.boardgame.utils.JsonUtils; -import com.wzf.boardgame.utils.MathUtilAndroid; import butterknife.Bind; import butterknife.ButterKnife; @@ -29,34 +27,18 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); - showToast(AppDeviceInfo.getNetworkType()); - - BaiDuMapManager.getInstance().getLocationMessage(new BaiDuMapManager.OnLocationMessageGetListener() { - @Override - public void onReceiveLocation(final String cityName, double lon, double lat) { - runOnUiThread(new Runnable() { - @Override - public void run() { - showToast(cityName); - } - }); - } - }); - RegisterRequestDto dto = new RegisterRequestDto(); - dto.setUserId("123"); - dto.setNickname("wzf"); - dto.setSmsCode("1234"); - dto.setUserPwd("qqqqqq"); - dto.setUserMobile("18521709590"); - UrlService.SERVICE.register(dto.toEncodeString()) + GetSmsCodeReqDto reqDto = new GetSmsCodeReqDto(); + reqDto.setUserMobile("18521709590"); + reqDto.setCodeType(GetSmsCodeReqDto.SMS_CODE_REGISTER); + UrlService.SERVICE.smsCode(reqDto.toEncodeString()) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(new ResponseSubscriber(this, true) { @Override public void onSuccess(Object loginResponseDto) throws Exception { super.onSuccess(loginResponseDto); - tv.setText(loginResponseDto.toString()); + showToast("验证码已发送"); } @Override @@ -65,5 +47,45 @@ public void onFailure(int code, String message) throws Exception { showToast(message); } }); + + + showToast(AppDeviceInfo.getNetworkType()); + + BaiDuMapManager.getInstance().getLocationMessage(new BaiDuMapManager.OnLocationMessageGetListener() { + @Override + public void onReceiveLocation(final String cityName, double lon, double lat) { + runOnUiThread(new Runnable() { + @Override + public void run() { + showToast(cityName); + } + }); + } + }); + + + +// RegisterRequestDto dto = new RegisterRequestDto(); +// dto.setUserId("123"); +// dto.setNickname("wzf"); +// dto.setSmsCode("1234"); +// dto.setUserPwd("qqqqqq"); +// dto.setUserMobile("18521709590"); +// UrlService.SERVICE.register(dto.toEncodeString()) +// .observeOn(AndroidSchedulers.mainThread()) +// .subscribeOn(Schedulers.io()) +// .subscribe(new ResponseSubscriber(this, true) { +// @Override +// public void onSuccess(Object loginResponseDto) throws Exception { +// super.onSuccess(loginResponseDto); +// tv.setText(loginResponseDto.toString()); +// } +// +// @Override +// public void onFailure(int code, String message) throws Exception { +// super.onFailure(code, message); +// showToast(message); +// } +// }); } } diff --git a/app/src/main/java/com/wzf/boardgame/ui/activity/RegisterActivity.java b/app/src/main/java/com/wzf/boardgame/ui/activity/RegisterActivity.java new file mode 100644 index 0000000..ea8a23f --- /dev/null +++ b/app/src/main/java/com/wzf/boardgame/ui/activity/RegisterActivity.java @@ -0,0 +1,108 @@ +package com.wzf.boardgame.ui.activity; + +import android.os.Bundle; +import android.os.Looper; +import android.text.TextUtils; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; + +import com.wzf.boardgame.R; +import com.wzf.boardgame.constant.UrlService; +import com.wzf.boardgame.function.http.OkHttpUtils; +import com.wzf.boardgame.function.http.ResponseSubscriber; +import com.wzf.boardgame.function.http.dto.request.GetSmsCodeReqDto; +import com.wzf.boardgame.ui.base.BaseActivity; +import com.wzf.boardgame.utils.DebugLog; +import com.wzf.boardgame.utils.REGX; + +import butterknife.Bind; +import butterknife.ButterKnife; +import butterknife.OnClick; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +/** + * Created by wzf on 2017/7/2. + */ + +public class RegisterActivity extends BaseActivity { + + + @Bind(R.id.im_left) + ImageView imLeft; + @Bind(R.id.tv_center) + TextView tvCenter; + @Bind(R.id.et_nickname) + EditText etNickname; + @Bind(R.id.et_phone) + EditText etPhone; + @Bind(R.id.et_psw) + EditText etPsw; + @Bind(R.id.et_sms_code) + EditText etSmsCode; + @Bind(R.id.btn_get_code) + Button btnGetCode; + @Bind(R.id.et_invite_code) + EditText etInviteCode; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_register); + ButterKnife.bind(this); + initView(); + } + + private void initView() { + tvCenter.setText("注册"); + tvCenter.setVisibility(View.VISIBLE); + imLeft.setVisibility(View.VISIBLE); + etPhone.setFilters(REGX.getFilters(REGX.REGX_MOBILE_INPUT)); + + } + + @OnClick({R.id.im_left, R.id.btn_get_code, R.id.btn_login}) + public void onViewClicked(View view) { + switch (view.getId()) { + case R.id.im_left: + finish(); + break; + case R.id.btn_get_code: + getSmsCode(); + break; + case R.id.btn_login: + break; + } + } + + private void getSmsCode() { + String phone = etPhone.getText().toString().trim(); + if(TextUtils.isEmpty(phone)){ + showToast("请输入手机号码"); + return; + } + + GetSmsCodeReqDto reqDto = new GetSmsCodeReqDto(); + reqDto.setUserMobile(phone); + reqDto.setCodeType(GetSmsCodeReqDto.SMS_CODE_REGISTER); + OkHttpUtils.getInstance().getUrlService(UrlService.class).smsCode(reqDto.toEncodeString()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribeOn(Schedulers.io()) + .subscribe(new ResponseSubscriber(this, true) { + @Override + public void onSuccess(Object loginResponseDto) throws Exception { + showToast("验证码已发送"); + } + + @Override + public void onFailure(int code, String message) throws Exception { + super.onFailure(code, message); + showToast(message); + } + }); + + } +} From 6d96ba1fd4ba8abc4288b586280a62e0ef8b0cf8 Mon Sep 17 00:00:00 2001 From: wangzhenfei <179576267@qq.com> Date: Sun, 2 Jul 2017 18:08:17 +0800 Subject: [PATCH 08/47] =?UTF-8?q?=E5=AE=B6=E9=87=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/wzf/boardgame/Test.java | 15 +- .../wzf/boardgame/constant/UrlService.java | 5 +- .../boardgame/ui/activity/LoginActivity.java | 14 +- .../boardgame/ui/activity/MainActivity.java | 37 +++-- .../ui/activity/RegisterActivity.java | 4 +- app/src/main/res/drawable/shape_blue_8.xml | 11 ++ app/src/main/res/layout/activity_login.xml | 110 ++++++++++++++ app/src/main/res/layout/activity_register.xml | 139 ++++++++++++++++++ app/src/main/res/layout/layout_top.xml | 63 ++++++++ app/src/main/res/mipmap-hdpi/ic_launcher.png | Bin 3418 -> 0 bytes .../res/mipmap-xhdpi/Fans_Btn_Back_nor.png | Bin 0 -> 2142 bytes .../res/mipmap-xhdpi/fans_btn_follow_nor.png | Bin 0 -> 2198 bytes .../mipmap-xhdpi/fans_btn_following_nor.png | Bin 0 -> 2424 bytes .../following_btn_addfriend_nor.png | Bin 0 -> 4782 bytes .../mipmap-xhdpi/following_btn_back_nor.png | Bin 0 -> 2142 bytes .../following_btn_following_nor.png | Bin 0 -> 2424 bytes .../mipmap-xhdpi/following_btn_friend_nor.png | Bin 0 -> 2624 bytes .../res/mipmap-xhdpi/forum_btn_back_nor.png | Bin 0 -> 2142 bytes .../mipmap-xhdpi/forum_btn_collect_nor.png | Bin 0 -> 3911 bytes .../mipmap-xhdpi/forum_btn_collect_sel.png | Bin 0 -> 2918 bytes .../mipmap-xhdpi/forum_btn_comment_nor.png | Bin 0 -> 3490 bytes .../res/mipmap-xhdpi/forum_btn_reply_nor.png | Bin 0 -> 1364 bytes .../res/mipmap-xhdpi/game_btn_mali_nor.png | Bin 0 -> 3591 bytes .../mipmap-xhdpi/gamedata_btn_back_nor.png | Bin 0 -> 2142 bytes .../mipmap-xhdpi/gamedata_btn_book_dis.png | Bin 0 -> 1375 bytes .../mipmap-xhdpi/gamedata_btn_book_nor.png | Bin 0 -> 1373 bytes .../mipmap-xhdpi/gamedata_btn_collect_nor.png | Bin 0 -> 3911 bytes .../mipmap-xhdpi/gamedata_btn_collect_sel.png | Bin 0 -> 2918 bytes .../mipmap-xhdpi/gamedata_btn_comment_nor.png | Bin 0 -> 3490 bytes .../mipmap-xhdpi/gamedata_btn_extend_dis.png | Bin 0 -> 1589 bytes .../mipmap-xhdpi/gamedata_btn_extend_nor.png | Bin 0 -> 1614 bytes .../mipmap-xhdpi/gamedata_btn_extend_sel.png | Bin 0 -> 1614 bytes .../mipmap-xhdpi/gamedata_btn_like_nor.png | Bin 0 -> 1535 bytes .../mipmap-xhdpi/gamedata_btn_like_sel.png | Bin 0 -> 1334 bytes .../mipmap-xhdpi/gamedata_btn_unlike_nor.png | Bin 0 -> 1537 bytes .../mipmap-xhdpi/gamedata_btn_unlike_sel.png | Bin 0 -> 1332 bytes .../mipmap-xhdpi/gamedata_btn_video_dis.png | Bin 0 -> 2177 bytes .../mipmap-xhdpi/gamedata_btn_video_nor.png | Bin 0 -> 2178 bytes .../mipmap-xhdpi/gamedata_btn_video_sel.png | Bin 0 -> 2196 bytes .../mipmap-xhdpi/gamedata_icon_clock_nor.png | Bin 0 -> 1660 bytes .../gamedata_icon_country_nor.png | Bin 0 -> 1483 bytes .../mipmap-xhdpi/gamedata_icon_date_nor.png | Bin 0 -> 1528 bytes .../gamedata_icon_designer_nor.png | Bin 0 -> 1710 bytes .../mipmap-xhdpi/gamedata_icon_people_nor.png | Bin 0 -> 1781 bytes .../mipmap-xhdpi/gamedatar_btn_book_sel.png | Bin 0 -> 1373 bytes .../res/mipmap-xhdpi/home_btn_write_nor.png | Bin 0 -> 4025 bytes .../mipmap-xhdpi/home_icon_comment_nor.png | Bin 0 -> 1335 bytes .../res/mipmap-xhdpi/home_icon_image_nor.png | Bin 0 -> 1434 bytes .../res/mipmap-xhdpi/home_icon_prime_nor.png | Bin 0 -> 1222 bytes .../res/mipmap-xhdpi/home_icon_up_nor.png | Bin 0 -> 1218 bytes .../res/mipmap-xhdpi/home_icon_view_nor.png | Bin 0 -> 1646 bytes .../mipmap-xhdpi/otheruser_btn_back_nor.png | Bin 0 -> 2142 bytes .../mipmap-xhdpi/otheruser_btn_follow_nor.png | Bin 0 -> 4792 bytes .../otheruser_btn_following_nor.png | Bin 0 -> 5062 bytes .../mipmap-xhdpi/otheruser_icon_man_nor.png | Bin 0 -> 2553 bytes .../mipmap-xhdpi/otheruser_icon_woman_nor.png | Bin 0 -> 2465 bytes .../mipmap-xhdpi/personal_btn_camera_nor.png | Bin 0 -> 2277 bytes .../mipmap-xhdpi/register_btn_code_dis.png | Bin 0 -> 10866 bytes .../mipmap-xhdpi/register_btn_code_nor.png | Bin 0 -> 10913 bytes .../register_btn_rsgister_nor.png | Bin 0 -> 4227 bytes .../register_btn_writecode_dis.png | Bin 0 -> 11732 bytes .../mipmap-xhdpi/search_btn_cancel_nor.png | Bin 0 -> 3214 bytes .../mipmap-xhdpi/search_btn_cancel_sel.png | Bin 0 -> 2762 bytes .../res/mipmap-xhdpi/send_btn_back_nor.png | Bin 0 -> 2142 bytes .../res/mipmap-xhdpi/send_btn_picture_nor.png | Bin 0 -> 1954 bytes .../res/mipmap-xhdpi/send_btn_send_nor.png | Bin 0 -> 4752 bytes .../mipmap-xhdpi/signin_btn_signin_dis.png | Bin 0 -> 4944 bytes .../mipmap-xhdpi/signin_btn_signin_nor.png | Bin 0 -> 4983 bytes .../mipmap-xhdpi/tabbar_btn_community_nor.png | Bin 0 -> 2299 bytes .../mipmap-xhdpi/tabbar_btn_community_sel.png | Bin 0 -> 2299 bytes .../res/mipmap-xhdpi/tabbar_btn_game_nor.png | Bin 0 -> 2248 bytes .../res/mipmap-xhdpi/tabbar_btn_game_sel.png | Bin 0 -> 2249 bytes .../res/mipmap-xhdpi/tabbar_btn_user_nor.png | Bin 0 -> 1880 bytes .../res/mipmap-xhdpi/tabbar_btn_user_sel.png | Bin 0 -> 1891 bytes .../mipmap-xhdpi/user_icon_collection_nor.png | Bin 0 -> 1911 bytes .../res/mipmap-xhdpi/user_icon_id_nor.png | Bin 0 -> 1537 bytes .../user_icon_information_nor.png | Bin 0 -> 1749 bytes .../res/mipmap-xhdpi/user_icon_man_nor.png | Bin 0 -> 2553 bytes .../res/mipmap-xhdpi/user_icon_news_nor.png | Bin 0 -> 1455 bytes .../mipmap-xhdpi/user_icon_reminder_nor.png | Bin 0 -> 1189 bytes .../res/mipmap-xhdpi/user_icon_right_nor.png | Bin 0 -> 1294 bytes .../res/mipmap-xhdpi/user_icon_updata_nor.png | Bin 0 -> 1914 bytes .../res/mipmap-xhdpi/user_icon_woman_nor.png | Bin 0 -> 2461 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 10486 -> 0 bytes app/src/main/res/values/colors.xml | 10 +- app/src/main/res/values/strings.xml | 1 + 86 files changed, 365 insertions(+), 44 deletions(-) create mode 100644 app/src/main/res/drawable/shape_blue_8.xml create mode 100644 app/src/main/res/layout/activity_login.xml create mode 100644 app/src/main/res/layout/activity_register.xml create mode 100644 app/src/main/res/layout/layout_top.xml delete mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xhdpi/Fans_Btn_Back_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/fans_btn_follow_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/fans_btn_following_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/following_btn_addfriend_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/following_btn_back_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/following_btn_following_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/following_btn_friend_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/forum_btn_back_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/forum_btn_collect_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/forum_btn_collect_sel.png create mode 100644 app/src/main/res/mipmap-xhdpi/forum_btn_comment_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/forum_btn_reply_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/game_btn_mali_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/gamedata_btn_back_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/gamedata_btn_book_dis.png create mode 100644 app/src/main/res/mipmap-xhdpi/gamedata_btn_book_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/gamedata_btn_collect_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/gamedata_btn_collect_sel.png create mode 100644 app/src/main/res/mipmap-xhdpi/gamedata_btn_comment_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/gamedata_btn_extend_dis.png create mode 100644 app/src/main/res/mipmap-xhdpi/gamedata_btn_extend_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/gamedata_btn_extend_sel.png create mode 100644 app/src/main/res/mipmap-xhdpi/gamedata_btn_like_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/gamedata_btn_like_sel.png create mode 100644 app/src/main/res/mipmap-xhdpi/gamedata_btn_unlike_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/gamedata_btn_unlike_sel.png create mode 100644 app/src/main/res/mipmap-xhdpi/gamedata_btn_video_dis.png create mode 100644 app/src/main/res/mipmap-xhdpi/gamedata_btn_video_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/gamedata_btn_video_sel.png create mode 100644 app/src/main/res/mipmap-xhdpi/gamedata_icon_clock_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/gamedata_icon_country_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/gamedata_icon_date_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/gamedata_icon_designer_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/gamedata_icon_people_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/gamedatar_btn_book_sel.png create mode 100644 app/src/main/res/mipmap-xhdpi/home_btn_write_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/home_icon_comment_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/home_icon_image_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/home_icon_prime_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/home_icon_up_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/home_icon_view_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/otheruser_btn_back_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/otheruser_btn_follow_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/otheruser_btn_following_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/otheruser_icon_man_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/otheruser_icon_woman_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/personal_btn_camera_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/register_btn_code_dis.png create mode 100644 app/src/main/res/mipmap-xhdpi/register_btn_code_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/register_btn_rsgister_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/register_btn_writecode_dis.png create mode 100644 app/src/main/res/mipmap-xhdpi/search_btn_cancel_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/search_btn_cancel_sel.png create mode 100644 app/src/main/res/mipmap-xhdpi/send_btn_back_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/send_btn_picture_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/send_btn_send_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/signin_btn_signin_dis.png create mode 100644 app/src/main/res/mipmap-xhdpi/signin_btn_signin_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/tabbar_btn_community_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/tabbar_btn_community_sel.png create mode 100644 app/src/main/res/mipmap-xhdpi/tabbar_btn_game_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/tabbar_btn_game_sel.png create mode 100644 app/src/main/res/mipmap-xhdpi/tabbar_btn_user_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/tabbar_btn_user_sel.png create mode 100644 app/src/main/res/mipmap-xhdpi/user_icon_collection_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/user_icon_id_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/user_icon_information_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/user_icon_man_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/user_icon_news_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/user_icon_reminder_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/user_icon_right_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/user_icon_updata_nor.png create mode 100644 app/src/main/res/mipmap-xhdpi/user_icon_woman_nor.png delete mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/app/src/main/java/com/wzf/boardgame/Test.java b/app/src/main/java/com/wzf/boardgame/Test.java index cf0a70e..270d43a 100644 --- a/app/src/main/java/com/wzf/boardgame/Test.java +++ b/app/src/main/java/com/wzf/boardgame/Test.java @@ -1,8 +1,6 @@ package com.wzf.boardgame; -import com.wzf.boardgame.function.http.dto.request.RegisterRequestDto; -import com.wzf.boardgame.utils.JsonUtils; -import com.wzf.boardgame.utils.MathUtilAndroid; +import java.io.File; /** * Created by wzf on 2017/6/28. @@ -10,15 +8,6 @@ public class Test { public static void main(String[] args) { - RegisterRequestDto dto = new RegisterRequestDto(); - dto.setUserId("123"); - dto.setNickname("wzf"); - dto.setSmsCode("1234"); - dto.setUserPwd("qqqqqq"); - dto.setUserMobile("18521709590"); - String befer = MathUtilAndroid.encodeAES(JsonUtils.toJson(dto)); - System.out.println(befer); - String after = MathUtilAndroid.decodeAES(befer); - System.out.println(after); + } } diff --git a/app/src/main/java/com/wzf/boardgame/constant/UrlService.java b/app/src/main/java/com/wzf/boardgame/constant/UrlService.java index 6901b28..f9e478a 100644 --- a/app/src/main/java/com/wzf/boardgame/constant/UrlService.java +++ b/app/src/main/java/com/wzf/boardgame/constant/UrlService.java @@ -40,9 +40,8 @@ public interface UrlService { Observable> login(@Query("os") String os); //获取验证码 - @POST("user/smsCode") - @FormUrlEncoded - Observable> smsCode(@Field("params") String params); + @GET("user/smsCode") + Observable> smsCode(@Query("params") String params); //注册 @POST("user/register") diff --git a/app/src/main/java/com/wzf/boardgame/ui/activity/LoginActivity.java b/app/src/main/java/com/wzf/boardgame/ui/activity/LoginActivity.java index 83d3d19..5f02d8b 100644 --- a/app/src/main/java/com/wzf/boardgame/ui/activity/LoginActivity.java +++ b/app/src/main/java/com/wzf/boardgame/ui/activity/LoginActivity.java @@ -11,6 +11,7 @@ import com.wzf.boardgame.constant.UrlService; import com.wzf.boardgame.function.http.ResponseSubscriber; import com.wzf.boardgame.function.http.dto.request.GetSmsCodeReqDto; +import com.wzf.boardgame.function.http.dto.request.RegisterRequestDto; import com.wzf.boardgame.ui.base.BaseActivity; import com.wzf.boardgame.utils.REGX; @@ -40,19 +41,20 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_login); ButterKnife.bind(this); initView(); - GetSmsCodeReqDto reqDto = new GetSmsCodeReqDto(); - reqDto.setUserMobile("18521709590"); - reqDto.setCodeType(GetSmsCodeReqDto.SMS_CODE_REGISTER); - UrlService.SERVICE.smsCode(reqDto.toEncodeString()) + RegisterRequestDto dto = new RegisterRequestDto(); + dto.setUserId("123"); + dto.setNickname("wzf"); + dto.setSmsCode("1234"); + dto.setUserPwd("qqqqqq"); + dto.setUserMobile("18521709590"); + UrlService.SERVICE.register(dto.toEncodeString()) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(new ResponseSubscriber(this, true) { @Override public void onSuccess(Object loginResponseDto) throws Exception { super.onSuccess(loginResponseDto); - showToast("验证码已发送"); } - @Override public void onFailure(int code, String message) throws Exception { super.onFailure(code, message); diff --git a/app/src/main/java/com/wzf/boardgame/ui/activity/MainActivity.java b/app/src/main/java/com/wzf/boardgame/ui/activity/MainActivity.java index 02ebd1a..0accac0 100644 --- a/app/src/main/java/com/wzf/boardgame/ui/activity/MainActivity.java +++ b/app/src/main/java/com/wzf/boardgame/ui/activity/MainActivity.java @@ -7,9 +7,12 @@ import com.wzf.boardgame.constant.UrlService; import com.wzf.boardgame.function.http.ResponseSubscriber; import com.wzf.boardgame.function.http.dto.request.GetSmsCodeReqDto; +import com.wzf.boardgame.function.http.dto.request.RegisterRequestDto; import com.wzf.boardgame.function.map.BaiDuMapManager; import com.wzf.boardgame.ui.base.BaseActivity; import com.wzf.boardgame.utils.AppDeviceInfo; +import com.wzf.boardgame.utils.JsonUtils; +import com.wzf.boardgame.utils.MathUtilAndroid; import butterknife.Bind; import butterknife.ButterKnife; @@ -27,6 +30,19 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); + showToast(AppDeviceInfo.getNetworkType()); + + BaiDuMapManager.getInstance().getLocationMessage(new BaiDuMapManager.OnLocationMessageGetListener() { + @Override + public void onReceiveLocation(final String cityName, double lon, double lat) { + runOnUiThread(new Runnable() { + @Override + public void run() { + showToast(cityName); + } + }); + } + }); GetSmsCodeReqDto reqDto = new GetSmsCodeReqDto(); reqDto.setUserMobile("18521709590"); @@ -34,9 +50,9 @@ protected void onCreate(Bundle savedInstanceState) { UrlService.SERVICE.smsCode(reqDto.toEncodeString()) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) - .subscribe(new ResponseSubscriber(this, true) { + .subscribe(new ResponseSubscriber(this, true) { @Override - public void onSuccess(Object loginResponseDto) throws Exception { + public void onSuccess(String loginResponseDto) throws Exception { super.onSuccess(loginResponseDto); showToast("验证码已发送"); } @@ -48,23 +64,6 @@ public void onFailure(int code, String message) throws Exception { } }); - - showToast(AppDeviceInfo.getNetworkType()); - - BaiDuMapManager.getInstance().getLocationMessage(new BaiDuMapManager.OnLocationMessageGetListener() { - @Override - public void onReceiveLocation(final String cityName, double lon, double lat) { - runOnUiThread(new Runnable() { - @Override - public void run() { - showToast(cityName); - } - }); - } - }); - - - // RegisterRequestDto dto = new RegisterRequestDto(); // dto.setUserId("123"); // dto.setNickname("wzf"); diff --git a/app/src/main/java/com/wzf/boardgame/ui/activity/RegisterActivity.java b/app/src/main/java/com/wzf/boardgame/ui/activity/RegisterActivity.java index ea8a23f..3777a1b 100644 --- a/app/src/main/java/com/wzf/boardgame/ui/activity/RegisterActivity.java +++ b/app/src/main/java/com/wzf/boardgame/ui/activity/RegisterActivity.java @@ -91,9 +91,9 @@ private void getSmsCode() { OkHttpUtils.getInstance().getUrlService(UrlService.class).smsCode(reqDto.toEncodeString()) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) - .subscribe(new ResponseSubscriber(this, true) { + .subscribe(new ResponseSubscriber(this, true) { @Override - public void onSuccess(Object loginResponseDto) throws Exception { + public void onSuccess(String loginResponseDto) throws Exception { showToast("验证码已发送"); } diff --git a/app/src/main/res/drawable/shape_blue_8.xml b/app/src/main/res/drawable/shape_blue_8.xml new file mode 100644 index 0000000..33ca876 --- /dev/null +++ b/app/src/main/res/drawable/shape_blue_8.xml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..10b75ba --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + +