Commit 4f854ee0731bc03102ce2f5f1219f93c05e7597a

Authored by 张道锋
2 parents d96a7aeb 92beb983

no message

Showing 29 changed files with 1565 additions and 98 deletions   Show diff stats
.idea/modules.xml
... ... @@ -4,8 +4,8 @@
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://$PROJECT_DIR$/parentWorkHolper.iml" filepath="$PROJECT_DIR$/parentWorkHolper.iml" />
8 7 <module fileurl="file://E:\parentwork\parentWorkHolper.iml" filepath="E:\parentwork\parentWorkHolper.iml" />
  8 + <module fileurl="file://$PROJECT_DIR$/parentwork.iml" filepath="$PROJECT_DIR$/parentwork.iml" />
9 9 <module fileurl="file://F:\parentWorkHolper\parentwork.iml" filepath="F:\parentWorkHolper\parentwork.iml" />
10 10 <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" />
11 11 </modules>
... ...
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 47  
48 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"/>
  49 + <uses-permission android:name="com.shunzhi.parent.permission.RECEIVE_MSG" />
  50 + <uses-permission android:name="android.permission.CALL_PHONE" />
51 51  
52 52 <application
53 53 android:name=".AppContext"
... ... @@ -59,7 +59,7 @@
59 59 android:theme="@style/Theme.AppCompat.Light.NoActionBar">
60 60  
61 61 <!-- 高德地图服务 -->
62   - <service android:name="com.amap.api.location.APSService"/>
  62 + <service android:name="com.amap.api.location.APSService" />
63 63 <!-- 高德地图密钥 -->
64 64 <!-- <meta-data -->
65 65 <!-- android:name="com.amap.api.v2.apikey" -->
... ... @@ -74,27 +74,27 @@
74 74  
75 75 <meta-data
76 76 android:name="com.netease.nim.appKey"
77   - android:value="a1ff0bc08fa0d6f95b480d131e55584b"/>
  77 + android:value="a1ff0bc08fa0d6f95b480d131e55584b" />
78 78 <meta-data
79 79 android:name="android.max_aspect"
80   - android:value="2.1"/>
  80 + android:value="2.1" />
81 81  
82 82 <!-- 声明云信后台服务 -->
83 83 <service
84 84 android:name="com.netease.nimlib.service.NimService"
85   - android:process=":core"/>
  85 + android:process=":core" />
86 86  
87 87 <!-- 运行后台辅助服务 -->
88 88 <service
89 89 android:name="com.netease.nimlib.service.NimService$Aux"
90   - android:process=":core"/>
  90 + android:process=":core" />
91 91  
92 92 <!-- 声明云信后台辅助服务 -->
93 93 <service
94 94 android:name="com.netease.nimlib.job.NIMJobService"
95 95 android:exported="true"
96 96 android:permission="android.permission.BIND_JOB_SERVICE"
97   - android:process=":core"/>
  97 + android:process=":core" />
98 98  
99 99 <!-- 云信SDK的监视系统启动和网络变化的广播接收器,用户开机自启动以及网络变化时候重新登录 -->
100 100 <receiver
... ... @@ -102,29 +102,29 @@
102 102 android:exported="false"
103 103 android:process=":core">
104 104 <intent-filter>
105   - <action android:name="android.intent.action.BOOT_COMPLETED"/>
106   - <action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
  105 + <action android:name="android.intent.action.BOOT_COMPLETED" />
  106 + <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
107 107 </intent-filter>
108 108 </receiver>
109 109  
110 110 <!-- 云信进程间通信receiver -->
111   - <receiver android:name="com.netease.nimlib.service.ResponseReceiver"/>
  111 + <receiver android:name="com.netease.nimlib.service.ResponseReceiver" />
112 112  
113 113 <!-- 云信进程间通信service -->
114   - <service android:name="com.netease.nimlib.service.ResponseService"/>
  114 + <service android:name="com.netease.nimlib.service.ResponseService" />
115 115  
116 116 <meta-data
117 117 android:name="com.amap.api.v2.apikey"
118   - android:value="1d130afb822d8a1019e6592cbaf10bcc"/>
  118 + android:value="1d130afb822d8a1019e6592cbaf10bcc" />
119 119  
120 120 <activity
121 121 android:name=".ui.activity.StartActivity"
122 122 android:launchMode="singleInstance"
123 123 android:windowSoftInputMode="adjustPan|stateAlwaysHidden">
124 124 <intent-filter>
125   - <action android:name="android.intent.action.MAIN"/>
  125 + <action android:name="android.intent.action.MAIN" />
126 126  
127   - <category android:name="android.intent.category.LAUNCHER"/>
  127 + <category android:name="android.intent.category.LAUNCHER" />
128 128 </intent-filter>
129 129 </activity>
130 130 <!-- <activity -->
... ... @@ -137,63 +137,61 @@
137 137 <!-- android:windowSoftInputMode="adjustPan|stateAlwaysHidden" /> -->
138 138 <activity
139 139 android:name=".ui.activity.MyChildActivity"
140   - android:screenOrientation="portrait"/>
  140 + android:screenOrientation="portrait" />
141 141 <activity
142 142 android:name=".ui.activity.consult.ConsultOneLevelActivity"
143   - android:windowSoftInputMode="adjustPan|stateAlwaysHidden"/>
  143 + android:windowSoftInputMode="adjustPan|stateAlwaysHidden" />
144 144 <activity
145 145 android:name=".ui.MainActivity"
146   - android:screenOrientation="portrait"/>
  146 + android:screenOrientation="portrait" />
147 147 <activity
148 148 android:name=".ui.activity.ChildDetialActivity"
149 149 android:launchMode="singleInstance"
150   - android:screenOrientation="portrait"/>
  150 + android:screenOrientation="portrait" />
151 151 <activity
152 152 android:name=".ui.activity.binding.CreateChildInfoActivity"
153 153 android:launchMode="singleInstance"
154 154 android:screenOrientation="portrait"
155   - android:windowSoftInputMode="adjustPan|stateHidden"/>
  155 + android:windowSoftInputMode="adjustPan|stateHidden" />
156 156 <activity
157 157 android:name=".ui.activity.binding.SelectSchoolActivity"
158 158 android:screenOrientation="portrait"
159   - android:windowSoftInputMode="adjustPan|stateHidden"/>
  159 + android:windowSoftInputMode="adjustPan|stateHidden" />
160 160 <activity
161 161 android:name=".ui.activity.LoginAndRegistActivity"
162 162 android:screenOrientation="portrait"
163   - android:windowSoftInputMode="adjustPan|stateHidden"/>
  163 + android:windowSoftInputMode="adjustPan|stateHidden" />
164 164 <activity
165 165 android:name=".ui.activity.PersonInfoActivity"
166 166 android:launchMode="singleInstance"
167 167 android:screenOrientation="portrait"
168   - android:windowSoftInputMode="adjustPan|stateHidden"/>
  168 + android:windowSoftInputMode="adjustPan|stateHidden" />
169 169 <activity
170 170 android:name=".ui.activity.binding.CheckInfoActivity"
171 171 android:launchMode="singleInstance"
172 172 android:screenOrientation="portrait"
173   - android:windowSoftInputMode="adjustPan|stateHidden"/>
  173 + android:windowSoftInputMode="adjustPan|stateHidden" />
174 174 <activity
175 175 android:name=".ui.activity.binding.InviteCodeActivity"
176 176 android:launchMode="singleInstance"
177   - android:screenOrientation="portrait"/>
  177 + android:screenOrientation="portrait" />
178 178 <activity
179 179 android:name=".ui.activity.mywebview.WebViewActivity"
180 180 android:launchMode="singleInstance"
181   - android:screenOrientation="portrait"/>
  181 + android:screenOrientation="portrait" />
182 182 <activity
183 183 android:name=".ui.activity.consult.ConsultTwoLevelActivity"
184 184 android:launchMode="singleInstance"
185   - android:windowSoftInputMode="adjustPan|stateAlwaysHidden"/>
  185 + android:windowSoftInputMode="adjustPan|stateAlwaysHidden" />
186 186 <activity
187 187 android:name=".ui.activity.orderdetail.OrderDetailActivity"
188   - android:launchMode="singleInstance"/>
  188 + android:launchMode="singleInstance" />
189 189  
190 190 <service
191 191 android:name=".ui.service.BadgeIntentService"
192   - android:exported="false">
193   - </service>
  192 + android:exported="false"></service>
194 193  
195   - <activity android:name=".DataBaseTestActivity">
196   - </activity>
  194 + <activity android:name=".ui.activity.message.MesageActivity"></activity>
197 195 </application>
198 196  
199 197 </manifest>
200 198 \ No newline at end of file
... ...
app/src/main/java/com/shunzhi/parent/AppConfig.java
... ... @@ -47,6 +47,7 @@ public class AppConfig {
47 47 public static String BASE_URL="http://campus.myjxt.com/";
48 48 public static String BASE_URL_ORDER="http://parent.myjxt.com/";
49 49 public static String BASE_URL_FILE="http://manage.myjxt.com";
  50 + public static final String url_version = BASE_URL + "api/Common/AppVersion?appType=3";
50 51  
51 52  
52 53 //默认日志保存的路径
... ... @@ -61,6 +62,7 @@ public class AppConfig {
61 62  
62 63 private static AppConfig appConfig = null;
63 64 private static Context mContext = null;
  65 + public static String url_apk="http://update.myjxt.com/zh_parent.apk";
64 66  
65 67 public static AppConfig getAppConfig(Context context) {
66 68 if (appConfig == null) {
... ...
app/src/main/java/com/shunzhi/parent/AppContext.java
... ... @@ -16,7 +16,6 @@ import com.netease.nimlib.sdk.SDKOptions;
16 16 import com.netease.nimlib.sdk.StatusBarNotificationConfig;
17 17 import com.netease.nimlib.sdk.auth.LoginInfo;
18 18 import com.share.mvpsdk.global.GlobalApplication;
19   -import com.amap.api.location.AMapLocationClientOption.AMapLocationMode;
20 19 import com.share.mvpsdk.helper.RetrofitCreateHelper;
21 20 import com.shunzhi.parent.bean.message.DaoMaster;
22 21 import com.shunzhi.parent.bean.message.DaoMaster.DevOpenHelper;
... ... @@ -28,6 +27,8 @@ import com.shunzhi.parent.ui.MainActivity;
28 27 import org.greenrobot.greendao.database.Database;
29 28 import org.greenrobot.greendao.database.DatabaseOpenHelper;
30 29  
  30 +import timber.log.Timber;
  31 +
31 32 /**
32 33 * Created by Administrator on 2018/3/7 0007.
33 34 */
... ... @@ -104,6 +105,7 @@ public class AppContext extends GlobalApplication {
104 105 SharedPreferences sp = getSharedPreferences("info", Context.MODE_PRIVATE);
105 106 String account = sp.getString("account", "");
106 107 String token = sp.getString("token", "");
  108 + Timber.i("---===account: %s token : %s",account,token);
107 109 if (account.length() > 0 && token.length() > 0) {
108 110 return new LoginInfo(account, token);
109 111 }
... ...
app/src/main/java/com/shunzhi/parent/api/IsUpdate.java 0 → 100644
... ... @@ -0,0 +1,17 @@
  1 +package com.shunzhi.parent.api;
  2 +
  3 +import com.google.gson.JsonObject;
  4 +
  5 +import io.reactivex.Observable;
  6 +import retrofit2.http.GET;
  7 +
  8 +/**
  9 + * Created by ToaHanDong on 2018/3/26.
  10 + */
  11 +
  12 +public interface IsUpdate {
  13 +
  14 + @GET("api/Common/AppVersion?appType=4")
  15 + Observable<JsonObject> isUpdateVersion();
  16 +
  17 +}
... ...
app/src/main/java/com/shunzhi/parent/bean/Version.java 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +package com.shunzhi.parent.bean;
  2 +
  3 +import java.io.Serializable;
  4 +
  5 +/**
  6 + * Created by xf on 2015/9/23.
  7 + */
  8 +public class Version implements Serializable {
  9 + public String verNo;
  10 + public String content;
  11 + public String inTime;
  12 +
  13 +}
  14 +
... ...
app/src/main/java/com/shunzhi/parent/bean/message/MyMessage.java 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +package com.shunzhi.parent.bean.message;
  2 +
  3 +import org.greenrobot.greendao.annotation.Entity;
  4 +
  5 +/**
  6 + * Created by ToaHanDong on 2018/3/26.
  7 + */
  8 +
  9 +@Entity(nameInDb = "mymessage")
  10 +public class MyMessage {
  11 +
  12 +
  13 +}
... ...
app/src/main/java/com/shunzhi/parent/bean/message/PHMessageSession.java
... ... @@ -2,12 +2,9 @@ package com.shunzhi.parent.bean.message;
2 2  
3 3 import com.shunzhi.parent.AppConfig;
4 4 import com.shunzhi.parent.AppContext;
5   -
6 5 import org.greenrobot.greendao.annotation.Entity;
7 6 import org.greenrobot.greendao.annotation.Id;
8   -
9 7 import java.util.Date;
10   -
11 8 import org.greenrobot.greendao.annotation.Generated;
12 9 import org.greenrobot.greendao.annotation.Keep;
13 10  
... ...
app/src/main/java/com/shunzhi/parent/manager/MessageManager.java
... ... @@ -7,6 +7,7 @@ import android.content.Context;
7 7 import android.content.Intent;
8 8 import android.content.SharedPreferences;
9 9 import android.support.v4.app.NotificationCompat;
  10 +import android.util.Log;
10 11  
11 12 import com.netease.nimlib.sdk.NIMClient;
12 13 import com.netease.nimlib.sdk.Observer;
... ... @@ -78,6 +79,7 @@ public class MessageManager {
78 79 @Override
79 80 public void onEvent(StatusCode statusCode) {
80 81 if (statusCode == StatusCode.KICKOUT) {
  82 + MessageManager.getInstance().logout();
81 83 Context context = AppContext.getInstance();
82 84 Intent i = new Intent(context, LoginAndRegistActivity.class);
83 85 i.putExtra("type", "登录");
... ... @@ -99,12 +101,13 @@ public class MessageManager {
99 101 JSONObject json = new JSONObject(customNotification.getContent());
100 102 String type = json.optString("type");
101 103 String uuid = json.optString("msgId");
  104 + Timber.d("onCustomNotificationReceive%s","json="+json.toString());
102 105 if ("homework".equals(type)) {
103 106 PHMessageSession session = PHMessageSession.findAndCreateSession(PHMessageSession.sessionType_homework, true);
104 107 session.setSessionName("作业通知");
105 108 session.setDate(new Date(customNotification.getTime()));
106 109 session.setSessionText(json.optString("title"));
107   - ToastUtils.showToast(json.optString("title")+"uuid="+uuid);
  110 +// ToastUtils.showToast(json.optString("title")+"uuid="+uuid);
108 111  
109 112 PHMessage message = new PHMessage();
110 113 PHMessageDao messageDao = AppContext.getInstance().getDaoSession().getPHMessageDao();
... ... @@ -175,25 +178,27 @@ public class MessageManager {
175 178 sp.edit().putString("token", password).apply();
176 179 NIMClient.getService(AuthService.class)
177 180 .login(new LoginInfo(account, password))
178   - .setCallback(new RequestCallback() {
  181 + .setCallback(new RequestCallback<Object>() {
179 182 @Override
180 183 public void onSuccess(Object o) {
181 184 NIMLoginResultBean bean = new NIMLoginResultBean(true, 200, null);
182 185 subject.onNext(bean);
183   - Timber.i("----===onSuccess : %s", o);
  186 +// Timber.i("----===onSuccess : %s", o);
  187 + Log.d("66666","云信服务器登录失败:" + o.toString());
184 188 }
185 189  
186 190 @Override
187 191 public void onFailed(int i) {
188   - Timber.i("----===nim login failed : %s", i);
189   - ToastUtils.showToast("云信服务器登录失败:" + i);
  192 + Log.d("66666","云信服务器登录失败:" + i);
  193 +// Timber.i("----===nim login failed : %s", i);
190 194 NIMLoginResultBean bean = new NIMLoginResultBean(false, i, null);
191 195 subject.onNext(bean);
192 196 }
193 197  
194 198 @Override
195 199 public void onException(Throwable throwable) {
196   - Timber.i("----===onException");
  200 + Log.d("66666","onException:" + throwable.toString());
  201 +// Timber.i("----===onException");
197 202 if (throwable != null) throwable.printStackTrace();
198 203 NIMLoginResultBean bean = new NIMLoginResultBean(false, 0, throwable);
199 204 subject.onNext(bean);
... ... @@ -204,9 +209,13 @@ public class MessageManager {
204 209  
205 210  
206 211 public void logout() {
  212 + SharedPreferences sp = AppContext.getInstance().getApplicationContext().getSharedPreferences("info", Context.MODE_PRIVATE);
  213 + sp.edit().putString("account", "").apply();
  214 + sp.edit().putString("token", "").apply();
207 215 NIMClient.getService(MsgServiceObserve.class).observeReceiveMessage(messageObserver, false);
208 216 NIMClient.getService(MsgServiceObserve.class).observeCustomNotification(customNotificationObserver, false);
209 217 NIMClient.getService(AuthService.class).logout();
  218 +
210 219 }
211 220  
212 221 public interface NIMLoginCallback {
... ...
app/src/main/java/com/shunzhi/parent/manager/UpdateManager.java 0 → 100644
... ... @@ -0,0 +1,375 @@
  1 +package com.shunzhi.parent.manager;
  2 +
  3 +import android.app.Dialog;
  4 +import android.content.Context;
  5 +import android.content.DialogInterface;
  6 +import android.content.DialogInterface.OnClickListener;
  7 +import android.os.Environment;
  8 +import android.os.Handler;
  9 +import android.os.Message;
  10 +import android.support.v7.app.AlertDialog;
  11 +import android.view.LayoutInflater;
  12 +import android.view.View;
  13 +import android.widget.ProgressBar;
  14 +import android.widget.TextView;
  15 +import android.widget.Toast;
  16 +
  17 +import com.google.gson.Gson;
  18 +import com.google.gson.JsonObject;
  19 +import com.share.mvpsdk.RxManager;
  20 +import com.share.mvpsdk.helper.RetrofitCreateHelper;
  21 +import com.share.mvpsdk.helper.RxHelper;
  22 +import com.share.mvpsdk.utils.ToastUtils;
  23 +import com.shunzhi.parent.AppConfig;
  24 +import com.shunzhi.parent.R;
  25 +import com.shunzhi.parent.api.IsUpdate;
  26 +import com.shunzhi.parent.bean.Version;
  27 +import com.shunzhi.parent.util.CloseUtils;
  28 +import com.shunzhi.parent.util.SystemHelper;
  29 +import com.shunzhi.parent.util.Utils;
  30 +import com.shunzhi.parent.views.MyVersionDialog;
  31 +
  32 +import java.io.File;
  33 +import java.io.FileOutputStream;
  34 +import java.io.IOException;
  35 +import java.io.InputStream;
  36 +import java.net.HttpURLConnection;
  37 +import java.net.MalformedURLException;
  38 +import java.net.URL;
  39 +import java.text.SimpleDateFormat;
  40 +import java.util.HashMap;
  41 +
  42 +import io.reactivex.functions.Consumer;
  43 +import timber.log.Timber;
  44 +
  45 +public class UpdateManager {
  46 +
  47 + AlertDialog dialogShowCheckingDialog;
  48 + /**
  49 + * 是否正在检查更新
  50 + */
  51 + public boolean ischeckingForUpdate = false;
  52 + /* 下载中 */
  53 + private static final int DOWNLOAD = 1;
  54 + /* 下载结束 */
  55 + private static final int DOWNLOAD_FINISH = 2;
  56 + /**
  57 + * 是否人为打断检查更新状态
  58 + */
  59 + private boolean isChechingInterrupted = false;
  60 + /**
  61 + * 结束正在获取更新
  62 + */
  63 + /* 保存解析的XML信息 */
  64 + static HashMap<String, String> mHashMap;
  65 + /* 下载保存路径 */
  66 + private String mSavePath;
  67 + /* 记录进度条数量 */
  68 + private int progress;
  69 + /* 是否取消更新 */
  70 + private static boolean cancelUpdate = false;
  71 +
  72 + private static Context mContext;
  73 + /* 更新进度条 */
  74 + private ProgressBar mProgress;
  75 + private TextView mProgressText;
  76 + private Dialog mDownloadDialog;
  77 + double serviceCode = 1;
  78 + int versionCode = 1;
  79 +
  80 + //mHandler
  81 +//region
  82 + private Handler mHandler = new Handler() {
  83 + public void handleMessage(Message msg) {
  84 + switch (msg.what) {
  85 + // 正在下载
  86 + case DOWNLOAD:
  87 + // 设置进度条位置
  88 + mProgress.setProgress(progress);
  89 + mProgressText.setText(progress + "%");
  90 + break;
  91 + case DOWNLOAD_FINISH:
  92 + mDownloadDialog.dismiss();
  93 + File apkfile = new File(mSavePath, mHashMap.get("name"));
  94 + SystemHelper.installAPK(mContext, apkfile.toString());
  95 + break;
  96 + default:
  97 + break;
  98 + }
  99 + }
  100 + };
  101 +
  102 + //endregion
  103 + private UpdateManager() {
  104 + mHashMap = new HashMap<String, String>();
  105 + mHashMap.put("url", AppConfig.url_apk);
  106 + mHashMap.put("name", "XSTApp.apk");
  107 +
  108 + }
  109 +
  110 + public UpdateManager(Context context) {
  111 + this.mContext = null;
  112 + this.mContext = context;
  113 + //获取更新版本和url
  114 + mHashMap = new HashMap<String, String>();
  115 + mHashMap.put("url", AppConfig.url_apk);
  116 + mHashMap.put("name", "XSTApp.apk");
  117 +
  118 + }
  119 +
  120 + /**
  121 + * 检查软件是否有更新版本
  122 + *
  123 + * @return
  124 + */
  125 + String date = "";
  126 +
  127 + /**
  128 + * @param shouldInterruptDialogShow 是否显示打断检查更新的对话框
  129 + */
  130 + RxManager rxManager=new RxManager();
  131 + public void isUpdate(final boolean shouldInterruptDialogShow) {
  132 + date = new SimpleDateFormat("yyyyMMddHHmmss").format(new java.util.Date());
  133 + // 获取当前软件版本
  134 + if (!ischeckingForUpdate) {
  135 + isChechingInterrupted = false;
  136 + if (shouldInterruptDialogShow) showCheckingDialog(mContext);
  137 + ischeckingForUpdate = true;
  138 + versionCode = SystemHelper.getAppVersionCode(mContext);
  139 + rxManager.register( RetrofitCreateHelper.getInstance().createApi(IsUpdate.class,AppConfig.BASE_URL)
  140 + .isUpdateVersion().compose(RxHelper.<JsonObject>rxSchedulerHelper()).subscribe(new Consumer<JsonObject>() {
  141 + @Override
  142 + public void accept(JsonObject jsonObject) throws Exception {
  143 + try {
  144 + Gson gson=new Gson();
  145 + Version version=gson.fromJson(jsonObject.get("data").getAsJsonObject().toString(),Version.class);
  146 + serviceCode = Double.parseDouble(version.verNo);
  147 + double currentVersion = serviceCode / 100;
  148 + Timber.d("66666%s","currentVersion="+currentVersion+"serviceCode="+serviceCode+"versionCode="+versionCode);
  149 + if ((serviceCode > versionCode) && ischeckingForUpdate && !isChechingInterrupted) {
  150 + showNoticeDialog(currentVersion, version.content, isChechingInterrupted);
  151 + } else if (!(serviceCode > versionCode) && shouldInterruptDialogShow && !isChechingInterrupted) {
  152 + Toast.makeText(mContext, "已经是最新版本啦!", Toast.LENGTH_SHORT).show();
  153 + mContext = null;
  154 + }
  155 +
  156 + }catch (Exception e){
  157 + e.printStackTrace();
  158 + }finally {
  159 + ischeckingForUpdate = false;
  160 + }
  161 + }
  162 + }, new Consumer<Throwable>() {
  163 + @Override
  164 + public void accept(Throwable throwable) throws Exception {
  165 + ToastUtils.showToast("更新失败:"+throwable.toString());
  166 + }
  167 + }));
  168 +
  169 +// Timber.d("sign:%s", Utils.getSignStr());
  170 + /*Ion.with(mContext)
  171 + .load(Constants.url_version)
  172 + .setHeader("sign", Utils.getSignStr())
  173 + .setTimeout(5000)
  174 + .asJsonObject()
  175 + .setCallback(new FutureCallback<JsonObject>() {
  176 + @Override
  177 + public void onCompleted(Exception e, JsonObject result) {
  178 + try {
  179 + Timber.i("exception : %s",e);
  180 + Timber.i("result : %s", result);
  181 + if (dialogShowCheckingDialog != null)
  182 + dialogShowCheckingDialog.dismiss();
  183 + Gson gson = new Gson();
  184 + String s = gson.toJson(result.getAsJsonObject("data"));
  185 + Version serverVersion = gson.fromJson(s, new TypeToken<Version>() {
  186 + }.getType());
  187 + serviceCode = Double.parseDouble(serverVersion.verNo);
  188 + double currentVersion = serviceCode / 100;
  189 + if ((serviceCode > versionCode) && ischeckingForUpdate && !isChechingInterrupted) {
  190 + showNoticeDialog(currentVersion, serverVersion.content, isChechingInterrupted);
  191 + } else if (!(serviceCode > versionCode) && shouldInterruptDialogShow && !isChechingInterrupted) {
  192 + Toast.makeText(mContext, "已经是最新版本啦!", Toast.LENGTH_SHORT).show();
  193 + mContext = null;
  194 + }
  195 + } catch (Exception ee) {
  196 + ee.printStackTrace();
  197 + if (shouldInterruptDialogShow)
  198 + Toast.makeText(mContext, "版本检测失败", Toast.LENGTH_LONG).show();
  199 + mContext = null;
  200 + } finally {
  201 + ischeckingForUpdate = false;
  202 + }
  203 + }
  204 + });*/
  205 + }
  206 + }
  207 +
  208 +
  209 + public UpdateManager setContext(Context ctx) {
  210 + mContext = ctx;
  211 + return this;
  212 + }
  213 +
  214 + public static UpdateManager getInstance() {
  215 +
  216 + return SingletonHolder.sInstance;
  217 + }
  218 +
  219 + private static class SingletonHolder {
  220 + private static final UpdateManager sInstance = new UpdateManager();
  221 + }
  222 +
  223 + /**
  224 + * 显示软件更新对话框
  225 + */
  226 + public void showNoticeDialog(double serviceCode, String content, Boolean isInterrupted) {
  227 + final MyVersionDialog dialog = new MyVersionDialog(mContext, "V" + serviceCode, "10.1M",
  228 + content, R.style.dialog, new MyVersionDialog.OnCustomDialogListener() {
  229 + @Override
  230 + public void clickSure() {
  231 + showDownloadDialog();
  232 + }
  233 +
  234 + @Override
  235 + public void clickCancel() {
  236 + mContext = null;
  237 + }
  238 + });
  239 + dialog.setCanceledOnTouchOutside(false);
  240 + if (!dialog.isShowing())
  241 + dialog.show();
  242 + ischeckingForUpdate = false;
  243 + }
  244 +
  245 + private void showCheckingDialog(Context ctx) {
  246 + dialogShowCheckingDialog = Utils.styleDialogBuilder(ctx)
  247 + .setMessage("正在检查更新...")
  248 + .setTitle("提示")
  249 + .setNegativeButton("取消", new OnClickListener() {
  250 + @Override
  251 + public void onClick(DialogInterface dialog, int which) {
  252 + isChechingInterrupted = true;
  253 + mContext = null;
  254 + dialog.dismiss();
  255 + }
  256 + }).create();
  257 + dialogShowCheckingDialog.setCanceledOnTouchOutside(false);
  258 + if (!dialogShowCheckingDialog.isShowing()) {
  259 + dialogShowCheckingDialog.show();
  260 + }
  261 + }
  262 +
  263 + /**
  264 + * 显示软件下载对话框
  265 + */
  266 + private void showDownloadDialog() {
  267 + // 构造软件下载对话框
  268 + AlertDialog.Builder builder = Utils.styleDialogBuilder(mContext);
  269 + builder.setTitle("更新中");
  270 + // 给下载对话框增加进度条
  271 + final LayoutInflater inflater = LayoutInflater.from(mContext);
  272 + View v = inflater.inflate(R.layout.progress_dialog, null);
  273 + mProgress = (ProgressBar) v.findViewById(R.id.pbar);
  274 + mProgressText = (TextView) v.findViewById(R.id.txt_wait);
  275 + builder.setView(v);
  276 + // 取消更新
  277 + builder.setNegativeButton("取消", new OnClickListener() {
  278 + @Override
  279 + public void onClick(DialogInterface dialog, int which) {
  280 + dialog.dismiss();
  281 + // 设置取消状态
  282 + File APKfile = new File(mSavePath);
  283 + //FileUtil.deleteFile(APKfile, APKfile + "/" + mHashMap.get("name"));
  284 + cancelUpdate = true;
  285 + }
  286 + });
  287 + mDownloadDialog = builder.create();
  288 + mDownloadDialog.setCanceledOnTouchOutside(false);
  289 + mDownloadDialog.show();
  290 + // 现在文件
  291 + downloadApk();
  292 + }
  293 +
  294 + /**
  295 + * 下载apk文件
  296 + */
  297 + private void downloadApk() {
  298 + // 启动新线程下载软件
  299 + cancelUpdate = false;
  300 + downloadApkThread downloadThread = new downloadApkThread();
  301 + downloadThread.start();
  302 + }
  303 +
  304 + /**
  305 + * 下载文件线程
  306 + *
  307 + * @author coolszy
  308 + * @date 2012-4-26
  309 + * @blog http://blog.92coding.com
  310 + */
  311 + private class downloadApkThread extends Thread {
  312 + HttpURLConnection conn = null;
  313 + InputStream is = null;
  314 + FileOutputStream fos = null;
  315 +
  316 + @Override
  317 + public void run() {
  318 + //cancelUpdate = false;
  319 + try {
  320 + // 判断SD卡是否存在,并且是否具有读写权限
  321 + if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
  322 + // 获得存储卡的路径
  323 + String sdpath = Environment.getExternalStorageDirectory() + "/";
  324 + mSavePath = sdpath + "download";
  325 + URL url = new URL(mHashMap.get("url"));
  326 + // 创建连接
  327 + conn = (HttpURLConnection) url.openConnection();
  328 + conn.connect();
  329 + // 获取文件大小
  330 + int length = conn.getContentLength();//服务端要设置 content length属性
  331 + // 创建输入流
  332 + is = conn.getInputStream();
  333 +
  334 + File file = new File(mSavePath);
  335 + // 判断文件目录是否存在
  336 + if (!file.exists()) {
  337 + if (!file.mkdir()) file.mkdirs();//创建文件失败,则创建文件夹
  338 + }
  339 + File apkFile = new File(mSavePath, mHashMap.get("name"));
  340 + fos = new FileOutputStream(apkFile);
  341 + int count = 0;
  342 + // 缓存
  343 + byte buf[] = new byte[1024];
  344 + // 写入到文件中
  345 + while (!cancelUpdate) {
  346 + int numread = is.read(buf);
  347 + count += numread;
  348 + progress = (int) (((float) count / length) * 100);// 计算进度条位置
  349 + mHandler.sendEmptyMessage(DOWNLOAD);// 更新进度
  350 + if (numread <= 0) {
  351 + // 下载完成
  352 + mHandler.sendEmptyMessage(DOWNLOAD_FINISH);
  353 + break;
  354 + }
  355 + // 写入文件
  356 + fos.write(buf, 0, numread);
  357 + } // 点击取消就停止下载.
  358 +
  359 + }
  360 + } catch (MalformedURLException e) {
  361 + Timber.d(e + "");
  362 + e.printStackTrace();
  363 + } catch (IOException e) {
  364 + Timber.d(e + "");
  365 + e.printStackTrace();
  366 + } finally {
  367 + conn.disconnect();
  368 + CloseUtils.closeQuietly(fos, is);
  369 + }
  370 + // 取消下载对话框显示
  371 + Thread.currentThread().interrupt();
  372 + rxManager.unSubscribe();
  373 + }
  374 + }
  375 +}
... ...
app/src/main/java/com/shunzhi/parent/ui/activity/message/MesageActivity.java 0 → 100644
... ... @@ -0,0 +1,121 @@
  1 +package com.shunzhi.parent.ui.activity.message;
  2 +
  3 +import android.support.v7.app.AppCompatActivity;
  4 +import android.os.Bundle;
  5 +import android.support.v7.widget.LinearLayoutManager;
  6 +import android.support.v7.widget.RecyclerView;
  7 +import android.view.LayoutInflater;
  8 +import android.view.View;
  9 +import android.view.ViewGroup;
  10 +import android.widget.ImageView;
  11 +import android.widget.TextView;
  12 +
  13 +import com.share.mvpsdk.base.activity.BaseCompatActivity;
  14 +import com.share.mvpsdk.base.adapter.BaseRecyclerViewAdapter;
  15 +import com.share.mvpsdk.base.adapter.BaseRecyclerViewHolder;
  16 +import com.share.mvpsdk.utils.DateUtils;
  17 +import com.shunzhi.parent.R;
  18 +import com.shunzhi.parent.bean.message.PHMessage;
  19 +import com.shunzhi.parent.bean.message.PHMessageSession;
  20 +
  21 +import java.util.ArrayList;
  22 +import java.util.List;
  23 +
  24 +public class MesageActivity extends BaseCompatActivity implements View.OnClickListener {
  25 +
  26 + RecyclerView recyclerView;
  27 +
  28 + ImageView iv_back;
  29 +
  30 + MEssageAdapter mEssageAdapter=null;
  31 +
  32 + List<PHMessage> phMessages=new ArrayList<>();
  33 +
  34 + @Override
  35 + protected void initView(Bundle savedInstanceState) {
  36 +
  37 + initViews();
  38 +
  39 + }
  40 +
  41 + private void initViews() {
  42 +
  43 + recyclerView = findViewById(R.id.recyclerView);
  44 + iv_back = findViewById(R.id.iv_back);
  45 +
  46 + iv_back.setOnClickListener(this);
  47 +
  48 + initAdapter();
  49 + }
  50 +
  51 + private void initAdapter() {
  52 +
  53 + if (null==mEssageAdapter)mEssageAdapter=new MEssageAdapter();
  54 + if (null==recyclerView.getAdapter())recyclerView.setAdapter(mEssageAdapter);
  55 + mEssageAdapter.addAll(phMessages);
  56 + recyclerView.setAdapter(mEssageAdapter);
  57 +
  58 + }
  59 +
  60 + @Override
  61 + protected int getLayoutId() {
  62 + return R.layout.activity_mesage;
  63 + }
  64 +
  65 + @Override
  66 + public void onClick(View view) {
  67 + switch (view.getId()) {
  68 + case R.id.iv_back:
  69 + finish();
  70 + break;
  71 + }
  72 + }
  73 +
  74 +
  75 + private class MEssageAdapter extends BaseRecyclerViewAdapter<PHMessage> {
  76 +
  77 + @Override
  78 + public void onAttachedToRecyclerView(RecyclerView recyclerView) {
  79 + super.onAttachedToRecyclerView(recyclerView);
  80 + LinearLayoutManager layoutManager = new LinearLayoutManager(MesageActivity.this);
  81 + layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
  82 + recyclerView.setLayoutManager(layoutManager);
  83 + }
  84 +
  85 + @Override
  86 + public BaseRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  87 +
  88 + View view = LayoutInflater.from(MesageActivity.this).inflate(R.layout.item_message, parent, false);
  89 + MessageViewHolder messageViewHolder = new MessageViewHolder(view);
  90 +
  91 + return messageViewHolder;
  92 + }
  93 +
  94 + private class MessageViewHolder extends BaseRecyclerViewHolder<PHMessage> {
  95 +
  96 + TextView tvMessageContent, tvDate;
  97 + List<String> dateString = new ArrayList<>();
  98 +
  99 + public MessageViewHolder(View itemView) {
  100 + super(itemView);
  101 + tvMessageContent = itemView.findViewById(R.id.tvMessageContent);
  102 + tvDate = itemView.findViewById(R.id.tvDate);
  103 + }
  104 +
  105 + @Override
  106 + public void onBindViewHolder(PHMessage object, int position) {
  107 + tvMessageContent.setText(object.getMessageText());
  108 + String date = DateUtils.date2str(object.getDate(), "yyyyMMDD");
  109 + if (!dateString.contains(date)) {
  110 + dateString.add(date);
  111 + tvDate.setText(date);
  112 + tvDate.setVisibility(View.VISIBLE);
  113 + }else {
  114 + tvDate.setVisibility(View.GONE);
  115 + }
  116 +
  117 + }
  118 + }
  119 + }
  120 +
  121 +}
... ...
app/src/main/java/com/shunzhi/parent/ui/fragment/ConsultFragment.java
... ... @@ -15,6 +15,7 @@ import android.widget.ImageView;
15 15 import android.widget.LinearLayout;
16 16 import android.widget.TextView;
17 17  
  18 +import com.bumptech.glide.Glide;
18 19 import com.jcodecraeer.xrecyclerview.XRecyclerView;
19 20 import com.share.mvpsdk.base.BasePresenter;
20 21 import com.share.mvpsdk.base.fragment.BaseMVPCompatFragment;
... ... @@ -111,7 +112,6 @@ public class ConsultFragment extends BaseMVPCompatFragment&lt;ConsultContract.Consu
111 112 }
112 113  
113 114 private void initRecycler() {
114   -
115 115 recycler_context.setPullRefreshEnabled(false);
116 116 recycler_context.setLoadingListener(new XRecyclerView.LoadingListener() {
117 117 @Override
... ... @@ -143,13 +143,7 @@ public class ConsultFragment extends BaseMVPCompatFragment&lt;ConsultContract.Consu
143 143 private void initBanners() {
144 144 xBanner.setData(imgesUrl, describeList);
145 145 // xBanner.setPointsIsVisible(false);
146   - xBanner.setmAdapter(new XBanner.XBannerAdapter() {
147   - @Override
148   - public void loadBanner(XBanner banner, Object model, View view, int position) {
149   - if(position<=imgesUrl.size()-1)
150   - GlideUtils.showImg(getActivity(),(ImageView) view,imgesUrl.get(position));
151   - }
152   - });
  146 + xBanner.setmAdapter(xBannerAdapter);
153 147  
154 148 xBanner.setOnItemClickListener(new XBanner.OnItemClickListener() {
155 149 @Override
... ... @@ -159,6 +153,14 @@ public class ConsultFragment extends BaseMVPCompatFragment&lt;ConsultContract.Consu
159 153 });
160 154 }
161 155  
  156 + private XBanner.XBannerAdapter xBannerAdapter=new XBanner.XBannerAdapter() {
  157 + @Override
  158 + public void loadBanner(XBanner banner, Object model, View view, int position) {
  159 + Glide.with(getContext()).load(imgesUrl.get(position)).into((ImageView) view);
  160 +// GlideUtils.showImg(getActivity(),(ImageView) view,imgesUrl.get(position));
  161 + }
  162 + };
  163 +
162 164 @NonNull
163 165 @Override
164 166 public BasePresenter initPresenter() {
... ...
app/src/main/java/com/shunzhi/parent/ui/fragment/MineFragment.java
... ... @@ -19,24 +19,30 @@ import com.share.mvpsdk.utils.CacheUtils;
19 19 import com.shunzhi.parent.AppConfig;
20 20 import com.shunzhi.parent.AppContext;
21 21 import com.shunzhi.parent.BuildConfig;
22   -import com.shunzhi.parent.DataBaseTestActivity;
23 22 import com.shunzhi.parent.R;
  23 +import com.shunzhi.parent.bean.message.PHMessage;
  24 +import com.shunzhi.parent.bean.message.PHMessageSession;
24 25 import com.shunzhi.parent.contract.loginandregister.LoginAndRegisterContract;
25 26 import com.shunzhi.parent.contract.mine.MineContract;
  27 +import com.shunzhi.parent.manager.MessageManager;
  28 +import com.shunzhi.parent.manager.UpdateManager;
26 29 import com.shunzhi.parent.presenter.mine.MinePresenter;
27 30 import com.shunzhi.parent.ui.activity.LoginAndRegistActivity;
28 31 import com.shunzhi.parent.ui.activity.MyChildActivity;
29 32 import com.shunzhi.parent.ui.activity.PersonInfoActivity;
  33 +import com.shunzhi.parent.ui.activity.message.MesageActivity;
30 34 import com.shunzhi.parent.ui.activity.mywebview.WebViewActivity;
31 35 import com.shunzhi.parent.ui.activity.orderdetail.OrderDetailActivity;
32 36  
  37 +
33 38 public class MineFragment extends BaseMVPCompatFragment<LoginAndRegisterContract.LoginPresenter, LoginAndRegisterContract.ILoginModel>
34 39 implements MineContract.IMineView, View.OnClickListener {
35 40  
36   - LinearLayout childlayout, personinfo, layout_orderDetail, layout_order, layout_cache, layout_about, layout_feedback, top_layout, layout_afterLogin;
  41 + LinearLayout childlayout, personinfo, layout_orderDetail, layout_order, layout_cache,
  42 + layout_about, layout_feedback, top_layout, layout_afterLogin, layout_message, layout_update;
37 43  
38 44 RoundedImageView user_photo;
39   - TextView user_name, user_mobile, tvExit, binding_state;
  45 + TextView user_name, user_mobile, tvExit, binding_state, tvMessageCount;
40 46  
41 47 @NonNull
42 48 @Override
... ... @@ -60,6 +66,12 @@ public class MineFragment extends BaseMVPCompatFragment&lt;LoginAndRegisterContract
60 66 layout_cache = view.findViewById(R.id.layout_cache);
61 67 layout_about = view.findViewById(R.id.layout_about);
62 68 layout_feedback = view.findViewById(R.id.layout_feedback);
  69 + tvMessageCount = view.findViewById(R.id.tvMessageCount);
  70 + layout_message = view.findViewById(R.id.layout_message);
  71 + layout_update = view.findViewById(R.id.layout_update);
  72 +
  73 + layout_update.setOnClickListener(this);
  74 + layout_message.setOnClickListener(this);
63 75 layout_about.setOnClickListener(this);
64 76 layout_feedback.setOnClickListener(this);
65 77 layout_cache.setOnClickListener(this);
... ... @@ -76,10 +88,12 @@ public class MineFragment extends BaseMVPCompatFragment&lt;LoginAndRegisterContract
76 88 binding_state = view.findViewById(R.id.binding_state);
77 89 layout_afterLogin.setVisibility(View.GONE);
78 90 if (BuildConfig.DEBUG) {
79   - View enter = view.findViewById(R.id.testEnter);
80   - enter.setVisibility(View.VISIBLE);
81   - enter.setOnClickListener(this);
82   - } else view.findViewById(R.id.testEnter).setVisibility(View.GONE);
  91 + view.findViewById(R.id.testEnter).setVisibility(View.VISIBLE);
  92 + } else {
  93 + view.findViewById(R.id.testEnter).setVisibility(View.GONE);
  94 + }
  95 +
  96 + tvMessageCount.setText(PHMessage.findUnreadNotificationCount() + "");
83 97  
84 98 }
85 99  
... ... @@ -89,9 +103,10 @@ public class MineFragment extends BaseMVPCompatFragment&lt;LoginAndRegisterContract
89 103 if (!TextUtils.isEmpty(useName)) AppConfig.ISLOGIN = true;
90 104 else AppConfig.ISLOGIN = false;
91 105  
92   - if (TextUtils.isEmpty(AppConfig.getAppConfig(getContext()).get(AppConfig.ISBINDING))) {
  106 + if (!TextUtils.isEmpty(AppConfig.getAppConfig(getContext()).get(AppConfig.ISBINDING))) {
93 107 binding_state.setText("");
94 108 }
  109 +
95 110 if (AppConfig.ISLOGIN) {
96 111 String url = AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.USER_IMAGE);
97 112 if (!TextUtils.isEmpty(url)) {
... ... @@ -123,6 +138,9 @@ public class MineFragment extends BaseMVPCompatFragment&lt;LoginAndRegisterContract
123 138 @Override
124 139 public void onClick(View v) {
125 140 switch (v.getId()) {
  141 + case R.id.layout_message:
  142 + startNewActivity(MesageActivity.class);
  143 + break;
126 144 case R.id.childlayout:
127 145 startActivity(new Intent().setClass(getActivity(), MyChildActivity.class));
128 146 break;
... ... @@ -154,9 +172,10 @@ public class MineFragment extends BaseMVPCompatFragment&lt;LoginAndRegisterContract
154 172  
155 173 case R.id.layout_feedback:
156 174 WebViewActivity.getInstance(getActivity(), AppConfig.BASE_URL_ORDER + "FeedBack.aspx?userid=" + AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.USER_ID), -1);
  175 +
157 176 break;
158   - case R.id.testEnter:
159   - DataBaseTestActivity.start(this);
  177 + case R.id.layout_update:
  178 + UpdateManager.getInstance().setContext(getContext()).isUpdate(true);
160 179 break;
161 180 default:
162 181 break;
... ... @@ -198,6 +217,7 @@ public class MineFragment extends BaseMVPCompatFragment&lt;LoginAndRegisterContract
198 217 AppConfig.getAppConfig(AppContext.getInstance()).set(AppConfig.LOGIN_NAME, "");
199 218 AppConfig.ISLOGIN = false;
200 219 setPersonInfo();
  220 + MessageManager.getInstance().logout();
201 221 startActivity(new Intent().putExtra("type", "登录").setClass(getActivity(), LoginAndRegistActivity.class));
202 222 // getActivity().finish();
203 223 }
... ...
app/src/main/java/com/shunzhi/parent/ui/fragment/StartFragment.java
... ... @@ -135,7 +135,6 @@ public class StartFragment extends BaseMVPCompatFragment&lt;ConsultContract.Consult
135 135 try {
136 136 imgUrl = new ArrayList<>();
137 137 describeList = new ArrayList<>();
138   -// Log.d("66666","isQidong="+isQidong);
139 138 if (isQidong) {
140 139 AppConfig.getAppConfig(getContext()).set(AppConfig.APP_IS_START, "1");
141 140 String fileUrl = "", describe = "";
... ... @@ -150,7 +149,6 @@ public class StartFragment extends BaseMVPCompatFragment&lt;ConsultContract.Consult
150 149 describeList.add(guangGaoBeanList.get(i).describe);
151 150 }
152 151 }
153   - Log.d("66666","fileUrl="+fileUrl);
154 152 if (!TextUtils.isEmpty(fileUrl)){
155 153 jiecaoVideo.setUp(fileUrl, JZVideoPlayerStandard.SCREEN_WINDOW_NORMAL, describe);
156 154 jiecaoVideo.startVideo();
... ...
app/src/main/java/com/shunzhi/parent/ui/fragment/loginandregistfragment/LoginAndRegistFragment.java
... ... @@ -146,8 +146,8 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment&lt;LoginAndRegist
146 146 getActivity().finish();
147 147 } else if (type == 1) {
148 148 PopupWindow popupWindow = new PopupWindow();
149   - popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
150   - popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
  149 + popupWindow.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
  150 + popupWindow.setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
151 151 backgroundAlpha(0.5f);
152 152 View view = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_view, null);
153 153 TextView dialogInfo = view.findViewById(R.id.dialog_info);
... ... @@ -294,7 +294,6 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment&lt;LoginAndRegist
294 294 }
295 295 };
296 296  
297   -
298 297 public void backgroundAlpha(float bgAlpha) {
299 298 WindowManager.LayoutParams lp = getActivity().getWindow().getAttributes();
300 299 lp.alpha = bgAlpha; //0.0-1.0
... ...
app/src/main/java/com/shunzhi/parent/util/CloseUtils.java 0 → 100644
... ... @@ -0,0 +1,33 @@
  1 +package com.shunzhi.parent.util;
  2 +
  3 +import android.support.annotation.Nullable;
  4 +
  5 +import java.io.Closeable;
  6 +import java.io.IOException;
  7 +
  8 +/**
  9 + * Created by zdf on 2016/1/20.
  10 + */
  11 +public class CloseUtils {
  12 + private CloseUtils() {
  13 + }
  14 +
  15 + /**
  16 + *
  17 + * @param closeable 所有实现Closeable接口的类的实例(常用有输入、输出流、Cursor等)
  18 + * @return 关闭成功
  19 + */
  20 + public static boolean closeQuietly(@Nullable Closeable... closeable) {
  21 + if (closeable != null && closeable.length > 0) {
  22 + try {
  23 + for (Closeable c : closeable) {
  24 + if (c != null) c.close();
  25 + }
  26 + } catch (IOException e) {
  27 + e.printStackTrace();
  28 + return false;
  29 + }
  30 + }
  31 + return true;
  32 + }
  33 +}
... ...
app/src/main/java/com/shunzhi/parent/util/SystemHelper.java 0 → 100644
... ... @@ -0,0 +1,420 @@
  1 +/**
  2 + * ClassName: MyApp.java
  3 + * created on 2013-1-24
  4 + * Copyrights 2013-1-24 hjgang All rights reserved.
  5 + * site: http://t.qq.com/hjgang2012
  6 + * email: hjgang@yahoo.cn
  7 + */
  8 +package com.shunzhi.parent.util;
  9 +
  10 +import android.Manifest;
  11 +import android.annotation.TargetApi;
  12 +import android.app.Activity;
  13 +import android.content.ContentResolver;
  14 +import android.content.Context;
  15 +import android.content.Intent;
  16 +import android.content.Intent.ShortcutIconResource;
  17 +import android.content.pm.PackageInfo;
  18 +import android.content.pm.PackageManager;
  19 +import android.database.Cursor;
  20 +import android.net.ConnectivityManager;
  21 +import android.net.NetworkInfo;
  22 +import android.net.NetworkInfo.State;
  23 +import android.net.Uri;
  24 +import android.os.Build;
  25 +import android.support.v4.app.ActivityCompat;
  26 +import android.telephony.TelephonyManager;
  27 +import android.util.DisplayMetrics;
  28 +import android.view.Window;
  29 +import android.view.WindowManager;
  30 +
  31 +import com.shunzhi.parent.R;
  32 +
  33 +import java.io.File;
  34 +import java.sql.Timestamp;
  35 +import java.text.ParseException;
  36 +import java.text.SimpleDateFormat;
  37 +import java.util.Date;
  38 +
  39 +import timber.log.Timber;
  40 +
  41 +
  42 +/**
  43 + * 获取系统信息的工具类
  44 + * @author hjgang
  45 + */
  46 +public class SystemHelper {
  47 + private SystemHelper() {
  48 + }
  49 +
  50 + /**
  51 + * 创建本应用的桌面快捷方式<br/>
  52 + * 注意:需要添加权限&lt;uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/&gt;
  53 + * @param
  54 + */
  55 + public static void createShortcut(Context context, Class<?> clazz) {
  56 + Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
  57 +
  58 + //快捷方式的名称
  59 + shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, context.getString(R.string.app_name));
  60 + shortcut.putExtra("duplicate", false); //不允许重复创建
  61 +
  62 + Intent localIntent2 = new Intent(context, clazz);
  63 + localIntent2.setAction(Intent.ACTION_MAIN);
  64 + localIntent2.addCategory(Intent.CATEGORY_LAUNCHER);
  65 +
  66 + shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, localIntent2);//指定快捷方式要启动的Activity类型
  67 +
  68 + //快捷方式的图标
  69 + ShortcutIconResource iconResource = ShortcutIconResource.fromContext(context, R.drawable.logo);
  70 + shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
  71 +
  72 + context.sendBroadcast(shortcut);
  73 + }
  74 +
  75 + /**
  76 + * 字符串转换成date
  77 + * @param time
  78 + * @return
  79 + */
  80 + public static Date getDateTime1(String time) {
  81 + Date newtime = null;
  82 + SimpleDateFormat sdfDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  83 + try {
  84 + if (time != null && !time.equals("0")) {
  85 + newtime = sdfDateFormat.parse(time);
  86 + }
  87 + } catch (Exception err) {
  88 +
  89 + }
  90 + return newtime;
  91 + }
  92 +
  93 + /**
  94 + * 将字符串转为 时间戳
  95 + * @param time
  96 + * @return
  97 + */
  98 + public static String getTimestamp(String time) {
  99 + Date newtime = null;
  100 + SimpleDateFormat sdfDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  101 + try {
  102 + if (time != null && !time.equals("0")) {
  103 + newtime = sdfDateFormat.parse(time);
  104 + }
  105 + } catch (Exception err) {
  106 +
  107 + }
  108 + return newtime.getTime() + "";
  109 + }
  110 +
  111 + /**
  112 + * 将时间戳转为 字符串
  113 + * yyyy-MM-dd HH:mm
  114 + * */
  115 + public static String getTimeStr(String time) {
  116 +
  117 + String newtime = null;
  118 + SimpleDateFormat sdfDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  119 + if (time != null && !time.equals("0")) {
  120 + newtime = sdfDateFormat.format(new Timestamp(Long.parseLong(time)));
  121 + }
  122 + return newtime;
  123 + }
  124 +
  125 + /**
  126 + * 将时间戳转为 字符串
  127 + * yyyy-MM-dd
  128 + * */
  129 + public static String getTimeStr3(String time) {
  130 + String newtime = null;
  131 + SimpleDateFormat sdfDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  132 + if (time != null && !time.equals("0")) {
  133 + newtime = sdfDateFormat.format(new Date(Long.parseLong(time) * 1000));
  134 + }
  135 + return newtime;
  136 + }
  137 +
  138 + // 将字符串转为时间戳
  139 + public static String getTime(String time) {
  140 + SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日hh时mm分");
  141 + Date date = null;
  142 + if (time == null || "".equals(time) || "null".equals(time)) {
  143 + return "0";
  144 + }
  145 + if (time.contains("年")) {
  146 + int year = Integer.parseInt(time.substring(0, time.indexOf("年")));
  147 + if (year <= 1970) {
  148 + return "0";
  149 + }
  150 + }
  151 + try {
  152 + date = format.parse(time);
  153 + } catch (ParseException e) {
  154 + e.printStackTrace();
  155 + return null;
  156 + }
  157 + return date.getTime() / 1000 + "";
  158 + }
  159 +
  160 + // 将字符串转为时间戳
  161 + public static String getTime2(String time) {
  162 + SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日");
  163 + Date date = null;
  164 + if (time == null || "".equals(time) || "null".equals(time)) {
  165 + return "0";
  166 + }
  167 + int year = Integer.parseInt(time.substring(0, time.indexOf("年")));
  168 + if (year <= 1970) {
  169 + return "0";
  170 + }
  171 + try {
  172 + date = format.parse(time);
  173 + } catch (ParseException e) {
  174 + e.printStackTrace();
  175 + }
  176 + return date.getTime() / 1000 + "";
  177 + }
  178 +
  179 + /**
  180 + * @author LuoB.
  181 + * @param oldTime 较小的时间
  182 + * @param newTime 较大的时间 (如果为空 默认当前时间 ,表示和当前时间相比)
  183 + * @return -1 :同一天. 0:昨天 . 1 :至少是前天.
  184 + * @throws ParseException 转换异常
  185 + */
  186 + public static int isYeaterday(Date oldTime, Date newTime) throws ParseException {
  187 + if (newTime == null) {
  188 + newTime = new Date();
  189 + }
  190 + //将下面的 理解成 yyyy-MM-dd 00:00:00 更好理解点
  191 + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
  192 + String todayStr = format.format(newTime);
  193 + Date today = format.parse(todayStr);
  194 + //昨天 86400000=24*60*60*1000 一天
  195 + if ((today.getTime() - oldTime.getTime()) > 0 && (today.getTime() - oldTime.getTime()) <= 86400000) {
  196 + return 0;
  197 + } else if ((today.getTime() - oldTime.getTime()) <= 0) { //至少是今天
  198 + return -1;
  199 + } else { //至少是前天
  200 + return 1;
  201 + }
  202 + }
  203 +
  204 + /**
  205 + * 检查是否已经创建了桌面快捷方式<br/>
  206 + * 注意:需要添加权限&lt;uses-permission android:name="com.android.launcher.permission.READ_SETTINGS"/&gt;
  207 + * @param context
  208 + * @return
  209 + */
  210 + public static boolean hasShortCut(Context context) {
  211 + String url = "";
  212 + if (Build.VERSION.SDK_INT < 8) {
  213 + url = "content://com.android.launcher.settings/favorites?notify=true";
  214 + } else {
  215 + url = "content://com.android.launcher2.settings/favorites?notify=true";
  216 + }
  217 + ContentResolver resolver = context.getContentResolver();
  218 + Cursor cursor = resolver.query(Uri.parse(url), null, "title=?",
  219 + new String[]{context.getString(R.string.app_name)}, null);
  220 +
  221 + if (cursor != null && cursor.moveToFirst()) {
  222 + cursor.close();
  223 + return true;
  224 + }
  225 +
  226 + return false;
  227 + }
  228 +
  229 + /**
  230 + * 获取当前机器的屏幕信息对象<br/>
  231 + * 另外:通过android.os.Build类可以获取当前系统的相关信息
  232 + *
  233 + * @param context
  234 + * @return
  235 + */
  236 + public static DisplayMetrics getScreenInfo(Context context) {
  237 + WindowManager windowManager = (WindowManager) context
  238 + .getSystemService(Context.WINDOW_SERVICE);
  239 + DisplayMetrics dm = new DisplayMetrics();
  240 + windowManager.getDefaultDisplay().getMetrics(dm);
  241 + // dm.widthPixels;//寬度
  242 + // dm.heightPixels; //高度
  243 + // dm.density; //密度
  244 + return dm;
  245 + }
  246 +
  247 + public static int dip2px(Context context, double dipValue) {
  248 + final float scale = context.getResources().getDisplayMetrics().density;
  249 + return (int) (dipValue * scale + 0.5f);
  250 + }
  251 +
  252 + public static int px2dip(Context context, double pxValue) {
  253 + final float scale = context.getResources().getDisplayMetrics().density;
  254 + return (int) (pxValue / scale + 0.5f);
  255 + }
  256 +
  257 + /**
  258 + * 获取手机号<br/>
  259 + * 注意:需要添加权限&lt;uses-permission
  260 + * android:name="android.permission.READ_PHONE_STATE"/&gt;。另外很多手机不能获取到当前手机号
  261 + *
  262 + * @param context
  263 + * @return
  264 + */
  265 + public static String getMobileNumber(Context context) {
  266 + TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
  267 + if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
  268 + // TODO: Consider calling
  269 + // ActivityCompat#requestPermissions
  270 + // here to request the missing permissions, and then overriding
  271 + // public void onRequestPermissionsResult(int requestCode, String[] permissions,
  272 + // int[] grantResults)
  273 + // to handle the case where the user grants the permission. See the documentation
  274 + // for ActivityCompat#requestPermissions for more details.
  275 + }
  276 + String deviceid = tm.getDeviceId();//获取智能设备唯一编号
  277 + String te1 = tm.getLine1Number();//获取本机号码
  278 + String imei = tm.getSimSerialNumber();//获得SIM卡的序号
  279 + String imsi = tm.getSubscriberId();//得到用户Id
  280 + return tm.getLine1Number();
  281 + }
  282 +
  283 + /**
  284 + * 检测当前的网络连接是否可用<br/>
  285 + * 注意:需要添加权限&lt;uses-permission
  286 + * android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
  287 + *
  288 + * @param context
  289 + * @return
  290 + */
  291 + public static boolean isConnected(Context context) {
  292 + boolean flag = false;
  293 + try {
  294 + ConnectivityManager connManager = (ConnectivityManager) context
  295 + .getSystemService(Context.CONNECTIVITY_SERVICE);
  296 + if (null != connManager) {
  297 + NetworkInfo info = connManager.getActiveNetworkInfo();
  298 + if (null != info && info.isAvailable()) {
  299 + flag = true;
  300 + }
  301 + }
  302 + } catch (Exception e) {
  303 + Timber.d(e + "");
  304 + }
  305 + return flag;
  306 + }
  307 +
  308 + /**
  309 + * 检测当前网络连接的类型<br/>
  310 + * 注意:需要添加权限&lt;uses-permission
  311 + * android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
  312 + *
  313 + * @param context
  314 + * @return 返回0代表GPRS网络;返回1,代表WIFI网络;返回-1代表网络不可用
  315 + */
  316 + public static int getNetworkType(Context context) {
  317 + int code = -1;
  318 + try {
  319 + ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
  320 + if (null != connManager) {
  321 + State state = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState();
  322 + if (State.CONNECTED == state) {
  323 + code = ConnectivityManager.TYPE_WIFI;
  324 + } else {
  325 + state = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState();
  326 + if (State.CONNECTED == state) {
  327 + code = ConnectivityManager.TYPE_MOBILE;
  328 + }
  329 + }
  330 + }
  331 + } catch (Exception e) {
  332 + Timber.d(e + "");
  333 + }
  334 + return code;
  335 + }
  336 +
  337 + /**
  338 + * 返回当前程序版本代码,如:1
  339 + * @param context
  340 + * @return 当前程序版本代码
  341 + */
  342 + public static int getAppVersionCode(Context context) {
  343 + int versionCode = -1;
  344 + try {
  345 + PackageManager pm = context.getApplicationContext().getPackageManager();
  346 + PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
  347 + versionCode = pi.versionCode;
  348 +
  349 + } catch (Exception e) {
  350 + Timber.d("66666%s" ,e.toString()+ "");
  351 + }
  352 + return versionCode;
  353 + }
  354 +
  355 + /**
  356 + * 返回当前程序版本名,如:1.0.1
  357 + *
  358 + * @param context
  359 + * @return 当前程序版本名
  360 + */
  361 + public static String getAppVersionName(Context context) {
  362 + String versionName = "";
  363 + try {
  364 + PackageManager pm = context.getPackageManager();
  365 + PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
  366 + versionName = pi.versionName;
  367 +
  368 + } catch (Exception e) {
  369 + e.printStackTrace();
  370 + }
  371 + return versionName;
  372 + }
  373 +
  374 + /**
  375 + * 安装指定的APK文件,主要用于本应用程序的更新
  376 + *
  377 + * @param context
  378 + * @param apk
  379 + * apk文件的全路径名
  380 + */
  381 + public static void installAPK(Context context, String apk) {
  382 + Intent intent = new Intent(Intent.ACTION_VIEW);
  383 + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  384 + intent.setDataAndType(Uri.fromFile(new File(apk)), "application/vnd.android.package-archive");
  385 + context.startActivity(intent);
  386 + android.os.Process.killProcess(android.os.Process.myPid());
  387 + }
  388 +
  389 + public static void remoteAPK(Context context) {
  390 + Uri packageURI = Uri.parse("package:net.shunzhi");
  391 + Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
  392 + context.startActivity(uninstallIntent);
  393 + }
  394 +
  395 +// public static void setSystemBar(Context context, boolean on, int color) {
  396 +// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
  397 +// SystemHelper.setTranslucentStatus(context, on);
  398 +// SystemBarTintManager mTintManager = new SystemBarTintManager((Activity) context);
  399 +// mTintManager.setStatusBarTintEnabled(true);
  400 +// //mTintManager.setNavigationBarTintEnabled(true);
  401 +// mTintManager.setStatusBarTintResource(color);
  402 +//
  403 +// //SystemBarTintManager.SystemBarConfig config = mTintManager.getConfig();
  404 +// //listViewDrawer.setPadding(0, config.getPixelInsetTop(true), 0, config.getPixelInsetBottom());
  405 +// }
  406 +// }
  407 +
  408 + @TargetApi(19)
  409 + public static void setTranslucentStatus(Context context, boolean on) {
  410 + Window win = ((Activity) context).getWindow();
  411 + WindowManager.LayoutParams winParams = win.getAttributes();
  412 + final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
  413 + if (on) {
  414 + winParams.flags |= bits;
  415 + } else {
  416 + winParams.flags &= ~bits;
  417 + }
  418 + win.setAttributes(winParams);
  419 + }
  420 +}
... ...
app/src/main/java/com/shunzhi/parent/util/Utils.java
1 1 package com.shunzhi.parent.util;
2 2  
  3 +import android.content.Context;
  4 +import android.support.v7.app.AlertDialog;
  5 +
  6 +import com.shunzhi.parent.R;
  7 +
3 8 public class Utils {
4 9 private Utils() {}
5 10  
... ... @@ -33,4 +38,8 @@ public class Utils {
33 38 return "";
34 39 }
35 40  
  41 + public static AlertDialog.Builder styleDialogBuilder(Context context) {
  42 + return new AlertDialog.Builder(context, R.style.AlertDialogCustom);
  43 + }
  44 +
36 45 }
... ...
app/src/main/java/com/shunzhi/parent/views/MyVersionDialog.java 0 → 100644
... ... @@ -0,0 +1,94 @@
  1 +package com.shunzhi.parent.views;
  2 +import android.app.Dialog;
  3 +import android.content.Context;
  4 +import android.content.res.Resources;
  5 +import android.os.Bundle;
  6 +import android.text.method.ScrollingMovementMethod;
  7 +import android.util.DisplayMetrics;
  8 +import android.view.Gravity;
  9 +import android.view.View;
  10 +import android.view.Window;
  11 +import android.view.WindowManager;
  12 +import android.widget.Button;
  13 +import android.widget.TextView;
  14 +
  15 +import com.shunzhi.parent.R;
  16 +
  17 +
  18 +/**
  19 + * 自定义dialog
  20 + * @author Mr.Xu
  21 + *
  22 + */
  23 +public class MyVersionDialog extends Dialog {
  24 + //定义回调事件,用于dialog的点击事件
  25 + public interface OnCustomDialogListener{
  26 + public void clickSure();
  27 + public void clickCancel();
  28 + }
  29 +
  30 + private OnCustomDialogListener customDialogListener;
  31 + String version = "",size="",content ="";
  32 + public MyVersionDialog(Context context, String pVerion, String pSize, String pContent, int style, OnCustomDialogListener customDialogListener) {
  33 + super(context, style);
  34 + this.customDialogListener = customDialogListener;
  35 + version = pVerion;
  36 + size = pSize;
  37 + content = pContent;
  38 + Window window = getWindow();
  39 + WindowManager.LayoutParams params = window.getAttributes();
  40 + //set width,height by density and gravity
  41 + float density = getDensity(context);
  42 + params.width = (int) (300*density);
  43 + params.height = (int) (90*density);
  44 + params.gravity = Gravity.CENTER;
  45 +
  46 +
  47 + //WindowManager.LayoutParams p = getWindow().getAttributes(); //获取对话框当前的参数值
  48 + //Display d = window.getDefaultDisplay(); //为获取屏幕宽、高
  49 + //p.height = (int) (d.getHeight() * 0.6); //高度设置为屏幕的0.6
  50 + //p.width = (int) (d.getWidth() * 0.95); //宽度设置为屏幕的0.95
  51 +
  52 + window.setAttributes(params);
  53 +
  54 + }
  55 + private float getDensity(Context context) {
  56 + Resources resources = context.getResources();
  57 + DisplayMetrics dm = resources.getDisplayMetrics();
  58 + return dm.density;
  59 + }
  60 + @Override
  61 + protected void onCreate(Bundle savedInstanceState) {
  62 + super.onCreate(savedInstanceState);
  63 + setContentView(R.layout.myversiondialog);
  64 + Button clickBtn = (Button) findViewById(R.id.btnSure);
  65 + clickBtn.setOnClickListener(clickListener);
  66 + Button clearBtn = (Button) findViewById(R.id.btnCancel);
  67 + clearBtn.setOnClickListener(clearListener);
  68 +
  69 + TextView txtVersionNum = (TextView) findViewById(R.id.txtVersionNum);
  70 + txtVersionNum.setText(version);
  71 +
  72 + TextView txtSizeNum = (TextView) findViewById(R.id.txtSizeNum);
  73 + txtSizeNum.setText(size);
  74 +
  75 + TextView txtContent = (TextView) findViewById(R.id.txtContent);
  76 + txtContent.setText(content);
  77 + txtContent.setMovementMethod(ScrollingMovementMethod.getInstance()) ;
  78 + }
  79 +
  80 + private View.OnClickListener clickListener = new View.OnClickListener() {
  81 + @Override
  82 + public void onClick(View v) {
  83 + customDialogListener.clickSure();
  84 + MyVersionDialog.this.dismiss();
  85 + }
  86 + };
  87 + private View.OnClickListener clearListener = new View.OnClickListener() {
  88 + @Override
  89 + public void onClick(View v) {
  90 + customDialogListener.clickCancel();
  91 + MyVersionDialog.this.dismiss();
  92 + }
  93 + };
  94 +}
... ...
app/src/main/res/drawable-xhdpi/update.png 0 → 100644

6.55 KB

app/src/main/res/layout/activity_mesage.xml 0 → 100644
... ... @@ -0,0 +1,43 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:app="http://schemas.android.com/apk/res-auto"
  4 + xmlns:tools="http://schemas.android.com/tools"
  5 + android:layout_width="match_parent"
  6 + android:layout_height="match_parent"
  7 + android:background="@color/bgColor"
  8 + android:orientation="vertical"
  9 + tools:context="com.shunzhi.parent.ui.activity.message.MesageActivity">
  10 +
  11 + <FrameLayout
  12 + android:layout_width="match_parent"
  13 + android:layout_height="?android:actionBarSize"
  14 + android:background="@color/titleColor">
  15 +
  16 + <ImageView
  17 + android:layout_width="wrap_content"
  18 + android:layout_height="match_parent"
  19 + android:src="@drawable/back"
  20 + android:paddingLeft="@dimen/size_dp_15"
  21 + android:paddingRight="@dimen/size_dp_15"
  22 + android:id="@+id/iv_back"
  23 + />
  24 +
  25 + <TextView
  26 + style="@style/TextView_Wrap_16"
  27 + android:layout_gravity="center"
  28 + android:gravity="center"
  29 + android:text="消息"
  30 + android:textSize="@dimen/textSize18"
  31 + android:textColor="@color/white" />
  32 +
  33 + </FrameLayout>
  34 +
  35 + <android.support.v7.widget.RecyclerView
  36 + android:layout_width="match_parent"
  37 + android:layout_height="match_parent"
  38 + android:id="@+id/recyclerView"
  39 + android:scrollbars="none"
  40 + android:layout_margin="@dimen/size_dp_10"
  41 + ></android.support.v7.widget.RecyclerView>
  42 +
  43 +</LinearLayout>
... ...
app/src/main/res/layout/activity_personinfo.xml
... ... @@ -19,19 +19,20 @@
19 19  
20 20 <RelativeLayout
21 21 android:layout_width="match_parent"
22   - android:layout_height="360dp">
  22 + android:layout_height="400dp">
23 23  
24 24 <LinearLayout
25 25 android:id="@+id/top_layout"
26 26 android:layout_width="match_parent"
27   - android:layout_height="180dp"
  27 + android:layout_height="200dp"
28 28 android:background="@drawable/backgroud_top"
29 29 android:orientation="vertical"
30   - android:paddingTop="20dp">
  30 + >
31 31  
32 32 <TextView
33 33 android:layout_width="match_parent"
34   - android:layout_height="wrap_content"
  34 + android:layout_height="?android:actionBarSize"
  35 + android:background="@color/back_top"
35 36 android:layout_gravity="center"
36 37 android:gravity="center"
37 38 android:text="个人资料"
... ...
app/src/main/res/layout/fragment_mine.xml
... ... @@ -14,15 +14,15 @@
14 14  
15 15 <LinearLayout
16 16 android:id="@+id/top_layout"
17   - android:paddingTop="20dp"
18 17 android:layout_width="match_parent"
19   - android:layout_height="180dp"
  18 + android:layout_height="200dp"
20 19 android:background="@color/back_top"
21 20 android:orientation="vertical">
22 21  
23 22 <TextView
24 23 android:layout_width="match_parent"
25   - android:layout_height="wrap_content"
  24 + android:layout_height="?android:actionBarSize"
  25 + android:background="@color/back_top"
26 26 android:layout_gravity="center"
27 27 android:gravity="center"
28 28 android:text="个人中心"
... ... @@ -98,6 +98,7 @@
98 98 android:orientation="vertical">
99 99  
100 100 <LinearLayout
  101 + android:id="@+id/layout_message"
101 102 android:layout_width="match_parent"
102 103 android:gravity="center_vertical"
103 104 android:layout_height="?android:actionBarSize">
... ... @@ -118,6 +119,7 @@
118 119 android:textSize="@dimen/txtsize_title" />
119 120  
120 121 <TextView
  122 + android:id="@+id/tvMessageCount"
121 123 android:layout_width="40dp"
122 124 android:layout_height="wrap_content"
123 125 android:layout_gravity="center_vertical"
... ... @@ -270,6 +272,38 @@
270 272 android:background="@color/bottomline" />
271 273  
272 274 <LinearLayout
  275 + android:id="@+id/layout_update"
  276 + android:layout_width="match_parent"
  277 + android:layout_height="?android:actionBarSize"
  278 + android:gravity="center_vertical"
  279 +
  280 + >
  281 +
  282 + <TextView
  283 + android:layout_width="25dp"
  284 + android:layout_height="25dp"
  285 + android:layout_marginLeft="15dp"
  286 + android:layout_marginRight="30dp"
  287 + android:background="@drawable/update" />
  288 +
  289 + <TextView
  290 + android:layout_width="wrap_content"
  291 + android:layout_height="wrap_content"
  292 + android:layout_gravity="center_vertical"
  293 + android:layout_weight="1"
  294 + android:text="版本更新"
  295 + android:textSize="@dimen/txtsize_title" />
  296 +
  297 + </LinearLayout>
  298 +
  299 + <TextView
  300 + android:layout_width="match_parent"
  301 + android:layout_height="0.5dp"
  302 + android:layout_marginLeft="15dp"
  303 + android:layout_marginRight="15dp"
  304 + android:background="@color/bottomline" />
  305 +
  306 + <LinearLayout
273 307 android:id="@+id/layout_cache"
274 308 android:layout_width="match_parent"
275 309 android:layout_height="?android:actionBarSize"
... ...
app/src/main/res/layout/fragment_start.xml
... ... @@ -14,6 +14,7 @@
14 14  
15 15 <cn.jzvd.JZVideoPlayerStandard
16 16 android:id="@+id/jiecaoVideo"
  17 + android:visibility="gone"
17 18 android:layout_width="match_parent"
18 19 android:layout_height="match_parent"></cn.jzvd.JZVideoPlayerStandard>
19 20  
... ...
app/src/main/res/layout/item_message.xml 0 → 100644
... ... @@ -0,0 +1,34 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:layout_width="match_parent"
  4 + android:background="@color/bgColor"
  5 + android:orientation="vertical"
  6 + android:layout_height="match_parent">
  7 +
  8 + <TextView
  9 + android:layout_width="wrap_content"
  10 + android:layout_height="wrap_content"
  11 + android:textColor="@color/textColor"
  12 + android:textSize="@dimen/size_dp_16"
  13 + android:text=""
  14 + android:id="@+id/tvDate"
  15 + android:layout_marginBottom="@dimen/size_dp_5"
  16 + />
  17 +
  18 + <TextView
  19 + android:layout_width="match_parent"
  20 + android:layout_height="wrap_content"
  21 + android:maxLines="2"
  22 + android:textSize="@dimen/textSize14"
  23 + android:textColor="@color/textColor"
  24 + android:background="@color/white"
  25 + android:padding="@dimen/size_dp_5"
  26 + android:ellipsize="end"
  27 + android:id="@+id/tvMessageContent"
  28 + />
  29 + <View
  30 + android:layout_width="match_parent"
  31 + android:layout_height="0.5dp"
  32 + android:background="@color/gray"
  33 + />
  34 +</LinearLayout>
0 35 \ No newline at end of file
... ...
app/src/main/res/layout/myversiondialog.xml 0 → 100644
... ... @@ -0,0 +1,180 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:id="@+id/layoutRoot"
  4 + android:layout_width="250dp"
  5 + android:layout_height="wrap_content"
  6 + android:background="@drawable/shape_radius8_whit"
  7 + android:orientation="vertical"
  8 + android:windowIsFloating="true">
  9 +
  10 +
  11 + <RelativeLayout
  12 + android:id="@+id/layoutTitle"
  13 + android:layout_width="fill_parent"
  14 + android:layout_height="50dp">
  15 +
  16 + <TextView
  17 + android:id="@+id/txtTitle"
  18 + android:layout_width="wrap_content"
  19 + android:layout_height="wrap_content"
  20 + android:layout_centerInParent="true"
  21 + android:text="发现新版本"
  22 + android:textColor="@color/textColor"
  23 + android:textSize="@dimen/textSize18" />
  24 +
  25 + <View
  26 + android:layout_width="fill_parent"
  27 + android:layout_height="1dp"
  28 + android:layout_alignParentBottom="true"
  29 + android:layout_alignParentLeft="true"
  30 + android:layout_alignParentStart="false"
  31 + android:background="@color/textColor" />
  32 +
  33 + </RelativeLayout>
  34 +
  35 + <LinearLayout
  36 + android:id="@+id/layoutContent"
  37 + android:layout_width="fill_parent"
  38 + android:layout_height="wrap_content"
  39 + android:orientation="vertical"
  40 + android:padding="10dp">
  41 +
  42 +
  43 + <RelativeLayout
  44 + android:id="@+id/layoutVersion"
  45 + android:layout_width="match_parent"
  46 + android:layout_height="20dp">
  47 +
  48 + <TextView
  49 + android:id="@+id/txtVersion"
  50 + android:layout_width="wrap_content"
  51 + android:layout_height="wrap_content"
  52 + android:layout_alignParentLeft="true"
  53 + android:layout_centerVertical="true"
  54 + android:text="新版本:"
  55 + android:textColor="@color/textColor"
  56 + android:textSize="@dimen/size_dp_14" />
  57 +
  58 + <TextView
  59 + android:id="@+id/txtVersionNum"
  60 + android:layout_width="wrap_content"
  61 + android:layout_height="wrap_content"
  62 + android:layout_centerVertical="true"
  63 + android:layout_toRightOf="@+id/txtVersion"
  64 + android:text="V1.1.1"
  65 + android:textColor="@color/textColor"
  66 + android:textSize="@dimen/size_dp_14" />
  67 + </RelativeLayout>
  68 +
  69 + <RelativeLayout
  70 + android:visibility="gone"
  71 + android:id="@+id/layoutSize"
  72 + android:layout_width="match_parent"
  73 + android:layout_height="20dp">
  74 +
  75 + <TextView
  76 + android:id="@+id/txtSize"
  77 + android:layout_width="wrap_content"
  78 + android:layout_height="wrap_content"
  79 + android:layout_alignParentLeft="true"
  80 + android:layout_centerVertical="true"
  81 + android:text="新版本大小:"
  82 + android:textColor="@color/textColor"
  83 + android:textSize="@dimen/size_dp_14" />
  84 +
  85 + <TextView
  86 + android:id="@+id/txtSizeNum"
  87 + android:layout_width="wrap_content"
  88 + android:layout_height="wrap_content"
  89 + android:layout_centerVertical="true"
  90 + android:layout_toRightOf="@+id/txtSize"
  91 + android:text="24.86M"
  92 + android:textColor="@color/textColor"
  93 + android:textSize="@dimen/size_dp_14" />
  94 + </RelativeLayout>
  95 +
  96 + <TextView
  97 + android:id="@+id/txtUpdate"
  98 + android:layout_width="wrap_content"
  99 + android:layout_height="wrap_content"
  100 + android:layout_below="@+id/dlgTtile"
  101 + android:layout_centerHorizontal="true"
  102 + android:text="更新内容"
  103 + android:textColor="@color/textColor"
  104 + android:textSize="@dimen/size_dp_14" />
  105 +
  106 + <TextView
  107 + android:id="@+id/txtContent"
  108 + android:layout_width="fill_parent"
  109 + android:layout_height="wrap_content"
  110 + android:layout_below="@+id/dlgTtile"
  111 + android:layout_centerHorizontal="true"
  112 + android:layout_marginTop="5dp"
  113 + android:maxHeight="100dp"
  114 + android:maxLines="4"
  115 + android:scrollbars="vertical"
  116 + android:text="这是确定消息"
  117 + android:textColor="@color/textColor"
  118 + android:textSize="@dimen/size_dp_14" />
  119 +
  120 + </LinearLayout>
  121 +
  122 + <RelativeLayout
  123 + android:id="@+id/layoutBottom"
  124 + android:layout_width="fill_parent"
  125 + android:layout_height="35dp"
  126 + android:layout_marginBottom="10dp">
  127 +
  128 + <Button
  129 + android:id="@+id/btnSure"
  130 + android:layout_width="wrap_content"
  131 + android:layout_height="wrap_content"
  132 + android:layout_centerVertical="true"
  133 + android:layout_marginRight="10dp"
  134 + android:layout_toLeftOf="@+id/line2"
  135 + android:layout_weight="1"
  136 + android:background="@color/xueqing_blue"
  137 + android:gravity="center"
  138 + android:paddingBottom="5dp"
  139 + android:paddingLeft="16dp"
  140 + android:paddingRight="16dp"
  141 + android:paddingTop="5dp"
  142 + android:text="立即更新"
  143 + android:textColor="@color/white"
  144 + android:textSize="@dimen/size_dp_14" />
  145 +
  146 + <Button
  147 + android:id="@+id/btnCancel"
  148 + android:layout_width="wrap_content"
  149 + android:layout_height="wrap_content"
  150 + android:layout_alignParentBottom="false"
  151 + android:layout_alignParentEnd="false"
  152 + android:layout_alignParentRight="false"
  153 + android:layout_centerVertical="true"
  154 + android:layout_marginLeft="10dp"
  155 + android:layout_toRightOf="@+id/line2"
  156 + android:layout_weight="1"
  157 + android:background="@color/textBlue"
  158 + android:gravity="center"
  159 + android:paddingBottom="5dp"
  160 + android:paddingLeft="16dp"
  161 + android:paddingRight="16dp"
  162 + android:paddingTop="5dp"
  163 + android:text="以后再说"
  164 + android:textColor="@color/white"
  165 + android:textSize="@dimen/size_dp_14" />
  166 +
  167 + <View
  168 + android:id="@+id/line2"
  169 + android:layout_width="0dp"
  170 + android:layout_height="50dp"
  171 + android:layout_alignParentTop="true"
  172 + android:layout_centerHorizontal="true"
  173 + android:layout_centerVertical="true"
  174 + android:layout_weight="0"
  175 + android:background="@color/gray" />
  176 +
  177 + </RelativeLayout>
  178 +
  179 +
  180 +</LinearLayout>
... ...
app/src/main/res/layout/progress_dialog.xml 0 → 100644
... ... @@ -0,0 +1,28 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:layout_width="fill_parent"
  4 + android:layout_height="fill_parent"
  5 + android:layout_gravity="center"
  6 + android:gravity="center"
  7 + android:orientation="vertical">
  8 + <ProgressBar
  9 + android:id="@+id/pbar"
  10 + style="?android:attr/progressBarStyleHorizontal"
  11 + android:layout_width="300dp"
  12 + android:layout_height="wrap_content"
  13 + android:max="100"
  14 + android:progress="0" />
  15 +
  16 + <TextView
  17 + android:id="@+id/txt_wait"
  18 + android:layout_width="wrap_content"
  19 + android:layout_height="wrap_content"
  20 + android:layout_gravity="center"
  21 + android:layout_marginTop="8.0dip"
  22 + android:focusable="false"
  23 + android:singleLine="true"
  24 + android:text="加载中..."
  25 + android:textColor="@color/textColor"
  26 + android:textSize="12.0sp" />
  27 +
  28 +</LinearLayout>
... ...
app/src/main/res/values/styles.xml
... ... @@ -8,6 +8,24 @@
8 8 <item name="colorAccent">@color/colorAccent</item>
9 9 </style>
10 10  
  11 + <style name="dialog" parent="Theme.AppCompat.Light.Dialog.Alert">
  12 + <item name="colorPrimary">@color/colorPrimary</item>
  13 + <item name="colorAccent">@color/colorAccent</item>
  14 + <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
  15 + <item name="android:windowFrame">@null</item>
  16 + <item name="android:windowIsFloating">true</item>
  17 + <item name="android:windowIsTranslucent">false</item>
  18 + <item name="android:windowNoTitle">true</item>
  19 + <item name="android:background">@android:color/transparent</item>
  20 + <item name="android:windowBackground">@android:color/transparent</item>
  21 + <item name="android:backgroundDimEnabled">true</item>
  22 + </style>
  23 +
  24 + <style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert">
  25 + <item name="colorPrimary">@color/colorPrimary</item>
  26 + <item name="colorAccent">@color/colorAccent</item>
  27 + <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
  28 + </style>
11 29  
12 30 <style name="TextView_Wrap_16">
13 31 <item name="android:layout_width">wrap_content</item>
... ...
mvpsdk/src/main/java/com/share/mvpsdk/global/GlobalApplication.java
... ... @@ -6,7 +6,9 @@ import android.os.Handler;
6 6  
7 7 import com.orhanobut.logger.LogLevel;
8 8 import com.orhanobut.logger.Logger;
  9 +import com.share.mvpsdk.utils.ToastUtils;
9 10  
  11 +import timber.log.BuildConfig;
10 12 import timber.log.Timber;
11 13  
12 14  
... ... @@ -34,8 +36,11 @@ public class GlobalApplication extends Application {
34 36 handler = new Handler();
35 37 mainThreadId = android.os.Process.myTid();
36 38 mApp=this;
  39 + if (!BuildConfig.DEBUG) {
  40 + Timber.plant(new Timber.DebugTree());
  41 + }
37 42 //LogLevel.FULL : LogLevel.NONE
38   - Logger.init(LOG_TAG).logLevel(LogLevel.FULL);
  43 +// Logger.init(LOG_TAG).logLevel(LogLevel.FULL);
39 44 }
40 45  
41 46 /**
... ...