diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java new file mode 100644 index 0000000..017a37e --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -0,0 +1,74 @@ +package com.casic.dcms.bean; + +public class PushResultBean { + + /** + * content : 您有一个工单超时,请快速处理 + * data : {"id":"1393113365064245250"} + * id : 1393117524798783490 + * title : 工单超时提醒 + * type : alarm + */ + + private String content; + private DataBean data; + private String id; + private String title; + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class DataBean { + /** + * id : 1393113365064245250 + */ + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java new file mode 100644 index 0000000..017a37e --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -0,0 +1,74 @@ +package com.casic.dcms.bean; + +public class PushResultBean { + + /** + * content : 您有一个工单超时,请快速处理 + * data : {"id":"1393113365064245250"} + * id : 1393117524798783490 + * title : 工单超时提醒 + * type : alarm + */ + + private String content; + private DataBean data; + private String id; + private String title; + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class DataBean { + /** + * id : 1393113365064245250 + */ + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java index 259eb85..c118368 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,11 +25,13 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property NoticeTitle = new Property(1, String.class, "noticeTitle", false, "NOTICE_TITLE"); - public final static Property NoticeDate = new Property(2, String.class, "noticeDate", false, "NOTICE_DATE"); - public final static Property NoticeContent = new Property(3, String.class, "noticeContent", false, "NOTICE_CONTENT"); - public final static Property SenderName = new Property(4, String.class, "senderName", false, "SENDER_NAME"); - public final static Property IsRead = new Property(5, String.class, "isRead", false, "IS_READ"); + public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property CaseId = new Property(2, String.class, "caseId", false, "CASE_ID"); + public final static Property Title = new Property(3, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(4, String.class, "content", false, "CONTENT"); + public final static Property PushDate = new Property(5, String.class, "pushDate", false, "PUSH_DATE"); + public final static Property Type = new Property(6, String.class, "type", false, "TYPE"); + public final static Property IsRead = new Property(7, String.class, "isRead", false, "IS_READ"); } @@ -46,11 +48,13 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"NOTICE_TITLE\" TEXT," + // 1: noticeTitle - "\"NOTICE_DATE\" TEXT," + // 2: noticeDate - "\"NOTICE_CONTENT\" TEXT," + // 3: noticeContent - "\"SENDER_NAME\" TEXT," + // 4: senderName - "\"IS_READ\" TEXT);"); // 5: isRead + "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"CASE_ID\" TEXT," + // 2: caseId + "\"TITLE\" TEXT," + // 3: title + "\"CONTENT\" TEXT," + // 4: content + "\"PUSH_DATE\" TEXT," + // 5: pushDate + "\"TYPE\" TEXT," + // 6: type + "\"IS_READ\" TEXT);"); // 7: isRead } /** Drops the underlying database table. */ @@ -68,29 +72,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -103,29 +117,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -138,11 +162,13 @@ public NoticeBean readEntity(Cursor cursor, int offset) { NoticeBean entity = new NoticeBean( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // noticeTitle - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // noticeDate - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // noticeContent - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // senderName - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // isRead + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userPhone + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // caseId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pushDate + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // type + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // isRead ); return entity; } @@ -150,11 +176,13 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setNoticeTitle(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setNoticeDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setNoticeContent(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setSenderName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setIsRead(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setCaseId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setPushDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setType(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setIsRead(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); } @Override diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java new file mode 100644 index 0000000..017a37e --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -0,0 +1,74 @@ +package com.casic.dcms.bean; + +public class PushResultBean { + + /** + * content : 您有一个工单超时,请快速处理 + * data : {"id":"1393113365064245250"} + * id : 1393117524798783490 + * title : 工单超时提醒 + * type : alarm + */ + + private String content; + private DataBean data; + private String id; + private String title; + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class DataBean { + /** + * id : 1393113365064245250 + */ + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java index 259eb85..c118368 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,11 +25,13 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property NoticeTitle = new Property(1, String.class, "noticeTitle", false, "NOTICE_TITLE"); - public final static Property NoticeDate = new Property(2, String.class, "noticeDate", false, "NOTICE_DATE"); - public final static Property NoticeContent = new Property(3, String.class, "noticeContent", false, "NOTICE_CONTENT"); - public final static Property SenderName = new Property(4, String.class, "senderName", false, "SENDER_NAME"); - public final static Property IsRead = new Property(5, String.class, "isRead", false, "IS_READ"); + public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property CaseId = new Property(2, String.class, "caseId", false, "CASE_ID"); + public final static Property Title = new Property(3, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(4, String.class, "content", false, "CONTENT"); + public final static Property PushDate = new Property(5, String.class, "pushDate", false, "PUSH_DATE"); + public final static Property Type = new Property(6, String.class, "type", false, "TYPE"); + public final static Property IsRead = new Property(7, String.class, "isRead", false, "IS_READ"); } @@ -46,11 +48,13 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"NOTICE_TITLE\" TEXT," + // 1: noticeTitle - "\"NOTICE_DATE\" TEXT," + // 2: noticeDate - "\"NOTICE_CONTENT\" TEXT," + // 3: noticeContent - "\"SENDER_NAME\" TEXT," + // 4: senderName - "\"IS_READ\" TEXT);"); // 5: isRead + "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"CASE_ID\" TEXT," + // 2: caseId + "\"TITLE\" TEXT," + // 3: title + "\"CONTENT\" TEXT," + // 4: content + "\"PUSH_DATE\" TEXT," + // 5: pushDate + "\"TYPE\" TEXT," + // 6: type + "\"IS_READ\" TEXT);"); // 7: isRead } /** Drops the underlying database table. */ @@ -68,29 +72,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -103,29 +117,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -138,11 +162,13 @@ public NoticeBean readEntity(Cursor cursor, int offset) { NoticeBean entity = new NoticeBean( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // noticeTitle - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // noticeDate - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // noticeContent - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // senderName - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // isRead + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userPhone + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // caseId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pushDate + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // type + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // isRead ); return entity; } @@ -150,11 +176,13 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setNoticeTitle(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setNoticeDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setNoticeContent(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setSenderName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setIsRead(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setCaseId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setPushDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setType(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setIsRead(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); } @Override diff --git a/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java new file mode 100644 index 0000000..7c3fb29 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface IPushRegisterModel { + Subscription sendRetrofitRequest(String clientid); +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java new file mode 100644 index 0000000..017a37e --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -0,0 +1,74 @@ +package com.casic.dcms.bean; + +public class PushResultBean { + + /** + * content : 您有一个工单超时,请快速处理 + * data : {"id":"1393113365064245250"} + * id : 1393117524798783490 + * title : 工单超时提醒 + * type : alarm + */ + + private String content; + private DataBean data; + private String id; + private String title; + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class DataBean { + /** + * id : 1393113365064245250 + */ + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java index 259eb85..c118368 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,11 +25,13 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property NoticeTitle = new Property(1, String.class, "noticeTitle", false, "NOTICE_TITLE"); - public final static Property NoticeDate = new Property(2, String.class, "noticeDate", false, "NOTICE_DATE"); - public final static Property NoticeContent = new Property(3, String.class, "noticeContent", false, "NOTICE_CONTENT"); - public final static Property SenderName = new Property(4, String.class, "senderName", false, "SENDER_NAME"); - public final static Property IsRead = new Property(5, String.class, "isRead", false, "IS_READ"); + public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property CaseId = new Property(2, String.class, "caseId", false, "CASE_ID"); + public final static Property Title = new Property(3, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(4, String.class, "content", false, "CONTENT"); + public final static Property PushDate = new Property(5, String.class, "pushDate", false, "PUSH_DATE"); + public final static Property Type = new Property(6, String.class, "type", false, "TYPE"); + public final static Property IsRead = new Property(7, String.class, "isRead", false, "IS_READ"); } @@ -46,11 +48,13 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"NOTICE_TITLE\" TEXT," + // 1: noticeTitle - "\"NOTICE_DATE\" TEXT," + // 2: noticeDate - "\"NOTICE_CONTENT\" TEXT," + // 3: noticeContent - "\"SENDER_NAME\" TEXT," + // 4: senderName - "\"IS_READ\" TEXT);"); // 5: isRead + "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"CASE_ID\" TEXT," + // 2: caseId + "\"TITLE\" TEXT," + // 3: title + "\"CONTENT\" TEXT," + // 4: content + "\"PUSH_DATE\" TEXT," + // 5: pushDate + "\"TYPE\" TEXT," + // 6: type + "\"IS_READ\" TEXT);"); // 7: isRead } /** Drops the underlying database table. */ @@ -68,29 +72,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -103,29 +117,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -138,11 +162,13 @@ public NoticeBean readEntity(Cursor cursor, int offset) { NoticeBean entity = new NoticeBean( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // noticeTitle - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // noticeDate - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // noticeContent - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // senderName - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // isRead + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userPhone + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // caseId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pushDate + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // type + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // isRead ); return entity; } @@ -150,11 +176,13 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setNoticeTitle(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setNoticeDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setNoticeContent(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setSenderName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setIsRead(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setCaseId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setPushDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setType(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setIsRead(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); } @Override diff --git a/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java new file mode 100644 index 0000000..7c3fb29 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface IPushRegisterModel { + Subscription sendRetrofitRequest(String clientid); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java new file mode 100644 index 0000000..c7ae0c1 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class PushRegisterModelImpl implements IPushRegisterModel { + + private OnRegisterListener updateListener; + + public PushRegisterModelImpl(OnRegisterListener listener) { + this.updateListener = listener; + } + + public interface OnRegisterListener { + void onSuccess(ActionResultBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest(String clientid) { + Observable observable = RetrofitServiceManager.getRegisterResult(clientid); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + updateListener.onFailure(e); + } + } + + @Override + public void onNext(ActionResultBean resultBean) { + if (resultBean != null) { + updateListener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java new file mode 100644 index 0000000..017a37e --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -0,0 +1,74 @@ +package com.casic.dcms.bean; + +public class PushResultBean { + + /** + * content : 您有一个工单超时,请快速处理 + * data : {"id":"1393113365064245250"} + * id : 1393117524798783490 + * title : 工单超时提醒 + * type : alarm + */ + + private String content; + private DataBean data; + private String id; + private String title; + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class DataBean { + /** + * id : 1393113365064245250 + */ + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java index 259eb85..c118368 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,11 +25,13 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property NoticeTitle = new Property(1, String.class, "noticeTitle", false, "NOTICE_TITLE"); - public final static Property NoticeDate = new Property(2, String.class, "noticeDate", false, "NOTICE_DATE"); - public final static Property NoticeContent = new Property(3, String.class, "noticeContent", false, "NOTICE_CONTENT"); - public final static Property SenderName = new Property(4, String.class, "senderName", false, "SENDER_NAME"); - public final static Property IsRead = new Property(5, String.class, "isRead", false, "IS_READ"); + public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property CaseId = new Property(2, String.class, "caseId", false, "CASE_ID"); + public final static Property Title = new Property(3, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(4, String.class, "content", false, "CONTENT"); + public final static Property PushDate = new Property(5, String.class, "pushDate", false, "PUSH_DATE"); + public final static Property Type = new Property(6, String.class, "type", false, "TYPE"); + public final static Property IsRead = new Property(7, String.class, "isRead", false, "IS_READ"); } @@ -46,11 +48,13 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"NOTICE_TITLE\" TEXT," + // 1: noticeTitle - "\"NOTICE_DATE\" TEXT," + // 2: noticeDate - "\"NOTICE_CONTENT\" TEXT," + // 3: noticeContent - "\"SENDER_NAME\" TEXT," + // 4: senderName - "\"IS_READ\" TEXT);"); // 5: isRead + "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"CASE_ID\" TEXT," + // 2: caseId + "\"TITLE\" TEXT," + // 3: title + "\"CONTENT\" TEXT," + // 4: content + "\"PUSH_DATE\" TEXT," + // 5: pushDate + "\"TYPE\" TEXT," + // 6: type + "\"IS_READ\" TEXT);"); // 7: isRead } /** Drops the underlying database table. */ @@ -68,29 +72,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -103,29 +117,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -138,11 +162,13 @@ public NoticeBean readEntity(Cursor cursor, int offset) { NoticeBean entity = new NoticeBean( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // noticeTitle - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // noticeDate - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // noticeContent - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // senderName - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // isRead + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userPhone + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // caseId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pushDate + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // type + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // isRead ); return entity; } @@ -150,11 +176,13 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setNoticeTitle(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setNoticeDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setNoticeContent(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setSenderName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setIsRead(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setCaseId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setPushDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setType(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setIsRead(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); } @Override diff --git a/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java new file mode 100644 index 0000000..7c3fb29 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface IPushRegisterModel { + Subscription sendRetrofitRequest(String clientid); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java new file mode 100644 index 0000000..c7ae0c1 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class PushRegisterModelImpl implements IPushRegisterModel { + + private OnRegisterListener updateListener; + + public PushRegisterModelImpl(OnRegisterListener listener) { + this.updateListener = listener; + } + + public interface OnRegisterListener { + void onSuccess(ActionResultBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest(String clientid) { + Observable observable = RetrofitServiceManager.getRegisterResult(clientid); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + updateListener.onFailure(e); + } + } + + @Override + public void onNext(ActionResultBean resultBean) { + if (resultBean != null) { + updateListener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java new file mode 100644 index 0000000..bb88db3 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface IPushRegisterPresenter { + void onReadyRetrofitRequest(String clientid); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java new file mode 100644 index 0000000..017a37e --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -0,0 +1,74 @@ +package com.casic.dcms.bean; + +public class PushResultBean { + + /** + * content : 您有一个工单超时,请快速处理 + * data : {"id":"1393113365064245250"} + * id : 1393117524798783490 + * title : 工单超时提醒 + * type : alarm + */ + + private String content; + private DataBean data; + private String id; + private String title; + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class DataBean { + /** + * id : 1393113365064245250 + */ + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java index 259eb85..c118368 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,11 +25,13 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property NoticeTitle = new Property(1, String.class, "noticeTitle", false, "NOTICE_TITLE"); - public final static Property NoticeDate = new Property(2, String.class, "noticeDate", false, "NOTICE_DATE"); - public final static Property NoticeContent = new Property(3, String.class, "noticeContent", false, "NOTICE_CONTENT"); - public final static Property SenderName = new Property(4, String.class, "senderName", false, "SENDER_NAME"); - public final static Property IsRead = new Property(5, String.class, "isRead", false, "IS_READ"); + public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property CaseId = new Property(2, String.class, "caseId", false, "CASE_ID"); + public final static Property Title = new Property(3, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(4, String.class, "content", false, "CONTENT"); + public final static Property PushDate = new Property(5, String.class, "pushDate", false, "PUSH_DATE"); + public final static Property Type = new Property(6, String.class, "type", false, "TYPE"); + public final static Property IsRead = new Property(7, String.class, "isRead", false, "IS_READ"); } @@ -46,11 +48,13 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"NOTICE_TITLE\" TEXT," + // 1: noticeTitle - "\"NOTICE_DATE\" TEXT," + // 2: noticeDate - "\"NOTICE_CONTENT\" TEXT," + // 3: noticeContent - "\"SENDER_NAME\" TEXT," + // 4: senderName - "\"IS_READ\" TEXT);"); // 5: isRead + "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"CASE_ID\" TEXT," + // 2: caseId + "\"TITLE\" TEXT," + // 3: title + "\"CONTENT\" TEXT," + // 4: content + "\"PUSH_DATE\" TEXT," + // 5: pushDate + "\"TYPE\" TEXT," + // 6: type + "\"IS_READ\" TEXT);"); // 7: isRead } /** Drops the underlying database table. */ @@ -68,29 +72,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -103,29 +117,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -138,11 +162,13 @@ public NoticeBean readEntity(Cursor cursor, int offset) { NoticeBean entity = new NoticeBean( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // noticeTitle - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // noticeDate - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // noticeContent - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // senderName - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // isRead + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userPhone + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // caseId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pushDate + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // type + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // isRead ); return entity; } @@ -150,11 +176,13 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setNoticeTitle(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setNoticeDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setNoticeContent(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setSenderName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setIsRead(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setCaseId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setPushDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setType(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setIsRead(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); } @Override diff --git a/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java new file mode 100644 index 0000000..7c3fb29 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface IPushRegisterModel { + Subscription sendRetrofitRequest(String clientid); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java new file mode 100644 index 0000000..c7ae0c1 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class PushRegisterModelImpl implements IPushRegisterModel { + + private OnRegisterListener updateListener; + + public PushRegisterModelImpl(OnRegisterListener listener) { + this.updateListener = listener; + } + + public interface OnRegisterListener { + void onSuccess(ActionResultBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest(String clientid) { + Observable observable = RetrofitServiceManager.getRegisterResult(clientid); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + updateListener.onFailure(e); + } + } + + @Override + public void onNext(ActionResultBean resultBean) { + if (resultBean != null) { + updateListener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java new file mode 100644 index 0000000..bb88db3 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface IPushRegisterPresenter { + void onReadyRetrofitRequest(String clientid); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java new file mode 100644 index 0000000..3a97b8f --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java @@ -0,0 +1,38 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.PushRegisterModelImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; + +public class PushRegisterPresenterImpl extends BasePresenter implements IPushRegisterPresenter, + PushRegisterModelImpl.OnRegisterListener { + + private IPushRegisterView view; + private PushRegisterModelImpl model; + + public PushRegisterPresenterImpl(IPushRegisterView pushRegisterView) { + this.view = pushRegisterView; + model = new PushRegisterModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest(String clientid) { + addSubscription(model.sendRetrofitRequest(clientid)); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(ActionResultBean resultBean) { + view.obtainRegisterResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java new file mode 100644 index 0000000..017a37e --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -0,0 +1,74 @@ +package com.casic.dcms.bean; + +public class PushResultBean { + + /** + * content : 您有一个工单超时,请快速处理 + * data : {"id":"1393113365064245250"} + * id : 1393117524798783490 + * title : 工单超时提醒 + * type : alarm + */ + + private String content; + private DataBean data; + private String id; + private String title; + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class DataBean { + /** + * id : 1393113365064245250 + */ + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java index 259eb85..c118368 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,11 +25,13 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property NoticeTitle = new Property(1, String.class, "noticeTitle", false, "NOTICE_TITLE"); - public final static Property NoticeDate = new Property(2, String.class, "noticeDate", false, "NOTICE_DATE"); - public final static Property NoticeContent = new Property(3, String.class, "noticeContent", false, "NOTICE_CONTENT"); - public final static Property SenderName = new Property(4, String.class, "senderName", false, "SENDER_NAME"); - public final static Property IsRead = new Property(5, String.class, "isRead", false, "IS_READ"); + public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property CaseId = new Property(2, String.class, "caseId", false, "CASE_ID"); + public final static Property Title = new Property(3, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(4, String.class, "content", false, "CONTENT"); + public final static Property PushDate = new Property(5, String.class, "pushDate", false, "PUSH_DATE"); + public final static Property Type = new Property(6, String.class, "type", false, "TYPE"); + public final static Property IsRead = new Property(7, String.class, "isRead", false, "IS_READ"); } @@ -46,11 +48,13 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"NOTICE_TITLE\" TEXT," + // 1: noticeTitle - "\"NOTICE_DATE\" TEXT," + // 2: noticeDate - "\"NOTICE_CONTENT\" TEXT," + // 3: noticeContent - "\"SENDER_NAME\" TEXT," + // 4: senderName - "\"IS_READ\" TEXT);"); // 5: isRead + "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"CASE_ID\" TEXT," + // 2: caseId + "\"TITLE\" TEXT," + // 3: title + "\"CONTENT\" TEXT," + // 4: content + "\"PUSH_DATE\" TEXT," + // 5: pushDate + "\"TYPE\" TEXT," + // 6: type + "\"IS_READ\" TEXT);"); // 7: isRead } /** Drops the underlying database table. */ @@ -68,29 +72,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -103,29 +117,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -138,11 +162,13 @@ public NoticeBean readEntity(Cursor cursor, int offset) { NoticeBean entity = new NoticeBean( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // noticeTitle - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // noticeDate - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // noticeContent - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // senderName - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // isRead + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userPhone + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // caseId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pushDate + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // type + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // isRead ); return entity; } @@ -150,11 +176,13 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setNoticeTitle(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setNoticeDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setNoticeContent(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setSenderName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setIsRead(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setCaseId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setPushDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setType(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setIsRead(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); } @Override diff --git a/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java new file mode 100644 index 0000000..7c3fb29 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface IPushRegisterModel { + Subscription sendRetrofitRequest(String clientid); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java new file mode 100644 index 0000000..c7ae0c1 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class PushRegisterModelImpl implements IPushRegisterModel { + + private OnRegisterListener updateListener; + + public PushRegisterModelImpl(OnRegisterListener listener) { + this.updateListener = listener; + } + + public interface OnRegisterListener { + void onSuccess(ActionResultBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest(String clientid) { + Observable observable = RetrofitServiceManager.getRegisterResult(clientid); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + updateListener.onFailure(e); + } + } + + @Override + public void onNext(ActionResultBean resultBean) { + if (resultBean != null) { + updateListener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java new file mode 100644 index 0000000..bb88db3 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface IPushRegisterPresenter { + void onReadyRetrofitRequest(String clientid); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java new file mode 100644 index 0000000..3a97b8f --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java @@ -0,0 +1,38 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.PushRegisterModelImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; + +public class PushRegisterPresenterImpl extends BasePresenter implements IPushRegisterPresenter, + PushRegisterModelImpl.OnRegisterListener { + + private IPushRegisterView view; + private PushRegisterModelImpl model; + + public PushRegisterPresenterImpl(IPushRegisterView pushRegisterView) { + this.view = pushRegisterView; + model = new PushRegisterModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest(String clientid) { + addSubscription(model.sendRetrofitRequest(clientid)); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(ActionResultBean resultBean) { + view.obtainRegisterResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java new file mode 100644 index 0000000..353903a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.ActionResultBean; + +public interface IPushRegisterView { + void obtainRegisterResult(ActionResultBean resultBean); +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java new file mode 100644 index 0000000..017a37e --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -0,0 +1,74 @@ +package com.casic.dcms.bean; + +public class PushResultBean { + + /** + * content : 您有一个工单超时,请快速处理 + * data : {"id":"1393113365064245250"} + * id : 1393117524798783490 + * title : 工单超时提醒 + * type : alarm + */ + + private String content; + private DataBean data; + private String id; + private String title; + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class DataBean { + /** + * id : 1393113365064245250 + */ + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java index 259eb85..c118368 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,11 +25,13 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property NoticeTitle = new Property(1, String.class, "noticeTitle", false, "NOTICE_TITLE"); - public final static Property NoticeDate = new Property(2, String.class, "noticeDate", false, "NOTICE_DATE"); - public final static Property NoticeContent = new Property(3, String.class, "noticeContent", false, "NOTICE_CONTENT"); - public final static Property SenderName = new Property(4, String.class, "senderName", false, "SENDER_NAME"); - public final static Property IsRead = new Property(5, String.class, "isRead", false, "IS_READ"); + public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property CaseId = new Property(2, String.class, "caseId", false, "CASE_ID"); + public final static Property Title = new Property(3, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(4, String.class, "content", false, "CONTENT"); + public final static Property PushDate = new Property(5, String.class, "pushDate", false, "PUSH_DATE"); + public final static Property Type = new Property(6, String.class, "type", false, "TYPE"); + public final static Property IsRead = new Property(7, String.class, "isRead", false, "IS_READ"); } @@ -46,11 +48,13 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"NOTICE_TITLE\" TEXT," + // 1: noticeTitle - "\"NOTICE_DATE\" TEXT," + // 2: noticeDate - "\"NOTICE_CONTENT\" TEXT," + // 3: noticeContent - "\"SENDER_NAME\" TEXT," + // 4: senderName - "\"IS_READ\" TEXT);"); // 5: isRead + "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"CASE_ID\" TEXT," + // 2: caseId + "\"TITLE\" TEXT," + // 3: title + "\"CONTENT\" TEXT," + // 4: content + "\"PUSH_DATE\" TEXT," + // 5: pushDate + "\"TYPE\" TEXT," + // 6: type + "\"IS_READ\" TEXT);"); // 7: isRead } /** Drops the underlying database table. */ @@ -68,29 +72,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -103,29 +117,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -138,11 +162,13 @@ public NoticeBean readEntity(Cursor cursor, int offset) { NoticeBean entity = new NoticeBean( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // noticeTitle - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // noticeDate - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // noticeContent - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // senderName - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // isRead + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userPhone + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // caseId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pushDate + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // type + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // isRead ); return entity; } @@ -150,11 +176,13 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setNoticeTitle(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setNoticeDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setNoticeContent(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setSenderName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setIsRead(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setCaseId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setPushDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setType(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setIsRead(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); } @Override diff --git a/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java new file mode 100644 index 0000000..7c3fb29 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface IPushRegisterModel { + Subscription sendRetrofitRequest(String clientid); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java new file mode 100644 index 0000000..c7ae0c1 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class PushRegisterModelImpl implements IPushRegisterModel { + + private OnRegisterListener updateListener; + + public PushRegisterModelImpl(OnRegisterListener listener) { + this.updateListener = listener; + } + + public interface OnRegisterListener { + void onSuccess(ActionResultBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest(String clientid) { + Observable observable = RetrofitServiceManager.getRegisterResult(clientid); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + updateListener.onFailure(e); + } + } + + @Override + public void onNext(ActionResultBean resultBean) { + if (resultBean != null) { + updateListener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java new file mode 100644 index 0000000..bb88db3 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface IPushRegisterPresenter { + void onReadyRetrofitRequest(String clientid); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java new file mode 100644 index 0000000..3a97b8f --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java @@ -0,0 +1,38 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.PushRegisterModelImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; + +public class PushRegisterPresenterImpl extends BasePresenter implements IPushRegisterPresenter, + PushRegisterModelImpl.OnRegisterListener { + + private IPushRegisterView view; + private PushRegisterModelImpl model; + + public PushRegisterPresenterImpl(IPushRegisterView pushRegisterView) { + this.view = pushRegisterView; + model = new PushRegisterModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest(String clientid) { + addSubscription(model.sendRetrofitRequest(clientid)); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(ActionResultBean resultBean) { + view.obtainRegisterResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java new file mode 100644 index 0000000..353903a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.ActionResultBean; + +public interface IPushRegisterView { + void obtainRegisterResult(ActionResultBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java index 0a4e1d2..865787a 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,15 +1,18 @@ package com.casic.dcms.service; import android.content.Context; +import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.utils.AuthenticationHelper; +import com.casic.dcms.bean.PushResultBean; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.casic.dcms.utils.TimeOrDateUtil; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.igexin.sdk.GTIntentService; import com.igexin.sdk.message.GTCmdMessage; import com.igexin.sdk.message.GTNotificationMessage; @@ -38,7 +41,12 @@ @Override public void onReceiveClientId(Context context, String clientid) { Log.d(TAG, "onReceiveClientId -> " + "clientid = " + clientid); - AuthenticationHelper.savePushClientID(clientid); + //通知MainActivity注册个推服务 + if (!TextUtils.isEmpty(clientid)) { + BroadcastManager.getInstance(context).sendBroadcast(Constant.REGISTER_PUSH, clientid); + } else { + Log.d(TAG, "onReceiveClientId: ===>clientid = " + clientid); + } } // cid 离线上线通知 @@ -50,28 +58,50 @@ // 各种事件处理回执 @Override public void onReceiveCommandResult(Context context, GTCmdMessage cmdMessage) { - +// Log.d(TAG, "onReceiveCommandResult -> " + cmdMessage); } // 通知到达,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageArrived(Context context, GTNotificationMessage msg) { + public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + /** + * appid = DR9oeLL9va6aG3DYXy2w39 + * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 + * messageid = b74187603fe34058a223949ead9f8dcf + * pkg = com.casic.dcms + * cid = cd1aec399b5504516102e399ecf7cda4 + * content = {"content":"您有一个工单超时,请快速处理","data":{"id":"1392655327805825025"},"id":1393131068164472834,"title":"工单超时提醒","type":"alarm"} + * title = 工单提醒 + * */ + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + NoticeBean noticeBean = new NoticeBean(); - noticeBean.setNoticeTitle(msg.getTitle()); - noticeBean.setSenderName("管理员"); - noticeBean.setNoticeDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); - noticeBean.setNoticeContent(msg.getContent()); + noticeBean.setUserPhone(StringHelper.getUserPhone()); + noticeBean.setCaseId(resultBean.getId()); + noticeBean.setTitle(resultBean.getTitle()); + noticeBean.setContent(resultBean.getContent()); + noticeBean.setType(resultBean.getType()); + noticeBean.setPushDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); noticeBean.setIsRead("1"); //存本地一份 BaseApplication.getDaoSession().insert(noticeBean); //发送消息更新界面 - BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, new Gson().toJson(noticeBean)); + BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, gson.toJson(noticeBean)); } // 通知点击,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageClicked(Context context, GTNotificationMessage msg) { + public void onNotificationMessageClicked(Context context, GTNotificationMessage message) { + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + String caseId = resultBean.getId(); + Log.d(TAG, "onNotificationMessageClicked: " + caseId); } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java new file mode 100644 index 0000000..017a37e --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -0,0 +1,74 @@ +package com.casic.dcms.bean; + +public class PushResultBean { + + /** + * content : 您有一个工单超时,请快速处理 + * data : {"id":"1393113365064245250"} + * id : 1393117524798783490 + * title : 工单超时提醒 + * type : alarm + */ + + private String content; + private DataBean data; + private String id; + private String title; + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class DataBean { + /** + * id : 1393113365064245250 + */ + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java index 259eb85..c118368 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,11 +25,13 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property NoticeTitle = new Property(1, String.class, "noticeTitle", false, "NOTICE_TITLE"); - public final static Property NoticeDate = new Property(2, String.class, "noticeDate", false, "NOTICE_DATE"); - public final static Property NoticeContent = new Property(3, String.class, "noticeContent", false, "NOTICE_CONTENT"); - public final static Property SenderName = new Property(4, String.class, "senderName", false, "SENDER_NAME"); - public final static Property IsRead = new Property(5, String.class, "isRead", false, "IS_READ"); + public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property CaseId = new Property(2, String.class, "caseId", false, "CASE_ID"); + public final static Property Title = new Property(3, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(4, String.class, "content", false, "CONTENT"); + public final static Property PushDate = new Property(5, String.class, "pushDate", false, "PUSH_DATE"); + public final static Property Type = new Property(6, String.class, "type", false, "TYPE"); + public final static Property IsRead = new Property(7, String.class, "isRead", false, "IS_READ"); } @@ -46,11 +48,13 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"NOTICE_TITLE\" TEXT," + // 1: noticeTitle - "\"NOTICE_DATE\" TEXT," + // 2: noticeDate - "\"NOTICE_CONTENT\" TEXT," + // 3: noticeContent - "\"SENDER_NAME\" TEXT," + // 4: senderName - "\"IS_READ\" TEXT);"); // 5: isRead + "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"CASE_ID\" TEXT," + // 2: caseId + "\"TITLE\" TEXT," + // 3: title + "\"CONTENT\" TEXT," + // 4: content + "\"PUSH_DATE\" TEXT," + // 5: pushDate + "\"TYPE\" TEXT," + // 6: type + "\"IS_READ\" TEXT);"); // 7: isRead } /** Drops the underlying database table. */ @@ -68,29 +72,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -103,29 +117,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -138,11 +162,13 @@ public NoticeBean readEntity(Cursor cursor, int offset) { NoticeBean entity = new NoticeBean( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // noticeTitle - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // noticeDate - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // noticeContent - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // senderName - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // isRead + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userPhone + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // caseId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pushDate + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // type + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // isRead ); return entity; } @@ -150,11 +176,13 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setNoticeTitle(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setNoticeDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setNoticeContent(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setSenderName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setIsRead(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setCaseId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setPushDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setType(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setIsRead(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); } @Override diff --git a/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java new file mode 100644 index 0000000..7c3fb29 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface IPushRegisterModel { + Subscription sendRetrofitRequest(String clientid); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java new file mode 100644 index 0000000..c7ae0c1 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class PushRegisterModelImpl implements IPushRegisterModel { + + private OnRegisterListener updateListener; + + public PushRegisterModelImpl(OnRegisterListener listener) { + this.updateListener = listener; + } + + public interface OnRegisterListener { + void onSuccess(ActionResultBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest(String clientid) { + Observable observable = RetrofitServiceManager.getRegisterResult(clientid); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + updateListener.onFailure(e); + } + } + + @Override + public void onNext(ActionResultBean resultBean) { + if (resultBean != null) { + updateListener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java new file mode 100644 index 0000000..bb88db3 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface IPushRegisterPresenter { + void onReadyRetrofitRequest(String clientid); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java new file mode 100644 index 0000000..3a97b8f --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java @@ -0,0 +1,38 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.PushRegisterModelImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; + +public class PushRegisterPresenterImpl extends BasePresenter implements IPushRegisterPresenter, + PushRegisterModelImpl.OnRegisterListener { + + private IPushRegisterView view; + private PushRegisterModelImpl model; + + public PushRegisterPresenterImpl(IPushRegisterView pushRegisterView) { + this.view = pushRegisterView; + model = new PushRegisterModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest(String clientid) { + addSubscription(model.sendRetrofitRequest(clientid)); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(ActionResultBean resultBean) { + view.obtainRegisterResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java new file mode 100644 index 0000000..353903a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.ActionResultBean; + +public interface IPushRegisterView { + void obtainRegisterResult(ActionResultBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java index 0a4e1d2..865787a 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,15 +1,18 @@ package com.casic.dcms.service; import android.content.Context; +import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.utils.AuthenticationHelper; +import com.casic.dcms.bean.PushResultBean; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.casic.dcms.utils.TimeOrDateUtil; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.igexin.sdk.GTIntentService; import com.igexin.sdk.message.GTCmdMessage; import com.igexin.sdk.message.GTNotificationMessage; @@ -38,7 +41,12 @@ @Override public void onReceiveClientId(Context context, String clientid) { Log.d(TAG, "onReceiveClientId -> " + "clientid = " + clientid); - AuthenticationHelper.savePushClientID(clientid); + //通知MainActivity注册个推服务 + if (!TextUtils.isEmpty(clientid)) { + BroadcastManager.getInstance(context).sendBroadcast(Constant.REGISTER_PUSH, clientid); + } else { + Log.d(TAG, "onReceiveClientId: ===>clientid = " + clientid); + } } // cid 离线上线通知 @@ -50,28 +58,50 @@ // 各种事件处理回执 @Override public void onReceiveCommandResult(Context context, GTCmdMessage cmdMessage) { - +// Log.d(TAG, "onReceiveCommandResult -> " + cmdMessage); } // 通知到达,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageArrived(Context context, GTNotificationMessage msg) { + public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + /** + * appid = DR9oeLL9va6aG3DYXy2w39 + * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 + * messageid = b74187603fe34058a223949ead9f8dcf + * pkg = com.casic.dcms + * cid = cd1aec399b5504516102e399ecf7cda4 + * content = {"content":"您有一个工单超时,请快速处理","data":{"id":"1392655327805825025"},"id":1393131068164472834,"title":"工单超时提醒","type":"alarm"} + * title = 工单提醒 + * */ + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + NoticeBean noticeBean = new NoticeBean(); - noticeBean.setNoticeTitle(msg.getTitle()); - noticeBean.setSenderName("管理员"); - noticeBean.setNoticeDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); - noticeBean.setNoticeContent(msg.getContent()); + noticeBean.setUserPhone(StringHelper.getUserPhone()); + noticeBean.setCaseId(resultBean.getId()); + noticeBean.setTitle(resultBean.getTitle()); + noticeBean.setContent(resultBean.getContent()); + noticeBean.setType(resultBean.getType()); + noticeBean.setPushDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); noticeBean.setIsRead("1"); //存本地一份 BaseApplication.getDaoSession().insert(noticeBean); //发送消息更新界面 - BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, new Gson().toJson(noticeBean)); + BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, gson.toJson(noticeBean)); } // 通知点击,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageClicked(Context context, GTNotificationMessage msg) { + public void onNotificationMessageClicked(Context context, GTNotificationMessage message) { + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + String caseId = resultBean.getId(); + Log.d(TAG, "onNotificationMessageClicked: " + caseId); } } diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index 219ae3b..db7d9ca 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -302,7 +302,8 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件地点所在网格为[" + gridId + "]" + ",\r\n选择部件为:" + objId + "(" + objName + ")" + .setMessage("该事件地点所在网格为[" + gridId + "]" + + "\r\n选择部件为:" + objId + "(" + objName + ")" + "\r\n部件大类为:" + largeType + "\r\n小类为:" + smallType + "\r\n确认提交?") @@ -332,7 +333,9 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件所在地点网格为[" + gridId + "]确认选择?") + .setMessage("该事件所在地点网格为[" + gridId + "]" + + "\r\n所在社区为:" + communityName + + "\r\n确认选择?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java new file mode 100644 index 0000000..017a37e --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -0,0 +1,74 @@ +package com.casic.dcms.bean; + +public class PushResultBean { + + /** + * content : 您有一个工单超时,请快速处理 + * data : {"id":"1393113365064245250"} + * id : 1393117524798783490 + * title : 工单超时提醒 + * type : alarm + */ + + private String content; + private DataBean data; + private String id; + private String title; + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class DataBean { + /** + * id : 1393113365064245250 + */ + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java index 259eb85..c118368 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,11 +25,13 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property NoticeTitle = new Property(1, String.class, "noticeTitle", false, "NOTICE_TITLE"); - public final static Property NoticeDate = new Property(2, String.class, "noticeDate", false, "NOTICE_DATE"); - public final static Property NoticeContent = new Property(3, String.class, "noticeContent", false, "NOTICE_CONTENT"); - public final static Property SenderName = new Property(4, String.class, "senderName", false, "SENDER_NAME"); - public final static Property IsRead = new Property(5, String.class, "isRead", false, "IS_READ"); + public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property CaseId = new Property(2, String.class, "caseId", false, "CASE_ID"); + public final static Property Title = new Property(3, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(4, String.class, "content", false, "CONTENT"); + public final static Property PushDate = new Property(5, String.class, "pushDate", false, "PUSH_DATE"); + public final static Property Type = new Property(6, String.class, "type", false, "TYPE"); + public final static Property IsRead = new Property(7, String.class, "isRead", false, "IS_READ"); } @@ -46,11 +48,13 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"NOTICE_TITLE\" TEXT," + // 1: noticeTitle - "\"NOTICE_DATE\" TEXT," + // 2: noticeDate - "\"NOTICE_CONTENT\" TEXT," + // 3: noticeContent - "\"SENDER_NAME\" TEXT," + // 4: senderName - "\"IS_READ\" TEXT);"); // 5: isRead + "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"CASE_ID\" TEXT," + // 2: caseId + "\"TITLE\" TEXT," + // 3: title + "\"CONTENT\" TEXT," + // 4: content + "\"PUSH_DATE\" TEXT," + // 5: pushDate + "\"TYPE\" TEXT," + // 6: type + "\"IS_READ\" TEXT);"); // 7: isRead } /** Drops the underlying database table. */ @@ -68,29 +72,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -103,29 +117,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -138,11 +162,13 @@ public NoticeBean readEntity(Cursor cursor, int offset) { NoticeBean entity = new NoticeBean( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // noticeTitle - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // noticeDate - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // noticeContent - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // senderName - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // isRead + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userPhone + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // caseId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pushDate + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // type + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // isRead ); return entity; } @@ -150,11 +176,13 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setNoticeTitle(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setNoticeDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setNoticeContent(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setSenderName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setIsRead(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setCaseId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setPushDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setType(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setIsRead(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); } @Override diff --git a/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java new file mode 100644 index 0000000..7c3fb29 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface IPushRegisterModel { + Subscription sendRetrofitRequest(String clientid); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java new file mode 100644 index 0000000..c7ae0c1 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class PushRegisterModelImpl implements IPushRegisterModel { + + private OnRegisterListener updateListener; + + public PushRegisterModelImpl(OnRegisterListener listener) { + this.updateListener = listener; + } + + public interface OnRegisterListener { + void onSuccess(ActionResultBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest(String clientid) { + Observable observable = RetrofitServiceManager.getRegisterResult(clientid); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + updateListener.onFailure(e); + } + } + + @Override + public void onNext(ActionResultBean resultBean) { + if (resultBean != null) { + updateListener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java new file mode 100644 index 0000000..bb88db3 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface IPushRegisterPresenter { + void onReadyRetrofitRequest(String clientid); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java new file mode 100644 index 0000000..3a97b8f --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java @@ -0,0 +1,38 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.PushRegisterModelImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; + +public class PushRegisterPresenterImpl extends BasePresenter implements IPushRegisterPresenter, + PushRegisterModelImpl.OnRegisterListener { + + private IPushRegisterView view; + private PushRegisterModelImpl model; + + public PushRegisterPresenterImpl(IPushRegisterView pushRegisterView) { + this.view = pushRegisterView; + model = new PushRegisterModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest(String clientid) { + addSubscription(model.sendRetrofitRequest(clientid)); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(ActionResultBean resultBean) { + view.obtainRegisterResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java new file mode 100644 index 0000000..353903a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.ActionResultBean; + +public interface IPushRegisterView { + void obtainRegisterResult(ActionResultBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java index 0a4e1d2..865787a 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,15 +1,18 @@ package com.casic.dcms.service; import android.content.Context; +import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.utils.AuthenticationHelper; +import com.casic.dcms.bean.PushResultBean; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.casic.dcms.utils.TimeOrDateUtil; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.igexin.sdk.GTIntentService; import com.igexin.sdk.message.GTCmdMessage; import com.igexin.sdk.message.GTNotificationMessage; @@ -38,7 +41,12 @@ @Override public void onReceiveClientId(Context context, String clientid) { Log.d(TAG, "onReceiveClientId -> " + "clientid = " + clientid); - AuthenticationHelper.savePushClientID(clientid); + //通知MainActivity注册个推服务 + if (!TextUtils.isEmpty(clientid)) { + BroadcastManager.getInstance(context).sendBroadcast(Constant.REGISTER_PUSH, clientid); + } else { + Log.d(TAG, "onReceiveClientId: ===>clientid = " + clientid); + } } // cid 离线上线通知 @@ -50,28 +58,50 @@ // 各种事件处理回执 @Override public void onReceiveCommandResult(Context context, GTCmdMessage cmdMessage) { - +// Log.d(TAG, "onReceiveCommandResult -> " + cmdMessage); } // 通知到达,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageArrived(Context context, GTNotificationMessage msg) { + public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + /** + * appid = DR9oeLL9va6aG3DYXy2w39 + * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 + * messageid = b74187603fe34058a223949ead9f8dcf + * pkg = com.casic.dcms + * cid = cd1aec399b5504516102e399ecf7cda4 + * content = {"content":"您有一个工单超时,请快速处理","data":{"id":"1392655327805825025"},"id":1393131068164472834,"title":"工单超时提醒","type":"alarm"} + * title = 工单提醒 + * */ + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + NoticeBean noticeBean = new NoticeBean(); - noticeBean.setNoticeTitle(msg.getTitle()); - noticeBean.setSenderName("管理员"); - noticeBean.setNoticeDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); - noticeBean.setNoticeContent(msg.getContent()); + noticeBean.setUserPhone(StringHelper.getUserPhone()); + noticeBean.setCaseId(resultBean.getId()); + noticeBean.setTitle(resultBean.getTitle()); + noticeBean.setContent(resultBean.getContent()); + noticeBean.setType(resultBean.getType()); + noticeBean.setPushDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); noticeBean.setIsRead("1"); //存本地一份 BaseApplication.getDaoSession().insert(noticeBean); //发送消息更新界面 - BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, new Gson().toJson(noticeBean)); + BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, gson.toJson(noticeBean)); } // 通知点击,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageClicked(Context context, GTNotificationMessage msg) { + public void onNotificationMessageClicked(Context context, GTNotificationMessage message) { + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + String caseId = resultBean.getId(); + Log.d(TAG, "onNotificationMessageClicked: " + caseId); } } diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index 219ae3b..db7d9ca 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -302,7 +302,8 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件地点所在网格为[" + gridId + "]" + ",\r\n选择部件为:" + objId + "(" + objName + ")" + .setMessage("该事件地点所在网格为[" + gridId + "]" + + "\r\n选择部件为:" + objId + "(" + objName + ")" + "\r\n部件大类为:" + largeType + "\r\n小类为:" + smallType + "\r\n确认提交?") @@ -332,7 +333,9 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件所在地点网格为[" + gridId + "]确认选择?") + .setMessage("该事件所在地点网格为[" + gridId + "]" + + "\r\n所在社区为:" + communityName + + "\r\n确认选择?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { diff --git a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java index 22d7bca..dfc9961 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java @@ -159,7 +159,7 @@ for (PointDataBean dataBean : casePointList) { double parseLng = Double.parseDouble(dataBean.getLng()); double parseLat = Double.parseDouble(dataBean.getLat()); - if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 || + if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 && Math.abs(parseLat - point.getY()) <= Constant.DELTA_LAT_10) { Message message = weakReferenceHandler.obtainMessage(); message.what = 2021051401; diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java new file mode 100644 index 0000000..017a37e --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -0,0 +1,74 @@ +package com.casic.dcms.bean; + +public class PushResultBean { + + /** + * content : 您有一个工单超时,请快速处理 + * data : {"id":"1393113365064245250"} + * id : 1393117524798783490 + * title : 工单超时提醒 + * type : alarm + */ + + private String content; + private DataBean data; + private String id; + private String title; + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class DataBean { + /** + * id : 1393113365064245250 + */ + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java index 259eb85..c118368 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,11 +25,13 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property NoticeTitle = new Property(1, String.class, "noticeTitle", false, "NOTICE_TITLE"); - public final static Property NoticeDate = new Property(2, String.class, "noticeDate", false, "NOTICE_DATE"); - public final static Property NoticeContent = new Property(3, String.class, "noticeContent", false, "NOTICE_CONTENT"); - public final static Property SenderName = new Property(4, String.class, "senderName", false, "SENDER_NAME"); - public final static Property IsRead = new Property(5, String.class, "isRead", false, "IS_READ"); + public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property CaseId = new Property(2, String.class, "caseId", false, "CASE_ID"); + public final static Property Title = new Property(3, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(4, String.class, "content", false, "CONTENT"); + public final static Property PushDate = new Property(5, String.class, "pushDate", false, "PUSH_DATE"); + public final static Property Type = new Property(6, String.class, "type", false, "TYPE"); + public final static Property IsRead = new Property(7, String.class, "isRead", false, "IS_READ"); } @@ -46,11 +48,13 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"NOTICE_TITLE\" TEXT," + // 1: noticeTitle - "\"NOTICE_DATE\" TEXT," + // 2: noticeDate - "\"NOTICE_CONTENT\" TEXT," + // 3: noticeContent - "\"SENDER_NAME\" TEXT," + // 4: senderName - "\"IS_READ\" TEXT);"); // 5: isRead + "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"CASE_ID\" TEXT," + // 2: caseId + "\"TITLE\" TEXT," + // 3: title + "\"CONTENT\" TEXT," + // 4: content + "\"PUSH_DATE\" TEXT," + // 5: pushDate + "\"TYPE\" TEXT," + // 6: type + "\"IS_READ\" TEXT);"); // 7: isRead } /** Drops the underlying database table. */ @@ -68,29 +72,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -103,29 +117,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -138,11 +162,13 @@ public NoticeBean readEntity(Cursor cursor, int offset) { NoticeBean entity = new NoticeBean( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // noticeTitle - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // noticeDate - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // noticeContent - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // senderName - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // isRead + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userPhone + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // caseId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pushDate + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // type + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // isRead ); return entity; } @@ -150,11 +176,13 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setNoticeTitle(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setNoticeDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setNoticeContent(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setSenderName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setIsRead(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setCaseId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setPushDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setType(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setIsRead(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); } @Override diff --git a/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java new file mode 100644 index 0000000..7c3fb29 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface IPushRegisterModel { + Subscription sendRetrofitRequest(String clientid); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java new file mode 100644 index 0000000..c7ae0c1 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class PushRegisterModelImpl implements IPushRegisterModel { + + private OnRegisterListener updateListener; + + public PushRegisterModelImpl(OnRegisterListener listener) { + this.updateListener = listener; + } + + public interface OnRegisterListener { + void onSuccess(ActionResultBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest(String clientid) { + Observable observable = RetrofitServiceManager.getRegisterResult(clientid); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + updateListener.onFailure(e); + } + } + + @Override + public void onNext(ActionResultBean resultBean) { + if (resultBean != null) { + updateListener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java new file mode 100644 index 0000000..bb88db3 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface IPushRegisterPresenter { + void onReadyRetrofitRequest(String clientid); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java new file mode 100644 index 0000000..3a97b8f --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java @@ -0,0 +1,38 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.PushRegisterModelImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; + +public class PushRegisterPresenterImpl extends BasePresenter implements IPushRegisterPresenter, + PushRegisterModelImpl.OnRegisterListener { + + private IPushRegisterView view; + private PushRegisterModelImpl model; + + public PushRegisterPresenterImpl(IPushRegisterView pushRegisterView) { + this.view = pushRegisterView; + model = new PushRegisterModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest(String clientid) { + addSubscription(model.sendRetrofitRequest(clientid)); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(ActionResultBean resultBean) { + view.obtainRegisterResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java new file mode 100644 index 0000000..353903a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.ActionResultBean; + +public interface IPushRegisterView { + void obtainRegisterResult(ActionResultBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java index 0a4e1d2..865787a 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,15 +1,18 @@ package com.casic.dcms.service; import android.content.Context; +import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.utils.AuthenticationHelper; +import com.casic.dcms.bean.PushResultBean; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.casic.dcms.utils.TimeOrDateUtil; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.igexin.sdk.GTIntentService; import com.igexin.sdk.message.GTCmdMessage; import com.igexin.sdk.message.GTNotificationMessage; @@ -38,7 +41,12 @@ @Override public void onReceiveClientId(Context context, String clientid) { Log.d(TAG, "onReceiveClientId -> " + "clientid = " + clientid); - AuthenticationHelper.savePushClientID(clientid); + //通知MainActivity注册个推服务 + if (!TextUtils.isEmpty(clientid)) { + BroadcastManager.getInstance(context).sendBroadcast(Constant.REGISTER_PUSH, clientid); + } else { + Log.d(TAG, "onReceiveClientId: ===>clientid = " + clientid); + } } // cid 离线上线通知 @@ -50,28 +58,50 @@ // 各种事件处理回执 @Override public void onReceiveCommandResult(Context context, GTCmdMessage cmdMessage) { - +// Log.d(TAG, "onReceiveCommandResult -> " + cmdMessage); } // 通知到达,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageArrived(Context context, GTNotificationMessage msg) { + public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + /** + * appid = DR9oeLL9va6aG3DYXy2w39 + * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 + * messageid = b74187603fe34058a223949ead9f8dcf + * pkg = com.casic.dcms + * cid = cd1aec399b5504516102e399ecf7cda4 + * content = {"content":"您有一个工单超时,请快速处理","data":{"id":"1392655327805825025"},"id":1393131068164472834,"title":"工单超时提醒","type":"alarm"} + * title = 工单提醒 + * */ + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + NoticeBean noticeBean = new NoticeBean(); - noticeBean.setNoticeTitle(msg.getTitle()); - noticeBean.setSenderName("管理员"); - noticeBean.setNoticeDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); - noticeBean.setNoticeContent(msg.getContent()); + noticeBean.setUserPhone(StringHelper.getUserPhone()); + noticeBean.setCaseId(resultBean.getId()); + noticeBean.setTitle(resultBean.getTitle()); + noticeBean.setContent(resultBean.getContent()); + noticeBean.setType(resultBean.getType()); + noticeBean.setPushDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); noticeBean.setIsRead("1"); //存本地一份 BaseApplication.getDaoSession().insert(noticeBean); //发送消息更新界面 - BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, new Gson().toJson(noticeBean)); + BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, gson.toJson(noticeBean)); } // 通知点击,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageClicked(Context context, GTNotificationMessage msg) { + public void onNotificationMessageClicked(Context context, GTNotificationMessage message) { + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + String caseId = resultBean.getId(); + Log.d(TAG, "onNotificationMessageClicked: " + caseId); } } diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index 219ae3b..db7d9ca 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -302,7 +302,8 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件地点所在网格为[" + gridId + "]" + ",\r\n选择部件为:" + objId + "(" + objName + ")" + .setMessage("该事件地点所在网格为[" + gridId + "]" + + "\r\n选择部件为:" + objId + "(" + objName + ")" + "\r\n部件大类为:" + largeType + "\r\n小类为:" + smallType + "\r\n确认提交?") @@ -332,7 +333,9 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件所在地点网格为[" + gridId + "]确认选择?") + .setMessage("该事件所在地点网格为[" + gridId + "]" + + "\r\n所在社区为:" + communityName + + "\r\n确认选择?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { diff --git a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java index 22d7bca..dfc9961 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java @@ -159,7 +159,7 @@ for (PointDataBean dataBean : casePointList) { double parseLng = Double.parseDouble(dataBean.getLng()); double parseLat = Double.parseDouble(dataBean.getLat()); - if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 || + if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 && Math.abs(parseLat - point.getY()) <= Constant.DELTA_LAT_10) { Message message = weakReferenceHandler.obtainMessage(); message.what = 2021051401; diff --git a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java index 8d37132..e3703e3 100644 --- a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java @@ -50,7 +50,7 @@ @Override public int initLayoutView() { - return R.layout.activity_analysis; + return R.layout.activity_case_analysis; } @Override diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java new file mode 100644 index 0000000..017a37e --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -0,0 +1,74 @@ +package com.casic.dcms.bean; + +public class PushResultBean { + + /** + * content : 您有一个工单超时,请快速处理 + * data : {"id":"1393113365064245250"} + * id : 1393117524798783490 + * title : 工单超时提醒 + * type : alarm + */ + + private String content; + private DataBean data; + private String id; + private String title; + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class DataBean { + /** + * id : 1393113365064245250 + */ + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java index 259eb85..c118368 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,11 +25,13 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property NoticeTitle = new Property(1, String.class, "noticeTitle", false, "NOTICE_TITLE"); - public final static Property NoticeDate = new Property(2, String.class, "noticeDate", false, "NOTICE_DATE"); - public final static Property NoticeContent = new Property(3, String.class, "noticeContent", false, "NOTICE_CONTENT"); - public final static Property SenderName = new Property(4, String.class, "senderName", false, "SENDER_NAME"); - public final static Property IsRead = new Property(5, String.class, "isRead", false, "IS_READ"); + public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property CaseId = new Property(2, String.class, "caseId", false, "CASE_ID"); + public final static Property Title = new Property(3, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(4, String.class, "content", false, "CONTENT"); + public final static Property PushDate = new Property(5, String.class, "pushDate", false, "PUSH_DATE"); + public final static Property Type = new Property(6, String.class, "type", false, "TYPE"); + public final static Property IsRead = new Property(7, String.class, "isRead", false, "IS_READ"); } @@ -46,11 +48,13 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"NOTICE_TITLE\" TEXT," + // 1: noticeTitle - "\"NOTICE_DATE\" TEXT," + // 2: noticeDate - "\"NOTICE_CONTENT\" TEXT," + // 3: noticeContent - "\"SENDER_NAME\" TEXT," + // 4: senderName - "\"IS_READ\" TEXT);"); // 5: isRead + "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"CASE_ID\" TEXT," + // 2: caseId + "\"TITLE\" TEXT," + // 3: title + "\"CONTENT\" TEXT," + // 4: content + "\"PUSH_DATE\" TEXT," + // 5: pushDate + "\"TYPE\" TEXT," + // 6: type + "\"IS_READ\" TEXT);"); // 7: isRead } /** Drops the underlying database table. */ @@ -68,29 +72,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -103,29 +117,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -138,11 +162,13 @@ public NoticeBean readEntity(Cursor cursor, int offset) { NoticeBean entity = new NoticeBean( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // noticeTitle - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // noticeDate - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // noticeContent - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // senderName - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // isRead + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userPhone + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // caseId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pushDate + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // type + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // isRead ); return entity; } @@ -150,11 +176,13 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setNoticeTitle(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setNoticeDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setNoticeContent(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setSenderName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setIsRead(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setCaseId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setPushDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setType(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setIsRead(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); } @Override diff --git a/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java new file mode 100644 index 0000000..7c3fb29 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface IPushRegisterModel { + Subscription sendRetrofitRequest(String clientid); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java new file mode 100644 index 0000000..c7ae0c1 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class PushRegisterModelImpl implements IPushRegisterModel { + + private OnRegisterListener updateListener; + + public PushRegisterModelImpl(OnRegisterListener listener) { + this.updateListener = listener; + } + + public interface OnRegisterListener { + void onSuccess(ActionResultBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest(String clientid) { + Observable observable = RetrofitServiceManager.getRegisterResult(clientid); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + updateListener.onFailure(e); + } + } + + @Override + public void onNext(ActionResultBean resultBean) { + if (resultBean != null) { + updateListener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java new file mode 100644 index 0000000..bb88db3 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface IPushRegisterPresenter { + void onReadyRetrofitRequest(String clientid); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java new file mode 100644 index 0000000..3a97b8f --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java @@ -0,0 +1,38 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.PushRegisterModelImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; + +public class PushRegisterPresenterImpl extends BasePresenter implements IPushRegisterPresenter, + PushRegisterModelImpl.OnRegisterListener { + + private IPushRegisterView view; + private PushRegisterModelImpl model; + + public PushRegisterPresenterImpl(IPushRegisterView pushRegisterView) { + this.view = pushRegisterView; + model = new PushRegisterModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest(String clientid) { + addSubscription(model.sendRetrofitRequest(clientid)); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(ActionResultBean resultBean) { + view.obtainRegisterResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java new file mode 100644 index 0000000..353903a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.ActionResultBean; + +public interface IPushRegisterView { + void obtainRegisterResult(ActionResultBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java index 0a4e1d2..865787a 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,15 +1,18 @@ package com.casic.dcms.service; import android.content.Context; +import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.utils.AuthenticationHelper; +import com.casic.dcms.bean.PushResultBean; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.casic.dcms.utils.TimeOrDateUtil; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.igexin.sdk.GTIntentService; import com.igexin.sdk.message.GTCmdMessage; import com.igexin.sdk.message.GTNotificationMessage; @@ -38,7 +41,12 @@ @Override public void onReceiveClientId(Context context, String clientid) { Log.d(TAG, "onReceiveClientId -> " + "clientid = " + clientid); - AuthenticationHelper.savePushClientID(clientid); + //通知MainActivity注册个推服务 + if (!TextUtils.isEmpty(clientid)) { + BroadcastManager.getInstance(context).sendBroadcast(Constant.REGISTER_PUSH, clientid); + } else { + Log.d(TAG, "onReceiveClientId: ===>clientid = " + clientid); + } } // cid 离线上线通知 @@ -50,28 +58,50 @@ // 各种事件处理回执 @Override public void onReceiveCommandResult(Context context, GTCmdMessage cmdMessage) { - +// Log.d(TAG, "onReceiveCommandResult -> " + cmdMessage); } // 通知到达,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageArrived(Context context, GTNotificationMessage msg) { + public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + /** + * appid = DR9oeLL9va6aG3DYXy2w39 + * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 + * messageid = b74187603fe34058a223949ead9f8dcf + * pkg = com.casic.dcms + * cid = cd1aec399b5504516102e399ecf7cda4 + * content = {"content":"您有一个工单超时,请快速处理","data":{"id":"1392655327805825025"},"id":1393131068164472834,"title":"工单超时提醒","type":"alarm"} + * title = 工单提醒 + * */ + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + NoticeBean noticeBean = new NoticeBean(); - noticeBean.setNoticeTitle(msg.getTitle()); - noticeBean.setSenderName("管理员"); - noticeBean.setNoticeDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); - noticeBean.setNoticeContent(msg.getContent()); + noticeBean.setUserPhone(StringHelper.getUserPhone()); + noticeBean.setCaseId(resultBean.getId()); + noticeBean.setTitle(resultBean.getTitle()); + noticeBean.setContent(resultBean.getContent()); + noticeBean.setType(resultBean.getType()); + noticeBean.setPushDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); noticeBean.setIsRead("1"); //存本地一份 BaseApplication.getDaoSession().insert(noticeBean); //发送消息更新界面 - BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, new Gson().toJson(noticeBean)); + BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, gson.toJson(noticeBean)); } // 通知点击,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageClicked(Context context, GTNotificationMessage msg) { + public void onNotificationMessageClicked(Context context, GTNotificationMessage message) { + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + String caseId = resultBean.getId(); + Log.d(TAG, "onNotificationMessageClicked: " + caseId); } } diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index 219ae3b..db7d9ca 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -302,7 +302,8 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件地点所在网格为[" + gridId + "]" + ",\r\n选择部件为:" + objId + "(" + objName + ")" + .setMessage("该事件地点所在网格为[" + gridId + "]" + + "\r\n选择部件为:" + objId + "(" + objName + ")" + "\r\n部件大类为:" + largeType + "\r\n小类为:" + smallType + "\r\n确认提交?") @@ -332,7 +333,9 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件所在地点网格为[" + gridId + "]确认选择?") + .setMessage("该事件所在地点网格为[" + gridId + "]" + + "\r\n所在社区为:" + communityName + + "\r\n确认选择?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { diff --git a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java index 22d7bca..dfc9961 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java @@ -159,7 +159,7 @@ for (PointDataBean dataBean : casePointList) { double parseLng = Double.parseDouble(dataBean.getLng()); double parseLat = Double.parseDouble(dataBean.getLat()); - if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 || + if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 && Math.abs(parseLat - point.getY()) <= Constant.DELTA_LAT_10) { Message message = weakReferenceHandler.obtainMessage(); message.what = 2021051401; diff --git a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java index 8d37132..e3703e3 100644 --- a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java @@ -50,7 +50,7 @@ @Override public int initLayoutView() { - return R.layout.activity_analysis; + return R.layout.activity_case_analysis; } @Override diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 4ab4cb8..cba9a54 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -18,11 +18,13 @@ import com.casic.dcms.adapter.MainPageAdapter; import com.casic.dcms.base.DoubleClickExitActivity; import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.presenter.PushRegisterPresenterImpl; import com.casic.dcms.mvp.presenter.UploadPositionPresenterImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; import com.casic.dcms.mvp.view.IUploadPositionView; -import com.casic.dcms.ui.fragment.DashBoardPageFragment; import com.casic.dcms.ui.fragment.HomePageFragment; import com.casic.dcms.ui.fragment.MinePageFragment; +import com.casic.dcms.ui.fragment.NoticePageFragment; import com.casic.dcms.ui.fragment.PhonePageFragment; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; @@ -40,7 +42,7 @@ import butterknife.BindView; -public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView { +public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView, IPushRegisterView { private static final String TAG = "MainActivity"; @BindView(R.id.pageTitleView) @@ -53,6 +55,7 @@ private List pageList; private BroadcastManager broadcastManager; private UploadPositionPresenterImpl uploadPositionPresenter; + private PushRegisterPresenterImpl registerPresenter; @Override public int initLayoutView() { @@ -71,27 +74,35 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); uploadPositionPresenter = new UploadPositionPresenterImpl(this); + registerPresenter = new PushRegisterPresenterImpl(this); pageList = new ArrayList<>(); pageList.add(new HomePageFragment()); pageList.add(new PhonePageFragment()); - pageList.add(new DashBoardPageFragment()); + pageList.add(new NoticePageFragment()); pageList.add(new MinePageFragment()); broadcastManager = BroadcastManager.getInstance(this); - broadcastManager.addAction(Constant.LOGIN_OUT_ACTION, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.LOGIN_OUT_ACTION.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - if (data.equals("请求成功")) { - finish(); + broadcastManager.addAction(new String[]{Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH}, + new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + switch (action) { + case Constant.LOGIN_OUT_ACTION: + String loginOut = intent.getStringExtra("data"); + assert loginOut != null; + if (loginOut.equals("请求成功")) { + finish(); + } + break; + case Constant.REGISTER_PUSH: + String clientid = intent.getStringExtra("data"); + registerPresenter.onReadyRetrofitRequest(clientid); + break; + } } } - } - } - }); + }); String imei = OtherUtils.obtainSimCardSerialNumber(this); if (TextUtils.isEmpty(imei)) { return; @@ -99,9 +110,13 @@ LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { - uploadPositionPresenter.onReadyRetrofitRequest(imei, - String.valueOf(location.getLatitude()), - String.valueOf(location.getLongitude())); + if (location != null) { + uploadPositionPresenter.onReadyRetrofitRequest(imei, + String.valueOf(location.getLatitude()), + String.valueOf(location.getLongitude())); + } else { + Log.d(TAG, "onLocationGet: location is null"); + } } }); } @@ -163,14 +178,22 @@ @Override protected void onDestroy() { super.onDestroy(); - broadcastManager.destroy(Constant.LOGIN_OUT_ACTION); + broadcastManager.destroy(Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH); if (uploadPositionPresenter != null) { uploadPositionPresenter.disposeRetrofitRequest(); } + if (registerPresenter != null) { + registerPresenter.disposeRetrofitRequest(); + } } @Override public void obtainUploadPositionResult(ActionResultBean resultBean) { - Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); +// Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); + } + + @Override + public void obtainRegisterResult(ActionResultBean resultBean) { + Log.d(TAG, "obtainRegisterResult: " + new Gson().toJson(resultBean)); } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java new file mode 100644 index 0000000..017a37e --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -0,0 +1,74 @@ +package com.casic.dcms.bean; + +public class PushResultBean { + + /** + * content : 您有一个工单超时,请快速处理 + * data : {"id":"1393113365064245250"} + * id : 1393117524798783490 + * title : 工单超时提醒 + * type : alarm + */ + + private String content; + private DataBean data; + private String id; + private String title; + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class DataBean { + /** + * id : 1393113365064245250 + */ + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java index 259eb85..c118368 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,11 +25,13 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property NoticeTitle = new Property(1, String.class, "noticeTitle", false, "NOTICE_TITLE"); - public final static Property NoticeDate = new Property(2, String.class, "noticeDate", false, "NOTICE_DATE"); - public final static Property NoticeContent = new Property(3, String.class, "noticeContent", false, "NOTICE_CONTENT"); - public final static Property SenderName = new Property(4, String.class, "senderName", false, "SENDER_NAME"); - public final static Property IsRead = new Property(5, String.class, "isRead", false, "IS_READ"); + public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property CaseId = new Property(2, String.class, "caseId", false, "CASE_ID"); + public final static Property Title = new Property(3, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(4, String.class, "content", false, "CONTENT"); + public final static Property PushDate = new Property(5, String.class, "pushDate", false, "PUSH_DATE"); + public final static Property Type = new Property(6, String.class, "type", false, "TYPE"); + public final static Property IsRead = new Property(7, String.class, "isRead", false, "IS_READ"); } @@ -46,11 +48,13 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"NOTICE_TITLE\" TEXT," + // 1: noticeTitle - "\"NOTICE_DATE\" TEXT," + // 2: noticeDate - "\"NOTICE_CONTENT\" TEXT," + // 3: noticeContent - "\"SENDER_NAME\" TEXT," + // 4: senderName - "\"IS_READ\" TEXT);"); // 5: isRead + "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"CASE_ID\" TEXT," + // 2: caseId + "\"TITLE\" TEXT," + // 3: title + "\"CONTENT\" TEXT," + // 4: content + "\"PUSH_DATE\" TEXT," + // 5: pushDate + "\"TYPE\" TEXT," + // 6: type + "\"IS_READ\" TEXT);"); // 7: isRead } /** Drops the underlying database table. */ @@ -68,29 +72,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -103,29 +117,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -138,11 +162,13 @@ public NoticeBean readEntity(Cursor cursor, int offset) { NoticeBean entity = new NoticeBean( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // noticeTitle - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // noticeDate - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // noticeContent - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // senderName - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // isRead + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userPhone + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // caseId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pushDate + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // type + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // isRead ); return entity; } @@ -150,11 +176,13 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setNoticeTitle(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setNoticeDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setNoticeContent(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setSenderName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setIsRead(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setCaseId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setPushDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setType(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setIsRead(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); } @Override diff --git a/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java new file mode 100644 index 0000000..7c3fb29 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface IPushRegisterModel { + Subscription sendRetrofitRequest(String clientid); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java new file mode 100644 index 0000000..c7ae0c1 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class PushRegisterModelImpl implements IPushRegisterModel { + + private OnRegisterListener updateListener; + + public PushRegisterModelImpl(OnRegisterListener listener) { + this.updateListener = listener; + } + + public interface OnRegisterListener { + void onSuccess(ActionResultBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest(String clientid) { + Observable observable = RetrofitServiceManager.getRegisterResult(clientid); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + updateListener.onFailure(e); + } + } + + @Override + public void onNext(ActionResultBean resultBean) { + if (resultBean != null) { + updateListener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java new file mode 100644 index 0000000..bb88db3 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface IPushRegisterPresenter { + void onReadyRetrofitRequest(String clientid); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java new file mode 100644 index 0000000..3a97b8f --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java @@ -0,0 +1,38 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.PushRegisterModelImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; + +public class PushRegisterPresenterImpl extends BasePresenter implements IPushRegisterPresenter, + PushRegisterModelImpl.OnRegisterListener { + + private IPushRegisterView view; + private PushRegisterModelImpl model; + + public PushRegisterPresenterImpl(IPushRegisterView pushRegisterView) { + this.view = pushRegisterView; + model = new PushRegisterModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest(String clientid) { + addSubscription(model.sendRetrofitRequest(clientid)); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(ActionResultBean resultBean) { + view.obtainRegisterResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java new file mode 100644 index 0000000..353903a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.ActionResultBean; + +public interface IPushRegisterView { + void obtainRegisterResult(ActionResultBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java index 0a4e1d2..865787a 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,15 +1,18 @@ package com.casic.dcms.service; import android.content.Context; +import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.utils.AuthenticationHelper; +import com.casic.dcms.bean.PushResultBean; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.casic.dcms.utils.TimeOrDateUtil; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.igexin.sdk.GTIntentService; import com.igexin.sdk.message.GTCmdMessage; import com.igexin.sdk.message.GTNotificationMessage; @@ -38,7 +41,12 @@ @Override public void onReceiveClientId(Context context, String clientid) { Log.d(TAG, "onReceiveClientId -> " + "clientid = " + clientid); - AuthenticationHelper.savePushClientID(clientid); + //通知MainActivity注册个推服务 + if (!TextUtils.isEmpty(clientid)) { + BroadcastManager.getInstance(context).sendBroadcast(Constant.REGISTER_PUSH, clientid); + } else { + Log.d(TAG, "onReceiveClientId: ===>clientid = " + clientid); + } } // cid 离线上线通知 @@ -50,28 +58,50 @@ // 各种事件处理回执 @Override public void onReceiveCommandResult(Context context, GTCmdMessage cmdMessage) { - +// Log.d(TAG, "onReceiveCommandResult -> " + cmdMessage); } // 通知到达,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageArrived(Context context, GTNotificationMessage msg) { + public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + /** + * appid = DR9oeLL9va6aG3DYXy2w39 + * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 + * messageid = b74187603fe34058a223949ead9f8dcf + * pkg = com.casic.dcms + * cid = cd1aec399b5504516102e399ecf7cda4 + * content = {"content":"您有一个工单超时,请快速处理","data":{"id":"1392655327805825025"},"id":1393131068164472834,"title":"工单超时提醒","type":"alarm"} + * title = 工单提醒 + * */ + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + NoticeBean noticeBean = new NoticeBean(); - noticeBean.setNoticeTitle(msg.getTitle()); - noticeBean.setSenderName("管理员"); - noticeBean.setNoticeDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); - noticeBean.setNoticeContent(msg.getContent()); + noticeBean.setUserPhone(StringHelper.getUserPhone()); + noticeBean.setCaseId(resultBean.getId()); + noticeBean.setTitle(resultBean.getTitle()); + noticeBean.setContent(resultBean.getContent()); + noticeBean.setType(resultBean.getType()); + noticeBean.setPushDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); noticeBean.setIsRead("1"); //存本地一份 BaseApplication.getDaoSession().insert(noticeBean); //发送消息更新界面 - BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, new Gson().toJson(noticeBean)); + BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, gson.toJson(noticeBean)); } // 通知点击,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageClicked(Context context, GTNotificationMessage msg) { + public void onNotificationMessageClicked(Context context, GTNotificationMessage message) { + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + String caseId = resultBean.getId(); + Log.d(TAG, "onNotificationMessageClicked: " + caseId); } } diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index 219ae3b..db7d9ca 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -302,7 +302,8 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件地点所在网格为[" + gridId + "]" + ",\r\n选择部件为:" + objId + "(" + objName + ")" + .setMessage("该事件地点所在网格为[" + gridId + "]" + + "\r\n选择部件为:" + objId + "(" + objName + ")" + "\r\n部件大类为:" + largeType + "\r\n小类为:" + smallType + "\r\n确认提交?") @@ -332,7 +333,9 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件所在地点网格为[" + gridId + "]确认选择?") + .setMessage("该事件所在地点网格为[" + gridId + "]" + + "\r\n所在社区为:" + communityName + + "\r\n确认选择?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { diff --git a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java index 22d7bca..dfc9961 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java @@ -159,7 +159,7 @@ for (PointDataBean dataBean : casePointList) { double parseLng = Double.parseDouble(dataBean.getLng()); double parseLat = Double.parseDouble(dataBean.getLat()); - if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 || + if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 && Math.abs(parseLat - point.getY()) <= Constant.DELTA_LAT_10) { Message message = weakReferenceHandler.obtainMessage(); message.what = 2021051401; diff --git a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java index 8d37132..e3703e3 100644 --- a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java @@ -50,7 +50,7 @@ @Override public int initLayoutView() { - return R.layout.activity_analysis; + return R.layout.activity_case_analysis; } @Override diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 4ab4cb8..cba9a54 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -18,11 +18,13 @@ import com.casic.dcms.adapter.MainPageAdapter; import com.casic.dcms.base.DoubleClickExitActivity; import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.presenter.PushRegisterPresenterImpl; import com.casic.dcms.mvp.presenter.UploadPositionPresenterImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; import com.casic.dcms.mvp.view.IUploadPositionView; -import com.casic.dcms.ui.fragment.DashBoardPageFragment; import com.casic.dcms.ui.fragment.HomePageFragment; import com.casic.dcms.ui.fragment.MinePageFragment; +import com.casic.dcms.ui.fragment.NoticePageFragment; import com.casic.dcms.ui.fragment.PhonePageFragment; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; @@ -40,7 +42,7 @@ import butterknife.BindView; -public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView { +public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView, IPushRegisterView { private static final String TAG = "MainActivity"; @BindView(R.id.pageTitleView) @@ -53,6 +55,7 @@ private List pageList; private BroadcastManager broadcastManager; private UploadPositionPresenterImpl uploadPositionPresenter; + private PushRegisterPresenterImpl registerPresenter; @Override public int initLayoutView() { @@ -71,27 +74,35 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); uploadPositionPresenter = new UploadPositionPresenterImpl(this); + registerPresenter = new PushRegisterPresenterImpl(this); pageList = new ArrayList<>(); pageList.add(new HomePageFragment()); pageList.add(new PhonePageFragment()); - pageList.add(new DashBoardPageFragment()); + pageList.add(new NoticePageFragment()); pageList.add(new MinePageFragment()); broadcastManager = BroadcastManager.getInstance(this); - broadcastManager.addAction(Constant.LOGIN_OUT_ACTION, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.LOGIN_OUT_ACTION.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - if (data.equals("请求成功")) { - finish(); + broadcastManager.addAction(new String[]{Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH}, + new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + switch (action) { + case Constant.LOGIN_OUT_ACTION: + String loginOut = intent.getStringExtra("data"); + assert loginOut != null; + if (loginOut.equals("请求成功")) { + finish(); + } + break; + case Constant.REGISTER_PUSH: + String clientid = intent.getStringExtra("data"); + registerPresenter.onReadyRetrofitRequest(clientid); + break; + } } } - } - } - }); + }); String imei = OtherUtils.obtainSimCardSerialNumber(this); if (TextUtils.isEmpty(imei)) { return; @@ -99,9 +110,13 @@ LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { - uploadPositionPresenter.onReadyRetrofitRequest(imei, - String.valueOf(location.getLatitude()), - String.valueOf(location.getLongitude())); + if (location != null) { + uploadPositionPresenter.onReadyRetrofitRequest(imei, + String.valueOf(location.getLatitude()), + String.valueOf(location.getLongitude())); + } else { + Log.d(TAG, "onLocationGet: location is null"); + } } }); } @@ -163,14 +178,22 @@ @Override protected void onDestroy() { super.onDestroy(); - broadcastManager.destroy(Constant.LOGIN_OUT_ACTION); + broadcastManager.destroy(Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH); if (uploadPositionPresenter != null) { uploadPositionPresenter.disposeRetrofitRequest(); } + if (registerPresenter != null) { + registerPresenter.disposeRetrofitRequest(); + } } @Override public void obtainUploadPositionResult(ActionResultBean resultBean) { - Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); +// Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); + } + + @Override + public void obtainRegisterResult(ActionResultBean resultBean) { + Log.d(TAG, "obtainRegisterResult: " + new Gson().toJson(resultBean)); } } diff --git a/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java b/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java deleted file mode 100644 index 6c9e96a..0000000 --- a/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.casic.dcms.ui; - -import android.annotation.SuppressLint; -import android.view.View; -import android.widget.TextView; - -import androidx.core.content.ContextCompat; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.NoticeBean; -import com.google.gson.Gson; -import com.qmuiteam.qmui.widget.QMUITopBarLayout; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 10:35 - * @email : 290677893@qq.com - **/ -public class NoticeActivity extends BaseActivity { - - @BindView(R.id.noticeTopLayout) - QMUITopBarLayout noticeTopLayout; - @BindView(R.id.noticeTitleView) - TextView noticeTitleView; - @BindView(R.id.noticeSenderView) - TextView noticeSenderView; - @BindView(R.id.noticeDateView) - TextView noticeDateView; - @BindView(R.id.noticeContentView) - TextView noticeContentView; - - @Override - public int initLayoutView() { - return R.layout.activity_notice; - } - - @Override - protected void setupTopBarLayout() { - noticeTopLayout.setTitle("消息内容").setTextColor(ContextCompat.getColor(this, R.color.white)); - noticeTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - noticeTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - finish(); - } - }); - } - - @SuppressLint("SetTextI18n") - @Override - public void initData() { - String noticeBeanJson = getIntent().getStringExtra("noticeBeanJson"); - NoticeBean noticeBean = new Gson().fromJson(noticeBeanJson, NoticeBean.class); - - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeSenderView.setText("发送者:" + noticeBean.getSenderName()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); - } - - @Override - public void initEvent() { - - } -} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java new file mode 100644 index 0000000..017a37e --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -0,0 +1,74 @@ +package com.casic.dcms.bean; + +public class PushResultBean { + + /** + * content : 您有一个工单超时,请快速处理 + * data : {"id":"1393113365064245250"} + * id : 1393117524798783490 + * title : 工单超时提醒 + * type : alarm + */ + + private String content; + private DataBean data; + private String id; + private String title; + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class DataBean { + /** + * id : 1393113365064245250 + */ + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java index 259eb85..c118368 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,11 +25,13 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property NoticeTitle = new Property(1, String.class, "noticeTitle", false, "NOTICE_TITLE"); - public final static Property NoticeDate = new Property(2, String.class, "noticeDate", false, "NOTICE_DATE"); - public final static Property NoticeContent = new Property(3, String.class, "noticeContent", false, "NOTICE_CONTENT"); - public final static Property SenderName = new Property(4, String.class, "senderName", false, "SENDER_NAME"); - public final static Property IsRead = new Property(5, String.class, "isRead", false, "IS_READ"); + public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property CaseId = new Property(2, String.class, "caseId", false, "CASE_ID"); + public final static Property Title = new Property(3, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(4, String.class, "content", false, "CONTENT"); + public final static Property PushDate = new Property(5, String.class, "pushDate", false, "PUSH_DATE"); + public final static Property Type = new Property(6, String.class, "type", false, "TYPE"); + public final static Property IsRead = new Property(7, String.class, "isRead", false, "IS_READ"); } @@ -46,11 +48,13 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"NOTICE_TITLE\" TEXT," + // 1: noticeTitle - "\"NOTICE_DATE\" TEXT," + // 2: noticeDate - "\"NOTICE_CONTENT\" TEXT," + // 3: noticeContent - "\"SENDER_NAME\" TEXT," + // 4: senderName - "\"IS_READ\" TEXT);"); // 5: isRead + "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"CASE_ID\" TEXT," + // 2: caseId + "\"TITLE\" TEXT," + // 3: title + "\"CONTENT\" TEXT," + // 4: content + "\"PUSH_DATE\" TEXT," + // 5: pushDate + "\"TYPE\" TEXT," + // 6: type + "\"IS_READ\" TEXT);"); // 7: isRead } /** Drops the underlying database table. */ @@ -68,29 +72,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -103,29 +117,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -138,11 +162,13 @@ public NoticeBean readEntity(Cursor cursor, int offset) { NoticeBean entity = new NoticeBean( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // noticeTitle - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // noticeDate - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // noticeContent - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // senderName - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // isRead + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userPhone + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // caseId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pushDate + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // type + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // isRead ); return entity; } @@ -150,11 +176,13 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setNoticeTitle(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setNoticeDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setNoticeContent(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setSenderName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setIsRead(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setCaseId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setPushDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setType(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setIsRead(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); } @Override diff --git a/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java new file mode 100644 index 0000000..7c3fb29 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface IPushRegisterModel { + Subscription sendRetrofitRequest(String clientid); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java new file mode 100644 index 0000000..c7ae0c1 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class PushRegisterModelImpl implements IPushRegisterModel { + + private OnRegisterListener updateListener; + + public PushRegisterModelImpl(OnRegisterListener listener) { + this.updateListener = listener; + } + + public interface OnRegisterListener { + void onSuccess(ActionResultBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest(String clientid) { + Observable observable = RetrofitServiceManager.getRegisterResult(clientid); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + updateListener.onFailure(e); + } + } + + @Override + public void onNext(ActionResultBean resultBean) { + if (resultBean != null) { + updateListener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java new file mode 100644 index 0000000..bb88db3 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface IPushRegisterPresenter { + void onReadyRetrofitRequest(String clientid); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java new file mode 100644 index 0000000..3a97b8f --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java @@ -0,0 +1,38 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.PushRegisterModelImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; + +public class PushRegisterPresenterImpl extends BasePresenter implements IPushRegisterPresenter, + PushRegisterModelImpl.OnRegisterListener { + + private IPushRegisterView view; + private PushRegisterModelImpl model; + + public PushRegisterPresenterImpl(IPushRegisterView pushRegisterView) { + this.view = pushRegisterView; + model = new PushRegisterModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest(String clientid) { + addSubscription(model.sendRetrofitRequest(clientid)); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(ActionResultBean resultBean) { + view.obtainRegisterResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java new file mode 100644 index 0000000..353903a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.ActionResultBean; + +public interface IPushRegisterView { + void obtainRegisterResult(ActionResultBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java index 0a4e1d2..865787a 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,15 +1,18 @@ package com.casic.dcms.service; import android.content.Context; +import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.utils.AuthenticationHelper; +import com.casic.dcms.bean.PushResultBean; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.casic.dcms.utils.TimeOrDateUtil; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.igexin.sdk.GTIntentService; import com.igexin.sdk.message.GTCmdMessage; import com.igexin.sdk.message.GTNotificationMessage; @@ -38,7 +41,12 @@ @Override public void onReceiveClientId(Context context, String clientid) { Log.d(TAG, "onReceiveClientId -> " + "clientid = " + clientid); - AuthenticationHelper.savePushClientID(clientid); + //通知MainActivity注册个推服务 + if (!TextUtils.isEmpty(clientid)) { + BroadcastManager.getInstance(context).sendBroadcast(Constant.REGISTER_PUSH, clientid); + } else { + Log.d(TAG, "onReceiveClientId: ===>clientid = " + clientid); + } } // cid 离线上线通知 @@ -50,28 +58,50 @@ // 各种事件处理回执 @Override public void onReceiveCommandResult(Context context, GTCmdMessage cmdMessage) { - +// Log.d(TAG, "onReceiveCommandResult -> " + cmdMessage); } // 通知到达,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageArrived(Context context, GTNotificationMessage msg) { + public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + /** + * appid = DR9oeLL9va6aG3DYXy2w39 + * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 + * messageid = b74187603fe34058a223949ead9f8dcf + * pkg = com.casic.dcms + * cid = cd1aec399b5504516102e399ecf7cda4 + * content = {"content":"您有一个工单超时,请快速处理","data":{"id":"1392655327805825025"},"id":1393131068164472834,"title":"工单超时提醒","type":"alarm"} + * title = 工单提醒 + * */ + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + NoticeBean noticeBean = new NoticeBean(); - noticeBean.setNoticeTitle(msg.getTitle()); - noticeBean.setSenderName("管理员"); - noticeBean.setNoticeDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); - noticeBean.setNoticeContent(msg.getContent()); + noticeBean.setUserPhone(StringHelper.getUserPhone()); + noticeBean.setCaseId(resultBean.getId()); + noticeBean.setTitle(resultBean.getTitle()); + noticeBean.setContent(resultBean.getContent()); + noticeBean.setType(resultBean.getType()); + noticeBean.setPushDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); noticeBean.setIsRead("1"); //存本地一份 BaseApplication.getDaoSession().insert(noticeBean); //发送消息更新界面 - BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, new Gson().toJson(noticeBean)); + BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, gson.toJson(noticeBean)); } // 通知点击,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageClicked(Context context, GTNotificationMessage msg) { + public void onNotificationMessageClicked(Context context, GTNotificationMessage message) { + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + String caseId = resultBean.getId(); + Log.d(TAG, "onNotificationMessageClicked: " + caseId); } } diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index 219ae3b..db7d9ca 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -302,7 +302,8 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件地点所在网格为[" + gridId + "]" + ",\r\n选择部件为:" + objId + "(" + objName + ")" + .setMessage("该事件地点所在网格为[" + gridId + "]" + + "\r\n选择部件为:" + objId + "(" + objName + ")" + "\r\n部件大类为:" + largeType + "\r\n小类为:" + smallType + "\r\n确认提交?") @@ -332,7 +333,9 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件所在地点网格为[" + gridId + "]确认选择?") + .setMessage("该事件所在地点网格为[" + gridId + "]" + + "\r\n所在社区为:" + communityName + + "\r\n确认选择?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { diff --git a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java index 22d7bca..dfc9961 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java @@ -159,7 +159,7 @@ for (PointDataBean dataBean : casePointList) { double parseLng = Double.parseDouble(dataBean.getLng()); double parseLat = Double.parseDouble(dataBean.getLat()); - if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 || + if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 && Math.abs(parseLat - point.getY()) <= Constant.DELTA_LAT_10) { Message message = weakReferenceHandler.obtainMessage(); message.what = 2021051401; diff --git a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java index 8d37132..e3703e3 100644 --- a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java @@ -50,7 +50,7 @@ @Override public int initLayoutView() { - return R.layout.activity_analysis; + return R.layout.activity_case_analysis; } @Override diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 4ab4cb8..cba9a54 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -18,11 +18,13 @@ import com.casic.dcms.adapter.MainPageAdapter; import com.casic.dcms.base.DoubleClickExitActivity; import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.presenter.PushRegisterPresenterImpl; import com.casic.dcms.mvp.presenter.UploadPositionPresenterImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; import com.casic.dcms.mvp.view.IUploadPositionView; -import com.casic.dcms.ui.fragment.DashBoardPageFragment; import com.casic.dcms.ui.fragment.HomePageFragment; import com.casic.dcms.ui.fragment.MinePageFragment; +import com.casic.dcms.ui.fragment.NoticePageFragment; import com.casic.dcms.ui.fragment.PhonePageFragment; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; @@ -40,7 +42,7 @@ import butterknife.BindView; -public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView { +public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView, IPushRegisterView { private static final String TAG = "MainActivity"; @BindView(R.id.pageTitleView) @@ -53,6 +55,7 @@ private List pageList; private BroadcastManager broadcastManager; private UploadPositionPresenterImpl uploadPositionPresenter; + private PushRegisterPresenterImpl registerPresenter; @Override public int initLayoutView() { @@ -71,27 +74,35 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); uploadPositionPresenter = new UploadPositionPresenterImpl(this); + registerPresenter = new PushRegisterPresenterImpl(this); pageList = new ArrayList<>(); pageList.add(new HomePageFragment()); pageList.add(new PhonePageFragment()); - pageList.add(new DashBoardPageFragment()); + pageList.add(new NoticePageFragment()); pageList.add(new MinePageFragment()); broadcastManager = BroadcastManager.getInstance(this); - broadcastManager.addAction(Constant.LOGIN_OUT_ACTION, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.LOGIN_OUT_ACTION.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - if (data.equals("请求成功")) { - finish(); + broadcastManager.addAction(new String[]{Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH}, + new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + switch (action) { + case Constant.LOGIN_OUT_ACTION: + String loginOut = intent.getStringExtra("data"); + assert loginOut != null; + if (loginOut.equals("请求成功")) { + finish(); + } + break; + case Constant.REGISTER_PUSH: + String clientid = intent.getStringExtra("data"); + registerPresenter.onReadyRetrofitRequest(clientid); + break; + } } } - } - } - }); + }); String imei = OtherUtils.obtainSimCardSerialNumber(this); if (TextUtils.isEmpty(imei)) { return; @@ -99,9 +110,13 @@ LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { - uploadPositionPresenter.onReadyRetrofitRequest(imei, - String.valueOf(location.getLatitude()), - String.valueOf(location.getLongitude())); + if (location != null) { + uploadPositionPresenter.onReadyRetrofitRequest(imei, + String.valueOf(location.getLatitude()), + String.valueOf(location.getLongitude())); + } else { + Log.d(TAG, "onLocationGet: location is null"); + } } }); } @@ -163,14 +178,22 @@ @Override protected void onDestroy() { super.onDestroy(); - broadcastManager.destroy(Constant.LOGIN_OUT_ACTION); + broadcastManager.destroy(Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH); if (uploadPositionPresenter != null) { uploadPositionPresenter.disposeRetrofitRequest(); } + if (registerPresenter != null) { + registerPresenter.disposeRetrofitRequest(); + } } @Override public void obtainUploadPositionResult(ActionResultBean resultBean) { - Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); +// Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); + } + + @Override + public void obtainRegisterResult(ActionResultBean resultBean) { + Log.d(TAG, "obtainRegisterResult: " + new Gson().toJson(resultBean)); } } diff --git a/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java b/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java deleted file mode 100644 index 6c9e96a..0000000 --- a/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.casic.dcms.ui; - -import android.annotation.SuppressLint; -import android.view.View; -import android.widget.TextView; - -import androidx.core.content.ContextCompat; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.NoticeBean; -import com.google.gson.Gson; -import com.qmuiteam.qmui.widget.QMUITopBarLayout; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 10:35 - * @email : 290677893@qq.com - **/ -public class NoticeActivity extends BaseActivity { - - @BindView(R.id.noticeTopLayout) - QMUITopBarLayout noticeTopLayout; - @BindView(R.id.noticeTitleView) - TextView noticeTitleView; - @BindView(R.id.noticeSenderView) - TextView noticeSenderView; - @BindView(R.id.noticeDateView) - TextView noticeDateView; - @BindView(R.id.noticeContentView) - TextView noticeContentView; - - @Override - public int initLayoutView() { - return R.layout.activity_notice; - } - - @Override - protected void setupTopBarLayout() { - noticeTopLayout.setTitle("消息内容").setTextColor(ContextCompat.getColor(this, R.color.white)); - noticeTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - noticeTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - finish(); - } - }); - } - - @SuppressLint("SetTextI18n") - @Override - public void initData() { - String noticeBeanJson = getIntent().getStringExtra("noticeBeanJson"); - NoticeBean noticeBean = new Gson().fromJson(noticeBeanJson, NoticeBean.class); - - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeSenderView.setText("发送者:" + noticeBean.getSenderName()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); - } - - @Override - public void initEvent() { - - } -} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java deleted file mode 100644 index 62d4aa2..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.Context; -import android.widget.LinearLayout; - -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -public class DashBoardPageFragment extends BaseFragment { - - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; - - private Context context; - - @Override - protected int initLayoutView() { - return R.layout.fragment_dashboard; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - List fragmentList = new ArrayList<>(); - fragmentList.add(new UnreadFragment()); - fragmentList.add(new ReadFragment()); - SubViewPagerAdapter adapter = new SubViewPagerAdapter(getChildFragmentManager(), pageTitles, fragmentList); - dashboardViewPager.setAdapter(adapter); - //绑定TabLayout - topTabLayout.setupWithViewPager(dashboardViewPager); - LinearLayout linearLayout = (LinearLayout) topTabLayout.getChildAt(0); - linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); - linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); - } - - @Override - protected void initEvent() { - - } -} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java new file mode 100644 index 0000000..017a37e --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -0,0 +1,74 @@ +package com.casic.dcms.bean; + +public class PushResultBean { + + /** + * content : 您有一个工单超时,请快速处理 + * data : {"id":"1393113365064245250"} + * id : 1393117524798783490 + * title : 工单超时提醒 + * type : alarm + */ + + private String content; + private DataBean data; + private String id; + private String title; + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class DataBean { + /** + * id : 1393113365064245250 + */ + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java index 259eb85..c118368 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,11 +25,13 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property NoticeTitle = new Property(1, String.class, "noticeTitle", false, "NOTICE_TITLE"); - public final static Property NoticeDate = new Property(2, String.class, "noticeDate", false, "NOTICE_DATE"); - public final static Property NoticeContent = new Property(3, String.class, "noticeContent", false, "NOTICE_CONTENT"); - public final static Property SenderName = new Property(4, String.class, "senderName", false, "SENDER_NAME"); - public final static Property IsRead = new Property(5, String.class, "isRead", false, "IS_READ"); + public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property CaseId = new Property(2, String.class, "caseId", false, "CASE_ID"); + public final static Property Title = new Property(3, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(4, String.class, "content", false, "CONTENT"); + public final static Property PushDate = new Property(5, String.class, "pushDate", false, "PUSH_DATE"); + public final static Property Type = new Property(6, String.class, "type", false, "TYPE"); + public final static Property IsRead = new Property(7, String.class, "isRead", false, "IS_READ"); } @@ -46,11 +48,13 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"NOTICE_TITLE\" TEXT," + // 1: noticeTitle - "\"NOTICE_DATE\" TEXT," + // 2: noticeDate - "\"NOTICE_CONTENT\" TEXT," + // 3: noticeContent - "\"SENDER_NAME\" TEXT," + // 4: senderName - "\"IS_READ\" TEXT);"); // 5: isRead + "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"CASE_ID\" TEXT," + // 2: caseId + "\"TITLE\" TEXT," + // 3: title + "\"CONTENT\" TEXT," + // 4: content + "\"PUSH_DATE\" TEXT," + // 5: pushDate + "\"TYPE\" TEXT," + // 6: type + "\"IS_READ\" TEXT);"); // 7: isRead } /** Drops the underlying database table. */ @@ -68,29 +72,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -103,29 +117,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -138,11 +162,13 @@ public NoticeBean readEntity(Cursor cursor, int offset) { NoticeBean entity = new NoticeBean( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // noticeTitle - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // noticeDate - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // noticeContent - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // senderName - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // isRead + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userPhone + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // caseId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pushDate + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // type + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // isRead ); return entity; } @@ -150,11 +176,13 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setNoticeTitle(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setNoticeDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setNoticeContent(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setSenderName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setIsRead(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setCaseId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setPushDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setType(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setIsRead(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); } @Override diff --git a/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java new file mode 100644 index 0000000..7c3fb29 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface IPushRegisterModel { + Subscription sendRetrofitRequest(String clientid); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java new file mode 100644 index 0000000..c7ae0c1 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class PushRegisterModelImpl implements IPushRegisterModel { + + private OnRegisterListener updateListener; + + public PushRegisterModelImpl(OnRegisterListener listener) { + this.updateListener = listener; + } + + public interface OnRegisterListener { + void onSuccess(ActionResultBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest(String clientid) { + Observable observable = RetrofitServiceManager.getRegisterResult(clientid); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + updateListener.onFailure(e); + } + } + + @Override + public void onNext(ActionResultBean resultBean) { + if (resultBean != null) { + updateListener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java new file mode 100644 index 0000000..bb88db3 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface IPushRegisterPresenter { + void onReadyRetrofitRequest(String clientid); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java new file mode 100644 index 0000000..3a97b8f --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java @@ -0,0 +1,38 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.PushRegisterModelImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; + +public class PushRegisterPresenterImpl extends BasePresenter implements IPushRegisterPresenter, + PushRegisterModelImpl.OnRegisterListener { + + private IPushRegisterView view; + private PushRegisterModelImpl model; + + public PushRegisterPresenterImpl(IPushRegisterView pushRegisterView) { + this.view = pushRegisterView; + model = new PushRegisterModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest(String clientid) { + addSubscription(model.sendRetrofitRequest(clientid)); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(ActionResultBean resultBean) { + view.obtainRegisterResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java new file mode 100644 index 0000000..353903a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.ActionResultBean; + +public interface IPushRegisterView { + void obtainRegisterResult(ActionResultBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java index 0a4e1d2..865787a 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,15 +1,18 @@ package com.casic.dcms.service; import android.content.Context; +import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.utils.AuthenticationHelper; +import com.casic.dcms.bean.PushResultBean; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.casic.dcms.utils.TimeOrDateUtil; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.igexin.sdk.GTIntentService; import com.igexin.sdk.message.GTCmdMessage; import com.igexin.sdk.message.GTNotificationMessage; @@ -38,7 +41,12 @@ @Override public void onReceiveClientId(Context context, String clientid) { Log.d(TAG, "onReceiveClientId -> " + "clientid = " + clientid); - AuthenticationHelper.savePushClientID(clientid); + //通知MainActivity注册个推服务 + if (!TextUtils.isEmpty(clientid)) { + BroadcastManager.getInstance(context).sendBroadcast(Constant.REGISTER_PUSH, clientid); + } else { + Log.d(TAG, "onReceiveClientId: ===>clientid = " + clientid); + } } // cid 离线上线通知 @@ -50,28 +58,50 @@ // 各种事件处理回执 @Override public void onReceiveCommandResult(Context context, GTCmdMessage cmdMessage) { - +// Log.d(TAG, "onReceiveCommandResult -> " + cmdMessage); } // 通知到达,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageArrived(Context context, GTNotificationMessage msg) { + public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + /** + * appid = DR9oeLL9va6aG3DYXy2w39 + * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 + * messageid = b74187603fe34058a223949ead9f8dcf + * pkg = com.casic.dcms + * cid = cd1aec399b5504516102e399ecf7cda4 + * content = {"content":"您有一个工单超时,请快速处理","data":{"id":"1392655327805825025"},"id":1393131068164472834,"title":"工单超时提醒","type":"alarm"} + * title = 工单提醒 + * */ + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + NoticeBean noticeBean = new NoticeBean(); - noticeBean.setNoticeTitle(msg.getTitle()); - noticeBean.setSenderName("管理员"); - noticeBean.setNoticeDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); - noticeBean.setNoticeContent(msg.getContent()); + noticeBean.setUserPhone(StringHelper.getUserPhone()); + noticeBean.setCaseId(resultBean.getId()); + noticeBean.setTitle(resultBean.getTitle()); + noticeBean.setContent(resultBean.getContent()); + noticeBean.setType(resultBean.getType()); + noticeBean.setPushDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); noticeBean.setIsRead("1"); //存本地一份 BaseApplication.getDaoSession().insert(noticeBean); //发送消息更新界面 - BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, new Gson().toJson(noticeBean)); + BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, gson.toJson(noticeBean)); } // 通知点击,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageClicked(Context context, GTNotificationMessage msg) { + public void onNotificationMessageClicked(Context context, GTNotificationMessage message) { + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + String caseId = resultBean.getId(); + Log.d(TAG, "onNotificationMessageClicked: " + caseId); } } diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index 219ae3b..db7d9ca 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -302,7 +302,8 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件地点所在网格为[" + gridId + "]" + ",\r\n选择部件为:" + objId + "(" + objName + ")" + .setMessage("该事件地点所在网格为[" + gridId + "]" + + "\r\n选择部件为:" + objId + "(" + objName + ")" + "\r\n部件大类为:" + largeType + "\r\n小类为:" + smallType + "\r\n确认提交?") @@ -332,7 +333,9 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件所在地点网格为[" + gridId + "]确认选择?") + .setMessage("该事件所在地点网格为[" + gridId + "]" + + "\r\n所在社区为:" + communityName + + "\r\n确认选择?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { diff --git a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java index 22d7bca..dfc9961 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java @@ -159,7 +159,7 @@ for (PointDataBean dataBean : casePointList) { double parseLng = Double.parseDouble(dataBean.getLng()); double parseLat = Double.parseDouble(dataBean.getLat()); - if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 || + if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 && Math.abs(parseLat - point.getY()) <= Constant.DELTA_LAT_10) { Message message = weakReferenceHandler.obtainMessage(); message.what = 2021051401; diff --git a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java index 8d37132..e3703e3 100644 --- a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java @@ -50,7 +50,7 @@ @Override public int initLayoutView() { - return R.layout.activity_analysis; + return R.layout.activity_case_analysis; } @Override diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 4ab4cb8..cba9a54 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -18,11 +18,13 @@ import com.casic.dcms.adapter.MainPageAdapter; import com.casic.dcms.base.DoubleClickExitActivity; import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.presenter.PushRegisterPresenterImpl; import com.casic.dcms.mvp.presenter.UploadPositionPresenterImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; import com.casic.dcms.mvp.view.IUploadPositionView; -import com.casic.dcms.ui.fragment.DashBoardPageFragment; import com.casic.dcms.ui.fragment.HomePageFragment; import com.casic.dcms.ui.fragment.MinePageFragment; +import com.casic.dcms.ui.fragment.NoticePageFragment; import com.casic.dcms.ui.fragment.PhonePageFragment; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; @@ -40,7 +42,7 @@ import butterknife.BindView; -public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView { +public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView, IPushRegisterView { private static final String TAG = "MainActivity"; @BindView(R.id.pageTitleView) @@ -53,6 +55,7 @@ private List pageList; private BroadcastManager broadcastManager; private UploadPositionPresenterImpl uploadPositionPresenter; + private PushRegisterPresenterImpl registerPresenter; @Override public int initLayoutView() { @@ -71,27 +74,35 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); uploadPositionPresenter = new UploadPositionPresenterImpl(this); + registerPresenter = new PushRegisterPresenterImpl(this); pageList = new ArrayList<>(); pageList.add(new HomePageFragment()); pageList.add(new PhonePageFragment()); - pageList.add(new DashBoardPageFragment()); + pageList.add(new NoticePageFragment()); pageList.add(new MinePageFragment()); broadcastManager = BroadcastManager.getInstance(this); - broadcastManager.addAction(Constant.LOGIN_OUT_ACTION, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.LOGIN_OUT_ACTION.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - if (data.equals("请求成功")) { - finish(); + broadcastManager.addAction(new String[]{Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH}, + new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + switch (action) { + case Constant.LOGIN_OUT_ACTION: + String loginOut = intent.getStringExtra("data"); + assert loginOut != null; + if (loginOut.equals("请求成功")) { + finish(); + } + break; + case Constant.REGISTER_PUSH: + String clientid = intent.getStringExtra("data"); + registerPresenter.onReadyRetrofitRequest(clientid); + break; + } } } - } - } - }); + }); String imei = OtherUtils.obtainSimCardSerialNumber(this); if (TextUtils.isEmpty(imei)) { return; @@ -99,9 +110,13 @@ LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { - uploadPositionPresenter.onReadyRetrofitRequest(imei, - String.valueOf(location.getLatitude()), - String.valueOf(location.getLongitude())); + if (location != null) { + uploadPositionPresenter.onReadyRetrofitRequest(imei, + String.valueOf(location.getLatitude()), + String.valueOf(location.getLongitude())); + } else { + Log.d(TAG, "onLocationGet: location is null"); + } } }); } @@ -163,14 +178,22 @@ @Override protected void onDestroy() { super.onDestroy(); - broadcastManager.destroy(Constant.LOGIN_OUT_ACTION); + broadcastManager.destroy(Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH); if (uploadPositionPresenter != null) { uploadPositionPresenter.disposeRetrofitRequest(); } + if (registerPresenter != null) { + registerPresenter.disposeRetrofitRequest(); + } } @Override public void obtainUploadPositionResult(ActionResultBean resultBean) { - Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); +// Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); + } + + @Override + public void obtainRegisterResult(ActionResultBean resultBean) { + Log.d(TAG, "obtainRegisterResult: " + new Gson().toJson(resultBean)); } } diff --git a/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java b/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java deleted file mode 100644 index 6c9e96a..0000000 --- a/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.casic.dcms.ui; - -import android.annotation.SuppressLint; -import android.view.View; -import android.widget.TextView; - -import androidx.core.content.ContextCompat; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.NoticeBean; -import com.google.gson.Gson; -import com.qmuiteam.qmui.widget.QMUITopBarLayout; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 10:35 - * @email : 290677893@qq.com - **/ -public class NoticeActivity extends BaseActivity { - - @BindView(R.id.noticeTopLayout) - QMUITopBarLayout noticeTopLayout; - @BindView(R.id.noticeTitleView) - TextView noticeTitleView; - @BindView(R.id.noticeSenderView) - TextView noticeSenderView; - @BindView(R.id.noticeDateView) - TextView noticeDateView; - @BindView(R.id.noticeContentView) - TextView noticeContentView; - - @Override - public int initLayoutView() { - return R.layout.activity_notice; - } - - @Override - protected void setupTopBarLayout() { - noticeTopLayout.setTitle("消息内容").setTextColor(ContextCompat.getColor(this, R.color.white)); - noticeTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - noticeTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - finish(); - } - }); - } - - @SuppressLint("SetTextI18n") - @Override - public void initData() { - String noticeBeanJson = getIntent().getStringExtra("noticeBeanJson"); - NoticeBean noticeBean = new Gson().fromJson(noticeBeanJson, NoticeBean.class); - - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeSenderView.setText("发送者:" + noticeBean.getSenderName()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); - } - - @Override - public void initEvent() { - - } -} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java deleted file mode 100644 index 62d4aa2..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.Context; -import android.widget.LinearLayout; - -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -public class DashBoardPageFragment extends BaseFragment { - - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; - - private Context context; - - @Override - protected int initLayoutView() { - return R.layout.fragment_dashboard; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - List fragmentList = new ArrayList<>(); - fragmentList.add(new UnreadFragment()); - fragmentList.add(new ReadFragment()); - SubViewPagerAdapter adapter = new SubViewPagerAdapter(getChildFragmentManager(), pageTitles, fragmentList); - dashboardViewPager.setAdapter(adapter); - //绑定TabLayout - topTabLayout.setupWithViewPager(dashboardViewPager); - LinearLayout linearLayout = (LinearLayout) topTabLayout.getChildAt(0); - linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); - linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); - } - - @Override - protected void initEvent() { - - } -} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java new file mode 100644 index 0000000..192b702 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -0,0 +1,58 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.LinearLayout; + +import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; + +import java.util.ArrayList; +import java.util.List; + +import butterknife.BindView; + +public class NoticePageFragment extends BaseFragment { + + private static final String[] pageTitles = {"未读消息", "已读消息"}; + @BindView(R.id.topTabLayout) + TabLayout topTabLayout; + @BindView(R.id.dashboardViewPager) + NoScrollViewPager dashboardViewPager; + + private Context context; + + @Override + protected int initLayoutView() { + return R.layout.fragment_dashboard; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + protected void initData() { + List fragmentList = new ArrayList<>(); + fragmentList.add(new UnreadFragment()); + fragmentList.add(new ReadFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getChildFragmentManager(), pageTitles, fragmentList); + dashboardViewPager.setAdapter(adapter); + //绑定TabLayout + topTabLayout.setupWithViewPager(dashboardViewPager); + LinearLayout linearLayout = (LinearLayout) topTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); + } + + @Override + protected void initEvent() { + + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java new file mode 100644 index 0000000..017a37e --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -0,0 +1,74 @@ +package com.casic.dcms.bean; + +public class PushResultBean { + + /** + * content : 您有一个工单超时,请快速处理 + * data : {"id":"1393113365064245250"} + * id : 1393117524798783490 + * title : 工单超时提醒 + * type : alarm + */ + + private String content; + private DataBean data; + private String id; + private String title; + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class DataBean { + /** + * id : 1393113365064245250 + */ + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java index 259eb85..c118368 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,11 +25,13 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property NoticeTitle = new Property(1, String.class, "noticeTitle", false, "NOTICE_TITLE"); - public final static Property NoticeDate = new Property(2, String.class, "noticeDate", false, "NOTICE_DATE"); - public final static Property NoticeContent = new Property(3, String.class, "noticeContent", false, "NOTICE_CONTENT"); - public final static Property SenderName = new Property(4, String.class, "senderName", false, "SENDER_NAME"); - public final static Property IsRead = new Property(5, String.class, "isRead", false, "IS_READ"); + public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property CaseId = new Property(2, String.class, "caseId", false, "CASE_ID"); + public final static Property Title = new Property(3, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(4, String.class, "content", false, "CONTENT"); + public final static Property PushDate = new Property(5, String.class, "pushDate", false, "PUSH_DATE"); + public final static Property Type = new Property(6, String.class, "type", false, "TYPE"); + public final static Property IsRead = new Property(7, String.class, "isRead", false, "IS_READ"); } @@ -46,11 +48,13 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"NOTICE_TITLE\" TEXT," + // 1: noticeTitle - "\"NOTICE_DATE\" TEXT," + // 2: noticeDate - "\"NOTICE_CONTENT\" TEXT," + // 3: noticeContent - "\"SENDER_NAME\" TEXT," + // 4: senderName - "\"IS_READ\" TEXT);"); // 5: isRead + "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"CASE_ID\" TEXT," + // 2: caseId + "\"TITLE\" TEXT," + // 3: title + "\"CONTENT\" TEXT," + // 4: content + "\"PUSH_DATE\" TEXT," + // 5: pushDate + "\"TYPE\" TEXT," + // 6: type + "\"IS_READ\" TEXT);"); // 7: isRead } /** Drops the underlying database table. */ @@ -68,29 +72,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -103,29 +117,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -138,11 +162,13 @@ public NoticeBean readEntity(Cursor cursor, int offset) { NoticeBean entity = new NoticeBean( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // noticeTitle - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // noticeDate - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // noticeContent - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // senderName - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // isRead + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userPhone + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // caseId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pushDate + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // type + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // isRead ); return entity; } @@ -150,11 +176,13 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setNoticeTitle(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setNoticeDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setNoticeContent(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setSenderName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setIsRead(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setCaseId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setPushDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setType(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setIsRead(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); } @Override diff --git a/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java new file mode 100644 index 0000000..7c3fb29 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface IPushRegisterModel { + Subscription sendRetrofitRequest(String clientid); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java new file mode 100644 index 0000000..c7ae0c1 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class PushRegisterModelImpl implements IPushRegisterModel { + + private OnRegisterListener updateListener; + + public PushRegisterModelImpl(OnRegisterListener listener) { + this.updateListener = listener; + } + + public interface OnRegisterListener { + void onSuccess(ActionResultBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest(String clientid) { + Observable observable = RetrofitServiceManager.getRegisterResult(clientid); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + updateListener.onFailure(e); + } + } + + @Override + public void onNext(ActionResultBean resultBean) { + if (resultBean != null) { + updateListener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java new file mode 100644 index 0000000..bb88db3 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface IPushRegisterPresenter { + void onReadyRetrofitRequest(String clientid); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java new file mode 100644 index 0000000..3a97b8f --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java @@ -0,0 +1,38 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.PushRegisterModelImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; + +public class PushRegisterPresenterImpl extends BasePresenter implements IPushRegisterPresenter, + PushRegisterModelImpl.OnRegisterListener { + + private IPushRegisterView view; + private PushRegisterModelImpl model; + + public PushRegisterPresenterImpl(IPushRegisterView pushRegisterView) { + this.view = pushRegisterView; + model = new PushRegisterModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest(String clientid) { + addSubscription(model.sendRetrofitRequest(clientid)); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(ActionResultBean resultBean) { + view.obtainRegisterResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java new file mode 100644 index 0000000..353903a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.ActionResultBean; + +public interface IPushRegisterView { + void obtainRegisterResult(ActionResultBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java index 0a4e1d2..865787a 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,15 +1,18 @@ package com.casic.dcms.service; import android.content.Context; +import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.utils.AuthenticationHelper; +import com.casic.dcms.bean.PushResultBean; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.casic.dcms.utils.TimeOrDateUtil; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.igexin.sdk.GTIntentService; import com.igexin.sdk.message.GTCmdMessage; import com.igexin.sdk.message.GTNotificationMessage; @@ -38,7 +41,12 @@ @Override public void onReceiveClientId(Context context, String clientid) { Log.d(TAG, "onReceiveClientId -> " + "clientid = " + clientid); - AuthenticationHelper.savePushClientID(clientid); + //通知MainActivity注册个推服务 + if (!TextUtils.isEmpty(clientid)) { + BroadcastManager.getInstance(context).sendBroadcast(Constant.REGISTER_PUSH, clientid); + } else { + Log.d(TAG, "onReceiveClientId: ===>clientid = " + clientid); + } } // cid 离线上线通知 @@ -50,28 +58,50 @@ // 各种事件处理回执 @Override public void onReceiveCommandResult(Context context, GTCmdMessage cmdMessage) { - +// Log.d(TAG, "onReceiveCommandResult -> " + cmdMessage); } // 通知到达,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageArrived(Context context, GTNotificationMessage msg) { + public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + /** + * appid = DR9oeLL9va6aG3DYXy2w39 + * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 + * messageid = b74187603fe34058a223949ead9f8dcf + * pkg = com.casic.dcms + * cid = cd1aec399b5504516102e399ecf7cda4 + * content = {"content":"您有一个工单超时,请快速处理","data":{"id":"1392655327805825025"},"id":1393131068164472834,"title":"工单超时提醒","type":"alarm"} + * title = 工单提醒 + * */ + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + NoticeBean noticeBean = new NoticeBean(); - noticeBean.setNoticeTitle(msg.getTitle()); - noticeBean.setSenderName("管理员"); - noticeBean.setNoticeDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); - noticeBean.setNoticeContent(msg.getContent()); + noticeBean.setUserPhone(StringHelper.getUserPhone()); + noticeBean.setCaseId(resultBean.getId()); + noticeBean.setTitle(resultBean.getTitle()); + noticeBean.setContent(resultBean.getContent()); + noticeBean.setType(resultBean.getType()); + noticeBean.setPushDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); noticeBean.setIsRead("1"); //存本地一份 BaseApplication.getDaoSession().insert(noticeBean); //发送消息更新界面 - BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, new Gson().toJson(noticeBean)); + BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, gson.toJson(noticeBean)); } // 通知点击,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageClicked(Context context, GTNotificationMessage msg) { + public void onNotificationMessageClicked(Context context, GTNotificationMessage message) { + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + String caseId = resultBean.getId(); + Log.d(TAG, "onNotificationMessageClicked: " + caseId); } } diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index 219ae3b..db7d9ca 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -302,7 +302,8 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件地点所在网格为[" + gridId + "]" + ",\r\n选择部件为:" + objId + "(" + objName + ")" + .setMessage("该事件地点所在网格为[" + gridId + "]" + + "\r\n选择部件为:" + objId + "(" + objName + ")" + "\r\n部件大类为:" + largeType + "\r\n小类为:" + smallType + "\r\n确认提交?") @@ -332,7 +333,9 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件所在地点网格为[" + gridId + "]确认选择?") + .setMessage("该事件所在地点网格为[" + gridId + "]" + + "\r\n所在社区为:" + communityName + + "\r\n确认选择?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { diff --git a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java index 22d7bca..dfc9961 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java @@ -159,7 +159,7 @@ for (PointDataBean dataBean : casePointList) { double parseLng = Double.parseDouble(dataBean.getLng()); double parseLat = Double.parseDouble(dataBean.getLat()); - if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 || + if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 && Math.abs(parseLat - point.getY()) <= Constant.DELTA_LAT_10) { Message message = weakReferenceHandler.obtainMessage(); message.what = 2021051401; diff --git a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java index 8d37132..e3703e3 100644 --- a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java @@ -50,7 +50,7 @@ @Override public int initLayoutView() { - return R.layout.activity_analysis; + return R.layout.activity_case_analysis; } @Override diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 4ab4cb8..cba9a54 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -18,11 +18,13 @@ import com.casic.dcms.adapter.MainPageAdapter; import com.casic.dcms.base.DoubleClickExitActivity; import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.presenter.PushRegisterPresenterImpl; import com.casic.dcms.mvp.presenter.UploadPositionPresenterImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; import com.casic.dcms.mvp.view.IUploadPositionView; -import com.casic.dcms.ui.fragment.DashBoardPageFragment; import com.casic.dcms.ui.fragment.HomePageFragment; import com.casic.dcms.ui.fragment.MinePageFragment; +import com.casic.dcms.ui.fragment.NoticePageFragment; import com.casic.dcms.ui.fragment.PhonePageFragment; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; @@ -40,7 +42,7 @@ import butterknife.BindView; -public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView { +public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView, IPushRegisterView { private static final String TAG = "MainActivity"; @BindView(R.id.pageTitleView) @@ -53,6 +55,7 @@ private List pageList; private BroadcastManager broadcastManager; private UploadPositionPresenterImpl uploadPositionPresenter; + private PushRegisterPresenterImpl registerPresenter; @Override public int initLayoutView() { @@ -71,27 +74,35 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); uploadPositionPresenter = new UploadPositionPresenterImpl(this); + registerPresenter = new PushRegisterPresenterImpl(this); pageList = new ArrayList<>(); pageList.add(new HomePageFragment()); pageList.add(new PhonePageFragment()); - pageList.add(new DashBoardPageFragment()); + pageList.add(new NoticePageFragment()); pageList.add(new MinePageFragment()); broadcastManager = BroadcastManager.getInstance(this); - broadcastManager.addAction(Constant.LOGIN_OUT_ACTION, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.LOGIN_OUT_ACTION.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - if (data.equals("请求成功")) { - finish(); + broadcastManager.addAction(new String[]{Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH}, + new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + switch (action) { + case Constant.LOGIN_OUT_ACTION: + String loginOut = intent.getStringExtra("data"); + assert loginOut != null; + if (loginOut.equals("请求成功")) { + finish(); + } + break; + case Constant.REGISTER_PUSH: + String clientid = intent.getStringExtra("data"); + registerPresenter.onReadyRetrofitRequest(clientid); + break; + } } } - } - } - }); + }); String imei = OtherUtils.obtainSimCardSerialNumber(this); if (TextUtils.isEmpty(imei)) { return; @@ -99,9 +110,13 @@ LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { - uploadPositionPresenter.onReadyRetrofitRequest(imei, - String.valueOf(location.getLatitude()), - String.valueOf(location.getLongitude())); + if (location != null) { + uploadPositionPresenter.onReadyRetrofitRequest(imei, + String.valueOf(location.getLatitude()), + String.valueOf(location.getLongitude())); + } else { + Log.d(TAG, "onLocationGet: location is null"); + } } }); } @@ -163,14 +178,22 @@ @Override protected void onDestroy() { super.onDestroy(); - broadcastManager.destroy(Constant.LOGIN_OUT_ACTION); + broadcastManager.destroy(Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH); if (uploadPositionPresenter != null) { uploadPositionPresenter.disposeRetrofitRequest(); } + if (registerPresenter != null) { + registerPresenter.disposeRetrofitRequest(); + } } @Override public void obtainUploadPositionResult(ActionResultBean resultBean) { - Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); +// Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); + } + + @Override + public void obtainRegisterResult(ActionResultBean resultBean) { + Log.d(TAG, "obtainRegisterResult: " + new Gson().toJson(resultBean)); } } diff --git a/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java b/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java deleted file mode 100644 index 6c9e96a..0000000 --- a/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.casic.dcms.ui; - -import android.annotation.SuppressLint; -import android.view.View; -import android.widget.TextView; - -import androidx.core.content.ContextCompat; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.NoticeBean; -import com.google.gson.Gson; -import com.qmuiteam.qmui.widget.QMUITopBarLayout; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 10:35 - * @email : 290677893@qq.com - **/ -public class NoticeActivity extends BaseActivity { - - @BindView(R.id.noticeTopLayout) - QMUITopBarLayout noticeTopLayout; - @BindView(R.id.noticeTitleView) - TextView noticeTitleView; - @BindView(R.id.noticeSenderView) - TextView noticeSenderView; - @BindView(R.id.noticeDateView) - TextView noticeDateView; - @BindView(R.id.noticeContentView) - TextView noticeContentView; - - @Override - public int initLayoutView() { - return R.layout.activity_notice; - } - - @Override - protected void setupTopBarLayout() { - noticeTopLayout.setTitle("消息内容").setTextColor(ContextCompat.getColor(this, R.color.white)); - noticeTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - noticeTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - finish(); - } - }); - } - - @SuppressLint("SetTextI18n") - @Override - public void initData() { - String noticeBeanJson = getIntent().getStringExtra("noticeBeanJson"); - NoticeBean noticeBean = new Gson().fromJson(noticeBeanJson, NoticeBean.class); - - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeSenderView.setText("发送者:" + noticeBean.getSenderName()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); - } - - @Override - public void initEvent() { - - } -} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java deleted file mode 100644 index 62d4aa2..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.Context; -import android.widget.LinearLayout; - -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -public class DashBoardPageFragment extends BaseFragment { - - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; - - private Context context; - - @Override - protected int initLayoutView() { - return R.layout.fragment_dashboard; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - List fragmentList = new ArrayList<>(); - fragmentList.add(new UnreadFragment()); - fragmentList.add(new ReadFragment()); - SubViewPagerAdapter adapter = new SubViewPagerAdapter(getChildFragmentManager(), pageTitles, fragmentList); - dashboardViewPager.setAdapter(adapter); - //绑定TabLayout - topTabLayout.setupWithViewPager(dashboardViewPager); - LinearLayout linearLayout = (LinearLayout) topTabLayout.getChildAt(0); - linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); - linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); - } - - @Override - protected void initEvent() { - - } -} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java new file mode 100644 index 0000000..192b702 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -0,0 +1,58 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.LinearLayout; + +import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; + +import java.util.ArrayList; +import java.util.List; + +import butterknife.BindView; + +public class NoticePageFragment extends BaseFragment { + + private static final String[] pageTitles = {"未读消息", "已读消息"}; + @BindView(R.id.topTabLayout) + TabLayout topTabLayout; + @BindView(R.id.dashboardViewPager) + NoScrollViewPager dashboardViewPager; + + private Context context; + + @Override + protected int initLayoutView() { + return R.layout.fragment_dashboard; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + protected void initData() { + List fragmentList = new ArrayList<>(); + fragmentList.add(new UnreadFragment()); + fragmentList.add(new ReadFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getChildFragmentManager(), pageTitles, fragmentList); + dashboardViewPager.setAdapter(adapter); + //绑定TabLayout + topTabLayout.setupWithViewPager(dashboardViewPager); + LinearLayout linearLayout = (LinearLayout) topTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); + } + + @Override + protected void initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java index 001fb6c..a0afe0f 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java @@ -3,6 +3,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.text.TextUtils; import android.view.ViewGroup; import androidx.annotation.NonNull; @@ -16,9 +17,11 @@ import com.casic.dcms.base.BaseFragment; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.greendao.DaoSession; -import com.casic.dcms.ui.NoticeActivity; +import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.google.gson.Gson; import com.qmuiteam.qmui.recyclerView.QMUIRVItemSwipeAction; import com.qmuiteam.qmui.recyclerView.QMUISwipeAction; @@ -61,8 +64,12 @@ gson = new Gson(); daoSession = BaseApplication.getDaoSession(); swipeViewAdapter = new SwipeViewAdapter(context); - //加载历史数据 - noticeBeans = daoSession.loadAll(NoticeBean.class); + //根据userPhone加载历史数据 + String userPhone = StringHelper.getUserPhone(); + if (TextUtils.isEmpty(userPhone)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserPhone.eq(userPhone)).list(); swipeViewAdapter.setData(noticeBeans); broadcastManager = BroadcastManager.getInstance(context); @@ -118,13 +125,14 @@ swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { @Override public void onClick(int position) { - //查看之后,未读消息变为已读消息 - NoticeBean noticeBean = noticeBeans.get(position); + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = new NoticeBean(); noticeBean.setIsRead("0"); daoSession.update(noticeBean); - Intent intent = new Intent(context, NoticeActivity.class); - intent.putExtra("noticeBeanJson", new Gson().toJson(noticeBean)); + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); startActivity(intent); } }); diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java new file mode 100644 index 0000000..017a37e --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -0,0 +1,74 @@ +package com.casic.dcms.bean; + +public class PushResultBean { + + /** + * content : 您有一个工单超时,请快速处理 + * data : {"id":"1393113365064245250"} + * id : 1393117524798783490 + * title : 工单超时提醒 + * type : alarm + */ + + private String content; + private DataBean data; + private String id; + private String title; + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class DataBean { + /** + * id : 1393113365064245250 + */ + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java index 259eb85..c118368 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,11 +25,13 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property NoticeTitle = new Property(1, String.class, "noticeTitle", false, "NOTICE_TITLE"); - public final static Property NoticeDate = new Property(2, String.class, "noticeDate", false, "NOTICE_DATE"); - public final static Property NoticeContent = new Property(3, String.class, "noticeContent", false, "NOTICE_CONTENT"); - public final static Property SenderName = new Property(4, String.class, "senderName", false, "SENDER_NAME"); - public final static Property IsRead = new Property(5, String.class, "isRead", false, "IS_READ"); + public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property CaseId = new Property(2, String.class, "caseId", false, "CASE_ID"); + public final static Property Title = new Property(3, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(4, String.class, "content", false, "CONTENT"); + public final static Property PushDate = new Property(5, String.class, "pushDate", false, "PUSH_DATE"); + public final static Property Type = new Property(6, String.class, "type", false, "TYPE"); + public final static Property IsRead = new Property(7, String.class, "isRead", false, "IS_READ"); } @@ -46,11 +48,13 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"NOTICE_TITLE\" TEXT," + // 1: noticeTitle - "\"NOTICE_DATE\" TEXT," + // 2: noticeDate - "\"NOTICE_CONTENT\" TEXT," + // 3: noticeContent - "\"SENDER_NAME\" TEXT," + // 4: senderName - "\"IS_READ\" TEXT);"); // 5: isRead + "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"CASE_ID\" TEXT," + // 2: caseId + "\"TITLE\" TEXT," + // 3: title + "\"CONTENT\" TEXT," + // 4: content + "\"PUSH_DATE\" TEXT," + // 5: pushDate + "\"TYPE\" TEXT," + // 6: type + "\"IS_READ\" TEXT);"); // 7: isRead } /** Drops the underlying database table. */ @@ -68,29 +72,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -103,29 +117,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -138,11 +162,13 @@ public NoticeBean readEntity(Cursor cursor, int offset) { NoticeBean entity = new NoticeBean( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // noticeTitle - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // noticeDate - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // noticeContent - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // senderName - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // isRead + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userPhone + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // caseId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pushDate + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // type + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // isRead ); return entity; } @@ -150,11 +176,13 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setNoticeTitle(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setNoticeDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setNoticeContent(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setSenderName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setIsRead(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setCaseId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setPushDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setType(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setIsRead(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); } @Override diff --git a/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java new file mode 100644 index 0000000..7c3fb29 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface IPushRegisterModel { + Subscription sendRetrofitRequest(String clientid); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java new file mode 100644 index 0000000..c7ae0c1 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class PushRegisterModelImpl implements IPushRegisterModel { + + private OnRegisterListener updateListener; + + public PushRegisterModelImpl(OnRegisterListener listener) { + this.updateListener = listener; + } + + public interface OnRegisterListener { + void onSuccess(ActionResultBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest(String clientid) { + Observable observable = RetrofitServiceManager.getRegisterResult(clientid); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + updateListener.onFailure(e); + } + } + + @Override + public void onNext(ActionResultBean resultBean) { + if (resultBean != null) { + updateListener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java new file mode 100644 index 0000000..bb88db3 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface IPushRegisterPresenter { + void onReadyRetrofitRequest(String clientid); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java new file mode 100644 index 0000000..3a97b8f --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java @@ -0,0 +1,38 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.PushRegisterModelImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; + +public class PushRegisterPresenterImpl extends BasePresenter implements IPushRegisterPresenter, + PushRegisterModelImpl.OnRegisterListener { + + private IPushRegisterView view; + private PushRegisterModelImpl model; + + public PushRegisterPresenterImpl(IPushRegisterView pushRegisterView) { + this.view = pushRegisterView; + model = new PushRegisterModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest(String clientid) { + addSubscription(model.sendRetrofitRequest(clientid)); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(ActionResultBean resultBean) { + view.obtainRegisterResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java new file mode 100644 index 0000000..353903a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.ActionResultBean; + +public interface IPushRegisterView { + void obtainRegisterResult(ActionResultBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java index 0a4e1d2..865787a 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,15 +1,18 @@ package com.casic.dcms.service; import android.content.Context; +import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.utils.AuthenticationHelper; +import com.casic.dcms.bean.PushResultBean; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.casic.dcms.utils.TimeOrDateUtil; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.igexin.sdk.GTIntentService; import com.igexin.sdk.message.GTCmdMessage; import com.igexin.sdk.message.GTNotificationMessage; @@ -38,7 +41,12 @@ @Override public void onReceiveClientId(Context context, String clientid) { Log.d(TAG, "onReceiveClientId -> " + "clientid = " + clientid); - AuthenticationHelper.savePushClientID(clientid); + //通知MainActivity注册个推服务 + if (!TextUtils.isEmpty(clientid)) { + BroadcastManager.getInstance(context).sendBroadcast(Constant.REGISTER_PUSH, clientid); + } else { + Log.d(TAG, "onReceiveClientId: ===>clientid = " + clientid); + } } // cid 离线上线通知 @@ -50,28 +58,50 @@ // 各种事件处理回执 @Override public void onReceiveCommandResult(Context context, GTCmdMessage cmdMessage) { - +// Log.d(TAG, "onReceiveCommandResult -> " + cmdMessage); } // 通知到达,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageArrived(Context context, GTNotificationMessage msg) { + public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + /** + * appid = DR9oeLL9va6aG3DYXy2w39 + * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 + * messageid = b74187603fe34058a223949ead9f8dcf + * pkg = com.casic.dcms + * cid = cd1aec399b5504516102e399ecf7cda4 + * content = {"content":"您有一个工单超时,请快速处理","data":{"id":"1392655327805825025"},"id":1393131068164472834,"title":"工单超时提醒","type":"alarm"} + * title = 工单提醒 + * */ + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + NoticeBean noticeBean = new NoticeBean(); - noticeBean.setNoticeTitle(msg.getTitle()); - noticeBean.setSenderName("管理员"); - noticeBean.setNoticeDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); - noticeBean.setNoticeContent(msg.getContent()); + noticeBean.setUserPhone(StringHelper.getUserPhone()); + noticeBean.setCaseId(resultBean.getId()); + noticeBean.setTitle(resultBean.getTitle()); + noticeBean.setContent(resultBean.getContent()); + noticeBean.setType(resultBean.getType()); + noticeBean.setPushDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); noticeBean.setIsRead("1"); //存本地一份 BaseApplication.getDaoSession().insert(noticeBean); //发送消息更新界面 - BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, new Gson().toJson(noticeBean)); + BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, gson.toJson(noticeBean)); } // 通知点击,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageClicked(Context context, GTNotificationMessage msg) { + public void onNotificationMessageClicked(Context context, GTNotificationMessage message) { + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + String caseId = resultBean.getId(); + Log.d(TAG, "onNotificationMessageClicked: " + caseId); } } diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index 219ae3b..db7d9ca 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -302,7 +302,8 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件地点所在网格为[" + gridId + "]" + ",\r\n选择部件为:" + objId + "(" + objName + ")" + .setMessage("该事件地点所在网格为[" + gridId + "]" + + "\r\n选择部件为:" + objId + "(" + objName + ")" + "\r\n部件大类为:" + largeType + "\r\n小类为:" + smallType + "\r\n确认提交?") @@ -332,7 +333,9 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件所在地点网格为[" + gridId + "]确认选择?") + .setMessage("该事件所在地点网格为[" + gridId + "]" + + "\r\n所在社区为:" + communityName + + "\r\n确认选择?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { diff --git a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java index 22d7bca..dfc9961 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java @@ -159,7 +159,7 @@ for (PointDataBean dataBean : casePointList) { double parseLng = Double.parseDouble(dataBean.getLng()); double parseLat = Double.parseDouble(dataBean.getLat()); - if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 || + if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 && Math.abs(parseLat - point.getY()) <= Constant.DELTA_LAT_10) { Message message = weakReferenceHandler.obtainMessage(); message.what = 2021051401; diff --git a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java index 8d37132..e3703e3 100644 --- a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java @@ -50,7 +50,7 @@ @Override public int initLayoutView() { - return R.layout.activity_analysis; + return R.layout.activity_case_analysis; } @Override diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 4ab4cb8..cba9a54 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -18,11 +18,13 @@ import com.casic.dcms.adapter.MainPageAdapter; import com.casic.dcms.base.DoubleClickExitActivity; import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.presenter.PushRegisterPresenterImpl; import com.casic.dcms.mvp.presenter.UploadPositionPresenterImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; import com.casic.dcms.mvp.view.IUploadPositionView; -import com.casic.dcms.ui.fragment.DashBoardPageFragment; import com.casic.dcms.ui.fragment.HomePageFragment; import com.casic.dcms.ui.fragment.MinePageFragment; +import com.casic.dcms.ui.fragment.NoticePageFragment; import com.casic.dcms.ui.fragment.PhonePageFragment; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; @@ -40,7 +42,7 @@ import butterknife.BindView; -public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView { +public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView, IPushRegisterView { private static final String TAG = "MainActivity"; @BindView(R.id.pageTitleView) @@ -53,6 +55,7 @@ private List pageList; private BroadcastManager broadcastManager; private UploadPositionPresenterImpl uploadPositionPresenter; + private PushRegisterPresenterImpl registerPresenter; @Override public int initLayoutView() { @@ -71,27 +74,35 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); uploadPositionPresenter = new UploadPositionPresenterImpl(this); + registerPresenter = new PushRegisterPresenterImpl(this); pageList = new ArrayList<>(); pageList.add(new HomePageFragment()); pageList.add(new PhonePageFragment()); - pageList.add(new DashBoardPageFragment()); + pageList.add(new NoticePageFragment()); pageList.add(new MinePageFragment()); broadcastManager = BroadcastManager.getInstance(this); - broadcastManager.addAction(Constant.LOGIN_OUT_ACTION, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.LOGIN_OUT_ACTION.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - if (data.equals("请求成功")) { - finish(); + broadcastManager.addAction(new String[]{Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH}, + new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + switch (action) { + case Constant.LOGIN_OUT_ACTION: + String loginOut = intent.getStringExtra("data"); + assert loginOut != null; + if (loginOut.equals("请求成功")) { + finish(); + } + break; + case Constant.REGISTER_PUSH: + String clientid = intent.getStringExtra("data"); + registerPresenter.onReadyRetrofitRequest(clientid); + break; + } } } - } - } - }); + }); String imei = OtherUtils.obtainSimCardSerialNumber(this); if (TextUtils.isEmpty(imei)) { return; @@ -99,9 +110,13 @@ LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { - uploadPositionPresenter.onReadyRetrofitRequest(imei, - String.valueOf(location.getLatitude()), - String.valueOf(location.getLongitude())); + if (location != null) { + uploadPositionPresenter.onReadyRetrofitRequest(imei, + String.valueOf(location.getLatitude()), + String.valueOf(location.getLongitude())); + } else { + Log.d(TAG, "onLocationGet: location is null"); + } } }); } @@ -163,14 +178,22 @@ @Override protected void onDestroy() { super.onDestroy(); - broadcastManager.destroy(Constant.LOGIN_OUT_ACTION); + broadcastManager.destroy(Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH); if (uploadPositionPresenter != null) { uploadPositionPresenter.disposeRetrofitRequest(); } + if (registerPresenter != null) { + registerPresenter.disposeRetrofitRequest(); + } } @Override public void obtainUploadPositionResult(ActionResultBean resultBean) { - Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); +// Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); + } + + @Override + public void obtainRegisterResult(ActionResultBean resultBean) { + Log.d(TAG, "obtainRegisterResult: " + new Gson().toJson(resultBean)); } } diff --git a/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java b/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java deleted file mode 100644 index 6c9e96a..0000000 --- a/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.casic.dcms.ui; - -import android.annotation.SuppressLint; -import android.view.View; -import android.widget.TextView; - -import androidx.core.content.ContextCompat; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.NoticeBean; -import com.google.gson.Gson; -import com.qmuiteam.qmui.widget.QMUITopBarLayout; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 10:35 - * @email : 290677893@qq.com - **/ -public class NoticeActivity extends BaseActivity { - - @BindView(R.id.noticeTopLayout) - QMUITopBarLayout noticeTopLayout; - @BindView(R.id.noticeTitleView) - TextView noticeTitleView; - @BindView(R.id.noticeSenderView) - TextView noticeSenderView; - @BindView(R.id.noticeDateView) - TextView noticeDateView; - @BindView(R.id.noticeContentView) - TextView noticeContentView; - - @Override - public int initLayoutView() { - return R.layout.activity_notice; - } - - @Override - protected void setupTopBarLayout() { - noticeTopLayout.setTitle("消息内容").setTextColor(ContextCompat.getColor(this, R.color.white)); - noticeTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - noticeTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - finish(); - } - }); - } - - @SuppressLint("SetTextI18n") - @Override - public void initData() { - String noticeBeanJson = getIntent().getStringExtra("noticeBeanJson"); - NoticeBean noticeBean = new Gson().fromJson(noticeBeanJson, NoticeBean.class); - - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeSenderView.setText("发送者:" + noticeBean.getSenderName()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); - } - - @Override - public void initEvent() { - - } -} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java deleted file mode 100644 index 62d4aa2..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.Context; -import android.widget.LinearLayout; - -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -public class DashBoardPageFragment extends BaseFragment { - - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; - - private Context context; - - @Override - protected int initLayoutView() { - return R.layout.fragment_dashboard; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - List fragmentList = new ArrayList<>(); - fragmentList.add(new UnreadFragment()); - fragmentList.add(new ReadFragment()); - SubViewPagerAdapter adapter = new SubViewPagerAdapter(getChildFragmentManager(), pageTitles, fragmentList); - dashboardViewPager.setAdapter(adapter); - //绑定TabLayout - topTabLayout.setupWithViewPager(dashboardViewPager); - LinearLayout linearLayout = (LinearLayout) topTabLayout.getChildAt(0); - linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); - linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); - } - - @Override - protected void initEvent() { - - } -} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java new file mode 100644 index 0000000..192b702 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -0,0 +1,58 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.LinearLayout; + +import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; + +import java.util.ArrayList; +import java.util.List; + +import butterknife.BindView; + +public class NoticePageFragment extends BaseFragment { + + private static final String[] pageTitles = {"未读消息", "已读消息"}; + @BindView(R.id.topTabLayout) + TabLayout topTabLayout; + @BindView(R.id.dashboardViewPager) + NoScrollViewPager dashboardViewPager; + + private Context context; + + @Override + protected int initLayoutView() { + return R.layout.fragment_dashboard; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + protected void initData() { + List fragmentList = new ArrayList<>(); + fragmentList.add(new UnreadFragment()); + fragmentList.add(new ReadFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getChildFragmentManager(), pageTitles, fragmentList); + dashboardViewPager.setAdapter(adapter); + //绑定TabLayout + topTabLayout.setupWithViewPager(dashboardViewPager); + LinearLayout linearLayout = (LinearLayout) topTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); + } + + @Override + protected void initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java index 001fb6c..a0afe0f 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java @@ -3,6 +3,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.text.TextUtils; import android.view.ViewGroup; import androidx.annotation.NonNull; @@ -16,9 +17,11 @@ import com.casic.dcms.base.BaseFragment; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.greendao.DaoSession; -import com.casic.dcms.ui.NoticeActivity; +import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.google.gson.Gson; import com.qmuiteam.qmui.recyclerView.QMUIRVItemSwipeAction; import com.qmuiteam.qmui.recyclerView.QMUISwipeAction; @@ -61,8 +64,12 @@ gson = new Gson(); daoSession = BaseApplication.getDaoSession(); swipeViewAdapter = new SwipeViewAdapter(context); - //加载历史数据 - noticeBeans = daoSession.loadAll(NoticeBean.class); + //根据userPhone加载历史数据 + String userPhone = StringHelper.getUserPhone(); + if (TextUtils.isEmpty(userPhone)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserPhone.eq(userPhone)).list(); swipeViewAdapter.setData(noticeBeans); broadcastManager = BroadcastManager.getInstance(context); @@ -118,13 +125,14 @@ swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { @Override public void onClick(int position) { - //查看之后,未读消息变为已读消息 - NoticeBean noticeBean = noticeBeans.get(position); + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = new NoticeBean(); noticeBean.setIsRead("0"); daoSession.update(noticeBean); - Intent intent = new Intent(context, NoticeActivity.class); - intent.putExtra("noticeBeanJson", new Gson().toJson(noticeBean)); + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); startActivity(intent); } }); diff --git a/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java b/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java index 4278463..47a076a 100644 --- a/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java @@ -17,12 +17,4 @@ public static String getToken() { return (String) SaveKeyValues.getValue("token", ""); } - - public static void savePushClientID(String clientid) { - SaveKeyValues.putValue("pushClientID", clientid); - } - - public static String getPushClientID() { - return (String) SaveKeyValues.getValue("pushClientID", ""); - } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java new file mode 100644 index 0000000..017a37e --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -0,0 +1,74 @@ +package com.casic.dcms.bean; + +public class PushResultBean { + + /** + * content : 您有一个工单超时,请快速处理 + * data : {"id":"1393113365064245250"} + * id : 1393117524798783490 + * title : 工单超时提醒 + * type : alarm + */ + + private String content; + private DataBean data; + private String id; + private String title; + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class DataBean { + /** + * id : 1393113365064245250 + */ + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java index 259eb85..c118368 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,11 +25,13 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property NoticeTitle = new Property(1, String.class, "noticeTitle", false, "NOTICE_TITLE"); - public final static Property NoticeDate = new Property(2, String.class, "noticeDate", false, "NOTICE_DATE"); - public final static Property NoticeContent = new Property(3, String.class, "noticeContent", false, "NOTICE_CONTENT"); - public final static Property SenderName = new Property(4, String.class, "senderName", false, "SENDER_NAME"); - public final static Property IsRead = new Property(5, String.class, "isRead", false, "IS_READ"); + public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property CaseId = new Property(2, String.class, "caseId", false, "CASE_ID"); + public final static Property Title = new Property(3, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(4, String.class, "content", false, "CONTENT"); + public final static Property PushDate = new Property(5, String.class, "pushDate", false, "PUSH_DATE"); + public final static Property Type = new Property(6, String.class, "type", false, "TYPE"); + public final static Property IsRead = new Property(7, String.class, "isRead", false, "IS_READ"); } @@ -46,11 +48,13 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"NOTICE_TITLE\" TEXT," + // 1: noticeTitle - "\"NOTICE_DATE\" TEXT," + // 2: noticeDate - "\"NOTICE_CONTENT\" TEXT," + // 3: noticeContent - "\"SENDER_NAME\" TEXT," + // 4: senderName - "\"IS_READ\" TEXT);"); // 5: isRead + "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"CASE_ID\" TEXT," + // 2: caseId + "\"TITLE\" TEXT," + // 3: title + "\"CONTENT\" TEXT," + // 4: content + "\"PUSH_DATE\" TEXT," + // 5: pushDate + "\"TYPE\" TEXT," + // 6: type + "\"IS_READ\" TEXT);"); // 7: isRead } /** Drops the underlying database table. */ @@ -68,29 +72,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -103,29 +117,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -138,11 +162,13 @@ public NoticeBean readEntity(Cursor cursor, int offset) { NoticeBean entity = new NoticeBean( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // noticeTitle - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // noticeDate - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // noticeContent - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // senderName - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // isRead + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userPhone + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // caseId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pushDate + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // type + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // isRead ); return entity; } @@ -150,11 +176,13 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setNoticeTitle(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setNoticeDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setNoticeContent(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setSenderName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setIsRead(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setCaseId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setPushDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setType(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setIsRead(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); } @Override diff --git a/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java new file mode 100644 index 0000000..7c3fb29 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface IPushRegisterModel { + Subscription sendRetrofitRequest(String clientid); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java new file mode 100644 index 0000000..c7ae0c1 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class PushRegisterModelImpl implements IPushRegisterModel { + + private OnRegisterListener updateListener; + + public PushRegisterModelImpl(OnRegisterListener listener) { + this.updateListener = listener; + } + + public interface OnRegisterListener { + void onSuccess(ActionResultBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest(String clientid) { + Observable observable = RetrofitServiceManager.getRegisterResult(clientid); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + updateListener.onFailure(e); + } + } + + @Override + public void onNext(ActionResultBean resultBean) { + if (resultBean != null) { + updateListener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java new file mode 100644 index 0000000..bb88db3 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface IPushRegisterPresenter { + void onReadyRetrofitRequest(String clientid); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java new file mode 100644 index 0000000..3a97b8f --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java @@ -0,0 +1,38 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.PushRegisterModelImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; + +public class PushRegisterPresenterImpl extends BasePresenter implements IPushRegisterPresenter, + PushRegisterModelImpl.OnRegisterListener { + + private IPushRegisterView view; + private PushRegisterModelImpl model; + + public PushRegisterPresenterImpl(IPushRegisterView pushRegisterView) { + this.view = pushRegisterView; + model = new PushRegisterModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest(String clientid) { + addSubscription(model.sendRetrofitRequest(clientid)); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(ActionResultBean resultBean) { + view.obtainRegisterResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java new file mode 100644 index 0000000..353903a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.ActionResultBean; + +public interface IPushRegisterView { + void obtainRegisterResult(ActionResultBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java index 0a4e1d2..865787a 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,15 +1,18 @@ package com.casic.dcms.service; import android.content.Context; +import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.utils.AuthenticationHelper; +import com.casic.dcms.bean.PushResultBean; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.casic.dcms.utils.TimeOrDateUtil; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.igexin.sdk.GTIntentService; import com.igexin.sdk.message.GTCmdMessage; import com.igexin.sdk.message.GTNotificationMessage; @@ -38,7 +41,12 @@ @Override public void onReceiveClientId(Context context, String clientid) { Log.d(TAG, "onReceiveClientId -> " + "clientid = " + clientid); - AuthenticationHelper.savePushClientID(clientid); + //通知MainActivity注册个推服务 + if (!TextUtils.isEmpty(clientid)) { + BroadcastManager.getInstance(context).sendBroadcast(Constant.REGISTER_PUSH, clientid); + } else { + Log.d(TAG, "onReceiveClientId: ===>clientid = " + clientid); + } } // cid 离线上线通知 @@ -50,28 +58,50 @@ // 各种事件处理回执 @Override public void onReceiveCommandResult(Context context, GTCmdMessage cmdMessage) { - +// Log.d(TAG, "onReceiveCommandResult -> " + cmdMessage); } // 通知到达,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageArrived(Context context, GTNotificationMessage msg) { + public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + /** + * appid = DR9oeLL9va6aG3DYXy2w39 + * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 + * messageid = b74187603fe34058a223949ead9f8dcf + * pkg = com.casic.dcms + * cid = cd1aec399b5504516102e399ecf7cda4 + * content = {"content":"您有一个工单超时,请快速处理","data":{"id":"1392655327805825025"},"id":1393131068164472834,"title":"工单超时提醒","type":"alarm"} + * title = 工单提醒 + * */ + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + NoticeBean noticeBean = new NoticeBean(); - noticeBean.setNoticeTitle(msg.getTitle()); - noticeBean.setSenderName("管理员"); - noticeBean.setNoticeDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); - noticeBean.setNoticeContent(msg.getContent()); + noticeBean.setUserPhone(StringHelper.getUserPhone()); + noticeBean.setCaseId(resultBean.getId()); + noticeBean.setTitle(resultBean.getTitle()); + noticeBean.setContent(resultBean.getContent()); + noticeBean.setType(resultBean.getType()); + noticeBean.setPushDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); noticeBean.setIsRead("1"); //存本地一份 BaseApplication.getDaoSession().insert(noticeBean); //发送消息更新界面 - BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, new Gson().toJson(noticeBean)); + BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, gson.toJson(noticeBean)); } // 通知点击,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageClicked(Context context, GTNotificationMessage msg) { + public void onNotificationMessageClicked(Context context, GTNotificationMessage message) { + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + String caseId = resultBean.getId(); + Log.d(TAG, "onNotificationMessageClicked: " + caseId); } } diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index 219ae3b..db7d9ca 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -302,7 +302,8 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件地点所在网格为[" + gridId + "]" + ",\r\n选择部件为:" + objId + "(" + objName + ")" + .setMessage("该事件地点所在网格为[" + gridId + "]" + + "\r\n选择部件为:" + objId + "(" + objName + ")" + "\r\n部件大类为:" + largeType + "\r\n小类为:" + smallType + "\r\n确认提交?") @@ -332,7 +333,9 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件所在地点网格为[" + gridId + "]确认选择?") + .setMessage("该事件所在地点网格为[" + gridId + "]" + + "\r\n所在社区为:" + communityName + + "\r\n确认选择?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { diff --git a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java index 22d7bca..dfc9961 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java @@ -159,7 +159,7 @@ for (PointDataBean dataBean : casePointList) { double parseLng = Double.parseDouble(dataBean.getLng()); double parseLat = Double.parseDouble(dataBean.getLat()); - if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 || + if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 && Math.abs(parseLat - point.getY()) <= Constant.DELTA_LAT_10) { Message message = weakReferenceHandler.obtainMessage(); message.what = 2021051401; diff --git a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java index 8d37132..e3703e3 100644 --- a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java @@ -50,7 +50,7 @@ @Override public int initLayoutView() { - return R.layout.activity_analysis; + return R.layout.activity_case_analysis; } @Override diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 4ab4cb8..cba9a54 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -18,11 +18,13 @@ import com.casic.dcms.adapter.MainPageAdapter; import com.casic.dcms.base.DoubleClickExitActivity; import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.presenter.PushRegisterPresenterImpl; import com.casic.dcms.mvp.presenter.UploadPositionPresenterImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; import com.casic.dcms.mvp.view.IUploadPositionView; -import com.casic.dcms.ui.fragment.DashBoardPageFragment; import com.casic.dcms.ui.fragment.HomePageFragment; import com.casic.dcms.ui.fragment.MinePageFragment; +import com.casic.dcms.ui.fragment.NoticePageFragment; import com.casic.dcms.ui.fragment.PhonePageFragment; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; @@ -40,7 +42,7 @@ import butterknife.BindView; -public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView { +public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView, IPushRegisterView { private static final String TAG = "MainActivity"; @BindView(R.id.pageTitleView) @@ -53,6 +55,7 @@ private List pageList; private BroadcastManager broadcastManager; private UploadPositionPresenterImpl uploadPositionPresenter; + private PushRegisterPresenterImpl registerPresenter; @Override public int initLayoutView() { @@ -71,27 +74,35 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); uploadPositionPresenter = new UploadPositionPresenterImpl(this); + registerPresenter = new PushRegisterPresenterImpl(this); pageList = new ArrayList<>(); pageList.add(new HomePageFragment()); pageList.add(new PhonePageFragment()); - pageList.add(new DashBoardPageFragment()); + pageList.add(new NoticePageFragment()); pageList.add(new MinePageFragment()); broadcastManager = BroadcastManager.getInstance(this); - broadcastManager.addAction(Constant.LOGIN_OUT_ACTION, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.LOGIN_OUT_ACTION.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - if (data.equals("请求成功")) { - finish(); + broadcastManager.addAction(new String[]{Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH}, + new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + switch (action) { + case Constant.LOGIN_OUT_ACTION: + String loginOut = intent.getStringExtra("data"); + assert loginOut != null; + if (loginOut.equals("请求成功")) { + finish(); + } + break; + case Constant.REGISTER_PUSH: + String clientid = intent.getStringExtra("data"); + registerPresenter.onReadyRetrofitRequest(clientid); + break; + } } } - } - } - }); + }); String imei = OtherUtils.obtainSimCardSerialNumber(this); if (TextUtils.isEmpty(imei)) { return; @@ -99,9 +110,13 @@ LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { - uploadPositionPresenter.onReadyRetrofitRequest(imei, - String.valueOf(location.getLatitude()), - String.valueOf(location.getLongitude())); + if (location != null) { + uploadPositionPresenter.onReadyRetrofitRequest(imei, + String.valueOf(location.getLatitude()), + String.valueOf(location.getLongitude())); + } else { + Log.d(TAG, "onLocationGet: location is null"); + } } }); } @@ -163,14 +178,22 @@ @Override protected void onDestroy() { super.onDestroy(); - broadcastManager.destroy(Constant.LOGIN_OUT_ACTION); + broadcastManager.destroy(Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH); if (uploadPositionPresenter != null) { uploadPositionPresenter.disposeRetrofitRequest(); } + if (registerPresenter != null) { + registerPresenter.disposeRetrofitRequest(); + } } @Override public void obtainUploadPositionResult(ActionResultBean resultBean) { - Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); +// Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); + } + + @Override + public void obtainRegisterResult(ActionResultBean resultBean) { + Log.d(TAG, "obtainRegisterResult: " + new Gson().toJson(resultBean)); } } diff --git a/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java b/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java deleted file mode 100644 index 6c9e96a..0000000 --- a/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.casic.dcms.ui; - -import android.annotation.SuppressLint; -import android.view.View; -import android.widget.TextView; - -import androidx.core.content.ContextCompat; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.NoticeBean; -import com.google.gson.Gson; -import com.qmuiteam.qmui.widget.QMUITopBarLayout; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 10:35 - * @email : 290677893@qq.com - **/ -public class NoticeActivity extends BaseActivity { - - @BindView(R.id.noticeTopLayout) - QMUITopBarLayout noticeTopLayout; - @BindView(R.id.noticeTitleView) - TextView noticeTitleView; - @BindView(R.id.noticeSenderView) - TextView noticeSenderView; - @BindView(R.id.noticeDateView) - TextView noticeDateView; - @BindView(R.id.noticeContentView) - TextView noticeContentView; - - @Override - public int initLayoutView() { - return R.layout.activity_notice; - } - - @Override - protected void setupTopBarLayout() { - noticeTopLayout.setTitle("消息内容").setTextColor(ContextCompat.getColor(this, R.color.white)); - noticeTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - noticeTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - finish(); - } - }); - } - - @SuppressLint("SetTextI18n") - @Override - public void initData() { - String noticeBeanJson = getIntent().getStringExtra("noticeBeanJson"); - NoticeBean noticeBean = new Gson().fromJson(noticeBeanJson, NoticeBean.class); - - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeSenderView.setText("发送者:" + noticeBean.getSenderName()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); - } - - @Override - public void initEvent() { - - } -} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java deleted file mode 100644 index 62d4aa2..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.Context; -import android.widget.LinearLayout; - -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -public class DashBoardPageFragment extends BaseFragment { - - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; - - private Context context; - - @Override - protected int initLayoutView() { - return R.layout.fragment_dashboard; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - List fragmentList = new ArrayList<>(); - fragmentList.add(new UnreadFragment()); - fragmentList.add(new ReadFragment()); - SubViewPagerAdapter adapter = new SubViewPagerAdapter(getChildFragmentManager(), pageTitles, fragmentList); - dashboardViewPager.setAdapter(adapter); - //绑定TabLayout - topTabLayout.setupWithViewPager(dashboardViewPager); - LinearLayout linearLayout = (LinearLayout) topTabLayout.getChildAt(0); - linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); - linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); - } - - @Override - protected void initEvent() { - - } -} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java new file mode 100644 index 0000000..192b702 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -0,0 +1,58 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.LinearLayout; + +import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; + +import java.util.ArrayList; +import java.util.List; + +import butterknife.BindView; + +public class NoticePageFragment extends BaseFragment { + + private static final String[] pageTitles = {"未读消息", "已读消息"}; + @BindView(R.id.topTabLayout) + TabLayout topTabLayout; + @BindView(R.id.dashboardViewPager) + NoScrollViewPager dashboardViewPager; + + private Context context; + + @Override + protected int initLayoutView() { + return R.layout.fragment_dashboard; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + protected void initData() { + List fragmentList = new ArrayList<>(); + fragmentList.add(new UnreadFragment()); + fragmentList.add(new ReadFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getChildFragmentManager(), pageTitles, fragmentList); + dashboardViewPager.setAdapter(adapter); + //绑定TabLayout + topTabLayout.setupWithViewPager(dashboardViewPager); + LinearLayout linearLayout = (LinearLayout) topTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); + } + + @Override + protected void initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java index 001fb6c..a0afe0f 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java @@ -3,6 +3,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.text.TextUtils; import android.view.ViewGroup; import androidx.annotation.NonNull; @@ -16,9 +17,11 @@ import com.casic.dcms.base.BaseFragment; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.greendao.DaoSession; -import com.casic.dcms.ui.NoticeActivity; +import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.google.gson.Gson; import com.qmuiteam.qmui.recyclerView.QMUIRVItemSwipeAction; import com.qmuiteam.qmui.recyclerView.QMUISwipeAction; @@ -61,8 +64,12 @@ gson = new Gson(); daoSession = BaseApplication.getDaoSession(); swipeViewAdapter = new SwipeViewAdapter(context); - //加载历史数据 - noticeBeans = daoSession.loadAll(NoticeBean.class); + //根据userPhone加载历史数据 + String userPhone = StringHelper.getUserPhone(); + if (TextUtils.isEmpty(userPhone)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserPhone.eq(userPhone)).list(); swipeViewAdapter.setData(noticeBeans); broadcastManager = BroadcastManager.getInstance(context); @@ -118,13 +125,14 @@ swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { @Override public void onClick(int position) { - //查看之后,未读消息变为已读消息 - NoticeBean noticeBean = noticeBeans.get(position); + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = new NoticeBean(); noticeBean.setIsRead("0"); daoSession.update(noticeBean); - Intent intent = new Intent(context, NoticeActivity.class); - intent.putExtra("noticeBeanJson", new Gson().toJson(noticeBean)); + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); startActivity(intent); } }); diff --git a/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java b/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java index 4278463..47a076a 100644 --- a/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java @@ -17,12 +17,4 @@ public static String getToken() { return (String) SaveKeyValues.getValue("token", ""); } - - public static void savePushClientID(String clientid) { - SaveKeyValues.putValue("pushClientID", clientid); - } - - public static String getPushClientID() { - return (String) SaveKeyValues.getValue("pushClientID", ""); - } } diff --git a/app/src/main/java/com/casic/dcms/utils/Constant.java b/app/src/main/java/com/casic/dcms/utils/Constant.java index 1ae7b82..f67e68b 100644 --- a/app/src/main/java/com/casic/dcms/utils/Constant.java +++ b/app/src/main/java/com/casic/dcms/utils/Constant.java @@ -49,8 +49,9 @@ public static final double DELTA_LAT_10 = 0.00002256;// 10米范围纬度值偏移量(大约) public static final String IP_KEY = "BASE_IP"; - public static final String LOGIN_OUT_ACTION = "loginOut"; - public static final String NOTICE_MSG = "receivePush"; + public static final String LOGIN_OUT_ACTION = "login_out"; + public static final String NOTICE_MSG = "receive_ush"; + public static final String REGISTER_PUSH = "register_push"; public static final String BASE_MAP_SERVICE_URL = "http://111.198.10.15:13002/arcgis/rest/services/crdt/MapServer";//崇仁城管地图底图 public static final String COMPONENT_SERVICE_URL = "http://111.198.10.15:13002/arcgis/rest/services/crbj/FeatureServer";//崇仁部件图层 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java new file mode 100644 index 0000000..017a37e --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -0,0 +1,74 @@ +package com.casic.dcms.bean; + +public class PushResultBean { + + /** + * content : 您有一个工单超时,请快速处理 + * data : {"id":"1393113365064245250"} + * id : 1393117524798783490 + * title : 工单超时提醒 + * type : alarm + */ + + private String content; + private DataBean data; + private String id; + private String title; + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class DataBean { + /** + * id : 1393113365064245250 + */ + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java index 259eb85..c118368 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,11 +25,13 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property NoticeTitle = new Property(1, String.class, "noticeTitle", false, "NOTICE_TITLE"); - public final static Property NoticeDate = new Property(2, String.class, "noticeDate", false, "NOTICE_DATE"); - public final static Property NoticeContent = new Property(3, String.class, "noticeContent", false, "NOTICE_CONTENT"); - public final static Property SenderName = new Property(4, String.class, "senderName", false, "SENDER_NAME"); - public final static Property IsRead = new Property(5, String.class, "isRead", false, "IS_READ"); + public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property CaseId = new Property(2, String.class, "caseId", false, "CASE_ID"); + public final static Property Title = new Property(3, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(4, String.class, "content", false, "CONTENT"); + public final static Property PushDate = new Property(5, String.class, "pushDate", false, "PUSH_DATE"); + public final static Property Type = new Property(6, String.class, "type", false, "TYPE"); + public final static Property IsRead = new Property(7, String.class, "isRead", false, "IS_READ"); } @@ -46,11 +48,13 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"NOTICE_TITLE\" TEXT," + // 1: noticeTitle - "\"NOTICE_DATE\" TEXT," + // 2: noticeDate - "\"NOTICE_CONTENT\" TEXT," + // 3: noticeContent - "\"SENDER_NAME\" TEXT," + // 4: senderName - "\"IS_READ\" TEXT);"); // 5: isRead + "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"CASE_ID\" TEXT," + // 2: caseId + "\"TITLE\" TEXT," + // 3: title + "\"CONTENT\" TEXT," + // 4: content + "\"PUSH_DATE\" TEXT," + // 5: pushDate + "\"TYPE\" TEXT," + // 6: type + "\"IS_READ\" TEXT);"); // 7: isRead } /** Drops the underlying database table. */ @@ -68,29 +72,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -103,29 +117,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -138,11 +162,13 @@ public NoticeBean readEntity(Cursor cursor, int offset) { NoticeBean entity = new NoticeBean( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // noticeTitle - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // noticeDate - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // noticeContent - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // senderName - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // isRead + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userPhone + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // caseId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pushDate + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // type + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // isRead ); return entity; } @@ -150,11 +176,13 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setNoticeTitle(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setNoticeDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setNoticeContent(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setSenderName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setIsRead(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setCaseId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setPushDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setType(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setIsRead(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); } @Override diff --git a/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java new file mode 100644 index 0000000..7c3fb29 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface IPushRegisterModel { + Subscription sendRetrofitRequest(String clientid); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java new file mode 100644 index 0000000..c7ae0c1 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class PushRegisterModelImpl implements IPushRegisterModel { + + private OnRegisterListener updateListener; + + public PushRegisterModelImpl(OnRegisterListener listener) { + this.updateListener = listener; + } + + public interface OnRegisterListener { + void onSuccess(ActionResultBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest(String clientid) { + Observable observable = RetrofitServiceManager.getRegisterResult(clientid); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + updateListener.onFailure(e); + } + } + + @Override + public void onNext(ActionResultBean resultBean) { + if (resultBean != null) { + updateListener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java new file mode 100644 index 0000000..bb88db3 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface IPushRegisterPresenter { + void onReadyRetrofitRequest(String clientid); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java new file mode 100644 index 0000000..3a97b8f --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java @@ -0,0 +1,38 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.PushRegisterModelImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; + +public class PushRegisterPresenterImpl extends BasePresenter implements IPushRegisterPresenter, + PushRegisterModelImpl.OnRegisterListener { + + private IPushRegisterView view; + private PushRegisterModelImpl model; + + public PushRegisterPresenterImpl(IPushRegisterView pushRegisterView) { + this.view = pushRegisterView; + model = new PushRegisterModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest(String clientid) { + addSubscription(model.sendRetrofitRequest(clientid)); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(ActionResultBean resultBean) { + view.obtainRegisterResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java new file mode 100644 index 0000000..353903a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.ActionResultBean; + +public interface IPushRegisterView { + void obtainRegisterResult(ActionResultBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java index 0a4e1d2..865787a 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,15 +1,18 @@ package com.casic.dcms.service; import android.content.Context; +import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.utils.AuthenticationHelper; +import com.casic.dcms.bean.PushResultBean; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.casic.dcms.utils.TimeOrDateUtil; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.igexin.sdk.GTIntentService; import com.igexin.sdk.message.GTCmdMessage; import com.igexin.sdk.message.GTNotificationMessage; @@ -38,7 +41,12 @@ @Override public void onReceiveClientId(Context context, String clientid) { Log.d(TAG, "onReceiveClientId -> " + "clientid = " + clientid); - AuthenticationHelper.savePushClientID(clientid); + //通知MainActivity注册个推服务 + if (!TextUtils.isEmpty(clientid)) { + BroadcastManager.getInstance(context).sendBroadcast(Constant.REGISTER_PUSH, clientid); + } else { + Log.d(TAG, "onReceiveClientId: ===>clientid = " + clientid); + } } // cid 离线上线通知 @@ -50,28 +58,50 @@ // 各种事件处理回执 @Override public void onReceiveCommandResult(Context context, GTCmdMessage cmdMessage) { - +// Log.d(TAG, "onReceiveCommandResult -> " + cmdMessage); } // 通知到达,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageArrived(Context context, GTNotificationMessage msg) { + public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + /** + * appid = DR9oeLL9va6aG3DYXy2w39 + * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 + * messageid = b74187603fe34058a223949ead9f8dcf + * pkg = com.casic.dcms + * cid = cd1aec399b5504516102e399ecf7cda4 + * content = {"content":"您有一个工单超时,请快速处理","data":{"id":"1392655327805825025"},"id":1393131068164472834,"title":"工单超时提醒","type":"alarm"} + * title = 工单提醒 + * */ + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + NoticeBean noticeBean = new NoticeBean(); - noticeBean.setNoticeTitle(msg.getTitle()); - noticeBean.setSenderName("管理员"); - noticeBean.setNoticeDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); - noticeBean.setNoticeContent(msg.getContent()); + noticeBean.setUserPhone(StringHelper.getUserPhone()); + noticeBean.setCaseId(resultBean.getId()); + noticeBean.setTitle(resultBean.getTitle()); + noticeBean.setContent(resultBean.getContent()); + noticeBean.setType(resultBean.getType()); + noticeBean.setPushDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); noticeBean.setIsRead("1"); //存本地一份 BaseApplication.getDaoSession().insert(noticeBean); //发送消息更新界面 - BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, new Gson().toJson(noticeBean)); + BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, gson.toJson(noticeBean)); } // 通知点击,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageClicked(Context context, GTNotificationMessage msg) { + public void onNotificationMessageClicked(Context context, GTNotificationMessage message) { + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + String caseId = resultBean.getId(); + Log.d(TAG, "onNotificationMessageClicked: " + caseId); } } diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index 219ae3b..db7d9ca 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -302,7 +302,8 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件地点所在网格为[" + gridId + "]" + ",\r\n选择部件为:" + objId + "(" + objName + ")" + .setMessage("该事件地点所在网格为[" + gridId + "]" + + "\r\n选择部件为:" + objId + "(" + objName + ")" + "\r\n部件大类为:" + largeType + "\r\n小类为:" + smallType + "\r\n确认提交?") @@ -332,7 +333,9 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件所在地点网格为[" + gridId + "]确认选择?") + .setMessage("该事件所在地点网格为[" + gridId + "]" + + "\r\n所在社区为:" + communityName + + "\r\n确认选择?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { diff --git a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java index 22d7bca..dfc9961 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java @@ -159,7 +159,7 @@ for (PointDataBean dataBean : casePointList) { double parseLng = Double.parseDouble(dataBean.getLng()); double parseLat = Double.parseDouble(dataBean.getLat()); - if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 || + if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 && Math.abs(parseLat - point.getY()) <= Constant.DELTA_LAT_10) { Message message = weakReferenceHandler.obtainMessage(); message.what = 2021051401; diff --git a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java index 8d37132..e3703e3 100644 --- a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java @@ -50,7 +50,7 @@ @Override public int initLayoutView() { - return R.layout.activity_analysis; + return R.layout.activity_case_analysis; } @Override diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 4ab4cb8..cba9a54 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -18,11 +18,13 @@ import com.casic.dcms.adapter.MainPageAdapter; import com.casic.dcms.base.DoubleClickExitActivity; import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.presenter.PushRegisterPresenterImpl; import com.casic.dcms.mvp.presenter.UploadPositionPresenterImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; import com.casic.dcms.mvp.view.IUploadPositionView; -import com.casic.dcms.ui.fragment.DashBoardPageFragment; import com.casic.dcms.ui.fragment.HomePageFragment; import com.casic.dcms.ui.fragment.MinePageFragment; +import com.casic.dcms.ui.fragment.NoticePageFragment; import com.casic.dcms.ui.fragment.PhonePageFragment; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; @@ -40,7 +42,7 @@ import butterknife.BindView; -public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView { +public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView, IPushRegisterView { private static final String TAG = "MainActivity"; @BindView(R.id.pageTitleView) @@ -53,6 +55,7 @@ private List pageList; private BroadcastManager broadcastManager; private UploadPositionPresenterImpl uploadPositionPresenter; + private PushRegisterPresenterImpl registerPresenter; @Override public int initLayoutView() { @@ -71,27 +74,35 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); uploadPositionPresenter = new UploadPositionPresenterImpl(this); + registerPresenter = new PushRegisterPresenterImpl(this); pageList = new ArrayList<>(); pageList.add(new HomePageFragment()); pageList.add(new PhonePageFragment()); - pageList.add(new DashBoardPageFragment()); + pageList.add(new NoticePageFragment()); pageList.add(new MinePageFragment()); broadcastManager = BroadcastManager.getInstance(this); - broadcastManager.addAction(Constant.LOGIN_OUT_ACTION, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.LOGIN_OUT_ACTION.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - if (data.equals("请求成功")) { - finish(); + broadcastManager.addAction(new String[]{Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH}, + new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + switch (action) { + case Constant.LOGIN_OUT_ACTION: + String loginOut = intent.getStringExtra("data"); + assert loginOut != null; + if (loginOut.equals("请求成功")) { + finish(); + } + break; + case Constant.REGISTER_PUSH: + String clientid = intent.getStringExtra("data"); + registerPresenter.onReadyRetrofitRequest(clientid); + break; + } } } - } - } - }); + }); String imei = OtherUtils.obtainSimCardSerialNumber(this); if (TextUtils.isEmpty(imei)) { return; @@ -99,9 +110,13 @@ LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { - uploadPositionPresenter.onReadyRetrofitRequest(imei, - String.valueOf(location.getLatitude()), - String.valueOf(location.getLongitude())); + if (location != null) { + uploadPositionPresenter.onReadyRetrofitRequest(imei, + String.valueOf(location.getLatitude()), + String.valueOf(location.getLongitude())); + } else { + Log.d(TAG, "onLocationGet: location is null"); + } } }); } @@ -163,14 +178,22 @@ @Override protected void onDestroy() { super.onDestroy(); - broadcastManager.destroy(Constant.LOGIN_OUT_ACTION); + broadcastManager.destroy(Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH); if (uploadPositionPresenter != null) { uploadPositionPresenter.disposeRetrofitRequest(); } + if (registerPresenter != null) { + registerPresenter.disposeRetrofitRequest(); + } } @Override public void obtainUploadPositionResult(ActionResultBean resultBean) { - Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); +// Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); + } + + @Override + public void obtainRegisterResult(ActionResultBean resultBean) { + Log.d(TAG, "obtainRegisterResult: " + new Gson().toJson(resultBean)); } } diff --git a/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java b/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java deleted file mode 100644 index 6c9e96a..0000000 --- a/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.casic.dcms.ui; - -import android.annotation.SuppressLint; -import android.view.View; -import android.widget.TextView; - -import androidx.core.content.ContextCompat; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.NoticeBean; -import com.google.gson.Gson; -import com.qmuiteam.qmui.widget.QMUITopBarLayout; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 10:35 - * @email : 290677893@qq.com - **/ -public class NoticeActivity extends BaseActivity { - - @BindView(R.id.noticeTopLayout) - QMUITopBarLayout noticeTopLayout; - @BindView(R.id.noticeTitleView) - TextView noticeTitleView; - @BindView(R.id.noticeSenderView) - TextView noticeSenderView; - @BindView(R.id.noticeDateView) - TextView noticeDateView; - @BindView(R.id.noticeContentView) - TextView noticeContentView; - - @Override - public int initLayoutView() { - return R.layout.activity_notice; - } - - @Override - protected void setupTopBarLayout() { - noticeTopLayout.setTitle("消息内容").setTextColor(ContextCompat.getColor(this, R.color.white)); - noticeTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - noticeTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - finish(); - } - }); - } - - @SuppressLint("SetTextI18n") - @Override - public void initData() { - String noticeBeanJson = getIntent().getStringExtra("noticeBeanJson"); - NoticeBean noticeBean = new Gson().fromJson(noticeBeanJson, NoticeBean.class); - - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeSenderView.setText("发送者:" + noticeBean.getSenderName()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); - } - - @Override - public void initEvent() { - - } -} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java deleted file mode 100644 index 62d4aa2..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.Context; -import android.widget.LinearLayout; - -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -public class DashBoardPageFragment extends BaseFragment { - - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; - - private Context context; - - @Override - protected int initLayoutView() { - return R.layout.fragment_dashboard; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - List fragmentList = new ArrayList<>(); - fragmentList.add(new UnreadFragment()); - fragmentList.add(new ReadFragment()); - SubViewPagerAdapter adapter = new SubViewPagerAdapter(getChildFragmentManager(), pageTitles, fragmentList); - dashboardViewPager.setAdapter(adapter); - //绑定TabLayout - topTabLayout.setupWithViewPager(dashboardViewPager); - LinearLayout linearLayout = (LinearLayout) topTabLayout.getChildAt(0); - linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); - linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); - } - - @Override - protected void initEvent() { - - } -} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java new file mode 100644 index 0000000..192b702 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -0,0 +1,58 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.LinearLayout; + +import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; + +import java.util.ArrayList; +import java.util.List; + +import butterknife.BindView; + +public class NoticePageFragment extends BaseFragment { + + private static final String[] pageTitles = {"未读消息", "已读消息"}; + @BindView(R.id.topTabLayout) + TabLayout topTabLayout; + @BindView(R.id.dashboardViewPager) + NoScrollViewPager dashboardViewPager; + + private Context context; + + @Override + protected int initLayoutView() { + return R.layout.fragment_dashboard; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + protected void initData() { + List fragmentList = new ArrayList<>(); + fragmentList.add(new UnreadFragment()); + fragmentList.add(new ReadFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getChildFragmentManager(), pageTitles, fragmentList); + dashboardViewPager.setAdapter(adapter); + //绑定TabLayout + topTabLayout.setupWithViewPager(dashboardViewPager); + LinearLayout linearLayout = (LinearLayout) topTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); + } + + @Override + protected void initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java index 001fb6c..a0afe0f 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java @@ -3,6 +3,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.text.TextUtils; import android.view.ViewGroup; import androidx.annotation.NonNull; @@ -16,9 +17,11 @@ import com.casic.dcms.base.BaseFragment; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.greendao.DaoSession; -import com.casic.dcms.ui.NoticeActivity; +import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.google.gson.Gson; import com.qmuiteam.qmui.recyclerView.QMUIRVItemSwipeAction; import com.qmuiteam.qmui.recyclerView.QMUISwipeAction; @@ -61,8 +64,12 @@ gson = new Gson(); daoSession = BaseApplication.getDaoSession(); swipeViewAdapter = new SwipeViewAdapter(context); - //加载历史数据 - noticeBeans = daoSession.loadAll(NoticeBean.class); + //根据userPhone加载历史数据 + String userPhone = StringHelper.getUserPhone(); + if (TextUtils.isEmpty(userPhone)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserPhone.eq(userPhone)).list(); swipeViewAdapter.setData(noticeBeans); broadcastManager = BroadcastManager.getInstance(context); @@ -118,13 +125,14 @@ swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { @Override public void onClick(int position) { - //查看之后,未读消息变为已读消息 - NoticeBean noticeBean = noticeBeans.get(position); + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = new NoticeBean(); noticeBean.setIsRead("0"); daoSession.update(noticeBean); - Intent intent = new Intent(context, NoticeActivity.class); - intent.putExtra("noticeBeanJson", new Gson().toJson(noticeBean)); + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); startActivity(intent); } }); diff --git a/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java b/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java index 4278463..47a076a 100644 --- a/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java @@ -17,12 +17,4 @@ public static String getToken() { return (String) SaveKeyValues.getValue("token", ""); } - - public static void savePushClientID(String clientid) { - SaveKeyValues.putValue("pushClientID", clientid); - } - - public static String getPushClientID() { - return (String) SaveKeyValues.getValue("pushClientID", ""); - } } diff --git a/app/src/main/java/com/casic/dcms/utils/Constant.java b/app/src/main/java/com/casic/dcms/utils/Constant.java index 1ae7b82..f67e68b 100644 --- a/app/src/main/java/com/casic/dcms/utils/Constant.java +++ b/app/src/main/java/com/casic/dcms/utils/Constant.java @@ -49,8 +49,9 @@ public static final double DELTA_LAT_10 = 0.00002256;// 10米范围纬度值偏移量(大约) public static final String IP_KEY = "BASE_IP"; - public static final String LOGIN_OUT_ACTION = "loginOut"; - public static final String NOTICE_MSG = "receivePush"; + public static final String LOGIN_OUT_ACTION = "login_out"; + public static final String NOTICE_MSG = "receive_ush"; + public static final String REGISTER_PUSH = "register_push"; public static final String BASE_MAP_SERVICE_URL = "http://111.198.10.15:13002/arcgis/rest/services/crdt/MapServer";//崇仁城管地图底图 public static final String COMPONENT_SERVICE_URL = "http://111.198.10.15:13002/arcgis/rest/services/crbj/FeatureServer";//崇仁部件图层 diff --git a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java index 8a532f3..f2bc047 100644 --- a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java +++ b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java @@ -427,4 +427,14 @@ @GET("/user/permission") Observable obtainHomePage(@Header("token") String token, @Query("resourceType") String resourceType); + + /** + * 个推推送cid注册 + *

+ * http://111.198.10.15:11409/userPush/register + */ + @FormUrlEncoded + @POST("/userPush/register") + Observable registerPush(@Header("token") String token, + @Field("clientId") String clientId); } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java new file mode 100644 index 0000000..017a37e --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -0,0 +1,74 @@ +package com.casic.dcms.bean; + +public class PushResultBean { + + /** + * content : 您有一个工单超时,请快速处理 + * data : {"id":"1393113365064245250"} + * id : 1393117524798783490 + * title : 工单超时提醒 + * type : alarm + */ + + private String content; + private DataBean data; + private String id; + private String title; + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class DataBean { + /** + * id : 1393113365064245250 + */ + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java index 259eb85..c118368 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,11 +25,13 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property NoticeTitle = new Property(1, String.class, "noticeTitle", false, "NOTICE_TITLE"); - public final static Property NoticeDate = new Property(2, String.class, "noticeDate", false, "NOTICE_DATE"); - public final static Property NoticeContent = new Property(3, String.class, "noticeContent", false, "NOTICE_CONTENT"); - public final static Property SenderName = new Property(4, String.class, "senderName", false, "SENDER_NAME"); - public final static Property IsRead = new Property(5, String.class, "isRead", false, "IS_READ"); + public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property CaseId = new Property(2, String.class, "caseId", false, "CASE_ID"); + public final static Property Title = new Property(3, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(4, String.class, "content", false, "CONTENT"); + public final static Property PushDate = new Property(5, String.class, "pushDate", false, "PUSH_DATE"); + public final static Property Type = new Property(6, String.class, "type", false, "TYPE"); + public final static Property IsRead = new Property(7, String.class, "isRead", false, "IS_READ"); } @@ -46,11 +48,13 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"NOTICE_TITLE\" TEXT," + // 1: noticeTitle - "\"NOTICE_DATE\" TEXT," + // 2: noticeDate - "\"NOTICE_CONTENT\" TEXT," + // 3: noticeContent - "\"SENDER_NAME\" TEXT," + // 4: senderName - "\"IS_READ\" TEXT);"); // 5: isRead + "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"CASE_ID\" TEXT," + // 2: caseId + "\"TITLE\" TEXT," + // 3: title + "\"CONTENT\" TEXT," + // 4: content + "\"PUSH_DATE\" TEXT," + // 5: pushDate + "\"TYPE\" TEXT," + // 6: type + "\"IS_READ\" TEXT);"); // 7: isRead } /** Drops the underlying database table. */ @@ -68,29 +72,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -103,29 +117,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -138,11 +162,13 @@ public NoticeBean readEntity(Cursor cursor, int offset) { NoticeBean entity = new NoticeBean( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // noticeTitle - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // noticeDate - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // noticeContent - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // senderName - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // isRead + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userPhone + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // caseId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pushDate + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // type + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // isRead ); return entity; } @@ -150,11 +176,13 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setNoticeTitle(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setNoticeDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setNoticeContent(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setSenderName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setIsRead(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setCaseId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setPushDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setType(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setIsRead(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); } @Override diff --git a/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java new file mode 100644 index 0000000..7c3fb29 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface IPushRegisterModel { + Subscription sendRetrofitRequest(String clientid); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java new file mode 100644 index 0000000..c7ae0c1 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class PushRegisterModelImpl implements IPushRegisterModel { + + private OnRegisterListener updateListener; + + public PushRegisterModelImpl(OnRegisterListener listener) { + this.updateListener = listener; + } + + public interface OnRegisterListener { + void onSuccess(ActionResultBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest(String clientid) { + Observable observable = RetrofitServiceManager.getRegisterResult(clientid); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + updateListener.onFailure(e); + } + } + + @Override + public void onNext(ActionResultBean resultBean) { + if (resultBean != null) { + updateListener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java new file mode 100644 index 0000000..bb88db3 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface IPushRegisterPresenter { + void onReadyRetrofitRequest(String clientid); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java new file mode 100644 index 0000000..3a97b8f --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java @@ -0,0 +1,38 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.PushRegisterModelImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; + +public class PushRegisterPresenterImpl extends BasePresenter implements IPushRegisterPresenter, + PushRegisterModelImpl.OnRegisterListener { + + private IPushRegisterView view; + private PushRegisterModelImpl model; + + public PushRegisterPresenterImpl(IPushRegisterView pushRegisterView) { + this.view = pushRegisterView; + model = new PushRegisterModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest(String clientid) { + addSubscription(model.sendRetrofitRequest(clientid)); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(ActionResultBean resultBean) { + view.obtainRegisterResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java new file mode 100644 index 0000000..353903a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.ActionResultBean; + +public interface IPushRegisterView { + void obtainRegisterResult(ActionResultBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java index 0a4e1d2..865787a 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,15 +1,18 @@ package com.casic.dcms.service; import android.content.Context; +import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.utils.AuthenticationHelper; +import com.casic.dcms.bean.PushResultBean; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.casic.dcms.utils.TimeOrDateUtil; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.igexin.sdk.GTIntentService; import com.igexin.sdk.message.GTCmdMessage; import com.igexin.sdk.message.GTNotificationMessage; @@ -38,7 +41,12 @@ @Override public void onReceiveClientId(Context context, String clientid) { Log.d(TAG, "onReceiveClientId -> " + "clientid = " + clientid); - AuthenticationHelper.savePushClientID(clientid); + //通知MainActivity注册个推服务 + if (!TextUtils.isEmpty(clientid)) { + BroadcastManager.getInstance(context).sendBroadcast(Constant.REGISTER_PUSH, clientid); + } else { + Log.d(TAG, "onReceiveClientId: ===>clientid = " + clientid); + } } // cid 离线上线通知 @@ -50,28 +58,50 @@ // 各种事件处理回执 @Override public void onReceiveCommandResult(Context context, GTCmdMessage cmdMessage) { - +// Log.d(TAG, "onReceiveCommandResult -> " + cmdMessage); } // 通知到达,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageArrived(Context context, GTNotificationMessage msg) { + public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + /** + * appid = DR9oeLL9va6aG3DYXy2w39 + * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 + * messageid = b74187603fe34058a223949ead9f8dcf + * pkg = com.casic.dcms + * cid = cd1aec399b5504516102e399ecf7cda4 + * content = {"content":"您有一个工单超时,请快速处理","data":{"id":"1392655327805825025"},"id":1393131068164472834,"title":"工单超时提醒","type":"alarm"} + * title = 工单提醒 + * */ + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + NoticeBean noticeBean = new NoticeBean(); - noticeBean.setNoticeTitle(msg.getTitle()); - noticeBean.setSenderName("管理员"); - noticeBean.setNoticeDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); - noticeBean.setNoticeContent(msg.getContent()); + noticeBean.setUserPhone(StringHelper.getUserPhone()); + noticeBean.setCaseId(resultBean.getId()); + noticeBean.setTitle(resultBean.getTitle()); + noticeBean.setContent(resultBean.getContent()); + noticeBean.setType(resultBean.getType()); + noticeBean.setPushDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); noticeBean.setIsRead("1"); //存本地一份 BaseApplication.getDaoSession().insert(noticeBean); //发送消息更新界面 - BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, new Gson().toJson(noticeBean)); + BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, gson.toJson(noticeBean)); } // 通知点击,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageClicked(Context context, GTNotificationMessage msg) { + public void onNotificationMessageClicked(Context context, GTNotificationMessage message) { + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + String caseId = resultBean.getId(); + Log.d(TAG, "onNotificationMessageClicked: " + caseId); } } diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index 219ae3b..db7d9ca 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -302,7 +302,8 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件地点所在网格为[" + gridId + "]" + ",\r\n选择部件为:" + objId + "(" + objName + ")" + .setMessage("该事件地点所在网格为[" + gridId + "]" + + "\r\n选择部件为:" + objId + "(" + objName + ")" + "\r\n部件大类为:" + largeType + "\r\n小类为:" + smallType + "\r\n确认提交?") @@ -332,7 +333,9 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件所在地点网格为[" + gridId + "]确认选择?") + .setMessage("该事件所在地点网格为[" + gridId + "]" + + "\r\n所在社区为:" + communityName + + "\r\n确认选择?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { diff --git a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java index 22d7bca..dfc9961 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java @@ -159,7 +159,7 @@ for (PointDataBean dataBean : casePointList) { double parseLng = Double.parseDouble(dataBean.getLng()); double parseLat = Double.parseDouble(dataBean.getLat()); - if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 || + if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 && Math.abs(parseLat - point.getY()) <= Constant.DELTA_LAT_10) { Message message = weakReferenceHandler.obtainMessage(); message.what = 2021051401; diff --git a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java index 8d37132..e3703e3 100644 --- a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java @@ -50,7 +50,7 @@ @Override public int initLayoutView() { - return R.layout.activity_analysis; + return R.layout.activity_case_analysis; } @Override diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 4ab4cb8..cba9a54 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -18,11 +18,13 @@ import com.casic.dcms.adapter.MainPageAdapter; import com.casic.dcms.base.DoubleClickExitActivity; import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.presenter.PushRegisterPresenterImpl; import com.casic.dcms.mvp.presenter.UploadPositionPresenterImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; import com.casic.dcms.mvp.view.IUploadPositionView; -import com.casic.dcms.ui.fragment.DashBoardPageFragment; import com.casic.dcms.ui.fragment.HomePageFragment; import com.casic.dcms.ui.fragment.MinePageFragment; +import com.casic.dcms.ui.fragment.NoticePageFragment; import com.casic.dcms.ui.fragment.PhonePageFragment; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; @@ -40,7 +42,7 @@ import butterknife.BindView; -public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView { +public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView, IPushRegisterView { private static final String TAG = "MainActivity"; @BindView(R.id.pageTitleView) @@ -53,6 +55,7 @@ private List pageList; private BroadcastManager broadcastManager; private UploadPositionPresenterImpl uploadPositionPresenter; + private PushRegisterPresenterImpl registerPresenter; @Override public int initLayoutView() { @@ -71,27 +74,35 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); uploadPositionPresenter = new UploadPositionPresenterImpl(this); + registerPresenter = new PushRegisterPresenterImpl(this); pageList = new ArrayList<>(); pageList.add(new HomePageFragment()); pageList.add(new PhonePageFragment()); - pageList.add(new DashBoardPageFragment()); + pageList.add(new NoticePageFragment()); pageList.add(new MinePageFragment()); broadcastManager = BroadcastManager.getInstance(this); - broadcastManager.addAction(Constant.LOGIN_OUT_ACTION, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.LOGIN_OUT_ACTION.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - if (data.equals("请求成功")) { - finish(); + broadcastManager.addAction(new String[]{Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH}, + new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + switch (action) { + case Constant.LOGIN_OUT_ACTION: + String loginOut = intent.getStringExtra("data"); + assert loginOut != null; + if (loginOut.equals("请求成功")) { + finish(); + } + break; + case Constant.REGISTER_PUSH: + String clientid = intent.getStringExtra("data"); + registerPresenter.onReadyRetrofitRequest(clientid); + break; + } } } - } - } - }); + }); String imei = OtherUtils.obtainSimCardSerialNumber(this); if (TextUtils.isEmpty(imei)) { return; @@ -99,9 +110,13 @@ LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { - uploadPositionPresenter.onReadyRetrofitRequest(imei, - String.valueOf(location.getLatitude()), - String.valueOf(location.getLongitude())); + if (location != null) { + uploadPositionPresenter.onReadyRetrofitRequest(imei, + String.valueOf(location.getLatitude()), + String.valueOf(location.getLongitude())); + } else { + Log.d(TAG, "onLocationGet: location is null"); + } } }); } @@ -163,14 +178,22 @@ @Override protected void onDestroy() { super.onDestroy(); - broadcastManager.destroy(Constant.LOGIN_OUT_ACTION); + broadcastManager.destroy(Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH); if (uploadPositionPresenter != null) { uploadPositionPresenter.disposeRetrofitRequest(); } + if (registerPresenter != null) { + registerPresenter.disposeRetrofitRequest(); + } } @Override public void obtainUploadPositionResult(ActionResultBean resultBean) { - Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); +// Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); + } + + @Override + public void obtainRegisterResult(ActionResultBean resultBean) { + Log.d(TAG, "obtainRegisterResult: " + new Gson().toJson(resultBean)); } } diff --git a/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java b/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java deleted file mode 100644 index 6c9e96a..0000000 --- a/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.casic.dcms.ui; - -import android.annotation.SuppressLint; -import android.view.View; -import android.widget.TextView; - -import androidx.core.content.ContextCompat; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.NoticeBean; -import com.google.gson.Gson; -import com.qmuiteam.qmui.widget.QMUITopBarLayout; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 10:35 - * @email : 290677893@qq.com - **/ -public class NoticeActivity extends BaseActivity { - - @BindView(R.id.noticeTopLayout) - QMUITopBarLayout noticeTopLayout; - @BindView(R.id.noticeTitleView) - TextView noticeTitleView; - @BindView(R.id.noticeSenderView) - TextView noticeSenderView; - @BindView(R.id.noticeDateView) - TextView noticeDateView; - @BindView(R.id.noticeContentView) - TextView noticeContentView; - - @Override - public int initLayoutView() { - return R.layout.activity_notice; - } - - @Override - protected void setupTopBarLayout() { - noticeTopLayout.setTitle("消息内容").setTextColor(ContextCompat.getColor(this, R.color.white)); - noticeTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - noticeTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - finish(); - } - }); - } - - @SuppressLint("SetTextI18n") - @Override - public void initData() { - String noticeBeanJson = getIntent().getStringExtra("noticeBeanJson"); - NoticeBean noticeBean = new Gson().fromJson(noticeBeanJson, NoticeBean.class); - - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeSenderView.setText("发送者:" + noticeBean.getSenderName()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); - } - - @Override - public void initEvent() { - - } -} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java deleted file mode 100644 index 62d4aa2..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.Context; -import android.widget.LinearLayout; - -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -public class DashBoardPageFragment extends BaseFragment { - - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; - - private Context context; - - @Override - protected int initLayoutView() { - return R.layout.fragment_dashboard; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - List fragmentList = new ArrayList<>(); - fragmentList.add(new UnreadFragment()); - fragmentList.add(new ReadFragment()); - SubViewPagerAdapter adapter = new SubViewPagerAdapter(getChildFragmentManager(), pageTitles, fragmentList); - dashboardViewPager.setAdapter(adapter); - //绑定TabLayout - topTabLayout.setupWithViewPager(dashboardViewPager); - LinearLayout linearLayout = (LinearLayout) topTabLayout.getChildAt(0); - linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); - linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); - } - - @Override - protected void initEvent() { - - } -} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java new file mode 100644 index 0000000..192b702 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -0,0 +1,58 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.LinearLayout; + +import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; + +import java.util.ArrayList; +import java.util.List; + +import butterknife.BindView; + +public class NoticePageFragment extends BaseFragment { + + private static final String[] pageTitles = {"未读消息", "已读消息"}; + @BindView(R.id.topTabLayout) + TabLayout topTabLayout; + @BindView(R.id.dashboardViewPager) + NoScrollViewPager dashboardViewPager; + + private Context context; + + @Override + protected int initLayoutView() { + return R.layout.fragment_dashboard; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + protected void initData() { + List fragmentList = new ArrayList<>(); + fragmentList.add(new UnreadFragment()); + fragmentList.add(new ReadFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getChildFragmentManager(), pageTitles, fragmentList); + dashboardViewPager.setAdapter(adapter); + //绑定TabLayout + topTabLayout.setupWithViewPager(dashboardViewPager); + LinearLayout linearLayout = (LinearLayout) topTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); + } + + @Override + protected void initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java index 001fb6c..a0afe0f 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java @@ -3,6 +3,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.text.TextUtils; import android.view.ViewGroup; import androidx.annotation.NonNull; @@ -16,9 +17,11 @@ import com.casic.dcms.base.BaseFragment; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.greendao.DaoSession; -import com.casic.dcms.ui.NoticeActivity; +import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.google.gson.Gson; import com.qmuiteam.qmui.recyclerView.QMUIRVItemSwipeAction; import com.qmuiteam.qmui.recyclerView.QMUISwipeAction; @@ -61,8 +64,12 @@ gson = new Gson(); daoSession = BaseApplication.getDaoSession(); swipeViewAdapter = new SwipeViewAdapter(context); - //加载历史数据 - noticeBeans = daoSession.loadAll(NoticeBean.class); + //根据userPhone加载历史数据 + String userPhone = StringHelper.getUserPhone(); + if (TextUtils.isEmpty(userPhone)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserPhone.eq(userPhone)).list(); swipeViewAdapter.setData(noticeBeans); broadcastManager = BroadcastManager.getInstance(context); @@ -118,13 +125,14 @@ swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { @Override public void onClick(int position) { - //查看之后,未读消息变为已读消息 - NoticeBean noticeBean = noticeBeans.get(position); + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = new NoticeBean(); noticeBean.setIsRead("0"); daoSession.update(noticeBean); - Intent intent = new Intent(context, NoticeActivity.class); - intent.putExtra("noticeBeanJson", new Gson().toJson(noticeBean)); + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); startActivity(intent); } }); diff --git a/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java b/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java index 4278463..47a076a 100644 --- a/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java @@ -17,12 +17,4 @@ public static String getToken() { return (String) SaveKeyValues.getValue("token", ""); } - - public static void savePushClientID(String clientid) { - SaveKeyValues.putValue("pushClientID", clientid); - } - - public static String getPushClientID() { - return (String) SaveKeyValues.getValue("pushClientID", ""); - } } diff --git a/app/src/main/java/com/casic/dcms/utils/Constant.java b/app/src/main/java/com/casic/dcms/utils/Constant.java index 1ae7b82..f67e68b 100644 --- a/app/src/main/java/com/casic/dcms/utils/Constant.java +++ b/app/src/main/java/com/casic/dcms/utils/Constant.java @@ -49,8 +49,9 @@ public static final double DELTA_LAT_10 = 0.00002256;// 10米范围纬度值偏移量(大约) public static final String IP_KEY = "BASE_IP"; - public static final String LOGIN_OUT_ACTION = "loginOut"; - public static final String NOTICE_MSG = "receivePush"; + public static final String LOGIN_OUT_ACTION = "login_out"; + public static final String NOTICE_MSG = "receive_ush"; + public static final String REGISTER_PUSH = "register_push"; public static final String BASE_MAP_SERVICE_URL = "http://111.198.10.15:13002/arcgis/rest/services/crdt/MapServer";//崇仁城管地图底图 public static final String COMPONENT_SERVICE_URL = "http://111.198.10.15:13002/arcgis/rest/services/crbj/FeatureServer";//崇仁部件图层 diff --git a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java index 8a532f3..f2bc047 100644 --- a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java +++ b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java @@ -427,4 +427,14 @@ @GET("/user/permission") Observable obtainHomePage(@Header("token") String token, @Query("resourceType") String resourceType); + + /** + * 个推推送cid注册 + *

+ * http://111.198.10.15:11409/userPush/register + */ + @FormUrlEncoded + @POST("/userPush/register") + Observable registerPush(@Header("token") String token, + @Field("clientId") String clientId); } diff --git a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java index 5d29f09..23adf26 100644 --- a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java +++ b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java @@ -476,4 +476,13 @@ RetrofitService service = retrofit.create(RetrofitService.class); return service.obtainHomePage(AuthenticationHelper.getToken(), resourceType); } + + /** + * 个推推送cid注册 + */ + public static Observable getRegisterResult(String clientId) { + Retrofit retrofit = createRetrofit(); + RetrofitService service = retrofit.create(RetrofitService.class); + return service.registerPush(AuthenticationHelper.getToken(), clientId); + } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java new file mode 100644 index 0000000..017a37e --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -0,0 +1,74 @@ +package com.casic.dcms.bean; + +public class PushResultBean { + + /** + * content : 您有一个工单超时,请快速处理 + * data : {"id":"1393113365064245250"} + * id : 1393117524798783490 + * title : 工单超时提醒 + * type : alarm + */ + + private String content; + private DataBean data; + private String id; + private String title; + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class DataBean { + /** + * id : 1393113365064245250 + */ + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java index 259eb85..c118368 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,11 +25,13 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property NoticeTitle = new Property(1, String.class, "noticeTitle", false, "NOTICE_TITLE"); - public final static Property NoticeDate = new Property(2, String.class, "noticeDate", false, "NOTICE_DATE"); - public final static Property NoticeContent = new Property(3, String.class, "noticeContent", false, "NOTICE_CONTENT"); - public final static Property SenderName = new Property(4, String.class, "senderName", false, "SENDER_NAME"); - public final static Property IsRead = new Property(5, String.class, "isRead", false, "IS_READ"); + public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property CaseId = new Property(2, String.class, "caseId", false, "CASE_ID"); + public final static Property Title = new Property(3, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(4, String.class, "content", false, "CONTENT"); + public final static Property PushDate = new Property(5, String.class, "pushDate", false, "PUSH_DATE"); + public final static Property Type = new Property(6, String.class, "type", false, "TYPE"); + public final static Property IsRead = new Property(7, String.class, "isRead", false, "IS_READ"); } @@ -46,11 +48,13 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"NOTICE_TITLE\" TEXT," + // 1: noticeTitle - "\"NOTICE_DATE\" TEXT," + // 2: noticeDate - "\"NOTICE_CONTENT\" TEXT," + // 3: noticeContent - "\"SENDER_NAME\" TEXT," + // 4: senderName - "\"IS_READ\" TEXT);"); // 5: isRead + "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"CASE_ID\" TEXT," + // 2: caseId + "\"TITLE\" TEXT," + // 3: title + "\"CONTENT\" TEXT," + // 4: content + "\"PUSH_DATE\" TEXT," + // 5: pushDate + "\"TYPE\" TEXT," + // 6: type + "\"IS_READ\" TEXT);"); // 7: isRead } /** Drops the underlying database table. */ @@ -68,29 +72,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -103,29 +117,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -138,11 +162,13 @@ public NoticeBean readEntity(Cursor cursor, int offset) { NoticeBean entity = new NoticeBean( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // noticeTitle - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // noticeDate - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // noticeContent - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // senderName - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // isRead + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userPhone + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // caseId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pushDate + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // type + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // isRead ); return entity; } @@ -150,11 +176,13 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setNoticeTitle(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setNoticeDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setNoticeContent(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setSenderName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setIsRead(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setCaseId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setPushDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setType(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setIsRead(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); } @Override diff --git a/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java new file mode 100644 index 0000000..7c3fb29 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface IPushRegisterModel { + Subscription sendRetrofitRequest(String clientid); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java new file mode 100644 index 0000000..c7ae0c1 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class PushRegisterModelImpl implements IPushRegisterModel { + + private OnRegisterListener updateListener; + + public PushRegisterModelImpl(OnRegisterListener listener) { + this.updateListener = listener; + } + + public interface OnRegisterListener { + void onSuccess(ActionResultBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest(String clientid) { + Observable observable = RetrofitServiceManager.getRegisterResult(clientid); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + updateListener.onFailure(e); + } + } + + @Override + public void onNext(ActionResultBean resultBean) { + if (resultBean != null) { + updateListener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java new file mode 100644 index 0000000..bb88db3 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface IPushRegisterPresenter { + void onReadyRetrofitRequest(String clientid); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java new file mode 100644 index 0000000..3a97b8f --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java @@ -0,0 +1,38 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.PushRegisterModelImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; + +public class PushRegisterPresenterImpl extends BasePresenter implements IPushRegisterPresenter, + PushRegisterModelImpl.OnRegisterListener { + + private IPushRegisterView view; + private PushRegisterModelImpl model; + + public PushRegisterPresenterImpl(IPushRegisterView pushRegisterView) { + this.view = pushRegisterView; + model = new PushRegisterModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest(String clientid) { + addSubscription(model.sendRetrofitRequest(clientid)); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(ActionResultBean resultBean) { + view.obtainRegisterResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java new file mode 100644 index 0000000..353903a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.ActionResultBean; + +public interface IPushRegisterView { + void obtainRegisterResult(ActionResultBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java index 0a4e1d2..865787a 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,15 +1,18 @@ package com.casic.dcms.service; import android.content.Context; +import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.utils.AuthenticationHelper; +import com.casic.dcms.bean.PushResultBean; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.casic.dcms.utils.TimeOrDateUtil; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.igexin.sdk.GTIntentService; import com.igexin.sdk.message.GTCmdMessage; import com.igexin.sdk.message.GTNotificationMessage; @@ -38,7 +41,12 @@ @Override public void onReceiveClientId(Context context, String clientid) { Log.d(TAG, "onReceiveClientId -> " + "clientid = " + clientid); - AuthenticationHelper.savePushClientID(clientid); + //通知MainActivity注册个推服务 + if (!TextUtils.isEmpty(clientid)) { + BroadcastManager.getInstance(context).sendBroadcast(Constant.REGISTER_PUSH, clientid); + } else { + Log.d(TAG, "onReceiveClientId: ===>clientid = " + clientid); + } } // cid 离线上线通知 @@ -50,28 +58,50 @@ // 各种事件处理回执 @Override public void onReceiveCommandResult(Context context, GTCmdMessage cmdMessage) { - +// Log.d(TAG, "onReceiveCommandResult -> " + cmdMessage); } // 通知到达,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageArrived(Context context, GTNotificationMessage msg) { + public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + /** + * appid = DR9oeLL9va6aG3DYXy2w39 + * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 + * messageid = b74187603fe34058a223949ead9f8dcf + * pkg = com.casic.dcms + * cid = cd1aec399b5504516102e399ecf7cda4 + * content = {"content":"您有一个工单超时,请快速处理","data":{"id":"1392655327805825025"},"id":1393131068164472834,"title":"工单超时提醒","type":"alarm"} + * title = 工单提醒 + * */ + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + NoticeBean noticeBean = new NoticeBean(); - noticeBean.setNoticeTitle(msg.getTitle()); - noticeBean.setSenderName("管理员"); - noticeBean.setNoticeDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); - noticeBean.setNoticeContent(msg.getContent()); + noticeBean.setUserPhone(StringHelper.getUserPhone()); + noticeBean.setCaseId(resultBean.getId()); + noticeBean.setTitle(resultBean.getTitle()); + noticeBean.setContent(resultBean.getContent()); + noticeBean.setType(resultBean.getType()); + noticeBean.setPushDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); noticeBean.setIsRead("1"); //存本地一份 BaseApplication.getDaoSession().insert(noticeBean); //发送消息更新界面 - BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, new Gson().toJson(noticeBean)); + BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, gson.toJson(noticeBean)); } // 通知点击,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageClicked(Context context, GTNotificationMessage msg) { + public void onNotificationMessageClicked(Context context, GTNotificationMessage message) { + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + String caseId = resultBean.getId(); + Log.d(TAG, "onNotificationMessageClicked: " + caseId); } } diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index 219ae3b..db7d9ca 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -302,7 +302,8 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件地点所在网格为[" + gridId + "]" + ",\r\n选择部件为:" + objId + "(" + objName + ")" + .setMessage("该事件地点所在网格为[" + gridId + "]" + + "\r\n选择部件为:" + objId + "(" + objName + ")" + "\r\n部件大类为:" + largeType + "\r\n小类为:" + smallType + "\r\n确认提交?") @@ -332,7 +333,9 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件所在地点网格为[" + gridId + "]确认选择?") + .setMessage("该事件所在地点网格为[" + gridId + "]" + + "\r\n所在社区为:" + communityName + + "\r\n确认选择?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { diff --git a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java index 22d7bca..dfc9961 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java @@ -159,7 +159,7 @@ for (PointDataBean dataBean : casePointList) { double parseLng = Double.parseDouble(dataBean.getLng()); double parseLat = Double.parseDouble(dataBean.getLat()); - if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 || + if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 && Math.abs(parseLat - point.getY()) <= Constant.DELTA_LAT_10) { Message message = weakReferenceHandler.obtainMessage(); message.what = 2021051401; diff --git a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java index 8d37132..e3703e3 100644 --- a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java @@ -50,7 +50,7 @@ @Override public int initLayoutView() { - return R.layout.activity_analysis; + return R.layout.activity_case_analysis; } @Override diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 4ab4cb8..cba9a54 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -18,11 +18,13 @@ import com.casic.dcms.adapter.MainPageAdapter; import com.casic.dcms.base.DoubleClickExitActivity; import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.presenter.PushRegisterPresenterImpl; import com.casic.dcms.mvp.presenter.UploadPositionPresenterImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; import com.casic.dcms.mvp.view.IUploadPositionView; -import com.casic.dcms.ui.fragment.DashBoardPageFragment; import com.casic.dcms.ui.fragment.HomePageFragment; import com.casic.dcms.ui.fragment.MinePageFragment; +import com.casic.dcms.ui.fragment.NoticePageFragment; import com.casic.dcms.ui.fragment.PhonePageFragment; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; @@ -40,7 +42,7 @@ import butterknife.BindView; -public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView { +public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView, IPushRegisterView { private static final String TAG = "MainActivity"; @BindView(R.id.pageTitleView) @@ -53,6 +55,7 @@ private List pageList; private BroadcastManager broadcastManager; private UploadPositionPresenterImpl uploadPositionPresenter; + private PushRegisterPresenterImpl registerPresenter; @Override public int initLayoutView() { @@ -71,27 +74,35 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); uploadPositionPresenter = new UploadPositionPresenterImpl(this); + registerPresenter = new PushRegisterPresenterImpl(this); pageList = new ArrayList<>(); pageList.add(new HomePageFragment()); pageList.add(new PhonePageFragment()); - pageList.add(new DashBoardPageFragment()); + pageList.add(new NoticePageFragment()); pageList.add(new MinePageFragment()); broadcastManager = BroadcastManager.getInstance(this); - broadcastManager.addAction(Constant.LOGIN_OUT_ACTION, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.LOGIN_OUT_ACTION.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - if (data.equals("请求成功")) { - finish(); + broadcastManager.addAction(new String[]{Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH}, + new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + switch (action) { + case Constant.LOGIN_OUT_ACTION: + String loginOut = intent.getStringExtra("data"); + assert loginOut != null; + if (loginOut.equals("请求成功")) { + finish(); + } + break; + case Constant.REGISTER_PUSH: + String clientid = intent.getStringExtra("data"); + registerPresenter.onReadyRetrofitRequest(clientid); + break; + } } } - } - } - }); + }); String imei = OtherUtils.obtainSimCardSerialNumber(this); if (TextUtils.isEmpty(imei)) { return; @@ -99,9 +110,13 @@ LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { - uploadPositionPresenter.onReadyRetrofitRequest(imei, - String.valueOf(location.getLatitude()), - String.valueOf(location.getLongitude())); + if (location != null) { + uploadPositionPresenter.onReadyRetrofitRequest(imei, + String.valueOf(location.getLatitude()), + String.valueOf(location.getLongitude())); + } else { + Log.d(TAG, "onLocationGet: location is null"); + } } }); } @@ -163,14 +178,22 @@ @Override protected void onDestroy() { super.onDestroy(); - broadcastManager.destroy(Constant.LOGIN_OUT_ACTION); + broadcastManager.destroy(Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH); if (uploadPositionPresenter != null) { uploadPositionPresenter.disposeRetrofitRequest(); } + if (registerPresenter != null) { + registerPresenter.disposeRetrofitRequest(); + } } @Override public void obtainUploadPositionResult(ActionResultBean resultBean) { - Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); +// Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); + } + + @Override + public void obtainRegisterResult(ActionResultBean resultBean) { + Log.d(TAG, "obtainRegisterResult: " + new Gson().toJson(resultBean)); } } diff --git a/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java b/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java deleted file mode 100644 index 6c9e96a..0000000 --- a/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.casic.dcms.ui; - -import android.annotation.SuppressLint; -import android.view.View; -import android.widget.TextView; - -import androidx.core.content.ContextCompat; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.NoticeBean; -import com.google.gson.Gson; -import com.qmuiteam.qmui.widget.QMUITopBarLayout; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 10:35 - * @email : 290677893@qq.com - **/ -public class NoticeActivity extends BaseActivity { - - @BindView(R.id.noticeTopLayout) - QMUITopBarLayout noticeTopLayout; - @BindView(R.id.noticeTitleView) - TextView noticeTitleView; - @BindView(R.id.noticeSenderView) - TextView noticeSenderView; - @BindView(R.id.noticeDateView) - TextView noticeDateView; - @BindView(R.id.noticeContentView) - TextView noticeContentView; - - @Override - public int initLayoutView() { - return R.layout.activity_notice; - } - - @Override - protected void setupTopBarLayout() { - noticeTopLayout.setTitle("消息内容").setTextColor(ContextCompat.getColor(this, R.color.white)); - noticeTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - noticeTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - finish(); - } - }); - } - - @SuppressLint("SetTextI18n") - @Override - public void initData() { - String noticeBeanJson = getIntent().getStringExtra("noticeBeanJson"); - NoticeBean noticeBean = new Gson().fromJson(noticeBeanJson, NoticeBean.class); - - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeSenderView.setText("发送者:" + noticeBean.getSenderName()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); - } - - @Override - public void initEvent() { - - } -} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java deleted file mode 100644 index 62d4aa2..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.Context; -import android.widget.LinearLayout; - -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -public class DashBoardPageFragment extends BaseFragment { - - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; - - private Context context; - - @Override - protected int initLayoutView() { - return R.layout.fragment_dashboard; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - List fragmentList = new ArrayList<>(); - fragmentList.add(new UnreadFragment()); - fragmentList.add(new ReadFragment()); - SubViewPagerAdapter adapter = new SubViewPagerAdapter(getChildFragmentManager(), pageTitles, fragmentList); - dashboardViewPager.setAdapter(adapter); - //绑定TabLayout - topTabLayout.setupWithViewPager(dashboardViewPager); - LinearLayout linearLayout = (LinearLayout) topTabLayout.getChildAt(0); - linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); - linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); - } - - @Override - protected void initEvent() { - - } -} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java new file mode 100644 index 0000000..192b702 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -0,0 +1,58 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.LinearLayout; + +import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; + +import java.util.ArrayList; +import java.util.List; + +import butterknife.BindView; + +public class NoticePageFragment extends BaseFragment { + + private static final String[] pageTitles = {"未读消息", "已读消息"}; + @BindView(R.id.topTabLayout) + TabLayout topTabLayout; + @BindView(R.id.dashboardViewPager) + NoScrollViewPager dashboardViewPager; + + private Context context; + + @Override + protected int initLayoutView() { + return R.layout.fragment_dashboard; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + protected void initData() { + List fragmentList = new ArrayList<>(); + fragmentList.add(new UnreadFragment()); + fragmentList.add(new ReadFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getChildFragmentManager(), pageTitles, fragmentList); + dashboardViewPager.setAdapter(adapter); + //绑定TabLayout + topTabLayout.setupWithViewPager(dashboardViewPager); + LinearLayout linearLayout = (LinearLayout) topTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); + } + + @Override + protected void initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java index 001fb6c..a0afe0f 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java @@ -3,6 +3,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.text.TextUtils; import android.view.ViewGroup; import androidx.annotation.NonNull; @@ -16,9 +17,11 @@ import com.casic.dcms.base.BaseFragment; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.greendao.DaoSession; -import com.casic.dcms.ui.NoticeActivity; +import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.google.gson.Gson; import com.qmuiteam.qmui.recyclerView.QMUIRVItemSwipeAction; import com.qmuiteam.qmui.recyclerView.QMUISwipeAction; @@ -61,8 +64,12 @@ gson = new Gson(); daoSession = BaseApplication.getDaoSession(); swipeViewAdapter = new SwipeViewAdapter(context); - //加载历史数据 - noticeBeans = daoSession.loadAll(NoticeBean.class); + //根据userPhone加载历史数据 + String userPhone = StringHelper.getUserPhone(); + if (TextUtils.isEmpty(userPhone)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserPhone.eq(userPhone)).list(); swipeViewAdapter.setData(noticeBeans); broadcastManager = BroadcastManager.getInstance(context); @@ -118,13 +125,14 @@ swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { @Override public void onClick(int position) { - //查看之后,未读消息变为已读消息 - NoticeBean noticeBean = noticeBeans.get(position); + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = new NoticeBean(); noticeBean.setIsRead("0"); daoSession.update(noticeBean); - Intent intent = new Intent(context, NoticeActivity.class); - intent.putExtra("noticeBeanJson", new Gson().toJson(noticeBean)); + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); startActivity(intent); } }); diff --git a/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java b/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java index 4278463..47a076a 100644 --- a/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java @@ -17,12 +17,4 @@ public static String getToken() { return (String) SaveKeyValues.getValue("token", ""); } - - public static void savePushClientID(String clientid) { - SaveKeyValues.putValue("pushClientID", clientid); - } - - public static String getPushClientID() { - return (String) SaveKeyValues.getValue("pushClientID", ""); - } } diff --git a/app/src/main/java/com/casic/dcms/utils/Constant.java b/app/src/main/java/com/casic/dcms/utils/Constant.java index 1ae7b82..f67e68b 100644 --- a/app/src/main/java/com/casic/dcms/utils/Constant.java +++ b/app/src/main/java/com/casic/dcms/utils/Constant.java @@ -49,8 +49,9 @@ public static final double DELTA_LAT_10 = 0.00002256;// 10米范围纬度值偏移量(大约) public static final String IP_KEY = "BASE_IP"; - public static final String LOGIN_OUT_ACTION = "loginOut"; - public static final String NOTICE_MSG = "receivePush"; + public static final String LOGIN_OUT_ACTION = "login_out"; + public static final String NOTICE_MSG = "receive_ush"; + public static final String REGISTER_PUSH = "register_push"; public static final String BASE_MAP_SERVICE_URL = "http://111.198.10.15:13002/arcgis/rest/services/crdt/MapServer";//崇仁城管地图底图 public static final String COMPONENT_SERVICE_URL = "http://111.198.10.15:13002/arcgis/rest/services/crbj/FeatureServer";//崇仁部件图层 diff --git a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java index 8a532f3..f2bc047 100644 --- a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java +++ b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java @@ -427,4 +427,14 @@ @GET("/user/permission") Observable obtainHomePage(@Header("token") String token, @Query("resourceType") String resourceType); + + /** + * 个推推送cid注册 + *

+ * http://111.198.10.15:11409/userPush/register + */ + @FormUrlEncoded + @POST("/userPush/register") + Observable registerPush(@Header("token") String token, + @Field("clientId") String clientId); } diff --git a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java index 5d29f09..23adf26 100644 --- a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java +++ b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java @@ -476,4 +476,13 @@ RetrofitService service = retrofit.create(RetrofitService.class); return service.obtainHomePage(AuthenticationHelper.getToken(), resourceType); } + + /** + * 个推推送cid注册 + */ + public static Observable getRegisterResult(String clientId) { + Retrofit retrofit = createRetrofit(); + RetrofitService service = retrofit.create(RetrofitService.class); + return service.registerPush(AuthenticationHelper.getToken(), clientId); + } } diff --git a/app/src/main/res/layout/activity_analysis.xml b/app/src/main/res/layout/activity_analysis.xml deleted file mode 100644 index aa1aa39..0000000 --- a/app/src/main/res/layout/activity_analysis.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java new file mode 100644 index 0000000..017a37e --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -0,0 +1,74 @@ +package com.casic.dcms.bean; + +public class PushResultBean { + + /** + * content : 您有一个工单超时,请快速处理 + * data : {"id":"1393113365064245250"} + * id : 1393117524798783490 + * title : 工单超时提醒 + * type : alarm + */ + + private String content; + private DataBean data; + private String id; + private String title; + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class DataBean { + /** + * id : 1393113365064245250 + */ + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java index 259eb85..c118368 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,11 +25,13 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property NoticeTitle = new Property(1, String.class, "noticeTitle", false, "NOTICE_TITLE"); - public final static Property NoticeDate = new Property(2, String.class, "noticeDate", false, "NOTICE_DATE"); - public final static Property NoticeContent = new Property(3, String.class, "noticeContent", false, "NOTICE_CONTENT"); - public final static Property SenderName = new Property(4, String.class, "senderName", false, "SENDER_NAME"); - public final static Property IsRead = new Property(5, String.class, "isRead", false, "IS_READ"); + public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property CaseId = new Property(2, String.class, "caseId", false, "CASE_ID"); + public final static Property Title = new Property(3, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(4, String.class, "content", false, "CONTENT"); + public final static Property PushDate = new Property(5, String.class, "pushDate", false, "PUSH_DATE"); + public final static Property Type = new Property(6, String.class, "type", false, "TYPE"); + public final static Property IsRead = new Property(7, String.class, "isRead", false, "IS_READ"); } @@ -46,11 +48,13 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"NOTICE_TITLE\" TEXT," + // 1: noticeTitle - "\"NOTICE_DATE\" TEXT," + // 2: noticeDate - "\"NOTICE_CONTENT\" TEXT," + // 3: noticeContent - "\"SENDER_NAME\" TEXT," + // 4: senderName - "\"IS_READ\" TEXT);"); // 5: isRead + "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"CASE_ID\" TEXT," + // 2: caseId + "\"TITLE\" TEXT," + // 3: title + "\"CONTENT\" TEXT," + // 4: content + "\"PUSH_DATE\" TEXT," + // 5: pushDate + "\"TYPE\" TEXT," + // 6: type + "\"IS_READ\" TEXT);"); // 7: isRead } /** Drops the underlying database table. */ @@ -68,29 +72,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -103,29 +117,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -138,11 +162,13 @@ public NoticeBean readEntity(Cursor cursor, int offset) { NoticeBean entity = new NoticeBean( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // noticeTitle - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // noticeDate - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // noticeContent - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // senderName - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // isRead + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userPhone + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // caseId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pushDate + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // type + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // isRead ); return entity; } @@ -150,11 +176,13 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setNoticeTitle(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setNoticeDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setNoticeContent(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setSenderName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setIsRead(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setCaseId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setPushDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setType(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setIsRead(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); } @Override diff --git a/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java new file mode 100644 index 0000000..7c3fb29 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface IPushRegisterModel { + Subscription sendRetrofitRequest(String clientid); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java new file mode 100644 index 0000000..c7ae0c1 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class PushRegisterModelImpl implements IPushRegisterModel { + + private OnRegisterListener updateListener; + + public PushRegisterModelImpl(OnRegisterListener listener) { + this.updateListener = listener; + } + + public interface OnRegisterListener { + void onSuccess(ActionResultBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest(String clientid) { + Observable observable = RetrofitServiceManager.getRegisterResult(clientid); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + updateListener.onFailure(e); + } + } + + @Override + public void onNext(ActionResultBean resultBean) { + if (resultBean != null) { + updateListener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java new file mode 100644 index 0000000..bb88db3 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface IPushRegisterPresenter { + void onReadyRetrofitRequest(String clientid); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java new file mode 100644 index 0000000..3a97b8f --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java @@ -0,0 +1,38 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.PushRegisterModelImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; + +public class PushRegisterPresenterImpl extends BasePresenter implements IPushRegisterPresenter, + PushRegisterModelImpl.OnRegisterListener { + + private IPushRegisterView view; + private PushRegisterModelImpl model; + + public PushRegisterPresenterImpl(IPushRegisterView pushRegisterView) { + this.view = pushRegisterView; + model = new PushRegisterModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest(String clientid) { + addSubscription(model.sendRetrofitRequest(clientid)); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(ActionResultBean resultBean) { + view.obtainRegisterResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java new file mode 100644 index 0000000..353903a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.ActionResultBean; + +public interface IPushRegisterView { + void obtainRegisterResult(ActionResultBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java index 0a4e1d2..865787a 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,15 +1,18 @@ package com.casic.dcms.service; import android.content.Context; +import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.utils.AuthenticationHelper; +import com.casic.dcms.bean.PushResultBean; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.casic.dcms.utils.TimeOrDateUtil; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.igexin.sdk.GTIntentService; import com.igexin.sdk.message.GTCmdMessage; import com.igexin.sdk.message.GTNotificationMessage; @@ -38,7 +41,12 @@ @Override public void onReceiveClientId(Context context, String clientid) { Log.d(TAG, "onReceiveClientId -> " + "clientid = " + clientid); - AuthenticationHelper.savePushClientID(clientid); + //通知MainActivity注册个推服务 + if (!TextUtils.isEmpty(clientid)) { + BroadcastManager.getInstance(context).sendBroadcast(Constant.REGISTER_PUSH, clientid); + } else { + Log.d(TAG, "onReceiveClientId: ===>clientid = " + clientid); + } } // cid 离线上线通知 @@ -50,28 +58,50 @@ // 各种事件处理回执 @Override public void onReceiveCommandResult(Context context, GTCmdMessage cmdMessage) { - +// Log.d(TAG, "onReceiveCommandResult -> " + cmdMessage); } // 通知到达,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageArrived(Context context, GTNotificationMessage msg) { + public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + /** + * appid = DR9oeLL9va6aG3DYXy2w39 + * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 + * messageid = b74187603fe34058a223949ead9f8dcf + * pkg = com.casic.dcms + * cid = cd1aec399b5504516102e399ecf7cda4 + * content = {"content":"您有一个工单超时,请快速处理","data":{"id":"1392655327805825025"},"id":1393131068164472834,"title":"工单超时提醒","type":"alarm"} + * title = 工单提醒 + * */ + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + NoticeBean noticeBean = new NoticeBean(); - noticeBean.setNoticeTitle(msg.getTitle()); - noticeBean.setSenderName("管理员"); - noticeBean.setNoticeDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); - noticeBean.setNoticeContent(msg.getContent()); + noticeBean.setUserPhone(StringHelper.getUserPhone()); + noticeBean.setCaseId(resultBean.getId()); + noticeBean.setTitle(resultBean.getTitle()); + noticeBean.setContent(resultBean.getContent()); + noticeBean.setType(resultBean.getType()); + noticeBean.setPushDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); noticeBean.setIsRead("1"); //存本地一份 BaseApplication.getDaoSession().insert(noticeBean); //发送消息更新界面 - BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, new Gson().toJson(noticeBean)); + BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, gson.toJson(noticeBean)); } // 通知点击,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageClicked(Context context, GTNotificationMessage msg) { + public void onNotificationMessageClicked(Context context, GTNotificationMessage message) { + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + String caseId = resultBean.getId(); + Log.d(TAG, "onNotificationMessageClicked: " + caseId); } } diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index 219ae3b..db7d9ca 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -302,7 +302,8 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件地点所在网格为[" + gridId + "]" + ",\r\n选择部件为:" + objId + "(" + objName + ")" + .setMessage("该事件地点所在网格为[" + gridId + "]" + + "\r\n选择部件为:" + objId + "(" + objName + ")" + "\r\n部件大类为:" + largeType + "\r\n小类为:" + smallType + "\r\n确认提交?") @@ -332,7 +333,9 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件所在地点网格为[" + gridId + "]确认选择?") + .setMessage("该事件所在地点网格为[" + gridId + "]" + + "\r\n所在社区为:" + communityName + + "\r\n确认选择?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { diff --git a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java index 22d7bca..dfc9961 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java @@ -159,7 +159,7 @@ for (PointDataBean dataBean : casePointList) { double parseLng = Double.parseDouble(dataBean.getLng()); double parseLat = Double.parseDouble(dataBean.getLat()); - if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 || + if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 && Math.abs(parseLat - point.getY()) <= Constant.DELTA_LAT_10) { Message message = weakReferenceHandler.obtainMessage(); message.what = 2021051401; diff --git a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java index 8d37132..e3703e3 100644 --- a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java @@ -50,7 +50,7 @@ @Override public int initLayoutView() { - return R.layout.activity_analysis; + return R.layout.activity_case_analysis; } @Override diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 4ab4cb8..cba9a54 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -18,11 +18,13 @@ import com.casic.dcms.adapter.MainPageAdapter; import com.casic.dcms.base.DoubleClickExitActivity; import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.presenter.PushRegisterPresenterImpl; import com.casic.dcms.mvp.presenter.UploadPositionPresenterImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; import com.casic.dcms.mvp.view.IUploadPositionView; -import com.casic.dcms.ui.fragment.DashBoardPageFragment; import com.casic.dcms.ui.fragment.HomePageFragment; import com.casic.dcms.ui.fragment.MinePageFragment; +import com.casic.dcms.ui.fragment.NoticePageFragment; import com.casic.dcms.ui.fragment.PhonePageFragment; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; @@ -40,7 +42,7 @@ import butterknife.BindView; -public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView { +public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView, IPushRegisterView { private static final String TAG = "MainActivity"; @BindView(R.id.pageTitleView) @@ -53,6 +55,7 @@ private List pageList; private BroadcastManager broadcastManager; private UploadPositionPresenterImpl uploadPositionPresenter; + private PushRegisterPresenterImpl registerPresenter; @Override public int initLayoutView() { @@ -71,27 +74,35 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); uploadPositionPresenter = new UploadPositionPresenterImpl(this); + registerPresenter = new PushRegisterPresenterImpl(this); pageList = new ArrayList<>(); pageList.add(new HomePageFragment()); pageList.add(new PhonePageFragment()); - pageList.add(new DashBoardPageFragment()); + pageList.add(new NoticePageFragment()); pageList.add(new MinePageFragment()); broadcastManager = BroadcastManager.getInstance(this); - broadcastManager.addAction(Constant.LOGIN_OUT_ACTION, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.LOGIN_OUT_ACTION.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - if (data.equals("请求成功")) { - finish(); + broadcastManager.addAction(new String[]{Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH}, + new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + switch (action) { + case Constant.LOGIN_OUT_ACTION: + String loginOut = intent.getStringExtra("data"); + assert loginOut != null; + if (loginOut.equals("请求成功")) { + finish(); + } + break; + case Constant.REGISTER_PUSH: + String clientid = intent.getStringExtra("data"); + registerPresenter.onReadyRetrofitRequest(clientid); + break; + } } } - } - } - }); + }); String imei = OtherUtils.obtainSimCardSerialNumber(this); if (TextUtils.isEmpty(imei)) { return; @@ -99,9 +110,13 @@ LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { - uploadPositionPresenter.onReadyRetrofitRequest(imei, - String.valueOf(location.getLatitude()), - String.valueOf(location.getLongitude())); + if (location != null) { + uploadPositionPresenter.onReadyRetrofitRequest(imei, + String.valueOf(location.getLatitude()), + String.valueOf(location.getLongitude())); + } else { + Log.d(TAG, "onLocationGet: location is null"); + } } }); } @@ -163,14 +178,22 @@ @Override protected void onDestroy() { super.onDestroy(); - broadcastManager.destroy(Constant.LOGIN_OUT_ACTION); + broadcastManager.destroy(Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH); if (uploadPositionPresenter != null) { uploadPositionPresenter.disposeRetrofitRequest(); } + if (registerPresenter != null) { + registerPresenter.disposeRetrofitRequest(); + } } @Override public void obtainUploadPositionResult(ActionResultBean resultBean) { - Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); +// Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); + } + + @Override + public void obtainRegisterResult(ActionResultBean resultBean) { + Log.d(TAG, "obtainRegisterResult: " + new Gson().toJson(resultBean)); } } diff --git a/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java b/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java deleted file mode 100644 index 6c9e96a..0000000 --- a/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.casic.dcms.ui; - -import android.annotation.SuppressLint; -import android.view.View; -import android.widget.TextView; - -import androidx.core.content.ContextCompat; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.NoticeBean; -import com.google.gson.Gson; -import com.qmuiteam.qmui.widget.QMUITopBarLayout; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 10:35 - * @email : 290677893@qq.com - **/ -public class NoticeActivity extends BaseActivity { - - @BindView(R.id.noticeTopLayout) - QMUITopBarLayout noticeTopLayout; - @BindView(R.id.noticeTitleView) - TextView noticeTitleView; - @BindView(R.id.noticeSenderView) - TextView noticeSenderView; - @BindView(R.id.noticeDateView) - TextView noticeDateView; - @BindView(R.id.noticeContentView) - TextView noticeContentView; - - @Override - public int initLayoutView() { - return R.layout.activity_notice; - } - - @Override - protected void setupTopBarLayout() { - noticeTopLayout.setTitle("消息内容").setTextColor(ContextCompat.getColor(this, R.color.white)); - noticeTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - noticeTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - finish(); - } - }); - } - - @SuppressLint("SetTextI18n") - @Override - public void initData() { - String noticeBeanJson = getIntent().getStringExtra("noticeBeanJson"); - NoticeBean noticeBean = new Gson().fromJson(noticeBeanJson, NoticeBean.class); - - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeSenderView.setText("发送者:" + noticeBean.getSenderName()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); - } - - @Override - public void initEvent() { - - } -} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java deleted file mode 100644 index 62d4aa2..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.Context; -import android.widget.LinearLayout; - -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -public class DashBoardPageFragment extends BaseFragment { - - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; - - private Context context; - - @Override - protected int initLayoutView() { - return R.layout.fragment_dashboard; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - List fragmentList = new ArrayList<>(); - fragmentList.add(new UnreadFragment()); - fragmentList.add(new ReadFragment()); - SubViewPagerAdapter adapter = new SubViewPagerAdapter(getChildFragmentManager(), pageTitles, fragmentList); - dashboardViewPager.setAdapter(adapter); - //绑定TabLayout - topTabLayout.setupWithViewPager(dashboardViewPager); - LinearLayout linearLayout = (LinearLayout) topTabLayout.getChildAt(0); - linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); - linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); - } - - @Override - protected void initEvent() { - - } -} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java new file mode 100644 index 0000000..192b702 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -0,0 +1,58 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.LinearLayout; + +import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; + +import java.util.ArrayList; +import java.util.List; + +import butterknife.BindView; + +public class NoticePageFragment extends BaseFragment { + + private static final String[] pageTitles = {"未读消息", "已读消息"}; + @BindView(R.id.topTabLayout) + TabLayout topTabLayout; + @BindView(R.id.dashboardViewPager) + NoScrollViewPager dashboardViewPager; + + private Context context; + + @Override + protected int initLayoutView() { + return R.layout.fragment_dashboard; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + protected void initData() { + List fragmentList = new ArrayList<>(); + fragmentList.add(new UnreadFragment()); + fragmentList.add(new ReadFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getChildFragmentManager(), pageTitles, fragmentList); + dashboardViewPager.setAdapter(adapter); + //绑定TabLayout + topTabLayout.setupWithViewPager(dashboardViewPager); + LinearLayout linearLayout = (LinearLayout) topTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); + } + + @Override + protected void initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java index 001fb6c..a0afe0f 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java @@ -3,6 +3,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.text.TextUtils; import android.view.ViewGroup; import androidx.annotation.NonNull; @@ -16,9 +17,11 @@ import com.casic.dcms.base.BaseFragment; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.greendao.DaoSession; -import com.casic.dcms.ui.NoticeActivity; +import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.google.gson.Gson; import com.qmuiteam.qmui.recyclerView.QMUIRVItemSwipeAction; import com.qmuiteam.qmui.recyclerView.QMUISwipeAction; @@ -61,8 +64,12 @@ gson = new Gson(); daoSession = BaseApplication.getDaoSession(); swipeViewAdapter = new SwipeViewAdapter(context); - //加载历史数据 - noticeBeans = daoSession.loadAll(NoticeBean.class); + //根据userPhone加载历史数据 + String userPhone = StringHelper.getUserPhone(); + if (TextUtils.isEmpty(userPhone)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserPhone.eq(userPhone)).list(); swipeViewAdapter.setData(noticeBeans); broadcastManager = BroadcastManager.getInstance(context); @@ -118,13 +125,14 @@ swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { @Override public void onClick(int position) { - //查看之后,未读消息变为已读消息 - NoticeBean noticeBean = noticeBeans.get(position); + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = new NoticeBean(); noticeBean.setIsRead("0"); daoSession.update(noticeBean); - Intent intent = new Intent(context, NoticeActivity.class); - intent.putExtra("noticeBeanJson", new Gson().toJson(noticeBean)); + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); startActivity(intent); } }); diff --git a/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java b/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java index 4278463..47a076a 100644 --- a/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java @@ -17,12 +17,4 @@ public static String getToken() { return (String) SaveKeyValues.getValue("token", ""); } - - public static void savePushClientID(String clientid) { - SaveKeyValues.putValue("pushClientID", clientid); - } - - public static String getPushClientID() { - return (String) SaveKeyValues.getValue("pushClientID", ""); - } } diff --git a/app/src/main/java/com/casic/dcms/utils/Constant.java b/app/src/main/java/com/casic/dcms/utils/Constant.java index 1ae7b82..f67e68b 100644 --- a/app/src/main/java/com/casic/dcms/utils/Constant.java +++ b/app/src/main/java/com/casic/dcms/utils/Constant.java @@ -49,8 +49,9 @@ public static final double DELTA_LAT_10 = 0.00002256;// 10米范围纬度值偏移量(大约) public static final String IP_KEY = "BASE_IP"; - public static final String LOGIN_OUT_ACTION = "loginOut"; - public static final String NOTICE_MSG = "receivePush"; + public static final String LOGIN_OUT_ACTION = "login_out"; + public static final String NOTICE_MSG = "receive_ush"; + public static final String REGISTER_PUSH = "register_push"; public static final String BASE_MAP_SERVICE_URL = "http://111.198.10.15:13002/arcgis/rest/services/crdt/MapServer";//崇仁城管地图底图 public static final String COMPONENT_SERVICE_URL = "http://111.198.10.15:13002/arcgis/rest/services/crbj/FeatureServer";//崇仁部件图层 diff --git a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java index 8a532f3..f2bc047 100644 --- a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java +++ b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java @@ -427,4 +427,14 @@ @GET("/user/permission") Observable obtainHomePage(@Header("token") String token, @Query("resourceType") String resourceType); + + /** + * 个推推送cid注册 + *

+ * http://111.198.10.15:11409/userPush/register + */ + @FormUrlEncoded + @POST("/userPush/register") + Observable registerPush(@Header("token") String token, + @Field("clientId") String clientId); } diff --git a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java index 5d29f09..23adf26 100644 --- a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java +++ b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java @@ -476,4 +476,13 @@ RetrofitService service = retrofit.create(RetrofitService.class); return service.obtainHomePage(AuthenticationHelper.getToken(), resourceType); } + + /** + * 个推推送cid注册 + */ + public static Observable getRegisterResult(String clientId) { + Retrofit retrofit = createRetrofit(); + RetrofitService service = retrofit.create(RetrofitService.class); + return service.registerPush(AuthenticationHelper.getToken(), clientId); + } } diff --git a/app/src/main/res/layout/activity_analysis.xml b/app/src/main/res/layout/activity_analysis.xml deleted file mode 100644 index aa1aa39..0000000 --- a/app/src/main/res/layout/activity_analysis.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_case_analysis.xml b/app/src/main/res/layout/activity_case_analysis.xml new file mode 100644 index 0000000..aa1aa39 --- /dev/null +++ b/app/src/main/res/layout/activity_case_analysis.xml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b516360..fffab0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:usesCleartextTraffic="true"> + android:excludeFromRecents="true"> @@ -52,7 +52,6 @@ - diff --git a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java index aa469ff..03c4b3f 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -67,9 +67,9 @@ TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); NoticeBean noticeBean = mData.get(position); - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); + noticeTitleView.setText(noticeBean.getTitle()); + noticeDateView.setText(noticeBean.getPushDate()); + noticeContentView.setText(noticeBean.getContent()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java index d9e8d71..1510cef 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -8,26 +8,33 @@ * @author : Pengxh * @time : 2021/4/15 10:03 * @email : 290677893@qq.com + *

+ * 推送消息本地持久化,便于用户查看过往的消息 **/ @Entity public class NoticeBean { @Id(autoincrement = true) - private Long id; - private String noticeTitle; - private String noticeDate; - private String noticeContent; - private String senderName; + private Long id;//主键ID + + private String userPhone;//用户手机号 + private String caseId;//案卷id + private String title;//案卷标题 + private String content;//案卷简介 + private String pushDate;//推送时间 + private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 2097216414) - public NoticeBean(Long id, String noticeTitle, String noticeDate, - String noticeContent, String senderName, String isRead) { + @Generated(hash = 1624806914) + public NoticeBean(Long id, String userPhone, String caseId, String title, + String content, String pushDate, String type, String isRead) { this.id = id; - this.noticeTitle = noticeTitle; - this.noticeDate = noticeDate; - this.noticeContent = noticeContent; - this.senderName = senderName; + this.userPhone = userPhone; + this.caseId = caseId; + this.title = title; + this.content = content; + this.pushDate = pushDate; + this.type = type; this.isRead = isRead; } @@ -43,36 +50,52 @@ this.id = id; } - public String getNoticeTitle() { - return this.noticeTitle; + public String getUserPhone() { + return this.userPhone; } - public void setNoticeTitle(String noticeTitle) { - this.noticeTitle = noticeTitle; + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; } - public String getNoticeDate() { - return this.noticeDate; + public String getCaseId() { + return this.caseId; } - public void setNoticeDate(String noticeDate) { - this.noticeDate = noticeDate; + public void setCaseId(String caseId) { + this.caseId = caseId; } - public String getNoticeContent() { - return this.noticeContent; + public String getTitle() { + return this.title; } - public void setNoticeContent(String noticeContent) { - this.noticeContent = noticeContent; + public void setTitle(String title) { + this.title = title; } - public String getSenderName() { - return this.senderName; + public String getContent() { + return this.content; } - public void setSenderName(String senderName) { - this.senderName = senderName; + public void setContent(String content) { + this.content = content; + } + + public String getPushDate() { + return this.pushDate; + } + + public void setPushDate(String pushDate) { + this.pushDate = pushDate; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; } public String getIsRead() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java new file mode 100644 index 0000000..017a37e --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -0,0 +1,74 @@ +package com.casic.dcms.bean; + +public class PushResultBean { + + /** + * content : 您有一个工单超时,请快速处理 + * data : {"id":"1393113365064245250"} + * id : 1393117524798783490 + * title : 工单超时提醒 + * type : alarm + */ + + private String content; + private DataBean data; + private String id; + private String title; + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class DataBean { + /** + * id : 1393113365064245250 + */ + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java index 259eb85..c118368 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,11 +25,13 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property NoticeTitle = new Property(1, String.class, "noticeTitle", false, "NOTICE_TITLE"); - public final static Property NoticeDate = new Property(2, String.class, "noticeDate", false, "NOTICE_DATE"); - public final static Property NoticeContent = new Property(3, String.class, "noticeContent", false, "NOTICE_CONTENT"); - public final static Property SenderName = new Property(4, String.class, "senderName", false, "SENDER_NAME"); - public final static Property IsRead = new Property(5, String.class, "isRead", false, "IS_READ"); + public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property CaseId = new Property(2, String.class, "caseId", false, "CASE_ID"); + public final static Property Title = new Property(3, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(4, String.class, "content", false, "CONTENT"); + public final static Property PushDate = new Property(5, String.class, "pushDate", false, "PUSH_DATE"); + public final static Property Type = new Property(6, String.class, "type", false, "TYPE"); + public final static Property IsRead = new Property(7, String.class, "isRead", false, "IS_READ"); } @@ -46,11 +48,13 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"NOTICE_TITLE\" TEXT," + // 1: noticeTitle - "\"NOTICE_DATE\" TEXT," + // 2: noticeDate - "\"NOTICE_CONTENT\" TEXT," + // 3: noticeContent - "\"SENDER_NAME\" TEXT," + // 4: senderName - "\"IS_READ\" TEXT);"); // 5: isRead + "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"CASE_ID\" TEXT," + // 2: caseId + "\"TITLE\" TEXT," + // 3: title + "\"CONTENT\" TEXT," + // 4: content + "\"PUSH_DATE\" TEXT," + // 5: pushDate + "\"TYPE\" TEXT," + // 6: type + "\"IS_READ\" TEXT);"); // 7: isRead } /** Drops the underlying database table. */ @@ -68,29 +72,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -103,29 +117,39 @@ stmt.bindLong(1, id); } - String noticeTitle = entity.getNoticeTitle(); - if (noticeTitle != null) { - stmt.bindString(2, noticeTitle); + String userPhone = entity.getUserPhone(); + if (userPhone != null) { + stmt.bindString(2, userPhone); } - String noticeDate = entity.getNoticeDate(); - if (noticeDate != null) { - stmt.bindString(3, noticeDate); + String caseId = entity.getCaseId(); + if (caseId != null) { + stmt.bindString(3, caseId); } - String noticeContent = entity.getNoticeContent(); - if (noticeContent != null) { - stmt.bindString(4, noticeContent); + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(4, title); } - String senderName = entity.getSenderName(); - if (senderName != null) { - stmt.bindString(5, senderName); + String content = entity.getContent(); + if (content != null) { + stmt.bindString(5, content); + } + + String pushDate = entity.getPushDate(); + if (pushDate != null) { + stmt.bindString(6, pushDate); + } + + String type = entity.getType(); + if (type != null) { + stmt.bindString(7, type); } String isRead = entity.getIsRead(); if (isRead != null) { - stmt.bindString(6, isRead); + stmt.bindString(8, isRead); } } @@ -138,11 +162,13 @@ public NoticeBean readEntity(Cursor cursor, int offset) { NoticeBean entity = new NoticeBean( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // noticeTitle - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // noticeDate - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // noticeContent - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // senderName - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // isRead + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userPhone + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // caseId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pushDate + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // type + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // isRead ); return entity; } @@ -150,11 +176,13 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setNoticeTitle(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setNoticeDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setNoticeContent(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setSenderName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setIsRead(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setCaseId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setPushDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setType(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setIsRead(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); } @Override diff --git a/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java new file mode 100644 index 0000000..7c3fb29 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/IPushRegisterModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface IPushRegisterModel { + Subscription sendRetrofitRequest(String clientid); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java new file mode 100644 index 0000000..c7ae0c1 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/PushRegisterModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class PushRegisterModelImpl implements IPushRegisterModel { + + private OnRegisterListener updateListener; + + public PushRegisterModelImpl(OnRegisterListener listener) { + this.updateListener = listener; + } + + public interface OnRegisterListener { + void onSuccess(ActionResultBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest(String clientid) { + Observable observable = RetrofitServiceManager.getRegisterResult(clientid); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + updateListener.onFailure(e); + } + } + + @Override + public void onNext(ActionResultBean resultBean) { + if (resultBean != null) { + updateListener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java new file mode 100644 index 0000000..bb88db3 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/IPushRegisterPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface IPushRegisterPresenter { + void onReadyRetrofitRequest(String clientid); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java new file mode 100644 index 0000000..3a97b8f --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/PushRegisterPresenterImpl.java @@ -0,0 +1,38 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.PushRegisterModelImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; + +public class PushRegisterPresenterImpl extends BasePresenter implements IPushRegisterPresenter, + PushRegisterModelImpl.OnRegisterListener { + + private IPushRegisterView view; + private PushRegisterModelImpl model; + + public PushRegisterPresenterImpl(IPushRegisterView pushRegisterView) { + this.view = pushRegisterView; + model = new PushRegisterModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest(String clientid) { + addSubscription(model.sendRetrofitRequest(clientid)); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(ActionResultBean resultBean) { + view.obtainRegisterResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java new file mode 100644 index 0000000..353903a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/IPushRegisterView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.ActionResultBean; + +public interface IPushRegisterView { + void obtainRegisterResult(ActionResultBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java index 0a4e1d2..865787a 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,15 +1,18 @@ package com.casic.dcms.service; import android.content.Context; +import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.utils.AuthenticationHelper; +import com.casic.dcms.bean.PushResultBean; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.casic.dcms.utils.TimeOrDateUtil; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.igexin.sdk.GTIntentService; import com.igexin.sdk.message.GTCmdMessage; import com.igexin.sdk.message.GTNotificationMessage; @@ -38,7 +41,12 @@ @Override public void onReceiveClientId(Context context, String clientid) { Log.d(TAG, "onReceiveClientId -> " + "clientid = " + clientid); - AuthenticationHelper.savePushClientID(clientid); + //通知MainActivity注册个推服务 + if (!TextUtils.isEmpty(clientid)) { + BroadcastManager.getInstance(context).sendBroadcast(Constant.REGISTER_PUSH, clientid); + } else { + Log.d(TAG, "onReceiveClientId: ===>clientid = " + clientid); + } } // cid 离线上线通知 @@ -50,28 +58,50 @@ // 各种事件处理回执 @Override public void onReceiveCommandResult(Context context, GTCmdMessage cmdMessage) { - +// Log.d(TAG, "onReceiveCommandResult -> " + cmdMessage); } // 通知到达,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageArrived(Context context, GTNotificationMessage msg) { + public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + /** + * appid = DR9oeLL9va6aG3DYXy2w39 + * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 + * messageid = b74187603fe34058a223949ead9f8dcf + * pkg = com.casic.dcms + * cid = cd1aec399b5504516102e399ecf7cda4 + * content = {"content":"您有一个工单超时,请快速处理","data":{"id":"1392655327805825025"},"id":1393131068164472834,"title":"工单超时提醒","type":"alarm"} + * title = 工单提醒 + * */ + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + NoticeBean noticeBean = new NoticeBean(); - noticeBean.setNoticeTitle(msg.getTitle()); - noticeBean.setSenderName("管理员"); - noticeBean.setNoticeDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); - noticeBean.setNoticeContent(msg.getContent()); + noticeBean.setUserPhone(StringHelper.getUserPhone()); + noticeBean.setCaseId(resultBean.getId()); + noticeBean.setTitle(resultBean.getTitle()); + noticeBean.setContent(resultBean.getContent()); + noticeBean.setType(resultBean.getType()); + noticeBean.setPushDate(TimeOrDateUtil.timestampToDate(System.currentTimeMillis())); noticeBean.setIsRead("1"); //存本地一份 BaseApplication.getDaoSession().insert(noticeBean); //发送消息更新界面 - BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, new Gson().toJson(noticeBean)); + BroadcastManager.getInstance(context).sendBroadcast(Constant.NOTICE_MSG, gson.toJson(noticeBean)); } // 通知点击,只有个推通道下发的通知会回调此方法 @Override - public void onNotificationMessageClicked(Context context, GTNotificationMessage msg) { + public void onNotificationMessageClicked(Context context, GTNotificationMessage message) { + Gson gson = new Gson(); + String messageContent = message.getContent(); + PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { + }.getType()); + String caseId = resultBean.getId(); + Log.d(TAG, "onNotificationMessageClicked: " + caseId); } } diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index 219ae3b..db7d9ca 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -302,7 +302,8 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件地点所在网格为[" + gridId + "]" + ",\r\n选择部件为:" + objId + "(" + objName + ")" + .setMessage("该事件地点所在网格为[" + gridId + "]" + + "\r\n选择部件为:" + objId + "(" + objName + ")" + "\r\n部件大类为:" + largeType + "\r\n小类为:" + smallType + "\r\n确认提交?") @@ -332,7 +333,9 @@ if (!this.isFinishing()) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("该事件所在地点网格为[" + gridId + "]确认选择?") + .setMessage("该事件所在地点网格为[" + gridId + "]" + + "\r\n所在社区为:" + communityName + + "\r\n确认选择?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { diff --git a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java index 22d7bca..dfc9961 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseOnMapActivity.java @@ -159,7 +159,7 @@ for (PointDataBean dataBean : casePointList) { double parseLng = Double.parseDouble(dataBean.getLng()); double parseLat = Double.parseDouble(dataBean.getLat()); - if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 || + if (Math.abs(parseLng - point.getX()) <= Constant.DELTA_LNG_10 && Math.abs(parseLat - point.getY()) <= Constant.DELTA_LAT_10) { Message message = weakReferenceHandler.obtainMessage(); message.what = 2021051401; diff --git a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java index 8d37132..e3703e3 100644 --- a/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/DataAnalysisActivity.java @@ -50,7 +50,7 @@ @Override public int initLayoutView() { - return R.layout.activity_analysis; + return R.layout.activity_case_analysis; } @Override diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 4ab4cb8..cba9a54 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -18,11 +18,13 @@ import com.casic.dcms.adapter.MainPageAdapter; import com.casic.dcms.base.DoubleClickExitActivity; import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.mvp.presenter.PushRegisterPresenterImpl; import com.casic.dcms.mvp.presenter.UploadPositionPresenterImpl; +import com.casic.dcms.mvp.view.IPushRegisterView; import com.casic.dcms.mvp.view.IUploadPositionView; -import com.casic.dcms.ui.fragment.DashBoardPageFragment; import com.casic.dcms.ui.fragment.HomePageFragment; import com.casic.dcms.ui.fragment.MinePageFragment; +import com.casic.dcms.ui.fragment.NoticePageFragment; import com.casic.dcms.ui.fragment.PhonePageFragment; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; @@ -40,7 +42,7 @@ import butterknife.BindView; -public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView { +public class MainActivity extends DoubleClickExitActivity implements IUploadPositionView, IPushRegisterView { private static final String TAG = "MainActivity"; @BindView(R.id.pageTitleView) @@ -53,6 +55,7 @@ private List pageList; private BroadcastManager broadcastManager; private UploadPositionPresenterImpl uploadPositionPresenter; + private PushRegisterPresenterImpl registerPresenter; @Override public int initLayoutView() { @@ -71,27 +74,35 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); uploadPositionPresenter = new UploadPositionPresenterImpl(this); + registerPresenter = new PushRegisterPresenterImpl(this); pageList = new ArrayList<>(); pageList.add(new HomePageFragment()); pageList.add(new PhonePageFragment()); - pageList.add(new DashBoardPageFragment()); + pageList.add(new NoticePageFragment()); pageList.add(new MinePageFragment()); broadcastManager = BroadcastManager.getInstance(this); - broadcastManager.addAction(Constant.LOGIN_OUT_ACTION, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.LOGIN_OUT_ACTION.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - if (data.equals("请求成功")) { - finish(); + broadcastManager.addAction(new String[]{Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH}, + new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + switch (action) { + case Constant.LOGIN_OUT_ACTION: + String loginOut = intent.getStringExtra("data"); + assert loginOut != null; + if (loginOut.equals("请求成功")) { + finish(); + } + break; + case Constant.REGISTER_PUSH: + String clientid = intent.getStringExtra("data"); + registerPresenter.onReadyRetrofitRequest(clientid); + break; + } } } - } - } - }); + }); String imei = OtherUtils.obtainSimCardSerialNumber(this); if (TextUtils.isEmpty(imei)) { return; @@ -99,9 +110,13 @@ LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { - uploadPositionPresenter.onReadyRetrofitRequest(imei, - String.valueOf(location.getLatitude()), - String.valueOf(location.getLongitude())); + if (location != null) { + uploadPositionPresenter.onReadyRetrofitRequest(imei, + String.valueOf(location.getLatitude()), + String.valueOf(location.getLongitude())); + } else { + Log.d(TAG, "onLocationGet: location is null"); + } } }); } @@ -163,14 +178,22 @@ @Override protected void onDestroy() { super.onDestroy(); - broadcastManager.destroy(Constant.LOGIN_OUT_ACTION); + broadcastManager.destroy(Constant.LOGIN_OUT_ACTION, Constant.REGISTER_PUSH); if (uploadPositionPresenter != null) { uploadPositionPresenter.disposeRetrofitRequest(); } + if (registerPresenter != null) { + registerPresenter.disposeRetrofitRequest(); + } } @Override public void obtainUploadPositionResult(ActionResultBean resultBean) { - Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); +// Log.d(TAG, "obtainUploadPositionResult: " + new Gson().toJson(resultBean)); + } + + @Override + public void obtainRegisterResult(ActionResultBean resultBean) { + Log.d(TAG, "obtainRegisterResult: " + new Gson().toJson(resultBean)); } } diff --git a/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java b/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java deleted file mode 100644 index 6c9e96a..0000000 --- a/app/src/main/java/com/casic/dcms/ui/NoticeActivity.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.casic.dcms.ui; - -import android.annotation.SuppressLint; -import android.view.View; -import android.widget.TextView; - -import androidx.core.content.ContextCompat; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.NoticeBean; -import com.google.gson.Gson; -import com.qmuiteam.qmui.widget.QMUITopBarLayout; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 10:35 - * @email : 290677893@qq.com - **/ -public class NoticeActivity extends BaseActivity { - - @BindView(R.id.noticeTopLayout) - QMUITopBarLayout noticeTopLayout; - @BindView(R.id.noticeTitleView) - TextView noticeTitleView; - @BindView(R.id.noticeSenderView) - TextView noticeSenderView; - @BindView(R.id.noticeDateView) - TextView noticeDateView; - @BindView(R.id.noticeContentView) - TextView noticeContentView; - - @Override - public int initLayoutView() { - return R.layout.activity_notice; - } - - @Override - protected void setupTopBarLayout() { - noticeTopLayout.setTitle("消息内容").setTextColor(ContextCompat.getColor(this, R.color.white)); - noticeTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - noticeTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - finish(); - } - }); - } - - @SuppressLint("SetTextI18n") - @Override - public void initData() { - String noticeBeanJson = getIntent().getStringExtra("noticeBeanJson"); - NoticeBean noticeBean = new Gson().fromJson(noticeBeanJson, NoticeBean.class); - - noticeTitleView.setText(noticeBean.getNoticeTitle()); - noticeSenderView.setText("发送者:" + noticeBean.getSenderName()); - noticeDateView.setText(noticeBean.getNoticeDate()); - noticeContentView.setText(noticeBean.getNoticeContent()); - } - - @Override - public void initEvent() { - - } -} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java deleted file mode 100644 index 62d4aa2..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/DashBoardPageFragment.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.Context; -import android.widget.LinearLayout; - -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -public class DashBoardPageFragment extends BaseFragment { - - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; - - private Context context; - - @Override - protected int initLayoutView() { - return R.layout.fragment_dashboard; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - List fragmentList = new ArrayList<>(); - fragmentList.add(new UnreadFragment()); - fragmentList.add(new ReadFragment()); - SubViewPagerAdapter adapter = new SubViewPagerAdapter(getChildFragmentManager(), pageTitles, fragmentList); - dashboardViewPager.setAdapter(adapter); - //绑定TabLayout - topTabLayout.setupWithViewPager(dashboardViewPager); - LinearLayout linearLayout = (LinearLayout) topTabLayout.getChildAt(0); - linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); - linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); - } - - @Override - protected void initEvent() { - - } -} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java new file mode 100644 index 0000000..192b702 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -0,0 +1,58 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.LinearLayout; + +import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; + +import java.util.ArrayList; +import java.util.List; + +import butterknife.BindView; + +public class NoticePageFragment extends BaseFragment { + + private static final String[] pageTitles = {"未读消息", "已读消息"}; + @BindView(R.id.topTabLayout) + TabLayout topTabLayout; + @BindView(R.id.dashboardViewPager) + NoScrollViewPager dashboardViewPager; + + private Context context; + + @Override + protected int initLayoutView() { + return R.layout.fragment_dashboard; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + protected void initData() { + List fragmentList = new ArrayList<>(); + fragmentList.add(new UnreadFragment()); + fragmentList.add(new ReadFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getChildFragmentManager(), pageTitles, fragmentList); + dashboardViewPager.setAdapter(adapter); + //绑定TabLayout + topTabLayout.setupWithViewPager(dashboardViewPager); + LinearLayout linearLayout = (LinearLayout) topTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); + } + + @Override + protected void initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java index 001fb6c..a0afe0f 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java @@ -3,6 +3,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.text.TextUtils; import android.view.ViewGroup; import androidx.annotation.NonNull; @@ -16,9 +17,11 @@ import com.casic.dcms.base.BaseFragment; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.greendao.DaoSession; -import com.casic.dcms.ui.NoticeActivity; +import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.StringHelper; import com.google.gson.Gson; import com.qmuiteam.qmui.recyclerView.QMUIRVItemSwipeAction; import com.qmuiteam.qmui.recyclerView.QMUISwipeAction; @@ -61,8 +64,12 @@ gson = new Gson(); daoSession = BaseApplication.getDaoSession(); swipeViewAdapter = new SwipeViewAdapter(context); - //加载历史数据 - noticeBeans = daoSession.loadAll(NoticeBean.class); + //根据userPhone加载历史数据 + String userPhone = StringHelper.getUserPhone(); + if (TextUtils.isEmpty(userPhone)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserPhone.eq(userPhone)).list(); swipeViewAdapter.setData(noticeBeans); broadcastManager = BroadcastManager.getInstance(context); @@ -118,13 +125,14 @@ swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { @Override public void onClick(int position) { - //查看之后,未读消息变为已读消息 - NoticeBean noticeBean = noticeBeans.get(position); + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = new NoticeBean(); noticeBean.setIsRead("0"); daoSession.update(noticeBean); - Intent intent = new Intent(context, NoticeActivity.class); - intent.putExtra("noticeBeanJson", new Gson().toJson(noticeBean)); + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); startActivity(intent); } }); diff --git a/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java b/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java index 4278463..47a076a 100644 --- a/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/AuthenticationHelper.java @@ -17,12 +17,4 @@ public static String getToken() { return (String) SaveKeyValues.getValue("token", ""); } - - public static void savePushClientID(String clientid) { - SaveKeyValues.putValue("pushClientID", clientid); - } - - public static String getPushClientID() { - return (String) SaveKeyValues.getValue("pushClientID", ""); - } } diff --git a/app/src/main/java/com/casic/dcms/utils/Constant.java b/app/src/main/java/com/casic/dcms/utils/Constant.java index 1ae7b82..f67e68b 100644 --- a/app/src/main/java/com/casic/dcms/utils/Constant.java +++ b/app/src/main/java/com/casic/dcms/utils/Constant.java @@ -49,8 +49,9 @@ public static final double DELTA_LAT_10 = 0.00002256;// 10米范围纬度值偏移量(大约) public static final String IP_KEY = "BASE_IP"; - public static final String LOGIN_OUT_ACTION = "loginOut"; - public static final String NOTICE_MSG = "receivePush"; + public static final String LOGIN_OUT_ACTION = "login_out"; + public static final String NOTICE_MSG = "receive_ush"; + public static final String REGISTER_PUSH = "register_push"; public static final String BASE_MAP_SERVICE_URL = "http://111.198.10.15:13002/arcgis/rest/services/crdt/MapServer";//崇仁城管地图底图 public static final String COMPONENT_SERVICE_URL = "http://111.198.10.15:13002/arcgis/rest/services/crbj/FeatureServer";//崇仁部件图层 diff --git a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java index 8a532f3..f2bc047 100644 --- a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java +++ b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java @@ -427,4 +427,14 @@ @GET("/user/permission") Observable obtainHomePage(@Header("token") String token, @Query("resourceType") String resourceType); + + /** + * 个推推送cid注册 + *

+ * http://111.198.10.15:11409/userPush/register + */ + @FormUrlEncoded + @POST("/userPush/register") + Observable registerPush(@Header("token") String token, + @Field("clientId") String clientId); } diff --git a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java index 5d29f09..23adf26 100644 --- a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java +++ b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java @@ -476,4 +476,13 @@ RetrofitService service = retrofit.create(RetrofitService.class); return service.obtainHomePage(AuthenticationHelper.getToken(), resourceType); } + + /** + * 个推推送cid注册 + */ + public static Observable getRegisterResult(String clientId) { + Retrofit retrofit = createRetrofit(); + RetrofitService service = retrofit.create(RetrofitService.class); + return service.registerPush(AuthenticationHelper.getToken(), clientId); + } } diff --git a/app/src/main/res/layout/activity_analysis.xml b/app/src/main/res/layout/activity_analysis.xml deleted file mode 100644 index aa1aa39..0000000 --- a/app/src/main/res/layout/activity_analysis.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_case_analysis.xml b/app/src/main/res/layout/activity_case_analysis.xml new file mode 100644 index 0000000..aa1aa39 --- /dev/null +++ b/app/src/main/res/layout/activity_case_analysis.xml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_notice.xml b/app/src/main/res/layout/activity_notice.xml deleted file mode 100644 index 06143ff..0000000 --- a/app/src/main/res/layout/activity_notice.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file