Commit 22bcc3a8f7d1bb2c114bd01aa64e213a6579a34a
1 parent
1ec4334b
Exists in
yxb_dev
and in
1 other branch
no message
Showing
12 changed files
with
367 additions
and
50 deletions
Show diff stats
app/libs/processor.jar
No preview for this file type
app/src/main/java/com/shunzhi/parent/AppConfig.java
@@ -39,17 +39,17 @@ public class AppConfig { | @@ -39,17 +39,17 @@ public class AppConfig { | ||
39 | public static String APP_IS_START = "app_is_start"; | 39 | public static String APP_IS_START = "app_is_start"; |
40 | 40 | ||
41 | //测试 | 41 | //测试 |
42 | - public static String BASE_URL="http://60.190.202.57:1000/"; | ||
43 | - public static String BASE_URL_ORDER="http://60.190.202.57:8101/"; | ||
44 | - public static String BASE_URL_FILE="http://60.190.202.57:8196"; | ||
45 | - public static String BASE_URL_VOTE = "http://60.190.202.57:8812/"; | 42 | +// public static String BASE_URL="http://60.190.202.57:1000/"; |
43 | +// public static String BASE_URL_ORDER="http://60.190.202.57:8101/"; | ||
44 | +// public static String BASE_URL_FILE="http://60.190.202.57:8196"; | ||
45 | +// public static String BASE_URL_VOTE = "http://60.190.202.57:8812/"; | ||
46 | 46 | ||
47 | 47 | ||
48 | //正式 | 48 | //正式 |
49 | -// public static String BASE_URL = "http://campus.myjxt.com/"; | ||
50 | -// public static String BASE_URL_ORDER = "http://parent.myjxt.com/"; | ||
51 | -// public static String BASE_URL_FILE = "http://manage.myjxt.com"; | ||
52 | -// public static String BASE_URL_VOTE = "www.sxspy.net/"; | 49 | + public static String BASE_URL = "http://campus.myjxt.com/"; |
50 | + public static String BASE_URL_ORDER = "http://parent.myjxt.com/"; | ||
51 | + public static String BASE_URL_FILE = "http://manage.myjxt.com"; | ||
52 | + public static String BASE_URL_VOTE = "www.sxspy.net/"; | ||
53 | // public static final String url_version = BASE_URL + "api/Common/AppVersion?appType=3"; | 53 | // public static final String url_version = BASE_URL + "api/Common/AppVersion?appType=3"; |
54 | 54 | ||
55 | 55 |
@@ -0,0 +1,43 @@ | @@ -0,0 +1,43 @@ | ||
1 | +package com.shunzhi.parent.db; | ||
2 | + | ||
3 | +import android.content.Context; | ||
4 | +import android.database.DatabaseErrorHandler; | ||
5 | +import android.database.sqlite.SQLiteDatabase; | ||
6 | +import android.database.sqlite.SQLiteOpenHelper; | ||
7 | + | ||
8 | +/** | ||
9 | + * Created by ToaHanDong on 2018/4/23. | ||
10 | + */ | ||
11 | + | ||
12 | +public class DBHelper extends SQLiteOpenHelper { | ||
13 | + | ||
14 | + public final int VERSION=1; | ||
15 | + | ||
16 | + public DBHelper(Context context, String name) { | ||
17 | + super(context, name, null, 2); | ||
18 | + } | ||
19 | + | ||
20 | + public DBHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version, DatabaseErrorHandler errorHandler) { | ||
21 | + super(context, name, factory, version, errorHandler); | ||
22 | + } | ||
23 | + | ||
24 | + @Override | ||
25 | + public void onCreate(SQLiteDatabase sqLiteDatabase) { | ||
26 | + DBMessageController.createSongTable(sqLiteDatabase); | ||
27 | + } | ||
28 | + /** | ||
29 | + * | ||
30 | + * @param sqLiteDatabase 数据库对象 | ||
31 | + * @param i 数据库旧版本 | ||
32 | + * @param i1 数据库新版本 | ||
33 | + */ | ||
34 | + @Override | ||
35 | + public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) { | ||
36 | + if (i1==2){ | ||
37 | + sqLiteDatabase.execSQL(DBMessageController.TEMP_SQL);//先把原来的表重命名 | ||
38 | + sqLiteDatabase.execSQL(DBMessageController.sqlVersion2);//创建新表 | ||
39 | + sqLiteDatabase.execSQL(DBMessageController.COPY_SQL);//导入数据 | ||
40 | + sqLiteDatabase.execSQL(DBMessageController.DROP_SQL);//删除备份的数据库 | ||
41 | + } | ||
42 | + } | ||
43 | +} |
app/src/main/java/com/shunzhi/parent/db/DBMessageController.java
0 → 100644
@@ -0,0 +1,146 @@ | @@ -0,0 +1,146 @@ | ||
1 | +package com.shunzhi.parent.db; | ||
2 | + | ||
3 | +import android.content.ContentValues; | ||
4 | +import android.content.Context; | ||
5 | +import android.database.Cursor; | ||
6 | +import android.database.sqlite.SQLiteDatabase; | ||
7 | + | ||
8 | +import java.util.ArrayList; | ||
9 | +import java.util.List; | ||
10 | + | ||
11 | +/** | ||
12 | + * Created by ToaHanDong on 2018/4/23. | ||
13 | + */ | ||
14 | + | ||
15 | +public class DBMessageController { | ||
16 | + | ||
17 | + public static DBMessageController dbMessageController = null; | ||
18 | + | ||
19 | + public static DBMessageController getInstance(Context context) { | ||
20 | + | ||
21 | + if (null == dbMessageController) { | ||
22 | + synchronized (DBMessageController.class) { | ||
23 | + if (null == dbMessageController) | ||
24 | + dbMessageController = new DBMessageController(context, false); | ||
25 | + } | ||
26 | + } | ||
27 | + return dbMessageController; | ||
28 | + } | ||
29 | + | ||
30 | + | ||
31 | + private Context context; | ||
32 | + private SQLiteDatabase database; | ||
33 | + | ||
34 | + public static final String DATABASE = "message.db"; | ||
35 | + | ||
36 | + public static final String TABLE_MESSAGE = "message";//表名 | ||
37 | + public static final String TABLE_TEMP="temp";//备份的表 | ||
38 | + | ||
39 | + public static String TEMP_SQL= "alter table "+TABLE_MESSAGE+" rename to "+TABLE_TEMP; | ||
40 | + public static String COPY_SQL="insert into "+TABLE_MESSAGE+" select * ,' ' from "+TABLE_TEMP; | ||
41 | + public static String DROP_SQL="drop table "+TABLE_TEMP; | ||
42 | + | ||
43 | + public static String sqlVersion2="create table if not exists " + DBMessageController.TABLE_MESSAGE + "(" + | ||
44 | + DBMessageController.MESSAGE_ID + " integer primary key autoincrement," + | ||
45 | + DBMessageController.MESSAGE_TITLE + " text unique," + | ||
46 | + DBMessageController.MESSAGE_MSGID + " text," + | ||
47 | + DBMessageController.MESSAGE_USERID + " text," + | ||
48 | + DBMessageController.MESSAGE_TYPE + " integer," + | ||
49 | + DBMessageController.MESSAGE_DATE+" text,"+ | ||
50 | + DBMessageController.MESSAGE_ISREAD + " text)"; | ||
51 | + | ||
52 | + public static final String MESSAGE_ID = "_id"; //主键 | ||
53 | + public static final String MESSAGE_TITLE = "title"; //内容 | ||
54 | + public static final String MESSAGE_USERID = "userid"; //用户的唯一标识 | ||
55 | + public static final String MESSAGE_TYPE = "type"; //消息类型 | ||
56 | + public static final String MESSAGE_ISREAD = "isread";//判断消息是否为已读 | ||
57 | + public static final String MESSAGE_MSGID = "msgid";//判断消息是否为已读 | ||
58 | + public static final String MESSAGE_DATE="date";//日期 | ||
59 | + | ||
60 | + static void createSongTable(SQLiteDatabase db) { | ||
61 | + String sql = "create table if not exists " + DBMessageController.TABLE_MESSAGE + "(" + | ||
62 | + DBMessageController.MESSAGE_ID + " integer primary key autoincrement," + | ||
63 | + DBMessageController.MESSAGE_TITLE + " text unique," + | ||
64 | + DBMessageController.MESSAGE_MSGID + " text," + | ||
65 | + DBMessageController.MESSAGE_USERID + " text," + | ||
66 | + DBMessageController.MESSAGE_TYPE + " integer," + | ||
67 | + DBMessageController.MESSAGE_ISREAD + " text)"; | ||
68 | + db.execSQL(sql); | ||
69 | + } | ||
70 | + | ||
71 | + /** | ||
72 | + * 在使用结束时应调用{@link #()}关闭数据库连接 | ||
73 | + */ | ||
74 | + public DBMessageController(Context context, boolean writable) { | ||
75 | + DBHelper helper = new DBHelper(context, DATABASE); | ||
76 | + if (writable) { | ||
77 | + this.database = helper.getWritableDatabase(); | ||
78 | + } else { | ||
79 | + this.database = helper.getReadableDatabase(); | ||
80 | + } | ||
81 | + this.context = context; | ||
82 | + } | ||
83 | + | ||
84 | + public void close() { | ||
85 | + if (database.isOpen()) { | ||
86 | + database.close(); | ||
87 | + } | ||
88 | + } | ||
89 | + | ||
90 | + public long addMessages(Messages messages) { | ||
91 | + | ||
92 | + ContentValues contentValues = new ContentValues(); | ||
93 | + contentValues.put(DBMessageController.MESSAGE_TITLE, messages.title); | ||
94 | + contentValues.put(DBMessageController.MESSAGE_TYPE, messages.type); | ||
95 | + contentValues.put(DBMessageController.MESSAGE_USERID, messages.userid); | ||
96 | + contentValues.put(DBMessageController.MESSAGE_ISREAD, messages.isRead); | ||
97 | + contentValues.put(DBMessageController.MESSAGE_MSGID, messages.msgId); | ||
98 | + contentValues.put(DBMessageController.MESSAGE_DATE,messages.date); | ||
99 | + return database.insert(DBMessageController.TABLE_MESSAGE, null, contentValues); | ||
100 | + } | ||
101 | + | ||
102 | + | ||
103 | + public int getMessagesCounts(String type) { | ||
104 | + String sql = "select * from " + TABLE_MESSAGE + "where type = ?"; | ||
105 | + Cursor cursor = database.rawQuery(sql, new String[]{type}); | ||
106 | + return cursor.getCount(); | ||
107 | + } | ||
108 | + | ||
109 | + public int getMessagesCountsAllNoRead() { | ||
110 | + String sql = "select * from " + TABLE_MESSAGE + " where isRead = ?"; | ||
111 | + Cursor cursor = database.rawQuery(sql, new String[]{"false"}); | ||
112 | + return cursor.getCount(); | ||
113 | + } | ||
114 | + | ||
115 | + public void setMeaasgesRead() { | ||
116 | + | ||
117 | + ContentValues contentValues = new ContentValues(); | ||
118 | + contentValues.put(MESSAGE_ISREAD, "true"); | ||
119 | + | ||
120 | + String whereClause="isRead = ?"; | ||
121 | + | ||
122 | + String[] whereArgs = new String[]{"false"}; | ||
123 | + | ||
124 | + database.update(TABLE_MESSAGE, contentValues, whereClause, whereArgs); | ||
125 | + | ||
126 | + | ||
127 | + } | ||
128 | + | ||
129 | + public List<Messages> getAllMessages() { | ||
130 | + | ||
131 | + String sql = "select * from " + TABLE_MESSAGE; | ||
132 | + | ||
133 | + Cursor cursor = database.rawQuery(sql, null); | ||
134 | + | ||
135 | + List<Messages> messagesList = new ArrayList<>(); | ||
136 | + | ||
137 | + while (cursor.moveToNext()) { | ||
138 | + Messages messages = new Messages(); | ||
139 | + messages.type = cursor.getInt(cursor.getColumnIndex(MESSAGE_TYPE)); | ||
140 | + messages.title = cursor.getString(cursor.getColumnIndex(MESSAGE_TITLE)); | ||
141 | + messages.date=cursor.getString(cursor.getColumnIndex(MESSAGE_DATE)); | ||
142 | + messagesList.add(messages); | ||
143 | + } | ||
144 | + return messagesList; | ||
145 | + } | ||
146 | +} |
@@ -0,0 +1,33 @@ | @@ -0,0 +1,33 @@ | ||
1 | +package com.shunzhi.parent.db; | ||
2 | + | ||
3 | +/** | ||
4 | + * Created by ToaHanDong on 2018/4/23. | ||
5 | + */ | ||
6 | + | ||
7 | +public class Messages { | ||
8 | + | ||
9 | + public int id; | ||
10 | + | ||
11 | + public String title; | ||
12 | + | ||
13 | + public String userid; | ||
14 | + | ||
15 | + public int type;//0:作业 1:考勤 2:请假 | ||
16 | + | ||
17 | + public String msgId; | ||
18 | + | ||
19 | + public String isRead;//标识是否已读 | ||
20 | + | ||
21 | + public String date;//收到通知消息的事件 | ||
22 | + | ||
23 | + @Override | ||
24 | + public String toString() { | ||
25 | + return "Messages{" + | ||
26 | + "id=" + id + | ||
27 | + ", title='" + title + '\'' + | ||
28 | + ", userid='" + userid + '\'' + | ||
29 | + ", type='" + type + '\'' + | ||
30 | + ", msgId='" + msgId + '\'' + | ||
31 | + '}'; | ||
32 | + } | ||
33 | +} |
app/src/main/java/com/shunzhi/parent/manager/MessageManager.java
@@ -19,6 +19,7 @@ import com.netease.nimlib.sdk.auth.LoginInfo; | @@ -19,6 +19,7 @@ import com.netease.nimlib.sdk.auth.LoginInfo; | ||
19 | import com.netease.nimlib.sdk.msg.MsgServiceObserve; | 19 | import com.netease.nimlib.sdk.msg.MsgServiceObserve; |
20 | import com.netease.nimlib.sdk.msg.model.CustomNotification; | 20 | import com.netease.nimlib.sdk.msg.model.CustomNotification; |
21 | import com.netease.nimlib.sdk.msg.model.IMMessage; | 21 | import com.netease.nimlib.sdk.msg.model.IMMessage; |
22 | +import com.share.mvpsdk.utils.DateUtils; | ||
22 | import com.share.mvpsdk.utils.ToastUtils; | 23 | import com.share.mvpsdk.utils.ToastUtils; |
23 | import com.shunzhi.parent.AppConfig; | 24 | import com.shunzhi.parent.AppConfig; |
24 | import com.shunzhi.parent.AppContext; | 25 | import com.shunzhi.parent.AppContext; |
@@ -27,6 +28,8 @@ import com.shunzhi.parent.bean.NIMLoginResultBean; | @@ -27,6 +28,8 @@ import com.shunzhi.parent.bean.NIMLoginResultBean; | ||
27 | import com.shunzhi.parent.bean.message.PHMessage; | 28 | import com.shunzhi.parent.bean.message.PHMessage; |
28 | import com.shunzhi.parent.bean.message.PHMessageDao; | 29 | import com.shunzhi.parent.bean.message.PHMessageDao; |
29 | import com.shunzhi.parent.bean.message.PHMessageSession; | 30 | import com.shunzhi.parent.bean.message.PHMessageSession; |
31 | +import com.shunzhi.parent.db.DBMessageController; | ||
32 | +import com.shunzhi.parent.db.Messages; | ||
30 | import com.shunzhi.parent.ui.MainActivity; | 33 | import com.shunzhi.parent.ui.MainActivity; |
31 | import com.shunzhi.parent.ui.activity.LoginAndRegistActivity; | 34 | import com.shunzhi.parent.ui.activity.LoginAndRegistActivity; |
32 | import com.shunzhi.parent.ui.service.BadgeIntentService; | 35 | import com.shunzhi.parent.ui.service.BadgeIntentService; |
@@ -61,14 +64,14 @@ public class MessageManager { | @@ -61,14 +64,14 @@ public class MessageManager { | ||
61 | private Observer<List<IMMessage>> messageObserver = new Observer<List<IMMessage>>() { | 64 | private Observer<List<IMMessage>> messageObserver = new Observer<List<IMMessage>>() { |
62 | @Override | 65 | @Override |
63 | public void onEvent(List<IMMessage> imMessages) { | 66 | public void onEvent(List<IMMessage> imMessages) { |
64 | - Log.d("77777","IMMessage="+imMessages.toString()); | 67 | +// Log.d("77777", "IMMessage=" + imMessages.toString()); |
65 | onMessageReceive(imMessages); | 68 | onMessageReceive(imMessages); |
66 | } | 69 | } |
67 | }; | 70 | }; |
68 | private Observer<CustomNotification> customNotificationObserver = new Observer<CustomNotification>() { | 71 | private Observer<CustomNotification> customNotificationObserver = new Observer<CustomNotification>() { |
69 | @Override | 72 | @Override |
70 | public void onEvent(CustomNotification customNotification) { | 73 | public void onEvent(CustomNotification customNotification) { |
71 | - Log.d("77777","customNotification="+customNotification.getContent()); | 74 | +// Log.d("77777", "customNotification=" + customNotification.getContent()); |
72 | onCustomNotificationReceive(customNotification); | 75 | onCustomNotificationReceive(customNotification); |
73 | } | 76 | } |
74 | }; | 77 | }; |
@@ -107,6 +110,38 @@ public class MessageManager { | @@ -107,6 +110,38 @@ public class MessageManager { | ||
107 | String uuid = json.optString("msgId"); | 110 | String uuid = json.optString("msgId"); |
108 | Timber.d("onCustomNotificationReceive%s", "json=" + json.toString()); | 111 | Timber.d("onCustomNotificationReceive%s", "json=" + json.toString()); |
109 | if ("homework".equals(type)) { | 112 | if ("homework".equals(type)) { |
113 | + Messages messages = new Messages(); | ||
114 | + messages.msgId = uuid; | ||
115 | + messages.title = json.optString("title"); | ||
116 | + messages.type = 0; | ||
117 | + messages.userid = json.optString("userid"); | ||
118 | + messages.isRead="false"; | ||
119 | + messages.date= DateUtils.dateFormat(new Date(),"yyyy年MM月dd日"); | ||
120 | + notifyNotification(uuid, DBMessageController.getInstance(AppContext.getContext()).addMessages(messages), "收到一条作业通知"); | ||
121 | + } else if ("attend".equals(type)) { | ||
122 | + Messages messages = new Messages(); | ||
123 | + messages.msgId = uuid; | ||
124 | + messages.title = json.optString("title"); | ||
125 | + messages.type = 1; | ||
126 | + messages.userid = json.optString("userid"); | ||
127 | + messages.isRead="false"; | ||
128 | + messages.date= DateUtils.dateFormat(new Date(),"yyyy年MM月dd日"); | ||
129 | + notifyNotification(uuid, DBMessageController.getInstance(AppContext.getContext()).addMessages(messages), "收到一条考勤通知"); | ||
130 | + } | ||
131 | + } catch (JSONException e) { | ||
132 | + e.printStackTrace(); | ||
133 | + } | ||
134 | + } | ||
135 | + | ||
136 | + /*private void onCustomNotificationReceive(CustomNotification customNotification) { | ||
137 | + Timber.d("sss-==" + customNotification.getContent()); | ||
138 | + try { | ||
139 | + JSONObject json = new JSONObject(customNotification.getContent()); | ||
140 | + Timber.d("sss-==" + json.toString()); | ||
141 | + String type = json.optString("type"); | ||
142 | + String uuid = json.optString("msgId"); | ||
143 | + Timber.d("onCustomNotificationReceive%s", "json=" + json.toString()); | ||
144 | + if ("homework".equals(type)) { | ||
110 | PHMessageSession session = PHMessageSession.findAndCreateSession(PHMessageSession.sessionType_homework, true); | 145 | PHMessageSession session = PHMessageSession.findAndCreateSession(PHMessageSession.sessionType_homework, true); |
111 | session.setSessionName("作业通知"); | 146 | session.setSessionName("作业通知"); |
112 | session.setDate(new Date(customNotification.getTime())); | 147 | session.setDate(new Date(customNotification.getTime())); |
@@ -144,13 +179,14 @@ public class MessageManager { | @@ -144,13 +179,14 @@ public class MessageManager { | ||
144 | } catch (JSONException e) { | 179 | } catch (JSONException e) { |
145 | e.printStackTrace(); | 180 | e.printStackTrace(); |
146 | } | 181 | } |
147 | - } | 182 | + }*/ |
148 | 183 | ||
149 | public void notifyNotification(String uuid, long msgLongId, String text) { | 184 | public void notifyNotification(String uuid, long msgLongId, String text) { |
150 | if (!isNotiNotification) { | 185 | if (!isNotiNotification) { |
151 | - return; | 186 | +// return; |
152 | } | 187 | } |
153 | - int notificationCount = (int) PHMessage.findUnreadNotificationCount();//XSTMessage.findUnreadNotificationCount(); | 188 | +// int notificationCount = (int) PHMessage.findUnreadNotificationCount();//XSTMessage.findUnreadNotificationCount(); |
189 | + int notificationCount=DBMessageController.getInstance(AppContext.getContext()).getMessagesCountsAllNoRead(); | ||
154 | boolean setBadgerSuccessful = ShortcutBadger.applyCount(AppContext.getInstance(), notificationCount); | 190 | boolean setBadgerSuccessful = ShortcutBadger.applyCount(AppContext.getInstance(), notificationCount); |
155 | Timber.i("----== notificationCount : %s ,setBadgerSuccessful : %s", notificationCount, setBadgerSuccessful); | 191 | Timber.i("----== notificationCount : %s ,setBadgerSuccessful : %s", notificationCount, setBadgerSuccessful); |
156 | if (!setBadgerSuccessful) { | 192 | if (!setBadgerSuccessful) { |
app/src/main/java/com/shunzhi/parent/presenter/loginandregister/LoginAndRegisterPresenter.java
@@ -157,6 +157,7 @@ public class LoginAndRegisterPresenter extends LoginAndRegisterContract.LoginPre | @@ -157,6 +157,7 @@ public class LoginAndRegisterPresenter extends LoginAndRegisterContract.LoginPre | ||
157 | mRxManager.register(mIModel.getUserInfo(mobile, school_id, captcha).subscribe(new Consumer<UserInfo>() { | 157 | mRxManager.register(mIModel.getUserInfo(mobile, school_id, captcha).subscribe(new Consumer<UserInfo>() { |
158 | @Override | 158 | @Override |
159 | public void accept(UserInfo userInfo) throws Exception { | 159 | public void accept(UserInfo userInfo) throws Exception { |
160 | + Log.d("77777","userInfo="+userInfo); | ||
160 | if (userInfo != null) { | 161 | if (userInfo != null) { |
161 | CurrentBean currentBean = userInfo.getData(); | 162 | CurrentBean currentBean = userInfo.getData(); |
162 | AppConfig.getAppConfig(AppContext.getInstance()).set(AppConfig.LOGIN_NAME, currentBean.getMobile()); | 163 | AppConfig.getAppConfig(AppContext.getInstance()).set(AppConfig.LOGIN_NAME, currentBean.getMobile()); |
app/src/main/java/com/shunzhi/parent/ui/activity/message/MesageActivity.java
1 | package com.shunzhi.parent.ui.activity.message; | 1 | package com.shunzhi.parent.ui.activity.message; |
2 | 2 | ||
3 | +import android.graphics.Color; | ||
3 | import android.os.Bundle; | 4 | import android.os.Bundle; |
4 | import android.support.v7.widget.LinearLayoutManager; | 5 | import android.support.v7.widget.LinearLayoutManager; |
5 | import android.support.v7.widget.RecyclerView; | 6 | import android.support.v7.widget.RecyclerView; |
7 | +import android.text.SpannableString; | ||
8 | +import android.text.Spanned; | ||
9 | +import android.text.SpannedString; | ||
10 | +import android.text.style.ForegroundColorSpan; | ||
6 | import android.view.LayoutInflater; | 11 | import android.view.LayoutInflater; |
7 | import android.view.View; | 12 | import android.view.View; |
8 | import android.view.ViewGroup; | 13 | import android.view.ViewGroup; |
@@ -16,6 +21,8 @@ import com.share.mvpsdk.utils.DateUtils; | @@ -16,6 +21,8 @@ import com.share.mvpsdk.utils.DateUtils; | ||
16 | import com.shunzhi.parent.AppContext; | 21 | import com.shunzhi.parent.AppContext; |
17 | import com.shunzhi.parent.R; | 22 | import com.shunzhi.parent.R; |
18 | import com.shunzhi.parent.bean.message.PHMessage; | 23 | import com.shunzhi.parent.bean.message.PHMessage; |
24 | +import com.shunzhi.parent.db.DBMessageController; | ||
25 | +import com.shunzhi.parent.db.Messages; | ||
19 | 26 | ||
20 | import java.util.ArrayList; | 27 | import java.util.ArrayList; |
21 | import java.util.List; | 28 | import java.util.List; |
@@ -26,9 +33,9 @@ public class MesageActivity extends BaseCompatActivity implements View.OnClickLi | @@ -26,9 +33,9 @@ public class MesageActivity extends BaseCompatActivity implements View.OnClickLi | ||
26 | 33 | ||
27 | ImageView iv_back; | 34 | ImageView iv_back; |
28 | 35 | ||
29 | - MEssageAdapter mEssageAdapter=null; | 36 | + MEssageAdapter mEssageAdapter = null; |
30 | 37 | ||
31 | - List<PHMessage> phMessages=new ArrayList<>(); | 38 | + List<Messages> phMessages = new ArrayList<>(); |
32 | 39 | ||
33 | @Override | 40 | @Override |
34 | protected void initView(Bundle savedInstanceState) { | 41 | protected void initView(Bundle savedInstanceState) { |
@@ -49,11 +56,11 @@ public class MesageActivity extends BaseCompatActivity implements View.OnClickLi | @@ -49,11 +56,11 @@ public class MesageActivity extends BaseCompatActivity implements View.OnClickLi | ||
49 | 56 | ||
50 | private void initAdapter() { | 57 | private void initAdapter() { |
51 | 58 | ||
52 | - if (null==mEssageAdapter)mEssageAdapter=new MEssageAdapter(); | ||
53 | - if (null==recyclerView.getAdapter())recyclerView.setAdapter(mEssageAdapter); | 59 | + if (null == mEssageAdapter) mEssageAdapter = new MEssageAdapter(); |
60 | + if (null == recyclerView.getAdapter()) recyclerView.setAdapter(mEssageAdapter); | ||
54 | 61 | ||
55 | - | ||
56 | - phMessages= AppContext.getInstance().getDaoSession().getPHMessageDao().loadAll(); | 62 | +// phMessages= AppContext.getInstance().getDaoSession().getPHMessageDao().loadAll(); |
63 | + phMessages = DBMessageController.getInstance(this).getAllMessages(); | ||
57 | mEssageAdapter.addAll(phMessages); | 64 | mEssageAdapter.addAll(phMessages); |
58 | recyclerView.setAdapter(mEssageAdapter); | 65 | recyclerView.setAdapter(mEssageAdapter); |
59 | 66 | ||
@@ -73,8 +80,7 @@ public class MesageActivity extends BaseCompatActivity implements View.OnClickLi | @@ -73,8 +80,7 @@ public class MesageActivity extends BaseCompatActivity implements View.OnClickLi | ||
73 | } | 80 | } |
74 | } | 81 | } |
75 | 82 | ||
76 | - | ||
77 | - private class MEssageAdapter extends BaseRecyclerViewAdapter<PHMessage> { | 83 | + private class MEssageAdapter extends BaseRecyclerViewAdapter<Messages> { |
78 | 84 | ||
79 | @Override | 85 | @Override |
80 | public void onAttachedToRecyclerView(RecyclerView recyclerView) { | 86 | public void onAttachedToRecyclerView(RecyclerView recyclerView) { |
@@ -93,28 +99,45 @@ public class MesageActivity extends BaseCompatActivity implements View.OnClickLi | @@ -93,28 +99,45 @@ public class MesageActivity extends BaseCompatActivity implements View.OnClickLi | ||
93 | return messageViewHolder; | 99 | return messageViewHolder; |
94 | } | 100 | } |
95 | 101 | ||
96 | - private class MessageViewHolder extends BaseRecyclerViewHolder<PHMessage> { | 102 | + private class MessageViewHolder extends BaseRecyclerViewHolder<Messages> { |
97 | 103 | ||
98 | - TextView tvMessageContent, tvDate; | 104 | + TextView tvMessageContent, tvDate, tvLookDetail; |
99 | List<String> dateString = new ArrayList<>(); | 105 | List<String> dateString = new ArrayList<>(); |
106 | + String indexDate = ""; | ||
100 | 107 | ||
101 | public MessageViewHolder(View itemView) { | 108 | public MessageViewHolder(View itemView) { |
102 | super(itemView); | 109 | super(itemView); |
103 | tvMessageContent = itemView.findViewById(R.id.tvMessageContent); | 110 | tvMessageContent = itemView.findViewById(R.id.tvMessageContent); |
104 | tvDate = itemView.findViewById(R.id.tvDate); | 111 | tvDate = itemView.findViewById(R.id.tvDate); |
112 | + tvLookDetail = itemView.findViewById(R.id.tvLookDetail); | ||
105 | } | 113 | } |
106 | 114 | ||
107 | @Override | 115 | @Override |
108 | - public void onBindViewHolder(PHMessage object, int position) { | ||
109 | - tvMessageContent.setText(object.getMessageText()); | ||
110 | - String date = DateUtils.date2str(object.getDate(), "yyyyMMDD"); | ||
111 | - if (!dateString.contains(date)) { | ||
112 | - dateString.add(date); | ||
113 | - tvDate.setText(date); | 116 | + public void onBindViewHolder(Messages object, int position) { |
117 | + | ||
118 | + String typeName = ""; | ||
119 | + if (object.type == 0) typeName = "作业通知:"; | ||
120 | + else if (object.type == 1) typeName = "考勤通知:"; | ||
121 | + else if (object.type == 2) tvLookDetail.setVisibility(View.VISIBLE); | ||
122 | + typeName += object.title; | ||
123 | + SpannableString spannableString = new SpannableString(typeName); | ||
124 | + ForegroundColorSpan colorSpan = new ForegroundColorSpan(Color.parseColor("#ff0000")); | ||
125 | + spannableString.setSpan(colorSpan, 0, 5, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); | ||
126 | + tvMessageContent.setText(spannableString); | ||
127 | + if (indexDate.equals(object.date)) tvDate.setVisibility(View.GONE); | ||
128 | + else { | ||
129 | + indexDate = object.date; | ||
114 | tvDate.setVisibility(View.VISIBLE); | 130 | tvDate.setVisibility(View.VISIBLE); |
115 | - }else { | ||
116 | - tvDate.setVisibility(View.GONE); | ||
117 | } | 131 | } |
132 | + if (object.date.equals("false")) tvDate.setText(""); | ||
133 | + else tvDate.setText(object.date); | ||
134 | + tvLookDetail.setOnClickListener(new View.OnClickListener() { | ||
135 | + @Override | ||
136 | + public void onClick(View view) { | ||
137 | + //查看请假详情 | ||
138 | + | ||
139 | + } | ||
140 | + }); | ||
118 | 141 | ||
119 | } | 142 | } |
120 | } | 143 | } |
app/src/main/java/com/shunzhi/parent/ui/fragment/MineFragment.java
@@ -23,6 +23,7 @@ import com.shunzhi.parent.R; | @@ -23,6 +23,7 @@ import com.shunzhi.parent.R; | ||
23 | import com.shunzhi.parent.bean.message.PHMessage; | 23 | import com.shunzhi.parent.bean.message.PHMessage; |
24 | import com.shunzhi.parent.contract.loginandregister.LoginAndRegisterContract; | 24 | import com.shunzhi.parent.contract.loginandregister.LoginAndRegisterContract; |
25 | import com.shunzhi.parent.contract.mine.MineContract; | 25 | import com.shunzhi.parent.contract.mine.MineContract; |
26 | +import com.shunzhi.parent.db.DBMessageController; | ||
26 | import com.shunzhi.parent.manager.MessageManager; | 27 | import com.shunzhi.parent.manager.MessageManager; |
27 | import com.shunzhi.parent.manager.UpdateManager; | 28 | import com.shunzhi.parent.manager.UpdateManager; |
28 | import com.shunzhi.parent.presenter.mine.MinePresenter; | 29 | import com.shunzhi.parent.presenter.mine.MinePresenter; |
@@ -92,7 +93,7 @@ public class MineFragment extends BaseMVPCompatFragment<LoginAndRegisterContract | @@ -92,7 +93,7 @@ public class MineFragment extends BaseMVPCompatFragment<LoginAndRegisterContract | ||
92 | view.findViewById(R.id.testEnter).setVisibility(View.GONE); | 93 | view.findViewById(R.id.testEnter).setVisibility(View.GONE); |
93 | } | 94 | } |
94 | 95 | ||
95 | - tvMessageCount.setText(PHMessage.findUnreadNotificationCount() + ""); | 96 | +// tvMessageCount.setText(PHMessage.findUnreadNotificationCount() + ""); |
96 | 97 | ||
97 | } | 98 | } |
98 | 99 | ||
@@ -131,6 +132,7 @@ public class MineFragment extends BaseMVPCompatFragment<LoginAndRegisterContract | @@ -131,6 +132,7 @@ public class MineFragment extends BaseMVPCompatFragment<LoginAndRegisterContract | ||
131 | layout_afterLogin.setVisibility(View.GONE); | 132 | layout_afterLogin.setVisibility(View.GONE); |
132 | tvExit.setVisibility(View.GONE); | 133 | tvExit.setVisibility(View.GONE); |
133 | } | 134 | } |
135 | + tvMessageCount.setText(DBMessageController.getInstance(getContext()).getMessagesCountsAllNoRead() + ""); | ||
134 | } | 136 | } |
135 | 137 | ||
136 | 138 | ||
@@ -139,6 +141,7 @@ public class MineFragment extends BaseMVPCompatFragment<LoginAndRegisterContract | @@ -139,6 +141,7 @@ public class MineFragment extends BaseMVPCompatFragment<LoginAndRegisterContract | ||
139 | switch (v.getId()) { | 141 | switch (v.getId()) { |
140 | case R.id.layout_message: | 142 | case R.id.layout_message: |
141 | startNewActivity(MesageActivity.class); | 143 | startNewActivity(MesageActivity.class); |
144 | + DBMessageController.getInstance(getContext()).setMeaasgesRead(); | ||
142 | break; | 145 | break; |
143 | case R.id.childlayout: | 146 | case R.id.childlayout: |
144 | startActivity(new Intent().setClass(getActivity(), MyChildActivity.class)); | 147 | startActivity(new Intent().setClass(getActivity(), MyChildActivity.class)); |
app/src/main/res/layout/item_message.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | android:layout_width="match_parent" | 3 | android:layout_width="match_parent" |
4 | + android:layout_height="wrap_content" | ||
4 | android:background="@color/bgColor" | 5 | android:background="@color/bgColor" |
5 | - android:orientation="vertical" | ||
6 | - android:layout_height="match_parent"> | 6 | + android:layout_marginTop="@dimen/size_dp_10" |
7 | + android:orientation="vertical"> | ||
7 | 8 | ||
8 | <TextView | 9 | <TextView |
10 | + android:id="@+id/tvDate" | ||
9 | android:layout_width="wrap_content" | 11 | android:layout_width="wrap_content" |
10 | android:layout_height="wrap_content" | 12 | 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" | 13 | android:layout_marginBottom="@dimen/size_dp_5" |
16 | - /> | 14 | + android:text="" |
15 | + android:textColor="@color/textColor" | ||
16 | + android:textSize="@dimen/size_dp_16" /> | ||
17 | + | ||
18 | + | ||
19 | + <LinearLayout | ||
20 | + android:orientation="vertical" | ||
21 | + android:layout_width="match_parent" | ||
22 | + android:layout_height="wrap_content" | ||
23 | + android:padding="@dimen/size_dp_10" | ||
24 | + android:background="@color/white"> | ||
17 | 25 | ||
18 | <TextView | 26 | <TextView |
27 | + android:id="@+id/tvMessageContent" | ||
19 | android:layout_width="match_parent" | 28 | android:layout_width="match_parent" |
20 | android:layout_height="wrap_content" | 29 | android:layout_height="wrap_content" |
30 | + android:ellipsize="end" | ||
21 | android:maxLines="2" | 31 | android:maxLines="2" |
22 | - android:textSize="@dimen/textSize14" | ||
23 | android:textColor="@color/textColor" | 32 | 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 | 33 | + android:textSize="@dimen/textSize14" /> |
34 | + | ||
35 | + <TextView | ||
36 | + android:id="@+id/tvLookDetail" | ||
37 | + android:visibility="gone" | ||
30 | android:layout_width="match_parent" | 38 | android:layout_width="match_parent" |
31 | - android:layout_height="0.5dp" | ||
32 | - android:background="@color/gray" | ||
33 | - /> | 39 | + android:gravity="right" |
40 | + android:paddingRight="@dimen/size_dp_15" | ||
41 | + android:paddingTop="@dimen/size_dp_5" | ||
42 | + android:paddingBottom="@dimen/size_dp_5" | ||
43 | + android:layout_height="wrap_content" | ||
44 | + android:layout_gravity="right" | ||
45 | + android:text="点击查看" | ||
46 | + android:textColor="@color/xueqing_blue" | ||
47 | + android:textSize="@dimen/size_dp_16" /> | ||
48 | + | ||
49 | + </LinearLayout> | ||
50 | + | ||
51 | + | ||
52 | + <View | ||
53 | + android:layout_width="match_parent" | ||
54 | + android:layout_height="0.5dp" | ||
55 | + android:background="@color/gray" /> | ||
34 | </LinearLayout> | 56 | </LinearLayout> |
35 | \ No newline at end of file | 57 | \ No newline at end of file |
mvpsdk/src/main/java/com/share/mvpsdk/utils/DBUtils.java
@@ -17,7 +17,8 @@ import com.share.mvpsdk.config.DBConfig; | @@ -17,7 +17,8 @@ import com.share.mvpsdk.config.DBConfig; | ||
17 | */ | 17 | */ |
18 | public class DBUtils { | 18 | public class DBUtils { |
19 | public static final String CREATE_TABLE_IF_NOT_EXISTS = "create table if not exists %s " + | 19 | public static final String CREATE_TABLE_IF_NOT_EXISTS = "create table if not exists %s " + |
20 | - "(id integer primary key autoincrement,key text unique,is_read integer)"; | 20 | + "(id integer primary key autoincrement,title text unique,image text)"; |
21 | + | ||
21 | 22 | ||
22 | private static DBUtils sDBUtis; | 23 | private static DBUtils sDBUtis; |
23 | private SQLiteDatabase mSQLiteDatabase; | 24 | private SQLiteDatabase mSQLiteDatabase; |
@@ -79,6 +80,10 @@ public class DBUtils { | @@ -79,6 +80,10 @@ public class DBUtils { | ||
79 | return isRead; | 80 | return isRead; |
80 | } | 81 | } |
81 | 82 | ||
83 | + public void insert(String table,String key,String value){ | ||
84 | + | ||
85 | + } | ||
86 | + | ||
82 | public class DBHelper extends SQLiteOpenHelper { | 87 | public class DBHelper extends SQLiteOpenHelper { |
83 | 88 | ||
84 | public DBHelper(Context context, String name) { | 89 | public DBHelper(Context context, String name) { |
mvpsdk/src/main/java/com/share/mvpsdk/utils/DateUtils.java
@@ -69,6 +69,11 @@ public class DateUtils { | @@ -69,6 +69,11 @@ public class DateUtils { | ||
69 | return date.split(PATTERN_SPLIT)[0]; | 69 | return date.split(PATTERN_SPLIT)[0]; |
70 | } | 70 | } |
71 | 71 | ||
72 | + public static String dateFormat(Date date,String fomart){ | ||
73 | + SimpleDateFormat simpleDateFormat=new SimpleDateFormat(fomart); | ||
74 | + return simpleDateFormat.format(date); | ||
75 | + } | ||
76 | + | ||
72 | /** | 77 | /** |
73 | * 原有日期上累加月 | 78 | * 原有日期上累加月 |
74 | * | 79 | * |