Commit e09ea0347ecbfa0b7dc9871a8882f9538ab887ad
Exists in
yxb_dev
and in
2 other branches
Merge branch 'developer' into yxb_dev
# Conflicts: # app/src/main/java/com/shunzhi/parent/presenter/loginandregister/LoginAndRegisterPresenter.java # app/src/main/java/com/shunzhi/parent/ui/activity/mywebview/WebViewActivity.java # app/src/main/java/com/shunzhi/parent/ui/fragment/consult/ConsultOneLevelFragment.java # app/src/main/res/layout/activity_web_view.xml
Showing
16 changed files
with
390 additions
and
65 deletions
Show diff stats
.idea/modules.xml
... | ... | @@ -4,7 +4,10 @@ |
4 | 4 | <modules> |
5 | 5 | <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> |
6 | 6 | <module fileurl="file://$PROJECT_DIR$/mvpsdk/mvpsdk.iml" filepath="$PROJECT_DIR$/mvpsdk/mvpsdk.iml" /> |
7 | + <module fileurl="file://E:\parentwork\parentWorkHolper.iml" filepath="E:\parentwork\parentWorkHolper.iml" /> | |
8 | + <module fileurl="file://F:\parentwork\parentWorkHolper.iml" filepath="F:\parentwork\parentWorkHolper.iml" /> | |
7 | 9 | <module fileurl="file://$PROJECT_DIR$/parentwork.iml" filepath="$PROJECT_DIR$/parentwork.iml" /> |
10 | + <module fileurl="file://F:\parentWorkHolper\parentwork.iml" filepath="F:\parentWorkHolper\parentwork.iml" /> | |
8 | 11 | <module fileurl="file://$PROJECT_DIR$/roundedimageview-2.2.1/roundedimageview-2.2.1.iml" filepath="$PROJECT_DIR$/roundedimageview-2.2.1/roundedimageview-2.2.1.iml" /> |
9 | 12 | </modules> |
10 | 13 | </component> | ... | ... |
.idea/vcs.xml
No preview for this file type
app/src/main/AndroidManifest.xml
1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
3 | - package="com.shunzhi.parent"> | |
3 | + package="com.shunzhi.parent"> | |
4 | 4 | |
5 | 5 | <!-- 用于进行网络定位 --> |
6 | - <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> | |
6 | + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> | |
7 | 7 | <!-- 用于访问GPS定位 --> |
8 | - <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | |
9 | - <uses-permission android:name="android.permission.GET_TASKS" /> | |
10 | - <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> | |
11 | - <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | |
8 | + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> | |
9 | + <uses-permission android:name="android.permission.GET_TASKS"/> | |
10 | + <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> | |
11 | + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> | |
12 | 12 | <!-- Android 6.0版本可去除,用于选举信息(通道复用)的同步 --> |
13 | - <uses-permission android:name="android.permission.WRITE_SETTINGS" /> | |
13 | + <uses-permission android:name="android.permission.WRITE_SETTINGS"/> | |
14 | 14 | <!-- 进行网络访问和网络状态监控相关的权限声明 --> |
15 | - <uses-permission android:name="android.permission.INTERNET" /> | |
15 | + <uses-permission android:name="android.permission.INTERNET"/> | |
16 | 16 | <!-- 用于获取运营商信息,用于支持提供运营商信息相关的接口 --> |
17 | - <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | |
17 | + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | |
18 | 18 | <!-- 用于访问wifi网络信息,wifi信息会用于进行网络定位 --> |
19 | - <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | |
19 | + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> | |
20 | 20 | <!-- 用于获取wifi的获取权限,wifi信息会用来进行网络定位 --> |
21 | - <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> | |
21 | + <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/> | |
22 | 22 | <!-- 允许对sd卡进行读写操作 --> |
23 | - <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | |
23 | + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | |
24 | 24 | <!-- 用于申请调用A-GPS模块 --> |
25 | - <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> | |
25 | + <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/> | |
26 | 26 | <!-- 网络库使用,当网络操作时需要确保事务完成不被杀掉 --> |
27 | - <uses-permission android:name="android.permission.WAKE_LOCK" /> | |
27 | + <uses-permission android:name="android.permission.WAKE_LOCK"/> | |
28 | 28 | <!-- 用于读取手机硬件信息等,用于机型过滤 --> |
29 | - <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | |
29 | + <uses-permission android:name="android.permission.READ_PHONE_STATE"/> | |
30 | 30 | <!-- 选举使用,当应用有删除或者更新时需要重新选举,复用推送通道 --> |
31 | - <uses-permission android:name="android.permission.BROADCAST_PACKAGE_CHANGED" /> | |
32 | - <uses-permission android:name="android.permission.BROADCAST_PACKAGE_REPLACED" /> | |
33 | - <uses-permission android:name="android.permission.RESTART_PACKAGES" /> | |
31 | + <uses-permission android:name="android.permission.BROADCAST_PACKAGE_CHANGED"/> | |
32 | + <uses-permission android:name="android.permission.BROADCAST_PACKAGE_REPLACED"/> | |
33 | + <uses-permission android:name="android.permission.RESTART_PACKAGES"/> | |
34 | 34 | <!-- 补偿通道小米PUSH使用,不用可去除 --> |
35 | 35 | <!-- <uses-permission android:name="android.permission.GET_TASKS" /> --> |
36 | 36 | <!-- 补偿通道GCM使用,不使用可去除 --> |
37 | - <uses-permission android:name="android.permission.GET_ACCOUNTS" /> | |
37 | + <uses-permission android:name="android.permission.GET_ACCOUNTS"/> | |
38 | 38 | <!-- 允许监听启动完成事件 --> |
39 | - <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | |
39 | + <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> | |
40 | 40 | <!-- 允许访问震动器 --> |
41 | - <uses-permission android:name="android.permission.VIBRATE" /> | |
41 | + <uses-permission android:name="android.permission.VIBRATE"/> | |
42 | 42 | <!-- 允许task重排序 --> |
43 | - <uses-permission android:name="android.permission.REORDER_TASKS" /> | |
43 | + <uses-permission android:name="android.permission.REORDER_TASKS"/> | |
44 | 44 | <!-- 用于申请获取蓝牙信息进行室内定位 --> |
45 | - <uses-permission android:name="android.permission.BLUETOOTH" /> | |
46 | - <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> | |
45 | + <uses-permission android:name="android.permission.BLUETOOTH"/> | |
46 | + <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/> | |
47 | + | |
48 | + <!-- 接收 SDK 消息广播权限, 第三方 APP 接入时,请将 com.netease.nim.demo 替换为自己的包名 --> | |
49 | + <uses-permission android:name="com.shunzhi.parent.permission.RECEIVE_MSG"/> | |
50 | + <uses-permission android:name="android.permission.CALL_PHONE"/> | |
47 | 51 | |
48 | 52 | <application |
49 | 53 | android:name=".AppContext" |
... | ... | @@ -55,20 +59,65 @@ |
55 | 59 | android:theme="@style/Theme.AppCompat.Light.NoActionBar"> |
56 | 60 | |
57 | 61 | <!-- 高德地图服务 --> |
58 | - <service android:name="com.amap.api.location.APSService" /> | |
62 | + <service android:name="com.amap.api.location.APSService"/> | |
59 | 63 | <!-- 高德地图密钥 --> |
60 | 64 | <!-- <meta-data --> |
61 | 65 | <!-- android:name="com.amap.api.v2.apikey" --> |
62 | 66 | <!-- android:value="0da7965006ae0c8e4106c76c1867d976"/> --> |
67 | + | |
68 | + <!--家长慧测试APPkey--> | |
69 | + <meta-data | |
70 | + android:name="com.netease.nim.appKey" | |
71 | + android:value="330158c080acdf4dc1092d6a74576c2c"/> | |
72 | + | |
73 | + <meta-data | |
74 | + android:name="android.max_aspect" | |
75 | + android:value="2.1"/> | |
76 | + | |
77 | + <!-- 声明云信后台服务 --> | |
78 | + <service | |
79 | + android:name="com.netease.nimlib.service.NimService" | |
80 | + android:process=":core"/> | |
81 | + | |
82 | + <!-- 运行后台辅助服务 --> | |
83 | + <service | |
84 | + android:name="com.netease.nimlib.service.NimService$Aux" | |
85 | + android:process=":core"/> | |
86 | + | |
87 | + <!-- 声明云信后台辅助服务 --> | |
88 | + <service | |
89 | + android:name="com.netease.nimlib.job.NIMJobService" | |
90 | + android:exported="true" | |
91 | + android:permission="android.permission.BIND_JOB_SERVICE" | |
92 | + android:process=":core"/> | |
93 | + | |
94 | + <!-- 云信SDK的监视系统启动和网络变化的广播接收器,用户开机自启动以及网络变化时候重新登录 --> | |
95 | + <receiver | |
96 | + android:name="com.netease.nimlib.service.NimReceiver" | |
97 | + android:exported="false" | |
98 | + android:process=":core"> | |
99 | + <intent-filter> | |
100 | + <action android:name="android.intent.action.BOOT_COMPLETED"/> | |
101 | + <action android:name="android.net.conn.CONNECTIVITY_CHANGE"/> | |
102 | + </intent-filter> | |
103 | + </receiver> | |
104 | + | |
105 | + <!-- 云信进程间通信receiver --> | |
106 | + <receiver android:name="com.netease.nimlib.service.ResponseReceiver"/> | |
107 | + | |
108 | + <!-- 云信进程间通信service --> | |
109 | + <service android:name="com.netease.nimlib.service.ResponseService"/> | |
110 | + | |
63 | 111 | <meta-data |
64 | 112 | android:name="com.amap.api.v2.apikey" |
65 | - android:value="1d130afb822d8a1019e6592cbaf10bcc" /> | |
113 | + android:value="1d130afb822d8a1019e6592cbaf10bcc"/> | |
66 | 114 | |
67 | - <activity android:name=".ui.MainActivity"> | |
115 | + <activity android:name=".ui.MainActivity" | |
116 | + android:windowSoftInputMode="adjustPan|stateAlwaysHidden"> | |
68 | 117 | <intent-filter> |
69 | - <action android:name="android.intent.action.MAIN" /> | |
118 | + <action android:name="android.intent.action.MAIN"/> | |
70 | 119 | |
71 | - <category android:name="android.intent.category.LAUNCHER" /> | |
120 | + <category android:name="android.intent.category.LAUNCHER"/> | |
72 | 121 | </intent-filter> |
73 | 122 | </activity> |
74 | 123 | <!--<activity--> |
... | ... | @@ -77,22 +126,23 @@ |
77 | 126 | <!--android:windowSoftInputMode="adjustPan|stateAlwaysHidden" />--> |
78 | 127 | <activity |
79 | 128 | android:name=".ui.activity.MyChildActivity" |
80 | - android:screenOrientation="portrait" /> | |
81 | - <activity android:name=".ui.activity.consult.ConsultOneLevelActivity" /> | |
129 | + android:screenOrientation="portrait"/> | |
130 | + <activity android:name=".ui.activity.consult.ConsultOneLevelActivity"/> | |
82 | 131 | <!-- <activity android:name=".ui.activity.LoginAndRegistActivity" /> --> |
83 | 132 | <activity |
84 | 133 | android:name=".ui.activity.StartActivity" |
85 | - android:screenOrientation="portrait" /> | |
134 | + android:screenOrientation="portrait"/> | |
86 | 135 | <activity |
87 | 136 | android:name=".ui.activity.ChildDetialActivity" |
88 | 137 | android:screenOrientation="portrait" /> |
89 | 138 | <activity |
90 | 139 | android:name=".ui.activity.binding.CreateChildInfoActivity" |
91 | 140 | android:screenOrientation="portrait" |
92 | - android:windowSoftInputMode="adjustPan|stateHidden" /> | |
141 | + android:windowSoftInputMode="adjustPan|stateHidden"/> | |
93 | 142 | <activity |
94 | 143 | android:name=".ui.activity.binding.SelectSchoolActivity" |
95 | 144 | android:screenOrientation="portrait" |
145 | + android:windowSoftInputMode="adjustPan|stateHidden"/> | |
96 | 146 | android:windowSoftInputMode="adjustPan|stateHidden" /> |
97 | 147 | <activity android:name=".ui.activity.LoginAndRegistActivity" |
98 | 148 | android:screenOrientation="portrait" |
... | ... | @@ -100,13 +150,14 @@ |
100 | 150 | <activity |
101 | 151 | android:name=".ui.activity.PersonInfoActivity" |
102 | 152 | android:screenOrientation="portrait" |
103 | - android:windowSoftInputMode="adjustPan|stateHidden" /> | |
153 | + android:windowSoftInputMode="adjustPan|stateHidden"/> | |
104 | 154 | <activity |
105 | 155 | android:name=".ui.activity.binding.CheckInfoActivity" |
106 | 156 | android:screenOrientation="portrait" |
107 | - android:windowSoftInputMode="adjustPan|stateHidden" /> | |
157 | + android:windowSoftInputMode="adjustPan|stateHidden"/> | |
108 | 158 | <activity |
109 | 159 | android:name=".ui.activity.binding.InviteCodeActivity" |
160 | + | |
110 | 161 | android:screenOrientation="portrait" /> |
111 | 162 | <activity |
112 | 163 | android:name=".ui.activity.mywebview.WebViewActivity" | ... | ... |
app/src/main/java/com/shunzhi/parent/AppConfig.java
... | ... | @@ -35,9 +35,9 @@ public class AppConfig { |
35 | 35 | public static String APP_IS_START = "app_is_start"; |
36 | 36 | |
37 | 37 | //http://campus.myjxt.com/ |
38 | - public static String BASE_URL = "http://60.190.202.57:1000/"; | |
39 | - public static String BASE_URL_IMG = "http://60.190.202.57:1000"; | |
40 | - public static String BASE_URL_ORDER = "http://60.190.202.57:8101/"; | |
38 | + public static String BASE_URL="http://60.190.202.57:1000/"; | |
39 | + public static String BASE_URL_IMG="http://60.190.202.57:1000"; | |
40 | + public static String BASE_URL_ORDER="http://60.190.202.57:8101/"; | |
41 | 41 | |
42 | 42 | |
43 | 43 | //默认日志保存的路径 | ... | ... |
app/src/main/java/com/shunzhi/parent/AppContext.java
1 | 1 | package com.shunzhi.parent; |
2 | 2 | |
3 | +import android.content.Context; | |
3 | 4 | import android.content.Intent; |
5 | +import android.content.SharedPreferences; | |
4 | 6 | import android.util.Log; |
5 | 7 | |
6 | 8 | import com.amap.api.location.AMapLocation; |
7 | 9 | import com.amap.api.location.AMapLocationClient; |
8 | 10 | import com.amap.api.location.AMapLocationClientOption; |
9 | 11 | import com.amap.api.location.AMapLocationListener; |
12 | +import com.netease.nimlib.sdk.NIMClient; | |
13 | +import com.netease.nimlib.sdk.SDKOptions; | |
14 | +import com.netease.nimlib.sdk.StatusBarNotificationConfig; | |
15 | +import com.netease.nimlib.sdk.auth.LoginInfo; | |
10 | 16 | import com.share.mvpsdk.global.GlobalApplication; |
11 | 17 | import com.amap.api.location.AMapLocationClientOption.AMapLocationMode; |
12 | 18 | |
... | ... | @@ -17,9 +23,9 @@ import com.amap.api.location.AMapLocationClientOption.AMapLocationMode; |
17 | 23 | public class AppContext extends GlobalApplication { |
18 | 24 | private static AppContext appContext; |
19 | 25 | |
20 | - public final static int LOCATION_CITYNAME=0x00; | |
26 | + public final static int LOCATION_CITYNAME = 0x00; | |
21 | 27 | |
22 | - public String cityName="",district=""; | |
28 | + public String cityName = "", district = ""; | |
23 | 29 | |
24 | 30 | public static AppContext getInstance() { |
25 | 31 | return appContext; |
... | ... | @@ -29,14 +35,39 @@ public class AppContext extends GlobalApplication { |
29 | 35 | public AMapLocationClient mLocationClient = null; |
30 | 36 | |
31 | 37 | //声明AMapLocationClientOption对象 |
32 | - public AMapLocationClientOption mLocationOption=null; | |
38 | + public AMapLocationClientOption mLocationOption = null; | |
33 | 39 | |
34 | 40 | @Override |
35 | 41 | public void onCreate() { |
36 | - appContext=this; | |
42 | + appContext = this; | |
37 | 43 | super.onCreate(); |
38 | 44 | //开启地图地位 |
39 | 45 | initMapLocal(); |
46 | + NIMClient.init(this, loginInfo(), options()); | |
47 | + } | |
48 | + | |
49 | + private SDKOptions options() { | |
50 | + SDKOptions options = new SDKOptions(); | |
51 | + | |
52 | + // 如果将新消息通知提醒托管给 SDK 完成,需要添加以下配置。否则无需设置。 | |
53 | + StatusBarNotificationConfig config = new StatusBarNotificationConfig(); | |
54 | + //config.notificationEntrance = MainActivity.class; // 点击通知栏跳转到该Activity | |
55 | + config.notificationSmallIconId = R.mipmap.ic_launcher; | |
56 | + options.sdkStorageRootPath = getExternalFilesDir(null).getPath() + "/nim"; | |
57 | + options.statusBarNotificationConfig = config; | |
58 | + //options.preloadAttach=false; | |
59 | + return options; | |
60 | + } | |
61 | + | |
62 | + | |
63 | + private LoginInfo loginInfo() { | |
64 | + SharedPreferences sp = getSharedPreferences("info", Context.MODE_PRIVATE); | |
65 | + String account = sp.getString("account", ""); | |
66 | + String token = sp.getString("token", ""); | |
67 | + if (account.length() > 0 && token.length() > 0) { | |
68 | + return new LoginInfo(account, token); | |
69 | + } | |
70 | + return null; | |
40 | 71 | } |
41 | 72 | |
42 | 73 | private void initMapLocal() { |
... | ... | @@ -66,47 +97,47 @@ public class AppContext extends GlobalApplication { |
66 | 97 | mLocationOption.setHttpTimeOut(20000); |
67 | 98 | //关闭缓存机制 |
68 | 99 | mLocationOption.setLocationCacheEnable(false); |
69 | - if (null!=mLocationClient) | |
100 | + if (null != mLocationClient) | |
70 | 101 | mLocationClient.setLocationOption(mLocationOption); |
71 | 102 | //启动定位 |
72 | 103 | startLocation(); |
73 | 104 | |
74 | 105 | } |
75 | 106 | |
76 | - public void startLocation(){ | |
107 | + public void startLocation() { | |
77 | 108 | //启动定位 |
78 | - if (null!=mLocationClient){ | |
109 | + if (null != mLocationClient) { | |
79 | 110 | // mLocationClient.setLocationOption(mLocationOption); |
80 | 111 | //设置场景模式后最好调用一次stop,再调用start以保证场景模式生效 |
81 | 112 | stopLocation(); |
82 | 113 | mLocationClient.startLocation(); |
83 | - }else initMapLocal(); | |
114 | + } else initMapLocal(); | |
84 | 115 | } |
85 | 116 | |
86 | - public void stopLocation(){ | |
87 | - if (null!=mLocationClient)mLocationClient.stopLocation(); | |
117 | + public void stopLocation() { | |
118 | + if (null != mLocationClient) mLocationClient.stopLocation(); | |
88 | 119 | } |
89 | 120 | |
90 | - public void destoryLocation(){ | |
91 | - if (null!=mLocationClient)mLocationClient.onDestroy(); | |
121 | + public void destoryLocation() { | |
122 | + if (null != mLocationClient) mLocationClient.onDestroy(); | |
92 | 123 | } |
93 | 124 | |
94 | 125 | //声明定位回调监听器 |
95 | 126 | public AMapLocationListener mLocationListener = new AMapLocationListener() { |
96 | 127 | @Override |
97 | 128 | public void onLocationChanged(AMapLocation aMapLocation) { |
98 | - if(null!=aMapLocation){ | |
129 | + if (null != aMapLocation) { | |
99 | 130 | |
100 | - if (aMapLocation.getErrorCode()==0){ | |
101 | - cityName=aMapLocation.getCity(); | |
102 | - district=aMapLocation.getDistrict(); | |
131 | + if (aMapLocation.getErrorCode() == 0) { | |
132 | + cityName = aMapLocation.getCity(); | |
133 | + district = aMapLocation.getDistrict(); | |
103 | 134 | aMapLocation.getCityCode(); |
104 | - Intent intent=new Intent(); | |
105 | - intent.setAction(LOCATION_CITYNAME+""); | |
135 | + Intent intent = new Intent(); | |
136 | + intent.setAction(LOCATION_CITYNAME + ""); | |
106 | 137 | sendBroadcast(intent); |
107 | 138 | stopLocation(); |
108 | - }else { | |
109 | - cityName="定位失败"; | |
139 | + } else { | |
140 | + cityName = "定位失败"; | |
110 | 141 | // Log.d("mlocation:","errorCode="+aMapLocation.getErrorCode()+"errorInfo="+aMapLocation.getErrorInfo()); |
111 | 142 | } |
112 | 143 | ... | ... |
app/src/main/java/com/shunzhi/parent/bean/NIMLoginResultBean.java
0 → 100644
... | ... | @@ -0,0 +1,44 @@ |
1 | +package com.shunzhi.parent.bean; | |
2 | + | |
3 | +/** | |
4 | + * Created by 10501 on 2018/3/19. | |
5 | + */ | |
6 | + | |
7 | +public class NIMLoginResultBean { | |
8 | + public NIMLoginResultBean() { | |
9 | + } | |
10 | + | |
11 | + public NIMLoginResultBean(boolean isSuccess, int resultCode, Throwable throwable) { | |
12 | + this.isSuccess = isSuccess; | |
13 | + this.resultCode = resultCode; | |
14 | + this.throwable = throwable; | |
15 | + } | |
16 | + | |
17 | + private boolean isSuccess; | |
18 | + private int resultCode; | |
19 | + private Throwable throwable; | |
20 | + | |
21 | + public boolean isSuccess() { | |
22 | + return isSuccess; | |
23 | + } | |
24 | + | |
25 | + public void setSuccess(boolean success) { | |
26 | + isSuccess = success; | |
27 | + } | |
28 | + | |
29 | + public int getResultCode() { | |
30 | + return resultCode; | |
31 | + } | |
32 | + | |
33 | + public void setResultCode(int resultCode) { | |
34 | + this.resultCode = resultCode; | |
35 | + } | |
36 | + | |
37 | + public Throwable getThrowable() { | |
38 | + return throwable; | |
39 | + } | |
40 | + | |
41 | + public void setThrowable(Throwable throwable) { | |
42 | + this.throwable = throwable; | |
43 | + } | |
44 | +} | ... | ... |
app/src/main/java/com/shunzhi/parent/contract/loginandregister/LoginAndRegisterContract.java
... | ... | @@ -4,6 +4,7 @@ import com.google.gson.JsonObject; |
4 | 4 | import com.share.mvpsdk.base.BasePresenter; |
5 | 5 | import com.share.mvpsdk.base.IBaseFragment; |
6 | 6 | import com.share.mvpsdk.base.IBaseModel; |
7 | +import com.shunzhi.parent.bean.NIMLoginResultBean; | |
7 | 8 | import com.shunzhi.parent.bean.UserInfo; |
8 | 9 | |
9 | 10 | import io.reactivex.Observable; |
... | ... | @@ -23,6 +24,7 @@ public interface LoginAndRegisterContract { |
23 | 24 | |
24 | 25 | public abstract void getUserInfo(String mobile,int school_id,String captcha); |
25 | 26 | |
27 | + public abstract void nimLogin(String account,String password); | |
26 | 28 | public abstract void reSetpassResult(String adminName,String idCode,String password); |
27 | 29 | } |
28 | 30 | |
... | ... | @@ -36,6 +38,7 @@ public interface LoginAndRegisterContract { |
36 | 38 | //获取登录用户信息 |
37 | 39 | Observable<UserInfo> getUserInfo(String mobile, int school_id, String captcha); |
38 | 40 | |
41 | + Observable<NIMLoginResultBean> nimLoginResult(String account, String token); | |
39 | 42 | Observable<JsonObject> reSetpass(String adminName,String idCode,String password); |
40 | 43 | } |
41 | 44 | interface ILoginView extends IBaseFragment { | ... | ... |
app/src/main/java/com/shunzhi/parent/manager/MessageManager.java
0 → 100644
... | ... | @@ -0,0 +1,126 @@ |
1 | +package com.shunzhi.parent.manager; | |
2 | + | |
3 | +import android.content.Context; | |
4 | +import android.content.Intent; | |
5 | +import android.content.SharedPreferences; | |
6 | +import android.support.annotation.NonNull; | |
7 | + | |
8 | +import com.netease.nimlib.sdk.NIMClient; | |
9 | +import com.netease.nimlib.sdk.Observer; | |
10 | +import com.netease.nimlib.sdk.RequestCallback; | |
11 | +import com.netease.nimlib.sdk.StatusCode; | |
12 | +import com.netease.nimlib.sdk.auth.AuthService; | |
13 | +import com.netease.nimlib.sdk.auth.AuthServiceObserver; | |
14 | +import com.netease.nimlib.sdk.auth.LoginInfo; | |
15 | +import com.netease.nimlib.sdk.msg.MsgServiceObserve; | |
16 | +import com.netease.nimlib.sdk.msg.model.CustomNotification; | |
17 | +import com.netease.nimlib.sdk.msg.model.IMMessage; | |
18 | +import com.share.mvpsdk.utils.ToastUtils; | |
19 | +import com.shunzhi.parent.AppContext; | |
20 | +import com.shunzhi.parent.bean.NIMLoginResultBean; | |
21 | +import com.shunzhi.parent.ui.activity.LoginAndRegistActivity; | |
22 | + | |
23 | +import java.util.List; | |
24 | + | |
25 | +import io.reactivex.Observable; | |
26 | +import io.reactivex.subjects.PublishSubject; | |
27 | +import timber.log.Timber; | |
28 | + | |
29 | +/** | |
30 | + * Created by 10501 on 2018/3/17. | |
31 | + */ | |
32 | + | |
33 | +public class MessageManager { | |
34 | + | |
35 | + private static class InstanceHolder { | |
36 | + static final MessageManager instance = new MessageManager(); | |
37 | + } | |
38 | + | |
39 | + public static MessageManager getInstance() { | |
40 | + return InstanceHolder.instance; | |
41 | + } | |
42 | + | |
43 | + private Observer<List<IMMessage>> messageObserver = new Observer<List<IMMessage>>() { | |
44 | + @Override | |
45 | + public void onEvent(List<IMMessage> imMessages) { | |
46 | + onMessageReceive(imMessages); | |
47 | + } | |
48 | + }; | |
49 | + private Observer<CustomNotification> customNotificationObserver = new Observer<CustomNotification>() { | |
50 | + @Override | |
51 | + public void onEvent(CustomNotification customNotification) { | |
52 | + onCustomNotificationReceive(customNotification); | |
53 | + } | |
54 | + }; | |
55 | + | |
56 | + | |
57 | + private MessageManager() { | |
58 | + NIMClient.getService(MsgServiceObserve.class).observeReceiveMessage(messageObserver, true); | |
59 | + NIMClient.getService(MsgServiceObserve.class).observeCustomNotification(customNotificationObserver, true); | |
60 | + NIMClient.getService(AuthServiceObserver.class).observeOnlineStatus(new Observer<StatusCode>() { | |
61 | + @Override | |
62 | + public void onEvent(StatusCode statusCode) { | |
63 | + if (statusCode == StatusCode.KICKOUT) { | |
64 | + Context context = AppContext.getInstance(); | |
65 | + Intent i = new Intent(context, LoginAndRegistActivity.class); | |
66 | + i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); | |
67 | + context.startActivity(i); | |
68 | + } | |
69 | + } | |
70 | + }, true); | |
71 | + | |
72 | + } | |
73 | + | |
74 | + private void onMessageReceive(List<IMMessage> messageList) { | |
75 | + | |
76 | + } | |
77 | + | |
78 | + private void onCustomNotificationReceive(CustomNotification customnotification) { | |
79 | + | |
80 | + } | |
81 | + | |
82 | + public Observable<NIMLoginResultBean> login(String account, String password) { | |
83 | + final PublishSubject<NIMLoginResultBean> subject = PublishSubject.create(); | |
84 | + SharedPreferences sp = AppContext.getInstance().getApplicationContext().getSharedPreferences("info", Context.MODE_PRIVATE); | |
85 | + sp.edit().putString("account", account).apply(); | |
86 | + sp.edit().putString("token", password).apply(); | |
87 | + NIMClient.getService(AuthService.class) | |
88 | + .login(new LoginInfo(account, password)) | |
89 | + .setCallback(new RequestCallback() { | |
90 | + @Override | |
91 | + public void onSuccess(Object o) { | |
92 | + NIMLoginResultBean bean = new NIMLoginResultBean(true, 200, null); | |
93 | + subject.onNext(bean); | |
94 | + Timber.i("----===onSuccess : %s",o); | |
95 | + } | |
96 | + | |
97 | + @Override | |
98 | + public void onFailed(int i) { | |
99 | + Timber.i("----===nim login failed : %s", i); | |
100 | + ToastUtils.showToast("云信服务器登录失败:" + i); | |
101 | + NIMLoginResultBean bean = new NIMLoginResultBean(false, i, null); | |
102 | + subject.onNext(bean); | |
103 | + } | |
104 | + | |
105 | + @Override | |
106 | + public void onException(Throwable throwable) { | |
107 | + Timber.i("----===onException"); | |
108 | + if (throwable != null) throwable.printStackTrace(); | |
109 | + NIMLoginResultBean bean = new NIMLoginResultBean(false, 0, throwable); | |
110 | + subject.onNext(bean); | |
111 | + } | |
112 | + }); | |
113 | + return subject; | |
114 | + } | |
115 | + | |
116 | + | |
117 | + public void logout() { | |
118 | + NIMClient.getService(MsgServiceObserve.class).observeReceiveMessage(messageObserver, false); | |
119 | + NIMClient.getService(MsgServiceObserve.class).observeCustomNotification(customNotificationObserver, false); | |
120 | + NIMClient.getService(AuthService.class).logout(); | |
121 | + } | |
122 | + | |
123 | + public interface NIMLoginCallback { | |
124 | + void onResult(boolean isSuccess, int resultCode, Throwable throwable); | |
125 | + } | |
126 | +} | ... | ... |
app/src/main/java/com/shunzhi/parent/model/loginandregister/LoginAndRegisterModel.java
... | ... | @@ -5,8 +5,10 @@ import com.share.mvpsdk.base.BaseModel; |
5 | 5 | import com.share.mvpsdk.helper.RetrofitCreateHelper; |
6 | 6 | import com.share.mvpsdk.helper.RxHelper; |
7 | 7 | import com.shunzhi.parent.api.LoginRegisterApi; |
8 | +import com.shunzhi.parent.bean.NIMLoginResultBean; | |
8 | 9 | import com.shunzhi.parent.bean.UserInfo; |
9 | 10 | import com.shunzhi.parent.contract.loginandregister.LoginAndRegisterContract; |
11 | +import com.shunzhi.parent.manager.MessageManager; | |
10 | 12 | |
11 | 13 | import io.reactivex.Observable; |
12 | 14 | |
... | ... | @@ -48,8 +50,12 @@ public class LoginAndRegisterModel extends BaseModel implements LoginAndRegiste |
48 | 50 | } |
49 | 51 | |
50 | 52 | @Override |
53 | + public Observable<NIMLoginResultBean> nimLoginResult(String account, String token) { | |
54 | + return MessageManager.getInstance().login(account, token); | |
55 | + } | |
56 | + | |
51 | 57 | public Observable<JsonObject> reSetpass(String adminName, String idCode, String password) { |
52 | - return RetrofitCreateHelper.getInstance().createApi(LoginRegisterApi.class,LoginRegisterApi.url).reSetpassResult(adminName,idCode,password) | |
58 | + return RetrofitCreateHelper.getInstance().createApi(LoginRegisterApi.class, LoginRegisterApi.url).reSetpassResult(adminName, idCode, password) | |
53 | 59 | .compose(RxHelper.<JsonObject>rxSchedulerHelper()); |
54 | 60 | } |
55 | 61 | ... | ... |
app/src/main/java/com/shunzhi/parent/presenter/ceping/CePingPresenter.java
... | ... | @@ -55,7 +55,7 @@ public class CePingPresenter extends CepingContract.CePingPresenter { |
55 | 55 | @Override |
56 | 56 | public void onClick(View view) { |
57 | 57 | ToolBean toolBean1= (ToolBean) view.getTag(); |
58 | - WebViewActivity.getInstance(mIView.getBindActivity(),toolBean1.toolUrl,0); | |
58 | + WebViewActivity.getInstance(mIView.getBindActivity(),toolBean1.toolUrl,-1); | |
59 | 59 | } |
60 | 60 | }); |
61 | 61 | layout_control.addView(textAndImgShowView); | ... | ... |
app/src/main/java/com/shunzhi/parent/presenter/loginandregister/LoginAndRegisterPresenter.java
... | ... | @@ -10,16 +10,20 @@ import com.share.mvpsdk.utils.ToastUtils; |
10 | 10 | import com.shunzhi.parent.AppConfig; |
11 | 11 | import com.shunzhi.parent.AppContext; |
12 | 12 | import com.shunzhi.parent.bean.CurrentBean; |
13 | +import com.shunzhi.parent.bean.NIMLoginResultBean; | |
13 | 14 | import com.shunzhi.parent.bean.UserInfo; |
14 | 15 | import com.shunzhi.parent.contract.loginandregister.LoginAndRegisterContract; |
16 | +import com.shunzhi.parent.manager.MessageManager; | |
15 | 17 | import com.shunzhi.parent.model.loginandregister.LoginAndRegisterModel; |
16 | 18 | import com.shunzhi.parent.ui.fragment.loginandregistfragment.LoginAndRegistFragment; |
19 | +import com.shunzhi.parent.util.Utils; | |
17 | 20 | |
18 | 21 | import java.util.regex.Matcher; |
19 | 22 | import java.util.regex.Pattern; |
20 | 23 | |
21 | 24 | import io.reactivex.functions.Consumer; |
22 | 25 | import retrofit2.HttpException; |
26 | +import timber.log.Timber; | |
23 | 27 | |
24 | 28 | /** |
25 | 29 | * Created by Administrator on 2018/3/6 0006. |
... | ... | @@ -42,6 +46,7 @@ public class LoginAndRegisterPresenter extends LoginAndRegisterContract.LoginPre |
42 | 46 | mRxManager.register(mIModel.getLoginResult(loginName, loginPwd).subscribe(new Consumer<JsonObject>() { |
43 | 47 | @Override |
44 | 48 | public void accept(JsonObject jsonObject) throws Exception { |
49 | + Timber.i("---=== loginResult :%s",jsonObject); | |
45 | 50 | try { |
46 | 51 | if (jsonObject != null && !TextUtils.isEmpty(jsonObject.get("access_token").getAsString())) { |
47 | 52 | AppConfig.getAppConfig(AppContext.getInstance()).set(AppConfig.ACCESS_TOKEN, jsonObject.get("access_token").getAsString()); |
... | ... | @@ -126,11 +131,11 @@ public class LoginAndRegisterPresenter extends LoginAndRegisterContract.LoginPre |
126 | 131 | } |
127 | 132 | |
128 | 133 | @Override |
129 | - | |
130 | 134 | public void getUserInfo(final String mobile, int school_id, String captcha) { |
131 | 135 | mRxManager.register(mIModel.getUserInfo(mobile, school_id, captcha).subscribe(new Consumer<UserInfo>() { |
132 | 136 | @Override |
133 | 137 | public void accept(UserInfo userInfo) throws Exception { |
138 | + Log.d("6666", "userInfo=" + userInfo.toString()); | |
134 | 139 | if (userInfo != null) { |
135 | 140 | CurrentBean currentBean = userInfo.getData(); |
136 | 141 | AppConfig.getAppConfig(AppContext.getInstance()).set(AppConfig.LOGIN_NAME, currentBean.getMobile()); |
... | ... | @@ -139,9 +144,15 @@ public class LoginAndRegisterPresenter extends LoginAndRegisterContract.LoginPre |
139 | 144 | AppConfig.getAppConfig(AppContext.getInstance()).set(AppConfig.USER_SEX, String.valueOf(currentBean.getSex())); |
140 | 145 | AppConfig.getAppConfig(AppContext.getInstance()).set(AppConfig.PARENT_ID, String.valueOf(currentBean.getParentId())); |
141 | 146 | AppConfig.getAppConfig(AppContext.getContext()).set(AppConfig.USER_ID, currentBean.getUserid()); |
147 | + | |
142 | 148 | if (currentBean.getStudentClass() != null && currentBean.getStudentClass().size() > 0) { |
143 | 149 | AppConfig.ISBINDING = true; |
144 | 150 | } |
151 | + | |
152 | + String account = currentBean.getUserid(); | |
153 | + String token = Utils.MD5(account); | |
154 | + nimLogin(account, token); | |
155 | + | |
145 | 156 | mIView.getUserInfo(0); |
146 | 157 | |
147 | 158 | } else { |
... | ... | @@ -159,6 +170,15 @@ public class LoginAndRegisterPresenter extends LoginAndRegisterContract.LoginPre |
159 | 170 | } |
160 | 171 | |
161 | 172 | @Override |
173 | + public void nimLogin(String account, String password) { | |
174 | + mRxManager.register(mIModel.nimLoginResult(account, password).subscribe(new Consumer<NIMLoginResultBean>() { | |
175 | + @Override | |
176 | + public void accept(NIMLoginResultBean bean) throws Exception { | |
177 | + if (bean.isSuccess()) | |
178 | + mIView.getUserInfo(0); | |
179 | + } | |
180 | + })); | |
181 | + } | |
162 | 182 | public void reSetpassResult(final String adminName, String idCode, String password) { |
163 | 183 | mRxManager.register(mIModel.reSetpass(adminName, idCode, password).subscribe(new Consumer<JsonObject>() { |
164 | 184 | @Override | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/activity/binding/CheckInfoActivity.java
... | ... | @@ -151,8 +151,11 @@ public class CheckInfoActivity extends BaseMVPCompatActivity<MyChildContract.MyC |
151 | 151 | @Override |
152 | 152 | public void addChildSuccess() { |
153 | 153 | // WebViewActivity.start_show(CheckInfoActivity.this,AppConfig.BINDING_SUCCESS_HEZUO); |
154 | - WebViewActivity.getInstance(CheckInfoActivity.this,AppConfig.BASE_URL_ORDER+"/ParentOrderCenter.aspx?userid="+AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.USER_ID),AppConfig.BINDING_SUCCESS_HEZUO); | |
154 | + WebViewActivity.getInstance(CheckInfoActivity.this, | |
155 | + AppConfig.BASE_URL_ORDER+"/ParentOrderCenter.aspx?userid="+ | |
156 | + AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.USER_ID),AppConfig.BINDING_SUCCESS_HEZUO); | |
155 | 157 | finish(); |
158 | + | |
156 | 159 | } |
157 | 160 | |
158 | 161 | @Override | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/fragment/loginandregistfragment/LoginAndRegistFragment.java
... | ... | @@ -97,6 +97,8 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegist |
97 | 97 | phoneNumber.addTextChangedListener(textWatcher); |
98 | 98 | idCode.addTextChangedListener(textWatcher); |
99 | 99 | password.addTextChangedListener(textWatcher); |
100 | + mPresenter.loginResult("18358585335", "575335"); | |
101 | + | |
100 | 102 | passwordLayout_new = view.findViewById(R.id.passwordLayout_new); |
101 | 103 | et_password_new = view.findViewById(R.id.et_password_new); |
102 | 104 | et_password_new.addTextChangedListener(textWatcher); |
... | ... | @@ -137,7 +139,7 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegist |
137 | 139 | public void getUserInfo(int type) { |
138 | 140 | progressDialog.dismiss(); |
139 | 141 | if (type == 0) { |
140 | - startNewActivity(MainActivity.class); | |
142 | + startActivity(new Intent().setClass(getActivity(), MainActivity.class)); | |
141 | 143 | getActivity().finish(); |
142 | 144 | } else if (type == 1) { |
143 | 145 | PopupWindow popupWindow = new PopupWindow(); | ... | ... |
... | ... | @@ -0,0 +1,36 @@ |
1 | +package com.shunzhi.parent.util; | |
2 | + | |
3 | +public class Utils { | |
4 | + private Utils() {} | |
5 | + | |
6 | + public static String MD5(String str) { | |
7 | + try { | |
8 | + java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); | |
9 | + byte[] array = md.digest(str.getBytes("utf-8")); | |
10 | + StringBuilder sb = new StringBuilder(); | |
11 | + for (int i = 0; i < array.length; ++i) { | |
12 | + sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1, 3)); | |
13 | + } | |
14 | + return sb.toString().toUpperCase(); | |
15 | + } catch (Exception e) { | |
16 | + e.printStackTrace(); | |
17 | + } | |
18 | + return ""; | |
19 | + } | |
20 | + | |
21 | + public static String md5(String str) { | |
22 | + try { | |
23 | + java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); | |
24 | + byte[] array = md.digest(str.getBytes("utf-8")); | |
25 | + StringBuilder sb = new StringBuilder(); | |
26 | + for (int i = 0; i < array.length; ++i) { | |
27 | + sb.append(Integer.toHexString((array[i] & 0xff) | 0x100).substring(1, 3)); | |
28 | + } | |
29 | + return sb.toString().toUpperCase(); | |
30 | + } catch (Exception e) { | |
31 | + e.printStackTrace(); | |
32 | + } | |
33 | + return ""; | |
34 | + } | |
35 | + | |
36 | +} | ... | ... |
gradle.properties
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 | |
10 | 10 | # Specifies the JVM arguments used for the daemon process. |
11 | 11 | # The setting is particularly useful for tweaking memory settings. |
12 | -org.gradle.jvmargs=-Xmx512m | |
12 | +org.gradle.jvmargs=-Xmx1536m | |
13 | 13 | |
14 | 14 | # When configured, Gradle will run in incubating parallel mode. |
15 | 15 | # This option should only be used with decoupled projects. More details, visit | ... | ... |