diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return id; diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); 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 865787a..fa17e1f 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,12 +1,14 @@ package com.casic.dcms.service; import android.content.Context; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.bean.PushResultBean; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; import com.casic.dcms.utils.StringHelper; @@ -64,6 +66,7 @@ // 通知到达,只有个推通道下发的通知会回调此方法 @Override public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + Log.d(TAG, "onNotificationMessageArrived: " + message.getContent()); /** * appid = DR9oeLL9va6aG3DYXy2w39 * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 @@ -79,8 +82,8 @@ }.getType()); NoticeBean noticeBean = new NoticeBean(); - noticeBean.setUserPhone(StringHelper.getUserPhone()); - noticeBean.setCaseId(resultBean.getId()); + noticeBean.setUserName(StringHelper.getUserName()); + noticeBean.setCaseId(resultBean.getData().getId()); noticeBean.setTitle(resultBean.getTitle()); noticeBean.setContent(resultBean.getContent()); noticeBean.setType(resultBean.getType()); @@ -101,7 +104,10 @@ PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { }.getType()); - String caseId = resultBean.getId(); + String caseId = resultBean.getData().getId(); Log.d(TAG, "onNotificationMessageClicked: " + caseId); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); } } diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); 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 865787a..fa17e1f 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,12 +1,14 @@ package com.casic.dcms.service; import android.content.Context; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.bean.PushResultBean; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; import com.casic.dcms.utils.StringHelper; @@ -64,6 +66,7 @@ // 通知到达,只有个推通道下发的通知会回调此方法 @Override public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + Log.d(TAG, "onNotificationMessageArrived: " + message.getContent()); /** * appid = DR9oeLL9va6aG3DYXy2w39 * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 @@ -79,8 +82,8 @@ }.getType()); NoticeBean noticeBean = new NoticeBean(); - noticeBean.setUserPhone(StringHelper.getUserPhone()); - noticeBean.setCaseId(resultBean.getId()); + noticeBean.setUserName(StringHelper.getUserName()); + noticeBean.setCaseId(resultBean.getData().getId()); noticeBean.setTitle(resultBean.getTitle()); noticeBean.setContent(resultBean.getContent()); noticeBean.setType(resultBean.getType()); @@ -101,7 +104,10 @@ PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { }.getType()); - String caseId = resultBean.getId(); + String caseId = resultBean.getData().getId(); Log.d(TAG, "onNotificationMessageClicked: " + caseId); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); } } 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 db7d9ca..a1bcef6 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -244,8 +244,6 @@ showShopDialog(featureBean.getBgid(), (String) feature.getAttributes().get("Note"), featureBean.getDutyname(), - featureBean.getTel(), - "暂无", String.valueOf(featureBean.getObjectid())); } }); @@ -269,10 +267,10 @@ /** * 三包 */ - private void showShopDialog(String gridId, String communityName, String shopName, String phoneNumber, String shopKeeper, String shopID) { + private void showShopDialog(String gridId, String communityName, String shopName, String shopID) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("已选择商户:" + shopName + "\r\n手机号:" + phoneNumber + "\r\n确认提交?") + .setMessage("已选择商户:" + shopName + "\r\n确认提交?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { @@ -281,8 +279,6 @@ dialog.dismiss(); Intent intent = new Intent(); intent.putExtra("shopName", shopName); - intent.putExtra("phoneNumber", phoneNumber); - intent.putExtra("shopKeeper", shopKeeper); intent.putExtra("shopID", shopID); intent.putExtra("latitude", clickPoint.getY()); intent.putExtra("longitude", clickPoint.getX()); diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); 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 865787a..fa17e1f 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,12 +1,14 @@ package com.casic.dcms.service; import android.content.Context; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.bean.PushResultBean; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; import com.casic.dcms.utils.StringHelper; @@ -64,6 +66,7 @@ // 通知到达,只有个推通道下发的通知会回调此方法 @Override public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + Log.d(TAG, "onNotificationMessageArrived: " + message.getContent()); /** * appid = DR9oeLL9va6aG3DYXy2w39 * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 @@ -79,8 +82,8 @@ }.getType()); NoticeBean noticeBean = new NoticeBean(); - noticeBean.setUserPhone(StringHelper.getUserPhone()); - noticeBean.setCaseId(resultBean.getId()); + noticeBean.setUserName(StringHelper.getUserName()); + noticeBean.setCaseId(resultBean.getData().getId()); noticeBean.setTitle(resultBean.getTitle()); noticeBean.setContent(resultBean.getContent()); noticeBean.setType(resultBean.getType()); @@ -101,7 +104,10 @@ PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { }.getType()); - String caseId = resultBean.getId(); + String caseId = resultBean.getData().getId(); Log.d(TAG, "onNotificationMessageClicked: " + caseId); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); } } 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 db7d9ca..a1bcef6 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -244,8 +244,6 @@ showShopDialog(featureBean.getBgid(), (String) feature.getAttributes().get("Note"), featureBean.getDutyname(), - featureBean.getTel(), - "暂无", String.valueOf(featureBean.getObjectid())); } }); @@ -269,10 +267,10 @@ /** * 三包 */ - private void showShopDialog(String gridId, String communityName, String shopName, String phoneNumber, String shopKeeper, String shopID) { + private void showShopDialog(String gridId, String communityName, String shopName, String shopID) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("已选择商户:" + shopName + "\r\n手机号:" + phoneNumber + "\r\n确认提交?") + .setMessage("已选择商户:" + shopName + "\r\n确认提交?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { @@ -281,8 +279,6 @@ dialog.dismiss(); Intent intent = new Intent(); intent.putExtra("shopName", shopName); - intent.putExtra("phoneNumber", phoneNumber); - intent.putExtra("shopKeeper", shopKeeper); intent.putExtra("shopID", shopID); intent.putExtra("latitude", clickPoint.getY()); intent.putExtra("longitude", clickPoint.getX()); diff --git a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java index 8e43b7e..3fa89ee 100644 --- a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java @@ -155,10 +155,6 @@ PublicKey publicKey = RSAUtils.keyStrToPublicKey(keyString); String userName = userNameView.getText().toString(); String userPassword = userPasswordView.getText().toString(); - if (rememberPasswordView.isChecked()) { - SaveKeyValues.putValue("name", userName); - SaveKeyValues.putValue("password", userPassword); - } if (autoLoginView.isChecked()) { SaveKeyValues.putValue("autoLogin", true); } else { @@ -172,6 +168,10 @@ ToastHelper.showToast("密码不能为空", ToastHelper.WARING); return; } + if (rememberPasswordView.isChecked()) { + SaveKeyValues.putValue("name", userName); + SaveKeyValues.putValue("password", userPassword); + } String dataByPublicKey = RSAUtils.encryptDataByPublicKey(userPassword.getBytes(), publicKey); //登录并获取Token,POST请求 loginPresenter.onReadyRetrofitRequest(userName, dataByPublicKey); diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); 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 865787a..fa17e1f 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,12 +1,14 @@ package com.casic.dcms.service; import android.content.Context; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.bean.PushResultBean; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; import com.casic.dcms.utils.StringHelper; @@ -64,6 +66,7 @@ // 通知到达,只有个推通道下发的通知会回调此方法 @Override public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + Log.d(TAG, "onNotificationMessageArrived: " + message.getContent()); /** * appid = DR9oeLL9va6aG3DYXy2w39 * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 @@ -79,8 +82,8 @@ }.getType()); NoticeBean noticeBean = new NoticeBean(); - noticeBean.setUserPhone(StringHelper.getUserPhone()); - noticeBean.setCaseId(resultBean.getId()); + noticeBean.setUserName(StringHelper.getUserName()); + noticeBean.setCaseId(resultBean.getData().getId()); noticeBean.setTitle(resultBean.getTitle()); noticeBean.setContent(resultBean.getContent()); noticeBean.setType(resultBean.getType()); @@ -101,7 +104,10 @@ PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { }.getType()); - String caseId = resultBean.getId(); + String caseId = resultBean.getData().getId(); Log.d(TAG, "onNotificationMessageClicked: " + caseId); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); } } 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 db7d9ca..a1bcef6 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -244,8 +244,6 @@ showShopDialog(featureBean.getBgid(), (String) feature.getAttributes().get("Note"), featureBean.getDutyname(), - featureBean.getTel(), - "暂无", String.valueOf(featureBean.getObjectid())); } }); @@ -269,10 +267,10 @@ /** * 三包 */ - private void showShopDialog(String gridId, String communityName, String shopName, String phoneNumber, String shopKeeper, String shopID) { + private void showShopDialog(String gridId, String communityName, String shopName, String shopID) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("已选择商户:" + shopName + "\r\n手机号:" + phoneNumber + "\r\n确认提交?") + .setMessage("已选择商户:" + shopName + "\r\n确认提交?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { @@ -281,8 +279,6 @@ dialog.dismiss(); Intent intent = new Intent(); intent.putExtra("shopName", shopName); - intent.putExtra("phoneNumber", phoneNumber); - intent.putExtra("shopKeeper", shopKeeper); intent.putExtra("shopID", shopID); intent.putExtra("latitude", clickPoint.getY()); intent.putExtra("longitude", clickPoint.getX()); diff --git a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java index 8e43b7e..3fa89ee 100644 --- a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java @@ -155,10 +155,6 @@ PublicKey publicKey = RSAUtils.keyStrToPublicKey(keyString); String userName = userNameView.getText().toString(); String userPassword = userPasswordView.getText().toString(); - if (rememberPasswordView.isChecked()) { - SaveKeyValues.putValue("name", userName); - SaveKeyValues.putValue("password", userPassword); - } if (autoLoginView.isChecked()) { SaveKeyValues.putValue("autoLogin", true); } else { @@ -172,6 +168,10 @@ ToastHelper.showToast("密码不能为空", ToastHelper.WARING); return; } + if (rememberPasswordView.isChecked()) { + SaveKeyValues.putValue("name", userName); + SaveKeyValues.putValue("password", userPassword); + } String dataByPublicKey = RSAUtils.encryptDataByPublicKey(userPassword.getBytes(), publicKey); //登录并获取Token,POST请求 loginPresenter.onReadyRetrofitRequest(userName, dataByPublicKey); diff --git a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java index dc5fc67..dad0718 100644 --- a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java @@ -56,6 +56,10 @@ EditText longitudeView; @BindView(R.id.latitudeView) EditText latitudeView; + @BindView(R.id.shopKeeperView) + EditText shopKeeperView; + @BindView(R.id.phoneNumberView) + EditText phoneNumberView; @BindView(R.id.caseLocationView) EditText caseLocationView; @BindView(R.id.caseDetailEditView) @@ -73,7 +77,7 @@ private QMUITipDialog submitDialog; private List realPaths = new ArrayList<>();//真是图片路径 private List mediaList = new ArrayList<>();//上传到服务器的数据集 - private String gridId, shopKeeper, phoneNumber, shopID; + private String gridId, shopID; @Override public int initLayoutView() { @@ -187,8 +191,6 @@ gridId = data.getStringExtra("gridId"); String community = data.getStringExtra("community"); String shopName = data.getStringExtra("shopName"); - phoneNumber = data.getStringExtra("phoneNumber"); - shopKeeper = data.getStringExtra("shopKeeper"); shopID = data.getStringExtra("shopID"); longitudeView.setText(String.valueOf(longitude)); @@ -212,28 +214,41 @@ ToastHelper.showToast("经纬度异常,请重新选择位置", ToastHelper.WARING); return; } - - String fieldIntro = caseLocationView.getText().toString(); - if (TextUtils.isEmpty(fieldIntro)) { - ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + String shopKeeper = shopKeeperView.getText().toString(); + if (TextUtils.isEmpty(shopKeeper)) { + ToastHelper.showToast("店主名还未填写", ToastHelper.WARING); return; } - String description = caseDetailEditView.getText().toString(); - if (TextUtils.isEmpty(description)) { - ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + String phoneNumber = phoneNumberView.getText().toString(); + if (TextUtils.isEmpty(phoneNumber)) { + ToastHelper.showToast("电话号码还未填写", ToastHelper.WARING); return; } - if (mediaList.size() != 2) { - ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); - return; + if (StringHelper.isPhoneNumber(phoneNumber)) { + String fieldIntro = caseLocationView.getText().toString(); + if (TextUtils.isEmpty(fieldIntro)) { + ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + return; + } + String description = caseDetailEditView.getText().toString(); + if (TextUtils.isEmpty(description)) { + ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + return; + } + if (mediaList.size() != 2) { + ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); + return; + } + shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, + "2", "1", + gridId.substring(0, 6), + gridId.substring(0, 9), + gridId.substring(0, 12), + gridId, description, fieldIntro, + StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); + } else { + ToastHelper.showToast("电话号码格式不对", ToastHelper.WARING); } - shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, - "2", "1", - gridId.substring(0, 6), - gridId.substring(0, 9), - gridId.substring(0, 12), - gridId, description, fieldIntro, - StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); } @Override diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); 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 865787a..fa17e1f 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,12 +1,14 @@ package com.casic.dcms.service; import android.content.Context; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.bean.PushResultBean; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; import com.casic.dcms.utils.StringHelper; @@ -64,6 +66,7 @@ // 通知到达,只有个推通道下发的通知会回调此方法 @Override public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + Log.d(TAG, "onNotificationMessageArrived: " + message.getContent()); /** * appid = DR9oeLL9va6aG3DYXy2w39 * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 @@ -79,8 +82,8 @@ }.getType()); NoticeBean noticeBean = new NoticeBean(); - noticeBean.setUserPhone(StringHelper.getUserPhone()); - noticeBean.setCaseId(resultBean.getId()); + noticeBean.setUserName(StringHelper.getUserName()); + noticeBean.setCaseId(resultBean.getData().getId()); noticeBean.setTitle(resultBean.getTitle()); noticeBean.setContent(resultBean.getContent()); noticeBean.setType(resultBean.getType()); @@ -101,7 +104,10 @@ PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { }.getType()); - String caseId = resultBean.getId(); + String caseId = resultBean.getData().getId(); Log.d(TAG, "onNotificationMessageClicked: " + caseId); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); } } 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 db7d9ca..a1bcef6 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -244,8 +244,6 @@ showShopDialog(featureBean.getBgid(), (String) feature.getAttributes().get("Note"), featureBean.getDutyname(), - featureBean.getTel(), - "暂无", String.valueOf(featureBean.getObjectid())); } }); @@ -269,10 +267,10 @@ /** * 三包 */ - private void showShopDialog(String gridId, String communityName, String shopName, String phoneNumber, String shopKeeper, String shopID) { + private void showShopDialog(String gridId, String communityName, String shopName, String shopID) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("已选择商户:" + shopName + "\r\n手机号:" + phoneNumber + "\r\n确认提交?") + .setMessage("已选择商户:" + shopName + "\r\n确认提交?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { @@ -281,8 +279,6 @@ dialog.dismiss(); Intent intent = new Intent(); intent.putExtra("shopName", shopName); - intent.putExtra("phoneNumber", phoneNumber); - intent.putExtra("shopKeeper", shopKeeper); intent.putExtra("shopID", shopID); intent.putExtra("latitude", clickPoint.getY()); intent.putExtra("longitude", clickPoint.getX()); diff --git a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java index 8e43b7e..3fa89ee 100644 --- a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java @@ -155,10 +155,6 @@ PublicKey publicKey = RSAUtils.keyStrToPublicKey(keyString); String userName = userNameView.getText().toString(); String userPassword = userPasswordView.getText().toString(); - if (rememberPasswordView.isChecked()) { - SaveKeyValues.putValue("name", userName); - SaveKeyValues.putValue("password", userPassword); - } if (autoLoginView.isChecked()) { SaveKeyValues.putValue("autoLogin", true); } else { @@ -172,6 +168,10 @@ ToastHelper.showToast("密码不能为空", ToastHelper.WARING); return; } + if (rememberPasswordView.isChecked()) { + SaveKeyValues.putValue("name", userName); + SaveKeyValues.putValue("password", userPassword); + } String dataByPublicKey = RSAUtils.encryptDataByPublicKey(userPassword.getBytes(), publicKey); //登录并获取Token,POST请求 loginPresenter.onReadyRetrofitRequest(userName, dataByPublicKey); diff --git a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java index dc5fc67..dad0718 100644 --- a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java @@ -56,6 +56,10 @@ EditText longitudeView; @BindView(R.id.latitudeView) EditText latitudeView; + @BindView(R.id.shopKeeperView) + EditText shopKeeperView; + @BindView(R.id.phoneNumberView) + EditText phoneNumberView; @BindView(R.id.caseLocationView) EditText caseLocationView; @BindView(R.id.caseDetailEditView) @@ -73,7 +77,7 @@ private QMUITipDialog submitDialog; private List realPaths = new ArrayList<>();//真是图片路径 private List mediaList = new ArrayList<>();//上传到服务器的数据集 - private String gridId, shopKeeper, phoneNumber, shopID; + private String gridId, shopID; @Override public int initLayoutView() { @@ -187,8 +191,6 @@ gridId = data.getStringExtra("gridId"); String community = data.getStringExtra("community"); String shopName = data.getStringExtra("shopName"); - phoneNumber = data.getStringExtra("phoneNumber"); - shopKeeper = data.getStringExtra("shopKeeper"); shopID = data.getStringExtra("shopID"); longitudeView.setText(String.valueOf(longitude)); @@ -212,28 +214,41 @@ ToastHelper.showToast("经纬度异常,请重新选择位置", ToastHelper.WARING); return; } - - String fieldIntro = caseLocationView.getText().toString(); - if (TextUtils.isEmpty(fieldIntro)) { - ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + String shopKeeper = shopKeeperView.getText().toString(); + if (TextUtils.isEmpty(shopKeeper)) { + ToastHelper.showToast("店主名还未填写", ToastHelper.WARING); return; } - String description = caseDetailEditView.getText().toString(); - if (TextUtils.isEmpty(description)) { - ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + String phoneNumber = phoneNumberView.getText().toString(); + if (TextUtils.isEmpty(phoneNumber)) { + ToastHelper.showToast("电话号码还未填写", ToastHelper.WARING); return; } - if (mediaList.size() != 2) { - ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); - return; + if (StringHelper.isPhoneNumber(phoneNumber)) { + String fieldIntro = caseLocationView.getText().toString(); + if (TextUtils.isEmpty(fieldIntro)) { + ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + return; + } + String description = caseDetailEditView.getText().toString(); + if (TextUtils.isEmpty(description)) { + ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + return; + } + if (mediaList.size() != 2) { + ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); + return; + } + shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, + "2", "1", + gridId.substring(0, 6), + gridId.substring(0, 9), + gridId.substring(0, 12), + gridId, description, fieldIntro, + StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); + } else { + ToastHelper.showToast("电话号码格式不对", ToastHelper.WARING); } - shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, - "2", "1", - gridId.substring(0, 6), - gridId.substring(0, 9), - gridId.substring(0, 12), - gridId, description, fieldIntro, - StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); } @Override 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 index 192b702..708f2a8 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -1,16 +1,30 @@ package com.casic.dcms.ui.fragment; +import android.content.BroadcastReceiver; import android.content.Context; -import android.widget.LinearLayout; +import android.content.Intent; +import android.text.TextUtils; +import android.view.ViewGroup; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.adapter.SwipeViewAdapter; +import com.casic.dcms.base.BaseApplication; import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; +import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.greendao.DaoSession; +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; import java.util.ArrayList; import java.util.List; @@ -19,17 +33,19 @@ public class NoticePageFragment extends BaseFragment { - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; + @BindView(R.id.swipeRecyclerView) + RecyclerView swipeRecyclerView; private Context context; + private List noticeBeans = new ArrayList<>(); + private SwipeViewAdapter swipeViewAdapter; + private BroadcastManager broadcastManager; + private Gson gson; + private DaoSession daoSession; @Override protected int initLayoutView() { - return R.layout.fragment_dashboard; + return R.layout.fragment_notice; } @Override @@ -39,20 +55,90 @@ @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)); + gson = new Gson(); + daoSession = BaseApplication.getDaoSession(); + swipeViewAdapter = new SwipeViewAdapter(context); + //根据userName加载历史数据 + String userName = StringHelper.getUserName(); + if (TextUtils.isEmpty(userName)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserName.eq(userName)).list(); + swipeViewAdapter.setData(noticeBeans); + + broadcastManager = BroadcastManager.getInstance(context); + broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + if (Constant.NOTICE_MSG.equals(action)) { + String data = intent.getStringExtra("data"); + assert data != null; + NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); + noticeBeans.add(noticeBean); + //更新数据 + swipeViewAdapter.setData(noticeBeans); + } + } + } + }); } @Override protected void initEvent() { + QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { + @Override + public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { + int position = viewHolder.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + @Override + public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { + return QMUIRVItemSwipeAction.SWIPE_LEFT; + } + + @Override + public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { + super.onClickAction(swipeAction, selected, action); + int position = selected.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + }); + swipeAction.attachToRecyclerView(swipeRecyclerView); + swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { + @Override + public RecyclerView.LayoutParams generateDefaultLayoutParams() { + return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + } + }); + swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); + swipeRecyclerView.setAdapter(swipeViewAdapter); + swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { + @Override + public void onClick(int position) { + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = noticeBeans.get(position); + noticeBean.setIsRead("0"); + daoSession.update(noticeBean); + swipeViewAdapter.notifyDataSetChanged(); + + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); + } + }); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (broadcastManager != null) { + broadcastManager.destroy(Constant.NOTICE_MSG); + } } } diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); 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 865787a..fa17e1f 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,12 +1,14 @@ package com.casic.dcms.service; import android.content.Context; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.bean.PushResultBean; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; import com.casic.dcms.utils.StringHelper; @@ -64,6 +66,7 @@ // 通知到达,只有个推通道下发的通知会回调此方法 @Override public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + Log.d(TAG, "onNotificationMessageArrived: " + message.getContent()); /** * appid = DR9oeLL9va6aG3DYXy2w39 * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 @@ -79,8 +82,8 @@ }.getType()); NoticeBean noticeBean = new NoticeBean(); - noticeBean.setUserPhone(StringHelper.getUserPhone()); - noticeBean.setCaseId(resultBean.getId()); + noticeBean.setUserName(StringHelper.getUserName()); + noticeBean.setCaseId(resultBean.getData().getId()); noticeBean.setTitle(resultBean.getTitle()); noticeBean.setContent(resultBean.getContent()); noticeBean.setType(resultBean.getType()); @@ -101,7 +104,10 @@ PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { }.getType()); - String caseId = resultBean.getId(); + String caseId = resultBean.getData().getId(); Log.d(TAG, "onNotificationMessageClicked: " + caseId); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); } } 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 db7d9ca..a1bcef6 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -244,8 +244,6 @@ showShopDialog(featureBean.getBgid(), (String) feature.getAttributes().get("Note"), featureBean.getDutyname(), - featureBean.getTel(), - "暂无", String.valueOf(featureBean.getObjectid())); } }); @@ -269,10 +267,10 @@ /** * 三包 */ - private void showShopDialog(String gridId, String communityName, String shopName, String phoneNumber, String shopKeeper, String shopID) { + private void showShopDialog(String gridId, String communityName, String shopName, String shopID) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("已选择商户:" + shopName + "\r\n手机号:" + phoneNumber + "\r\n确认提交?") + .setMessage("已选择商户:" + shopName + "\r\n确认提交?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { @@ -281,8 +279,6 @@ dialog.dismiss(); Intent intent = new Intent(); intent.putExtra("shopName", shopName); - intent.putExtra("phoneNumber", phoneNumber); - intent.putExtra("shopKeeper", shopKeeper); intent.putExtra("shopID", shopID); intent.putExtra("latitude", clickPoint.getY()); intent.putExtra("longitude", clickPoint.getX()); diff --git a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java index 8e43b7e..3fa89ee 100644 --- a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java @@ -155,10 +155,6 @@ PublicKey publicKey = RSAUtils.keyStrToPublicKey(keyString); String userName = userNameView.getText().toString(); String userPassword = userPasswordView.getText().toString(); - if (rememberPasswordView.isChecked()) { - SaveKeyValues.putValue("name", userName); - SaveKeyValues.putValue("password", userPassword); - } if (autoLoginView.isChecked()) { SaveKeyValues.putValue("autoLogin", true); } else { @@ -172,6 +168,10 @@ ToastHelper.showToast("密码不能为空", ToastHelper.WARING); return; } + if (rememberPasswordView.isChecked()) { + SaveKeyValues.putValue("name", userName); + SaveKeyValues.putValue("password", userPassword); + } String dataByPublicKey = RSAUtils.encryptDataByPublicKey(userPassword.getBytes(), publicKey); //登录并获取Token,POST请求 loginPresenter.onReadyRetrofitRequest(userName, dataByPublicKey); diff --git a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java index dc5fc67..dad0718 100644 --- a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java @@ -56,6 +56,10 @@ EditText longitudeView; @BindView(R.id.latitudeView) EditText latitudeView; + @BindView(R.id.shopKeeperView) + EditText shopKeeperView; + @BindView(R.id.phoneNumberView) + EditText phoneNumberView; @BindView(R.id.caseLocationView) EditText caseLocationView; @BindView(R.id.caseDetailEditView) @@ -73,7 +77,7 @@ private QMUITipDialog submitDialog; private List realPaths = new ArrayList<>();//真是图片路径 private List mediaList = new ArrayList<>();//上传到服务器的数据集 - private String gridId, shopKeeper, phoneNumber, shopID; + private String gridId, shopID; @Override public int initLayoutView() { @@ -187,8 +191,6 @@ gridId = data.getStringExtra("gridId"); String community = data.getStringExtra("community"); String shopName = data.getStringExtra("shopName"); - phoneNumber = data.getStringExtra("phoneNumber"); - shopKeeper = data.getStringExtra("shopKeeper"); shopID = data.getStringExtra("shopID"); longitudeView.setText(String.valueOf(longitude)); @@ -212,28 +214,41 @@ ToastHelper.showToast("经纬度异常,请重新选择位置", ToastHelper.WARING); return; } - - String fieldIntro = caseLocationView.getText().toString(); - if (TextUtils.isEmpty(fieldIntro)) { - ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + String shopKeeper = shopKeeperView.getText().toString(); + if (TextUtils.isEmpty(shopKeeper)) { + ToastHelper.showToast("店主名还未填写", ToastHelper.WARING); return; } - String description = caseDetailEditView.getText().toString(); - if (TextUtils.isEmpty(description)) { - ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + String phoneNumber = phoneNumberView.getText().toString(); + if (TextUtils.isEmpty(phoneNumber)) { + ToastHelper.showToast("电话号码还未填写", ToastHelper.WARING); return; } - if (mediaList.size() != 2) { - ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); - return; + if (StringHelper.isPhoneNumber(phoneNumber)) { + String fieldIntro = caseLocationView.getText().toString(); + if (TextUtils.isEmpty(fieldIntro)) { + ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + return; + } + String description = caseDetailEditView.getText().toString(); + if (TextUtils.isEmpty(description)) { + ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + return; + } + if (mediaList.size() != 2) { + ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); + return; + } + shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, + "2", "1", + gridId.substring(0, 6), + gridId.substring(0, 9), + gridId.substring(0, 12), + gridId, description, fieldIntro, + StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); + } else { + ToastHelper.showToast("电话号码格式不对", ToastHelper.WARING); } - shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, - "2", "1", - gridId.substring(0, 6), - gridId.substring(0, 9), - gridId.substring(0, 12), - gridId, description, fieldIntro, - StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); } @Override 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 index 192b702..708f2a8 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -1,16 +1,30 @@ package com.casic.dcms.ui.fragment; +import android.content.BroadcastReceiver; import android.content.Context; -import android.widget.LinearLayout; +import android.content.Intent; +import android.text.TextUtils; +import android.view.ViewGroup; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.adapter.SwipeViewAdapter; +import com.casic.dcms.base.BaseApplication; import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; +import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.greendao.DaoSession; +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; import java.util.ArrayList; import java.util.List; @@ -19,17 +33,19 @@ public class NoticePageFragment extends BaseFragment { - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; + @BindView(R.id.swipeRecyclerView) + RecyclerView swipeRecyclerView; private Context context; + private List noticeBeans = new ArrayList<>(); + private SwipeViewAdapter swipeViewAdapter; + private BroadcastManager broadcastManager; + private Gson gson; + private DaoSession daoSession; @Override protected int initLayoutView() { - return R.layout.fragment_dashboard; + return R.layout.fragment_notice; } @Override @@ -39,20 +55,90 @@ @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)); + gson = new Gson(); + daoSession = BaseApplication.getDaoSession(); + swipeViewAdapter = new SwipeViewAdapter(context); + //根据userName加载历史数据 + String userName = StringHelper.getUserName(); + if (TextUtils.isEmpty(userName)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserName.eq(userName)).list(); + swipeViewAdapter.setData(noticeBeans); + + broadcastManager = BroadcastManager.getInstance(context); + broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + if (Constant.NOTICE_MSG.equals(action)) { + String data = intent.getStringExtra("data"); + assert data != null; + NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); + noticeBeans.add(noticeBean); + //更新数据 + swipeViewAdapter.setData(noticeBeans); + } + } + } + }); } @Override protected void initEvent() { + QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { + @Override + public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { + int position = viewHolder.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + @Override + public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { + return QMUIRVItemSwipeAction.SWIPE_LEFT; + } + + @Override + public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { + super.onClickAction(swipeAction, selected, action); + int position = selected.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + }); + swipeAction.attachToRecyclerView(swipeRecyclerView); + swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { + @Override + public RecyclerView.LayoutParams generateDefaultLayoutParams() { + return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + } + }); + swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); + swipeRecyclerView.setAdapter(swipeViewAdapter); + swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { + @Override + public void onClick(int position) { + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = noticeBeans.get(position); + noticeBean.setIsRead("0"); + daoSession.update(noticeBean); + swipeViewAdapter.notifyDataSetChanged(); + + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); + } + }); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (broadcastManager != null) { + broadcastManager.destroy(Constant.NOTICE_MSG); + } } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java deleted file mode 100644 index 7b1e1fb..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class ReadFragment extends BaseFragment { - @Override - protected int initLayoutView() { - return R.layout.fragment_read; - } - - @Override - protected void setupTopBarLayout() { - - } - - @Override - protected void initData() { - - } - - @Override - protected void initEvent() { - - } -} diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); 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 865787a..fa17e1f 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,12 +1,14 @@ package com.casic.dcms.service; import android.content.Context; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.bean.PushResultBean; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; import com.casic.dcms.utils.StringHelper; @@ -64,6 +66,7 @@ // 通知到达,只有个推通道下发的通知会回调此方法 @Override public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + Log.d(TAG, "onNotificationMessageArrived: " + message.getContent()); /** * appid = DR9oeLL9va6aG3DYXy2w39 * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 @@ -79,8 +82,8 @@ }.getType()); NoticeBean noticeBean = new NoticeBean(); - noticeBean.setUserPhone(StringHelper.getUserPhone()); - noticeBean.setCaseId(resultBean.getId()); + noticeBean.setUserName(StringHelper.getUserName()); + noticeBean.setCaseId(resultBean.getData().getId()); noticeBean.setTitle(resultBean.getTitle()); noticeBean.setContent(resultBean.getContent()); noticeBean.setType(resultBean.getType()); @@ -101,7 +104,10 @@ PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { }.getType()); - String caseId = resultBean.getId(); + String caseId = resultBean.getData().getId(); Log.d(TAG, "onNotificationMessageClicked: " + caseId); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); } } 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 db7d9ca..a1bcef6 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -244,8 +244,6 @@ showShopDialog(featureBean.getBgid(), (String) feature.getAttributes().get("Note"), featureBean.getDutyname(), - featureBean.getTel(), - "暂无", String.valueOf(featureBean.getObjectid())); } }); @@ -269,10 +267,10 @@ /** * 三包 */ - private void showShopDialog(String gridId, String communityName, String shopName, String phoneNumber, String shopKeeper, String shopID) { + private void showShopDialog(String gridId, String communityName, String shopName, String shopID) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("已选择商户:" + shopName + "\r\n手机号:" + phoneNumber + "\r\n确认提交?") + .setMessage("已选择商户:" + shopName + "\r\n确认提交?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { @@ -281,8 +279,6 @@ dialog.dismiss(); Intent intent = new Intent(); intent.putExtra("shopName", shopName); - intent.putExtra("phoneNumber", phoneNumber); - intent.putExtra("shopKeeper", shopKeeper); intent.putExtra("shopID", shopID); intent.putExtra("latitude", clickPoint.getY()); intent.putExtra("longitude", clickPoint.getX()); diff --git a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java index 8e43b7e..3fa89ee 100644 --- a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java @@ -155,10 +155,6 @@ PublicKey publicKey = RSAUtils.keyStrToPublicKey(keyString); String userName = userNameView.getText().toString(); String userPassword = userPasswordView.getText().toString(); - if (rememberPasswordView.isChecked()) { - SaveKeyValues.putValue("name", userName); - SaveKeyValues.putValue("password", userPassword); - } if (autoLoginView.isChecked()) { SaveKeyValues.putValue("autoLogin", true); } else { @@ -172,6 +168,10 @@ ToastHelper.showToast("密码不能为空", ToastHelper.WARING); return; } + if (rememberPasswordView.isChecked()) { + SaveKeyValues.putValue("name", userName); + SaveKeyValues.putValue("password", userPassword); + } String dataByPublicKey = RSAUtils.encryptDataByPublicKey(userPassword.getBytes(), publicKey); //登录并获取Token,POST请求 loginPresenter.onReadyRetrofitRequest(userName, dataByPublicKey); diff --git a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java index dc5fc67..dad0718 100644 --- a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java @@ -56,6 +56,10 @@ EditText longitudeView; @BindView(R.id.latitudeView) EditText latitudeView; + @BindView(R.id.shopKeeperView) + EditText shopKeeperView; + @BindView(R.id.phoneNumberView) + EditText phoneNumberView; @BindView(R.id.caseLocationView) EditText caseLocationView; @BindView(R.id.caseDetailEditView) @@ -73,7 +77,7 @@ private QMUITipDialog submitDialog; private List realPaths = new ArrayList<>();//真是图片路径 private List mediaList = new ArrayList<>();//上传到服务器的数据集 - private String gridId, shopKeeper, phoneNumber, shopID; + private String gridId, shopID; @Override public int initLayoutView() { @@ -187,8 +191,6 @@ gridId = data.getStringExtra("gridId"); String community = data.getStringExtra("community"); String shopName = data.getStringExtra("shopName"); - phoneNumber = data.getStringExtra("phoneNumber"); - shopKeeper = data.getStringExtra("shopKeeper"); shopID = data.getStringExtra("shopID"); longitudeView.setText(String.valueOf(longitude)); @@ -212,28 +214,41 @@ ToastHelper.showToast("经纬度异常,请重新选择位置", ToastHelper.WARING); return; } - - String fieldIntro = caseLocationView.getText().toString(); - if (TextUtils.isEmpty(fieldIntro)) { - ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + String shopKeeper = shopKeeperView.getText().toString(); + if (TextUtils.isEmpty(shopKeeper)) { + ToastHelper.showToast("店主名还未填写", ToastHelper.WARING); return; } - String description = caseDetailEditView.getText().toString(); - if (TextUtils.isEmpty(description)) { - ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + String phoneNumber = phoneNumberView.getText().toString(); + if (TextUtils.isEmpty(phoneNumber)) { + ToastHelper.showToast("电话号码还未填写", ToastHelper.WARING); return; } - if (mediaList.size() != 2) { - ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); - return; + if (StringHelper.isPhoneNumber(phoneNumber)) { + String fieldIntro = caseLocationView.getText().toString(); + if (TextUtils.isEmpty(fieldIntro)) { + ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + return; + } + String description = caseDetailEditView.getText().toString(); + if (TextUtils.isEmpty(description)) { + ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + return; + } + if (mediaList.size() != 2) { + ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); + return; + } + shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, + "2", "1", + gridId.substring(0, 6), + gridId.substring(0, 9), + gridId.substring(0, 12), + gridId, description, fieldIntro, + StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); + } else { + ToastHelper.showToast("电话号码格式不对", ToastHelper.WARING); } - shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, - "2", "1", - gridId.substring(0, 6), - gridId.substring(0, 9), - gridId.substring(0, 12), - gridId, description, fieldIntro, - StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); } @Override 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 index 192b702..708f2a8 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -1,16 +1,30 @@ package com.casic.dcms.ui.fragment; +import android.content.BroadcastReceiver; import android.content.Context; -import android.widget.LinearLayout; +import android.content.Intent; +import android.text.TextUtils; +import android.view.ViewGroup; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.adapter.SwipeViewAdapter; +import com.casic.dcms.base.BaseApplication; import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; +import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.greendao.DaoSession; +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; import java.util.ArrayList; import java.util.List; @@ -19,17 +33,19 @@ public class NoticePageFragment extends BaseFragment { - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; + @BindView(R.id.swipeRecyclerView) + RecyclerView swipeRecyclerView; private Context context; + private List noticeBeans = new ArrayList<>(); + private SwipeViewAdapter swipeViewAdapter; + private BroadcastManager broadcastManager; + private Gson gson; + private DaoSession daoSession; @Override protected int initLayoutView() { - return R.layout.fragment_dashboard; + return R.layout.fragment_notice; } @Override @@ -39,20 +55,90 @@ @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)); + gson = new Gson(); + daoSession = BaseApplication.getDaoSession(); + swipeViewAdapter = new SwipeViewAdapter(context); + //根据userName加载历史数据 + String userName = StringHelper.getUserName(); + if (TextUtils.isEmpty(userName)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserName.eq(userName)).list(); + swipeViewAdapter.setData(noticeBeans); + + broadcastManager = BroadcastManager.getInstance(context); + broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + if (Constant.NOTICE_MSG.equals(action)) { + String data = intent.getStringExtra("data"); + assert data != null; + NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); + noticeBeans.add(noticeBean); + //更新数据 + swipeViewAdapter.setData(noticeBeans); + } + } + } + }); } @Override protected void initEvent() { + QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { + @Override + public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { + int position = viewHolder.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + @Override + public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { + return QMUIRVItemSwipeAction.SWIPE_LEFT; + } + + @Override + public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { + super.onClickAction(swipeAction, selected, action); + int position = selected.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + }); + swipeAction.attachToRecyclerView(swipeRecyclerView); + swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { + @Override + public RecyclerView.LayoutParams generateDefaultLayoutParams() { + return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + } + }); + swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); + swipeRecyclerView.setAdapter(swipeViewAdapter); + swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { + @Override + public void onClick(int position) { + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = noticeBeans.get(position); + noticeBean.setIsRead("0"); + daoSession.update(noticeBean); + swipeViewAdapter.notifyDataSetChanged(); + + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); + } + }); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (broadcastManager != null) { + broadcastManager.destroy(Constant.NOTICE_MSG); + } } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java deleted file mode 100644 index 7b1e1fb..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class ReadFragment extends BaseFragment { - @Override - protected int initLayoutView() { - return R.layout.fragment_read; - } - - @Override - protected void setupTopBarLayout() { - - } - - @Override - protected void initData() { - - } - - @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 deleted file mode 100644 index a0afe0f..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.text.TextUtils; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.DividerItemDecoration; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SwipeViewAdapter; -import com.casic.dcms.base.BaseApplication; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.greendao.DaoSession; -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; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class UnreadFragment extends BaseFragment { - - private static final String TAG = "UnreadFragment"; - @BindView(R.id.swipeRecyclerView) - RecyclerView swipeRecyclerView; - - private Context context; - private List noticeBeans = new ArrayList<>(); - private SwipeViewAdapter swipeViewAdapter; - private BroadcastManager broadcastManager; - private Gson gson; - private DaoSession daoSession; - - @Override - protected int initLayoutView() { - return R.layout.fragment_unread; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - gson = new Gson(); - daoSession = BaseApplication.getDaoSession(); - swipeViewAdapter = new SwipeViewAdapter(context); - //根据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); - broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.NOTICE_MSG.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); - noticeBeans.add(noticeBean); - //更新数据 - swipeViewAdapter.setData(noticeBeans); - } - } - } - }); - } - - protected void initEvent() { - QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { - @Override - public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { - int position = viewHolder.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - - @Override - public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { - return QMUIRVItemSwipeAction.SWIPE_LEFT; - } - - @Override - public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { - super.onClickAction(swipeAction, selected, action); - int position = selected.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - }); - swipeAction.attachToRecyclerView(swipeRecyclerView); - swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { - @Override - public RecyclerView.LayoutParams generateDefaultLayoutParams() { - return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - } - }); - swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); - swipeRecyclerView.setAdapter(swipeViewAdapter); - swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { - @Override - public void onClick(int position) { - //点击之后之后,未读消息变为已读消息 - NoticeBean noticeBean = new NoticeBean(); - noticeBean.setIsRead("0"); - daoSession.update(noticeBean); - - String caseId = noticeBeans.get(position).getCaseId(); - Intent intent = new Intent(context, CaseDetailActivity.class); - intent.putExtra("id", caseId); - startActivity(intent); - } - }); - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - broadcastManager.destroy(Constant.NOTICE_MSG); - } -} diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); 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 865787a..fa17e1f 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,12 +1,14 @@ package com.casic.dcms.service; import android.content.Context; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.bean.PushResultBean; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; import com.casic.dcms.utils.StringHelper; @@ -64,6 +66,7 @@ // 通知到达,只有个推通道下发的通知会回调此方法 @Override public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + Log.d(TAG, "onNotificationMessageArrived: " + message.getContent()); /** * appid = DR9oeLL9va6aG3DYXy2w39 * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 @@ -79,8 +82,8 @@ }.getType()); NoticeBean noticeBean = new NoticeBean(); - noticeBean.setUserPhone(StringHelper.getUserPhone()); - noticeBean.setCaseId(resultBean.getId()); + noticeBean.setUserName(StringHelper.getUserName()); + noticeBean.setCaseId(resultBean.getData().getId()); noticeBean.setTitle(resultBean.getTitle()); noticeBean.setContent(resultBean.getContent()); noticeBean.setType(resultBean.getType()); @@ -101,7 +104,10 @@ PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { }.getType()); - String caseId = resultBean.getId(); + String caseId = resultBean.getData().getId(); Log.d(TAG, "onNotificationMessageClicked: " + caseId); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); } } 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 db7d9ca..a1bcef6 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -244,8 +244,6 @@ showShopDialog(featureBean.getBgid(), (String) feature.getAttributes().get("Note"), featureBean.getDutyname(), - featureBean.getTel(), - "暂无", String.valueOf(featureBean.getObjectid())); } }); @@ -269,10 +267,10 @@ /** * 三包 */ - private void showShopDialog(String gridId, String communityName, String shopName, String phoneNumber, String shopKeeper, String shopID) { + private void showShopDialog(String gridId, String communityName, String shopName, String shopID) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("已选择商户:" + shopName + "\r\n手机号:" + phoneNumber + "\r\n确认提交?") + .setMessage("已选择商户:" + shopName + "\r\n确认提交?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { @@ -281,8 +279,6 @@ dialog.dismiss(); Intent intent = new Intent(); intent.putExtra("shopName", shopName); - intent.putExtra("phoneNumber", phoneNumber); - intent.putExtra("shopKeeper", shopKeeper); intent.putExtra("shopID", shopID); intent.putExtra("latitude", clickPoint.getY()); intent.putExtra("longitude", clickPoint.getX()); diff --git a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java index 8e43b7e..3fa89ee 100644 --- a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java @@ -155,10 +155,6 @@ PublicKey publicKey = RSAUtils.keyStrToPublicKey(keyString); String userName = userNameView.getText().toString(); String userPassword = userPasswordView.getText().toString(); - if (rememberPasswordView.isChecked()) { - SaveKeyValues.putValue("name", userName); - SaveKeyValues.putValue("password", userPassword); - } if (autoLoginView.isChecked()) { SaveKeyValues.putValue("autoLogin", true); } else { @@ -172,6 +168,10 @@ ToastHelper.showToast("密码不能为空", ToastHelper.WARING); return; } + if (rememberPasswordView.isChecked()) { + SaveKeyValues.putValue("name", userName); + SaveKeyValues.putValue("password", userPassword); + } String dataByPublicKey = RSAUtils.encryptDataByPublicKey(userPassword.getBytes(), publicKey); //登录并获取Token,POST请求 loginPresenter.onReadyRetrofitRequest(userName, dataByPublicKey); diff --git a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java index dc5fc67..dad0718 100644 --- a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java @@ -56,6 +56,10 @@ EditText longitudeView; @BindView(R.id.latitudeView) EditText latitudeView; + @BindView(R.id.shopKeeperView) + EditText shopKeeperView; + @BindView(R.id.phoneNumberView) + EditText phoneNumberView; @BindView(R.id.caseLocationView) EditText caseLocationView; @BindView(R.id.caseDetailEditView) @@ -73,7 +77,7 @@ private QMUITipDialog submitDialog; private List realPaths = new ArrayList<>();//真是图片路径 private List mediaList = new ArrayList<>();//上传到服务器的数据集 - private String gridId, shopKeeper, phoneNumber, shopID; + private String gridId, shopID; @Override public int initLayoutView() { @@ -187,8 +191,6 @@ gridId = data.getStringExtra("gridId"); String community = data.getStringExtra("community"); String shopName = data.getStringExtra("shopName"); - phoneNumber = data.getStringExtra("phoneNumber"); - shopKeeper = data.getStringExtra("shopKeeper"); shopID = data.getStringExtra("shopID"); longitudeView.setText(String.valueOf(longitude)); @@ -212,28 +214,41 @@ ToastHelper.showToast("经纬度异常,请重新选择位置", ToastHelper.WARING); return; } - - String fieldIntro = caseLocationView.getText().toString(); - if (TextUtils.isEmpty(fieldIntro)) { - ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + String shopKeeper = shopKeeperView.getText().toString(); + if (TextUtils.isEmpty(shopKeeper)) { + ToastHelper.showToast("店主名还未填写", ToastHelper.WARING); return; } - String description = caseDetailEditView.getText().toString(); - if (TextUtils.isEmpty(description)) { - ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + String phoneNumber = phoneNumberView.getText().toString(); + if (TextUtils.isEmpty(phoneNumber)) { + ToastHelper.showToast("电话号码还未填写", ToastHelper.WARING); return; } - if (mediaList.size() != 2) { - ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); - return; + if (StringHelper.isPhoneNumber(phoneNumber)) { + String fieldIntro = caseLocationView.getText().toString(); + if (TextUtils.isEmpty(fieldIntro)) { + ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + return; + } + String description = caseDetailEditView.getText().toString(); + if (TextUtils.isEmpty(description)) { + ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + return; + } + if (mediaList.size() != 2) { + ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); + return; + } + shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, + "2", "1", + gridId.substring(0, 6), + gridId.substring(0, 9), + gridId.substring(0, 12), + gridId, description, fieldIntro, + StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); + } else { + ToastHelper.showToast("电话号码格式不对", ToastHelper.WARING); } - shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, - "2", "1", - gridId.substring(0, 6), - gridId.substring(0, 9), - gridId.substring(0, 12), - gridId, description, fieldIntro, - StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); } @Override 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 index 192b702..708f2a8 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -1,16 +1,30 @@ package com.casic.dcms.ui.fragment; +import android.content.BroadcastReceiver; import android.content.Context; -import android.widget.LinearLayout; +import android.content.Intent; +import android.text.TextUtils; +import android.view.ViewGroup; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.adapter.SwipeViewAdapter; +import com.casic.dcms.base.BaseApplication; import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; +import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.greendao.DaoSession; +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; import java.util.ArrayList; import java.util.List; @@ -19,17 +33,19 @@ public class NoticePageFragment extends BaseFragment { - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; + @BindView(R.id.swipeRecyclerView) + RecyclerView swipeRecyclerView; private Context context; + private List noticeBeans = new ArrayList<>(); + private SwipeViewAdapter swipeViewAdapter; + private BroadcastManager broadcastManager; + private Gson gson; + private DaoSession daoSession; @Override protected int initLayoutView() { - return R.layout.fragment_dashboard; + return R.layout.fragment_notice; } @Override @@ -39,20 +55,90 @@ @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)); + gson = new Gson(); + daoSession = BaseApplication.getDaoSession(); + swipeViewAdapter = new SwipeViewAdapter(context); + //根据userName加载历史数据 + String userName = StringHelper.getUserName(); + if (TextUtils.isEmpty(userName)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserName.eq(userName)).list(); + swipeViewAdapter.setData(noticeBeans); + + broadcastManager = BroadcastManager.getInstance(context); + broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + if (Constant.NOTICE_MSG.equals(action)) { + String data = intent.getStringExtra("data"); + assert data != null; + NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); + noticeBeans.add(noticeBean); + //更新数据 + swipeViewAdapter.setData(noticeBeans); + } + } + } + }); } @Override protected void initEvent() { + QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { + @Override + public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { + int position = viewHolder.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + @Override + public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { + return QMUIRVItemSwipeAction.SWIPE_LEFT; + } + + @Override + public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { + super.onClickAction(swipeAction, selected, action); + int position = selected.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + }); + swipeAction.attachToRecyclerView(swipeRecyclerView); + swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { + @Override + public RecyclerView.LayoutParams generateDefaultLayoutParams() { + return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + } + }); + swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); + swipeRecyclerView.setAdapter(swipeViewAdapter); + swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { + @Override + public void onClick(int position) { + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = noticeBeans.get(position); + noticeBean.setIsRead("0"); + daoSession.update(noticeBean); + swipeViewAdapter.notifyDataSetChanged(); + + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); + } + }); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (broadcastManager != null) { + broadcastManager.destroy(Constant.NOTICE_MSG); + } } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java deleted file mode 100644 index 7b1e1fb..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class ReadFragment extends BaseFragment { - @Override - protected int initLayoutView() { - return R.layout.fragment_read; - } - - @Override - protected void setupTopBarLayout() { - - } - - @Override - protected void initData() { - - } - - @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 deleted file mode 100644 index a0afe0f..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.text.TextUtils; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.DividerItemDecoration; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SwipeViewAdapter; -import com.casic.dcms.base.BaseApplication; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.greendao.DaoSession; -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; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class UnreadFragment extends BaseFragment { - - private static final String TAG = "UnreadFragment"; - @BindView(R.id.swipeRecyclerView) - RecyclerView swipeRecyclerView; - - private Context context; - private List noticeBeans = new ArrayList<>(); - private SwipeViewAdapter swipeViewAdapter; - private BroadcastManager broadcastManager; - private Gson gson; - private DaoSession daoSession; - - @Override - protected int initLayoutView() { - return R.layout.fragment_unread; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - gson = new Gson(); - daoSession = BaseApplication.getDaoSession(); - swipeViewAdapter = new SwipeViewAdapter(context); - //根据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); - broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.NOTICE_MSG.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); - noticeBeans.add(noticeBean); - //更新数据 - swipeViewAdapter.setData(noticeBeans); - } - } - } - }); - } - - protected void initEvent() { - QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { - @Override - public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { - int position = viewHolder.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - - @Override - public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { - return QMUIRVItemSwipeAction.SWIPE_LEFT; - } - - @Override - public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { - super.onClickAction(swipeAction, selected, action); - int position = selected.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - }); - swipeAction.attachToRecyclerView(swipeRecyclerView); - swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { - @Override - public RecyclerView.LayoutParams generateDefaultLayoutParams() { - return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - } - }); - swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); - swipeRecyclerView.setAdapter(swipeViewAdapter); - swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { - @Override - public void onClick(int position) { - //点击之后之后,未读消息变为已读消息 - NoticeBean noticeBean = new NoticeBean(); - noticeBean.setIsRead("0"); - daoSession.update(noticeBean); - - String caseId = noticeBeans.get(position).getCaseId(); - Intent intent = new Intent(context, CaseDetailActivity.class); - intent.putExtra("id", caseId); - startActivity(intent); - } - }); - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - broadcastManager.destroy(Constant.NOTICE_MSG); - } -} diff --git a/app/src/main/java/com/casic/dcms/utils/StringHelper.java b/app/src/main/java/com/casic/dcms/utils/StringHelper.java index f5d5acb..3947941 100644 --- a/app/src/main/java/com/casic/dcms/utils/StringHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/StringHelper.java @@ -6,6 +6,8 @@ import com.casic.dcms.R; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class StringHelper { @@ -56,6 +58,22 @@ return isDigit && isLetter; } + public static boolean isPhoneNumber(String number) { + String regExp = "^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$"; + if (number.length() != 11) { + Log.d(TAG, "手机号应为11位数"); + return false; + } else { + Pattern p = Pattern.compile(regExp); + Matcher m = p.matcher(number); + boolean isMatch = m.matches(); + if (!isMatch) { + Log.d(TAG, "请填入正确的手机号"); + } + return isMatch; + } + } + public static String appendCompleteURL(String url) { if (TextUtils.isEmpty(url)) { return ""; diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); 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 865787a..fa17e1f 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,12 +1,14 @@ package com.casic.dcms.service; import android.content.Context; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.bean.PushResultBean; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; import com.casic.dcms.utils.StringHelper; @@ -64,6 +66,7 @@ // 通知到达,只有个推通道下发的通知会回调此方法 @Override public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + Log.d(TAG, "onNotificationMessageArrived: " + message.getContent()); /** * appid = DR9oeLL9va6aG3DYXy2w39 * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 @@ -79,8 +82,8 @@ }.getType()); NoticeBean noticeBean = new NoticeBean(); - noticeBean.setUserPhone(StringHelper.getUserPhone()); - noticeBean.setCaseId(resultBean.getId()); + noticeBean.setUserName(StringHelper.getUserName()); + noticeBean.setCaseId(resultBean.getData().getId()); noticeBean.setTitle(resultBean.getTitle()); noticeBean.setContent(resultBean.getContent()); noticeBean.setType(resultBean.getType()); @@ -101,7 +104,10 @@ PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { }.getType()); - String caseId = resultBean.getId(); + String caseId = resultBean.getData().getId(); Log.d(TAG, "onNotificationMessageClicked: " + caseId); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); } } 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 db7d9ca..a1bcef6 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -244,8 +244,6 @@ showShopDialog(featureBean.getBgid(), (String) feature.getAttributes().get("Note"), featureBean.getDutyname(), - featureBean.getTel(), - "暂无", String.valueOf(featureBean.getObjectid())); } }); @@ -269,10 +267,10 @@ /** * 三包 */ - private void showShopDialog(String gridId, String communityName, String shopName, String phoneNumber, String shopKeeper, String shopID) { + private void showShopDialog(String gridId, String communityName, String shopName, String shopID) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("已选择商户:" + shopName + "\r\n手机号:" + phoneNumber + "\r\n确认提交?") + .setMessage("已选择商户:" + shopName + "\r\n确认提交?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { @@ -281,8 +279,6 @@ dialog.dismiss(); Intent intent = new Intent(); intent.putExtra("shopName", shopName); - intent.putExtra("phoneNumber", phoneNumber); - intent.putExtra("shopKeeper", shopKeeper); intent.putExtra("shopID", shopID); intent.putExtra("latitude", clickPoint.getY()); intent.putExtra("longitude", clickPoint.getX()); diff --git a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java index 8e43b7e..3fa89ee 100644 --- a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java @@ -155,10 +155,6 @@ PublicKey publicKey = RSAUtils.keyStrToPublicKey(keyString); String userName = userNameView.getText().toString(); String userPassword = userPasswordView.getText().toString(); - if (rememberPasswordView.isChecked()) { - SaveKeyValues.putValue("name", userName); - SaveKeyValues.putValue("password", userPassword); - } if (autoLoginView.isChecked()) { SaveKeyValues.putValue("autoLogin", true); } else { @@ -172,6 +168,10 @@ ToastHelper.showToast("密码不能为空", ToastHelper.WARING); return; } + if (rememberPasswordView.isChecked()) { + SaveKeyValues.putValue("name", userName); + SaveKeyValues.putValue("password", userPassword); + } String dataByPublicKey = RSAUtils.encryptDataByPublicKey(userPassword.getBytes(), publicKey); //登录并获取Token,POST请求 loginPresenter.onReadyRetrofitRequest(userName, dataByPublicKey); diff --git a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java index dc5fc67..dad0718 100644 --- a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java @@ -56,6 +56,10 @@ EditText longitudeView; @BindView(R.id.latitudeView) EditText latitudeView; + @BindView(R.id.shopKeeperView) + EditText shopKeeperView; + @BindView(R.id.phoneNumberView) + EditText phoneNumberView; @BindView(R.id.caseLocationView) EditText caseLocationView; @BindView(R.id.caseDetailEditView) @@ -73,7 +77,7 @@ private QMUITipDialog submitDialog; private List realPaths = new ArrayList<>();//真是图片路径 private List mediaList = new ArrayList<>();//上传到服务器的数据集 - private String gridId, shopKeeper, phoneNumber, shopID; + private String gridId, shopID; @Override public int initLayoutView() { @@ -187,8 +191,6 @@ gridId = data.getStringExtra("gridId"); String community = data.getStringExtra("community"); String shopName = data.getStringExtra("shopName"); - phoneNumber = data.getStringExtra("phoneNumber"); - shopKeeper = data.getStringExtra("shopKeeper"); shopID = data.getStringExtra("shopID"); longitudeView.setText(String.valueOf(longitude)); @@ -212,28 +214,41 @@ ToastHelper.showToast("经纬度异常,请重新选择位置", ToastHelper.WARING); return; } - - String fieldIntro = caseLocationView.getText().toString(); - if (TextUtils.isEmpty(fieldIntro)) { - ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + String shopKeeper = shopKeeperView.getText().toString(); + if (TextUtils.isEmpty(shopKeeper)) { + ToastHelper.showToast("店主名还未填写", ToastHelper.WARING); return; } - String description = caseDetailEditView.getText().toString(); - if (TextUtils.isEmpty(description)) { - ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + String phoneNumber = phoneNumberView.getText().toString(); + if (TextUtils.isEmpty(phoneNumber)) { + ToastHelper.showToast("电话号码还未填写", ToastHelper.WARING); return; } - if (mediaList.size() != 2) { - ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); - return; + if (StringHelper.isPhoneNumber(phoneNumber)) { + String fieldIntro = caseLocationView.getText().toString(); + if (TextUtils.isEmpty(fieldIntro)) { + ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + return; + } + String description = caseDetailEditView.getText().toString(); + if (TextUtils.isEmpty(description)) { + ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + return; + } + if (mediaList.size() != 2) { + ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); + return; + } + shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, + "2", "1", + gridId.substring(0, 6), + gridId.substring(0, 9), + gridId.substring(0, 12), + gridId, description, fieldIntro, + StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); + } else { + ToastHelper.showToast("电话号码格式不对", ToastHelper.WARING); } - shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, - "2", "1", - gridId.substring(0, 6), - gridId.substring(0, 9), - gridId.substring(0, 12), - gridId, description, fieldIntro, - StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); } @Override 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 index 192b702..708f2a8 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -1,16 +1,30 @@ package com.casic.dcms.ui.fragment; +import android.content.BroadcastReceiver; import android.content.Context; -import android.widget.LinearLayout; +import android.content.Intent; +import android.text.TextUtils; +import android.view.ViewGroup; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.adapter.SwipeViewAdapter; +import com.casic.dcms.base.BaseApplication; import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; +import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.greendao.DaoSession; +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; import java.util.ArrayList; import java.util.List; @@ -19,17 +33,19 @@ public class NoticePageFragment extends BaseFragment { - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; + @BindView(R.id.swipeRecyclerView) + RecyclerView swipeRecyclerView; private Context context; + private List noticeBeans = new ArrayList<>(); + private SwipeViewAdapter swipeViewAdapter; + private BroadcastManager broadcastManager; + private Gson gson; + private DaoSession daoSession; @Override protected int initLayoutView() { - return R.layout.fragment_dashboard; + return R.layout.fragment_notice; } @Override @@ -39,20 +55,90 @@ @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)); + gson = new Gson(); + daoSession = BaseApplication.getDaoSession(); + swipeViewAdapter = new SwipeViewAdapter(context); + //根据userName加载历史数据 + String userName = StringHelper.getUserName(); + if (TextUtils.isEmpty(userName)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserName.eq(userName)).list(); + swipeViewAdapter.setData(noticeBeans); + + broadcastManager = BroadcastManager.getInstance(context); + broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + if (Constant.NOTICE_MSG.equals(action)) { + String data = intent.getStringExtra("data"); + assert data != null; + NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); + noticeBeans.add(noticeBean); + //更新数据 + swipeViewAdapter.setData(noticeBeans); + } + } + } + }); } @Override protected void initEvent() { + QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { + @Override + public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { + int position = viewHolder.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + @Override + public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { + return QMUIRVItemSwipeAction.SWIPE_LEFT; + } + + @Override + public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { + super.onClickAction(swipeAction, selected, action); + int position = selected.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + }); + swipeAction.attachToRecyclerView(swipeRecyclerView); + swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { + @Override + public RecyclerView.LayoutParams generateDefaultLayoutParams() { + return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + } + }); + swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); + swipeRecyclerView.setAdapter(swipeViewAdapter); + swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { + @Override + public void onClick(int position) { + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = noticeBeans.get(position); + noticeBean.setIsRead("0"); + daoSession.update(noticeBean); + swipeViewAdapter.notifyDataSetChanged(); + + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); + } + }); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (broadcastManager != null) { + broadcastManager.destroy(Constant.NOTICE_MSG); + } } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java deleted file mode 100644 index 7b1e1fb..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class ReadFragment extends BaseFragment { - @Override - protected int initLayoutView() { - return R.layout.fragment_read; - } - - @Override - protected void setupTopBarLayout() { - - } - - @Override - protected void initData() { - - } - - @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 deleted file mode 100644 index a0afe0f..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.text.TextUtils; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.DividerItemDecoration; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SwipeViewAdapter; -import com.casic.dcms.base.BaseApplication; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.greendao.DaoSession; -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; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class UnreadFragment extends BaseFragment { - - private static final String TAG = "UnreadFragment"; - @BindView(R.id.swipeRecyclerView) - RecyclerView swipeRecyclerView; - - private Context context; - private List noticeBeans = new ArrayList<>(); - private SwipeViewAdapter swipeViewAdapter; - private BroadcastManager broadcastManager; - private Gson gson; - private DaoSession daoSession; - - @Override - protected int initLayoutView() { - return R.layout.fragment_unread; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - gson = new Gson(); - daoSession = BaseApplication.getDaoSession(); - swipeViewAdapter = new SwipeViewAdapter(context); - //根据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); - broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.NOTICE_MSG.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); - noticeBeans.add(noticeBean); - //更新数据 - swipeViewAdapter.setData(noticeBeans); - } - } - } - }); - } - - protected void initEvent() { - QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { - @Override - public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { - int position = viewHolder.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - - @Override - public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { - return QMUIRVItemSwipeAction.SWIPE_LEFT; - } - - @Override - public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { - super.onClickAction(swipeAction, selected, action); - int position = selected.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - }); - swipeAction.attachToRecyclerView(swipeRecyclerView); - swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { - @Override - public RecyclerView.LayoutParams generateDefaultLayoutParams() { - return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - } - }); - swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); - swipeRecyclerView.setAdapter(swipeViewAdapter); - swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { - @Override - public void onClick(int position) { - //点击之后之后,未读消息变为已读消息 - NoticeBean noticeBean = new NoticeBean(); - noticeBean.setIsRead("0"); - daoSession.update(noticeBean); - - String caseId = noticeBeans.get(position).getCaseId(); - Intent intent = new Intent(context, CaseDetailActivity.class); - intent.putExtra("id", caseId); - startActivity(intent); - } - }); - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - broadcastManager.destroy(Constant.NOTICE_MSG); - } -} diff --git a/app/src/main/java/com/casic/dcms/utils/StringHelper.java b/app/src/main/java/com/casic/dcms/utils/StringHelper.java index f5d5acb..3947941 100644 --- a/app/src/main/java/com/casic/dcms/utils/StringHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/StringHelper.java @@ -6,6 +6,8 @@ import com.casic.dcms.R; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class StringHelper { @@ -56,6 +58,22 @@ return isDigit && isLetter; } + public static boolean isPhoneNumber(String number) { + String regExp = "^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$"; + if (number.length() != 11) { + Log.d(TAG, "手机号应为11位数"); + return false; + } else { + Pattern p = Pattern.compile(regExp); + Matcher m = p.matcher(number); + boolean isMatch = m.matches(); + if (!isMatch) { + Log.d(TAG, "请填入正确的手机号"); + } + return isMatch; + } + } + public static String appendCompleteURL(String url) { if (TextUtils.isEmpty(url)) { return ""; diff --git a/app/src/main/res/drawable-hdpi/normal.png b/app/src/main/res/drawable-hdpi/normal.png new file mode 100644 index 0000000..3feab7d --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal.png Binary files differ diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); 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 865787a..fa17e1f 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,12 +1,14 @@ package com.casic.dcms.service; import android.content.Context; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.bean.PushResultBean; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; import com.casic.dcms.utils.StringHelper; @@ -64,6 +66,7 @@ // 通知到达,只有个推通道下发的通知会回调此方法 @Override public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + Log.d(TAG, "onNotificationMessageArrived: " + message.getContent()); /** * appid = DR9oeLL9va6aG3DYXy2w39 * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 @@ -79,8 +82,8 @@ }.getType()); NoticeBean noticeBean = new NoticeBean(); - noticeBean.setUserPhone(StringHelper.getUserPhone()); - noticeBean.setCaseId(resultBean.getId()); + noticeBean.setUserName(StringHelper.getUserName()); + noticeBean.setCaseId(resultBean.getData().getId()); noticeBean.setTitle(resultBean.getTitle()); noticeBean.setContent(resultBean.getContent()); noticeBean.setType(resultBean.getType()); @@ -101,7 +104,10 @@ PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { }.getType()); - String caseId = resultBean.getId(); + String caseId = resultBean.getData().getId(); Log.d(TAG, "onNotificationMessageClicked: " + caseId); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); } } 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 db7d9ca..a1bcef6 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -244,8 +244,6 @@ showShopDialog(featureBean.getBgid(), (String) feature.getAttributes().get("Note"), featureBean.getDutyname(), - featureBean.getTel(), - "暂无", String.valueOf(featureBean.getObjectid())); } }); @@ -269,10 +267,10 @@ /** * 三包 */ - private void showShopDialog(String gridId, String communityName, String shopName, String phoneNumber, String shopKeeper, String shopID) { + private void showShopDialog(String gridId, String communityName, String shopName, String shopID) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("已选择商户:" + shopName + "\r\n手机号:" + phoneNumber + "\r\n确认提交?") + .setMessage("已选择商户:" + shopName + "\r\n确认提交?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { @@ -281,8 +279,6 @@ dialog.dismiss(); Intent intent = new Intent(); intent.putExtra("shopName", shopName); - intent.putExtra("phoneNumber", phoneNumber); - intent.putExtra("shopKeeper", shopKeeper); intent.putExtra("shopID", shopID); intent.putExtra("latitude", clickPoint.getY()); intent.putExtra("longitude", clickPoint.getX()); diff --git a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java index 8e43b7e..3fa89ee 100644 --- a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java @@ -155,10 +155,6 @@ PublicKey publicKey = RSAUtils.keyStrToPublicKey(keyString); String userName = userNameView.getText().toString(); String userPassword = userPasswordView.getText().toString(); - if (rememberPasswordView.isChecked()) { - SaveKeyValues.putValue("name", userName); - SaveKeyValues.putValue("password", userPassword); - } if (autoLoginView.isChecked()) { SaveKeyValues.putValue("autoLogin", true); } else { @@ -172,6 +168,10 @@ ToastHelper.showToast("密码不能为空", ToastHelper.WARING); return; } + if (rememberPasswordView.isChecked()) { + SaveKeyValues.putValue("name", userName); + SaveKeyValues.putValue("password", userPassword); + } String dataByPublicKey = RSAUtils.encryptDataByPublicKey(userPassword.getBytes(), publicKey); //登录并获取Token,POST请求 loginPresenter.onReadyRetrofitRequest(userName, dataByPublicKey); diff --git a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java index dc5fc67..dad0718 100644 --- a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java @@ -56,6 +56,10 @@ EditText longitudeView; @BindView(R.id.latitudeView) EditText latitudeView; + @BindView(R.id.shopKeeperView) + EditText shopKeeperView; + @BindView(R.id.phoneNumberView) + EditText phoneNumberView; @BindView(R.id.caseLocationView) EditText caseLocationView; @BindView(R.id.caseDetailEditView) @@ -73,7 +77,7 @@ private QMUITipDialog submitDialog; private List realPaths = new ArrayList<>();//真是图片路径 private List mediaList = new ArrayList<>();//上传到服务器的数据集 - private String gridId, shopKeeper, phoneNumber, shopID; + private String gridId, shopID; @Override public int initLayoutView() { @@ -187,8 +191,6 @@ gridId = data.getStringExtra("gridId"); String community = data.getStringExtra("community"); String shopName = data.getStringExtra("shopName"); - phoneNumber = data.getStringExtra("phoneNumber"); - shopKeeper = data.getStringExtra("shopKeeper"); shopID = data.getStringExtra("shopID"); longitudeView.setText(String.valueOf(longitude)); @@ -212,28 +214,41 @@ ToastHelper.showToast("经纬度异常,请重新选择位置", ToastHelper.WARING); return; } - - String fieldIntro = caseLocationView.getText().toString(); - if (TextUtils.isEmpty(fieldIntro)) { - ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + String shopKeeper = shopKeeperView.getText().toString(); + if (TextUtils.isEmpty(shopKeeper)) { + ToastHelper.showToast("店主名还未填写", ToastHelper.WARING); return; } - String description = caseDetailEditView.getText().toString(); - if (TextUtils.isEmpty(description)) { - ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + String phoneNumber = phoneNumberView.getText().toString(); + if (TextUtils.isEmpty(phoneNumber)) { + ToastHelper.showToast("电话号码还未填写", ToastHelper.WARING); return; } - if (mediaList.size() != 2) { - ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); - return; + if (StringHelper.isPhoneNumber(phoneNumber)) { + String fieldIntro = caseLocationView.getText().toString(); + if (TextUtils.isEmpty(fieldIntro)) { + ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + return; + } + String description = caseDetailEditView.getText().toString(); + if (TextUtils.isEmpty(description)) { + ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + return; + } + if (mediaList.size() != 2) { + ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); + return; + } + shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, + "2", "1", + gridId.substring(0, 6), + gridId.substring(0, 9), + gridId.substring(0, 12), + gridId, description, fieldIntro, + StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); + } else { + ToastHelper.showToast("电话号码格式不对", ToastHelper.WARING); } - shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, - "2", "1", - gridId.substring(0, 6), - gridId.substring(0, 9), - gridId.substring(0, 12), - gridId, description, fieldIntro, - StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); } @Override 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 index 192b702..708f2a8 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -1,16 +1,30 @@ package com.casic.dcms.ui.fragment; +import android.content.BroadcastReceiver; import android.content.Context; -import android.widget.LinearLayout; +import android.content.Intent; +import android.text.TextUtils; +import android.view.ViewGroup; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.adapter.SwipeViewAdapter; +import com.casic.dcms.base.BaseApplication; import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; +import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.greendao.DaoSession; +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; import java.util.ArrayList; import java.util.List; @@ -19,17 +33,19 @@ public class NoticePageFragment extends BaseFragment { - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; + @BindView(R.id.swipeRecyclerView) + RecyclerView swipeRecyclerView; private Context context; + private List noticeBeans = new ArrayList<>(); + private SwipeViewAdapter swipeViewAdapter; + private BroadcastManager broadcastManager; + private Gson gson; + private DaoSession daoSession; @Override protected int initLayoutView() { - return R.layout.fragment_dashboard; + return R.layout.fragment_notice; } @Override @@ -39,20 +55,90 @@ @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)); + gson = new Gson(); + daoSession = BaseApplication.getDaoSession(); + swipeViewAdapter = new SwipeViewAdapter(context); + //根据userName加载历史数据 + String userName = StringHelper.getUserName(); + if (TextUtils.isEmpty(userName)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserName.eq(userName)).list(); + swipeViewAdapter.setData(noticeBeans); + + broadcastManager = BroadcastManager.getInstance(context); + broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + if (Constant.NOTICE_MSG.equals(action)) { + String data = intent.getStringExtra("data"); + assert data != null; + NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); + noticeBeans.add(noticeBean); + //更新数据 + swipeViewAdapter.setData(noticeBeans); + } + } + } + }); } @Override protected void initEvent() { + QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { + @Override + public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { + int position = viewHolder.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + @Override + public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { + return QMUIRVItemSwipeAction.SWIPE_LEFT; + } + + @Override + public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { + super.onClickAction(swipeAction, selected, action); + int position = selected.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + }); + swipeAction.attachToRecyclerView(swipeRecyclerView); + swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { + @Override + public RecyclerView.LayoutParams generateDefaultLayoutParams() { + return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + } + }); + swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); + swipeRecyclerView.setAdapter(swipeViewAdapter); + swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { + @Override + public void onClick(int position) { + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = noticeBeans.get(position); + noticeBean.setIsRead("0"); + daoSession.update(noticeBean); + swipeViewAdapter.notifyDataSetChanged(); + + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); + } + }); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (broadcastManager != null) { + broadcastManager.destroy(Constant.NOTICE_MSG); + } } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java deleted file mode 100644 index 7b1e1fb..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class ReadFragment extends BaseFragment { - @Override - protected int initLayoutView() { - return R.layout.fragment_read; - } - - @Override - protected void setupTopBarLayout() { - - } - - @Override - protected void initData() { - - } - - @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 deleted file mode 100644 index a0afe0f..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.text.TextUtils; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.DividerItemDecoration; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SwipeViewAdapter; -import com.casic.dcms.base.BaseApplication; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.greendao.DaoSession; -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; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class UnreadFragment extends BaseFragment { - - private static final String TAG = "UnreadFragment"; - @BindView(R.id.swipeRecyclerView) - RecyclerView swipeRecyclerView; - - private Context context; - private List noticeBeans = new ArrayList<>(); - private SwipeViewAdapter swipeViewAdapter; - private BroadcastManager broadcastManager; - private Gson gson; - private DaoSession daoSession; - - @Override - protected int initLayoutView() { - return R.layout.fragment_unread; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - gson = new Gson(); - daoSession = BaseApplication.getDaoSession(); - swipeViewAdapter = new SwipeViewAdapter(context); - //根据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); - broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.NOTICE_MSG.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); - noticeBeans.add(noticeBean); - //更新数据 - swipeViewAdapter.setData(noticeBeans); - } - } - } - }); - } - - protected void initEvent() { - QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { - @Override - public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { - int position = viewHolder.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - - @Override - public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { - return QMUIRVItemSwipeAction.SWIPE_LEFT; - } - - @Override - public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { - super.onClickAction(swipeAction, selected, action); - int position = selected.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - }); - swipeAction.attachToRecyclerView(swipeRecyclerView); - swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { - @Override - public RecyclerView.LayoutParams generateDefaultLayoutParams() { - return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - } - }); - swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); - swipeRecyclerView.setAdapter(swipeViewAdapter); - swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { - @Override - public void onClick(int position) { - //点击之后之后,未读消息变为已读消息 - NoticeBean noticeBean = new NoticeBean(); - noticeBean.setIsRead("0"); - daoSession.update(noticeBean); - - String caseId = noticeBeans.get(position).getCaseId(); - Intent intent = new Intent(context, CaseDetailActivity.class); - intent.putExtra("id", caseId); - startActivity(intent); - } - }); - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - broadcastManager.destroy(Constant.NOTICE_MSG); - } -} diff --git a/app/src/main/java/com/casic/dcms/utils/StringHelper.java b/app/src/main/java/com/casic/dcms/utils/StringHelper.java index f5d5acb..3947941 100644 --- a/app/src/main/java/com/casic/dcms/utils/StringHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/StringHelper.java @@ -6,6 +6,8 @@ import com.casic.dcms.R; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class StringHelper { @@ -56,6 +58,22 @@ return isDigit && isLetter; } + public static boolean isPhoneNumber(String number) { + String regExp = "^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$"; + if (number.length() != 11) { + Log.d(TAG, "手机号应为11位数"); + return false; + } else { + Pattern p = Pattern.compile(regExp); + Matcher m = p.matcher(number); + boolean isMatch = m.matches(); + if (!isMatch) { + Log.d(TAG, "请填入正确的手机号"); + } + return isMatch; + } + } + public static String appendCompleteURL(String url) { if (TextUtils.isEmpty(url)) { return ""; diff --git a/app/src/main/res/drawable-hdpi/normal.png b/app/src/main/res/drawable-hdpi/normal.png new file mode 100644 index 0000000..3feab7d --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-hdpi/normal_small.png b/app/src/main/res/drawable-hdpi/normal_small.png new file mode 100644 index 0000000..4387126 --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal_small.png Binary files differ diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); 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 865787a..fa17e1f 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,12 +1,14 @@ package com.casic.dcms.service; import android.content.Context; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.bean.PushResultBean; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; import com.casic.dcms.utils.StringHelper; @@ -64,6 +66,7 @@ // 通知到达,只有个推通道下发的通知会回调此方法 @Override public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + Log.d(TAG, "onNotificationMessageArrived: " + message.getContent()); /** * appid = DR9oeLL9va6aG3DYXy2w39 * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 @@ -79,8 +82,8 @@ }.getType()); NoticeBean noticeBean = new NoticeBean(); - noticeBean.setUserPhone(StringHelper.getUserPhone()); - noticeBean.setCaseId(resultBean.getId()); + noticeBean.setUserName(StringHelper.getUserName()); + noticeBean.setCaseId(resultBean.getData().getId()); noticeBean.setTitle(resultBean.getTitle()); noticeBean.setContent(resultBean.getContent()); noticeBean.setType(resultBean.getType()); @@ -101,7 +104,10 @@ PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { }.getType()); - String caseId = resultBean.getId(); + String caseId = resultBean.getData().getId(); Log.d(TAG, "onNotificationMessageClicked: " + caseId); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); } } 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 db7d9ca..a1bcef6 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -244,8 +244,6 @@ showShopDialog(featureBean.getBgid(), (String) feature.getAttributes().get("Note"), featureBean.getDutyname(), - featureBean.getTel(), - "暂无", String.valueOf(featureBean.getObjectid())); } }); @@ -269,10 +267,10 @@ /** * 三包 */ - private void showShopDialog(String gridId, String communityName, String shopName, String phoneNumber, String shopKeeper, String shopID) { + private void showShopDialog(String gridId, String communityName, String shopName, String shopID) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("已选择商户:" + shopName + "\r\n手机号:" + phoneNumber + "\r\n确认提交?") + .setMessage("已选择商户:" + shopName + "\r\n确认提交?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { @@ -281,8 +279,6 @@ dialog.dismiss(); Intent intent = new Intent(); intent.putExtra("shopName", shopName); - intent.putExtra("phoneNumber", phoneNumber); - intent.putExtra("shopKeeper", shopKeeper); intent.putExtra("shopID", shopID); intent.putExtra("latitude", clickPoint.getY()); intent.putExtra("longitude", clickPoint.getX()); diff --git a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java index 8e43b7e..3fa89ee 100644 --- a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java @@ -155,10 +155,6 @@ PublicKey publicKey = RSAUtils.keyStrToPublicKey(keyString); String userName = userNameView.getText().toString(); String userPassword = userPasswordView.getText().toString(); - if (rememberPasswordView.isChecked()) { - SaveKeyValues.putValue("name", userName); - SaveKeyValues.putValue("password", userPassword); - } if (autoLoginView.isChecked()) { SaveKeyValues.putValue("autoLogin", true); } else { @@ -172,6 +168,10 @@ ToastHelper.showToast("密码不能为空", ToastHelper.WARING); return; } + if (rememberPasswordView.isChecked()) { + SaveKeyValues.putValue("name", userName); + SaveKeyValues.putValue("password", userPassword); + } String dataByPublicKey = RSAUtils.encryptDataByPublicKey(userPassword.getBytes(), publicKey); //登录并获取Token,POST请求 loginPresenter.onReadyRetrofitRequest(userName, dataByPublicKey); diff --git a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java index dc5fc67..dad0718 100644 --- a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java @@ -56,6 +56,10 @@ EditText longitudeView; @BindView(R.id.latitudeView) EditText latitudeView; + @BindView(R.id.shopKeeperView) + EditText shopKeeperView; + @BindView(R.id.phoneNumberView) + EditText phoneNumberView; @BindView(R.id.caseLocationView) EditText caseLocationView; @BindView(R.id.caseDetailEditView) @@ -73,7 +77,7 @@ private QMUITipDialog submitDialog; private List realPaths = new ArrayList<>();//真是图片路径 private List mediaList = new ArrayList<>();//上传到服务器的数据集 - private String gridId, shopKeeper, phoneNumber, shopID; + private String gridId, shopID; @Override public int initLayoutView() { @@ -187,8 +191,6 @@ gridId = data.getStringExtra("gridId"); String community = data.getStringExtra("community"); String shopName = data.getStringExtra("shopName"); - phoneNumber = data.getStringExtra("phoneNumber"); - shopKeeper = data.getStringExtra("shopKeeper"); shopID = data.getStringExtra("shopID"); longitudeView.setText(String.valueOf(longitude)); @@ -212,28 +214,41 @@ ToastHelper.showToast("经纬度异常,请重新选择位置", ToastHelper.WARING); return; } - - String fieldIntro = caseLocationView.getText().toString(); - if (TextUtils.isEmpty(fieldIntro)) { - ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + String shopKeeper = shopKeeperView.getText().toString(); + if (TextUtils.isEmpty(shopKeeper)) { + ToastHelper.showToast("店主名还未填写", ToastHelper.WARING); return; } - String description = caseDetailEditView.getText().toString(); - if (TextUtils.isEmpty(description)) { - ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + String phoneNumber = phoneNumberView.getText().toString(); + if (TextUtils.isEmpty(phoneNumber)) { + ToastHelper.showToast("电话号码还未填写", ToastHelper.WARING); return; } - if (mediaList.size() != 2) { - ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); - return; + if (StringHelper.isPhoneNumber(phoneNumber)) { + String fieldIntro = caseLocationView.getText().toString(); + if (TextUtils.isEmpty(fieldIntro)) { + ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + return; + } + String description = caseDetailEditView.getText().toString(); + if (TextUtils.isEmpty(description)) { + ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + return; + } + if (mediaList.size() != 2) { + ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); + return; + } + shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, + "2", "1", + gridId.substring(0, 6), + gridId.substring(0, 9), + gridId.substring(0, 12), + gridId, description, fieldIntro, + StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); + } else { + ToastHelper.showToast("电话号码格式不对", ToastHelper.WARING); } - shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, - "2", "1", - gridId.substring(0, 6), - gridId.substring(0, 9), - gridId.substring(0, 12), - gridId, description, fieldIntro, - StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); } @Override 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 index 192b702..708f2a8 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -1,16 +1,30 @@ package com.casic.dcms.ui.fragment; +import android.content.BroadcastReceiver; import android.content.Context; -import android.widget.LinearLayout; +import android.content.Intent; +import android.text.TextUtils; +import android.view.ViewGroup; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.adapter.SwipeViewAdapter; +import com.casic.dcms.base.BaseApplication; import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; +import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.greendao.DaoSession; +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; import java.util.ArrayList; import java.util.List; @@ -19,17 +33,19 @@ public class NoticePageFragment extends BaseFragment { - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; + @BindView(R.id.swipeRecyclerView) + RecyclerView swipeRecyclerView; private Context context; + private List noticeBeans = new ArrayList<>(); + private SwipeViewAdapter swipeViewAdapter; + private BroadcastManager broadcastManager; + private Gson gson; + private DaoSession daoSession; @Override protected int initLayoutView() { - return R.layout.fragment_dashboard; + return R.layout.fragment_notice; } @Override @@ -39,20 +55,90 @@ @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)); + gson = new Gson(); + daoSession = BaseApplication.getDaoSession(); + swipeViewAdapter = new SwipeViewAdapter(context); + //根据userName加载历史数据 + String userName = StringHelper.getUserName(); + if (TextUtils.isEmpty(userName)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserName.eq(userName)).list(); + swipeViewAdapter.setData(noticeBeans); + + broadcastManager = BroadcastManager.getInstance(context); + broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + if (Constant.NOTICE_MSG.equals(action)) { + String data = intent.getStringExtra("data"); + assert data != null; + NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); + noticeBeans.add(noticeBean); + //更新数据 + swipeViewAdapter.setData(noticeBeans); + } + } + } + }); } @Override protected void initEvent() { + QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { + @Override + public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { + int position = viewHolder.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + @Override + public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { + return QMUIRVItemSwipeAction.SWIPE_LEFT; + } + + @Override + public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { + super.onClickAction(swipeAction, selected, action); + int position = selected.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + }); + swipeAction.attachToRecyclerView(swipeRecyclerView); + swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { + @Override + public RecyclerView.LayoutParams generateDefaultLayoutParams() { + return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + } + }); + swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); + swipeRecyclerView.setAdapter(swipeViewAdapter); + swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { + @Override + public void onClick(int position) { + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = noticeBeans.get(position); + noticeBean.setIsRead("0"); + daoSession.update(noticeBean); + swipeViewAdapter.notifyDataSetChanged(); + + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); + } + }); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (broadcastManager != null) { + broadcastManager.destroy(Constant.NOTICE_MSG); + } } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java deleted file mode 100644 index 7b1e1fb..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class ReadFragment extends BaseFragment { - @Override - protected int initLayoutView() { - return R.layout.fragment_read; - } - - @Override - protected void setupTopBarLayout() { - - } - - @Override - protected void initData() { - - } - - @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 deleted file mode 100644 index a0afe0f..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.text.TextUtils; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.DividerItemDecoration; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SwipeViewAdapter; -import com.casic.dcms.base.BaseApplication; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.greendao.DaoSession; -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; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class UnreadFragment extends BaseFragment { - - private static final String TAG = "UnreadFragment"; - @BindView(R.id.swipeRecyclerView) - RecyclerView swipeRecyclerView; - - private Context context; - private List noticeBeans = new ArrayList<>(); - private SwipeViewAdapter swipeViewAdapter; - private BroadcastManager broadcastManager; - private Gson gson; - private DaoSession daoSession; - - @Override - protected int initLayoutView() { - return R.layout.fragment_unread; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - gson = new Gson(); - daoSession = BaseApplication.getDaoSession(); - swipeViewAdapter = new SwipeViewAdapter(context); - //根据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); - broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.NOTICE_MSG.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); - noticeBeans.add(noticeBean); - //更新数据 - swipeViewAdapter.setData(noticeBeans); - } - } - } - }); - } - - protected void initEvent() { - QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { - @Override - public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { - int position = viewHolder.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - - @Override - public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { - return QMUIRVItemSwipeAction.SWIPE_LEFT; - } - - @Override - public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { - super.onClickAction(swipeAction, selected, action); - int position = selected.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - }); - swipeAction.attachToRecyclerView(swipeRecyclerView); - swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { - @Override - public RecyclerView.LayoutParams generateDefaultLayoutParams() { - return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - } - }); - swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); - swipeRecyclerView.setAdapter(swipeViewAdapter); - swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { - @Override - public void onClick(int position) { - //点击之后之后,未读消息变为已读消息 - NoticeBean noticeBean = new NoticeBean(); - noticeBean.setIsRead("0"); - daoSession.update(noticeBean); - - String caseId = noticeBeans.get(position).getCaseId(); - Intent intent = new Intent(context, CaseDetailActivity.class); - intent.putExtra("id", caseId); - startActivity(intent); - } - }); - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - broadcastManager.destroy(Constant.NOTICE_MSG); - } -} diff --git a/app/src/main/java/com/casic/dcms/utils/StringHelper.java b/app/src/main/java/com/casic/dcms/utils/StringHelper.java index f5d5acb..3947941 100644 --- a/app/src/main/java/com/casic/dcms/utils/StringHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/StringHelper.java @@ -6,6 +6,8 @@ import com.casic.dcms.R; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class StringHelper { @@ -56,6 +58,22 @@ return isDigit && isLetter; } + public static boolean isPhoneNumber(String number) { + String regExp = "^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$"; + if (number.length() != 11) { + Log.d(TAG, "手机号应为11位数"); + return false; + } else { + Pattern p = Pattern.compile(regExp); + Matcher m = p.matcher(number); + boolean isMatch = m.matches(); + if (!isMatch) { + Log.d(TAG, "请填入正确的手机号"); + } + return isMatch; + } + } + public static String appendCompleteURL(String url) { if (TextUtils.isEmpty(url)) { return ""; diff --git a/app/src/main/res/drawable-hdpi/normal.png b/app/src/main/res/drawable-hdpi/normal.png new file mode 100644 index 0000000..3feab7d --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-hdpi/normal_small.png b/app/src/main/res/drawable-hdpi/normal_small.png new file mode 100644 index 0000000..4387126 --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal.png b/app/src/main/res/drawable-ldpi/normal.png new file mode 100644 index 0000000..175184c --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal.png Binary files differ diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); 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 865787a..fa17e1f 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,12 +1,14 @@ package com.casic.dcms.service; import android.content.Context; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.bean.PushResultBean; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; import com.casic.dcms.utils.StringHelper; @@ -64,6 +66,7 @@ // 通知到达,只有个推通道下发的通知会回调此方法 @Override public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + Log.d(TAG, "onNotificationMessageArrived: " + message.getContent()); /** * appid = DR9oeLL9va6aG3DYXy2w39 * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 @@ -79,8 +82,8 @@ }.getType()); NoticeBean noticeBean = new NoticeBean(); - noticeBean.setUserPhone(StringHelper.getUserPhone()); - noticeBean.setCaseId(resultBean.getId()); + noticeBean.setUserName(StringHelper.getUserName()); + noticeBean.setCaseId(resultBean.getData().getId()); noticeBean.setTitle(resultBean.getTitle()); noticeBean.setContent(resultBean.getContent()); noticeBean.setType(resultBean.getType()); @@ -101,7 +104,10 @@ PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { }.getType()); - String caseId = resultBean.getId(); + String caseId = resultBean.getData().getId(); Log.d(TAG, "onNotificationMessageClicked: " + caseId); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); } } 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 db7d9ca..a1bcef6 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -244,8 +244,6 @@ showShopDialog(featureBean.getBgid(), (String) feature.getAttributes().get("Note"), featureBean.getDutyname(), - featureBean.getTel(), - "暂无", String.valueOf(featureBean.getObjectid())); } }); @@ -269,10 +267,10 @@ /** * 三包 */ - private void showShopDialog(String gridId, String communityName, String shopName, String phoneNumber, String shopKeeper, String shopID) { + private void showShopDialog(String gridId, String communityName, String shopName, String shopID) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("已选择商户:" + shopName + "\r\n手机号:" + phoneNumber + "\r\n确认提交?") + .setMessage("已选择商户:" + shopName + "\r\n确认提交?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { @@ -281,8 +279,6 @@ dialog.dismiss(); Intent intent = new Intent(); intent.putExtra("shopName", shopName); - intent.putExtra("phoneNumber", phoneNumber); - intent.putExtra("shopKeeper", shopKeeper); intent.putExtra("shopID", shopID); intent.putExtra("latitude", clickPoint.getY()); intent.putExtra("longitude", clickPoint.getX()); diff --git a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java index 8e43b7e..3fa89ee 100644 --- a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java @@ -155,10 +155,6 @@ PublicKey publicKey = RSAUtils.keyStrToPublicKey(keyString); String userName = userNameView.getText().toString(); String userPassword = userPasswordView.getText().toString(); - if (rememberPasswordView.isChecked()) { - SaveKeyValues.putValue("name", userName); - SaveKeyValues.putValue("password", userPassword); - } if (autoLoginView.isChecked()) { SaveKeyValues.putValue("autoLogin", true); } else { @@ -172,6 +168,10 @@ ToastHelper.showToast("密码不能为空", ToastHelper.WARING); return; } + if (rememberPasswordView.isChecked()) { + SaveKeyValues.putValue("name", userName); + SaveKeyValues.putValue("password", userPassword); + } String dataByPublicKey = RSAUtils.encryptDataByPublicKey(userPassword.getBytes(), publicKey); //登录并获取Token,POST请求 loginPresenter.onReadyRetrofitRequest(userName, dataByPublicKey); diff --git a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java index dc5fc67..dad0718 100644 --- a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java @@ -56,6 +56,10 @@ EditText longitudeView; @BindView(R.id.latitudeView) EditText latitudeView; + @BindView(R.id.shopKeeperView) + EditText shopKeeperView; + @BindView(R.id.phoneNumberView) + EditText phoneNumberView; @BindView(R.id.caseLocationView) EditText caseLocationView; @BindView(R.id.caseDetailEditView) @@ -73,7 +77,7 @@ private QMUITipDialog submitDialog; private List realPaths = new ArrayList<>();//真是图片路径 private List mediaList = new ArrayList<>();//上传到服务器的数据集 - private String gridId, shopKeeper, phoneNumber, shopID; + private String gridId, shopID; @Override public int initLayoutView() { @@ -187,8 +191,6 @@ gridId = data.getStringExtra("gridId"); String community = data.getStringExtra("community"); String shopName = data.getStringExtra("shopName"); - phoneNumber = data.getStringExtra("phoneNumber"); - shopKeeper = data.getStringExtra("shopKeeper"); shopID = data.getStringExtra("shopID"); longitudeView.setText(String.valueOf(longitude)); @@ -212,28 +214,41 @@ ToastHelper.showToast("经纬度异常,请重新选择位置", ToastHelper.WARING); return; } - - String fieldIntro = caseLocationView.getText().toString(); - if (TextUtils.isEmpty(fieldIntro)) { - ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + String shopKeeper = shopKeeperView.getText().toString(); + if (TextUtils.isEmpty(shopKeeper)) { + ToastHelper.showToast("店主名还未填写", ToastHelper.WARING); return; } - String description = caseDetailEditView.getText().toString(); - if (TextUtils.isEmpty(description)) { - ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + String phoneNumber = phoneNumberView.getText().toString(); + if (TextUtils.isEmpty(phoneNumber)) { + ToastHelper.showToast("电话号码还未填写", ToastHelper.WARING); return; } - if (mediaList.size() != 2) { - ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); - return; + if (StringHelper.isPhoneNumber(phoneNumber)) { + String fieldIntro = caseLocationView.getText().toString(); + if (TextUtils.isEmpty(fieldIntro)) { + ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + return; + } + String description = caseDetailEditView.getText().toString(); + if (TextUtils.isEmpty(description)) { + ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + return; + } + if (mediaList.size() != 2) { + ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); + return; + } + shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, + "2", "1", + gridId.substring(0, 6), + gridId.substring(0, 9), + gridId.substring(0, 12), + gridId, description, fieldIntro, + StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); + } else { + ToastHelper.showToast("电话号码格式不对", ToastHelper.WARING); } - shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, - "2", "1", - gridId.substring(0, 6), - gridId.substring(0, 9), - gridId.substring(0, 12), - gridId, description, fieldIntro, - StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); } @Override 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 index 192b702..708f2a8 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -1,16 +1,30 @@ package com.casic.dcms.ui.fragment; +import android.content.BroadcastReceiver; import android.content.Context; -import android.widget.LinearLayout; +import android.content.Intent; +import android.text.TextUtils; +import android.view.ViewGroup; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.adapter.SwipeViewAdapter; +import com.casic.dcms.base.BaseApplication; import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; +import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.greendao.DaoSession; +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; import java.util.ArrayList; import java.util.List; @@ -19,17 +33,19 @@ public class NoticePageFragment extends BaseFragment { - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; + @BindView(R.id.swipeRecyclerView) + RecyclerView swipeRecyclerView; private Context context; + private List noticeBeans = new ArrayList<>(); + private SwipeViewAdapter swipeViewAdapter; + private BroadcastManager broadcastManager; + private Gson gson; + private DaoSession daoSession; @Override protected int initLayoutView() { - return R.layout.fragment_dashboard; + return R.layout.fragment_notice; } @Override @@ -39,20 +55,90 @@ @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)); + gson = new Gson(); + daoSession = BaseApplication.getDaoSession(); + swipeViewAdapter = new SwipeViewAdapter(context); + //根据userName加载历史数据 + String userName = StringHelper.getUserName(); + if (TextUtils.isEmpty(userName)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserName.eq(userName)).list(); + swipeViewAdapter.setData(noticeBeans); + + broadcastManager = BroadcastManager.getInstance(context); + broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + if (Constant.NOTICE_MSG.equals(action)) { + String data = intent.getStringExtra("data"); + assert data != null; + NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); + noticeBeans.add(noticeBean); + //更新数据 + swipeViewAdapter.setData(noticeBeans); + } + } + } + }); } @Override protected void initEvent() { + QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { + @Override + public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { + int position = viewHolder.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + @Override + public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { + return QMUIRVItemSwipeAction.SWIPE_LEFT; + } + + @Override + public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { + super.onClickAction(swipeAction, selected, action); + int position = selected.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + }); + swipeAction.attachToRecyclerView(swipeRecyclerView); + swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { + @Override + public RecyclerView.LayoutParams generateDefaultLayoutParams() { + return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + } + }); + swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); + swipeRecyclerView.setAdapter(swipeViewAdapter); + swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { + @Override + public void onClick(int position) { + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = noticeBeans.get(position); + noticeBean.setIsRead("0"); + daoSession.update(noticeBean); + swipeViewAdapter.notifyDataSetChanged(); + + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); + } + }); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (broadcastManager != null) { + broadcastManager.destroy(Constant.NOTICE_MSG); + } } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java deleted file mode 100644 index 7b1e1fb..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class ReadFragment extends BaseFragment { - @Override - protected int initLayoutView() { - return R.layout.fragment_read; - } - - @Override - protected void setupTopBarLayout() { - - } - - @Override - protected void initData() { - - } - - @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 deleted file mode 100644 index a0afe0f..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.text.TextUtils; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.DividerItemDecoration; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SwipeViewAdapter; -import com.casic.dcms.base.BaseApplication; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.greendao.DaoSession; -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; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class UnreadFragment extends BaseFragment { - - private static final String TAG = "UnreadFragment"; - @BindView(R.id.swipeRecyclerView) - RecyclerView swipeRecyclerView; - - private Context context; - private List noticeBeans = new ArrayList<>(); - private SwipeViewAdapter swipeViewAdapter; - private BroadcastManager broadcastManager; - private Gson gson; - private DaoSession daoSession; - - @Override - protected int initLayoutView() { - return R.layout.fragment_unread; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - gson = new Gson(); - daoSession = BaseApplication.getDaoSession(); - swipeViewAdapter = new SwipeViewAdapter(context); - //根据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); - broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.NOTICE_MSG.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); - noticeBeans.add(noticeBean); - //更新数据 - swipeViewAdapter.setData(noticeBeans); - } - } - } - }); - } - - protected void initEvent() { - QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { - @Override - public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { - int position = viewHolder.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - - @Override - public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { - return QMUIRVItemSwipeAction.SWIPE_LEFT; - } - - @Override - public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { - super.onClickAction(swipeAction, selected, action); - int position = selected.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - }); - swipeAction.attachToRecyclerView(swipeRecyclerView); - swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { - @Override - public RecyclerView.LayoutParams generateDefaultLayoutParams() { - return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - } - }); - swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); - swipeRecyclerView.setAdapter(swipeViewAdapter); - swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { - @Override - public void onClick(int position) { - //点击之后之后,未读消息变为已读消息 - NoticeBean noticeBean = new NoticeBean(); - noticeBean.setIsRead("0"); - daoSession.update(noticeBean); - - String caseId = noticeBeans.get(position).getCaseId(); - Intent intent = new Intent(context, CaseDetailActivity.class); - intent.putExtra("id", caseId); - startActivity(intent); - } - }); - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - broadcastManager.destroy(Constant.NOTICE_MSG); - } -} diff --git a/app/src/main/java/com/casic/dcms/utils/StringHelper.java b/app/src/main/java/com/casic/dcms/utils/StringHelper.java index f5d5acb..3947941 100644 --- a/app/src/main/java/com/casic/dcms/utils/StringHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/StringHelper.java @@ -6,6 +6,8 @@ import com.casic.dcms.R; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class StringHelper { @@ -56,6 +58,22 @@ return isDigit && isLetter; } + public static boolean isPhoneNumber(String number) { + String regExp = "^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$"; + if (number.length() != 11) { + Log.d(TAG, "手机号应为11位数"); + return false; + } else { + Pattern p = Pattern.compile(regExp); + Matcher m = p.matcher(number); + boolean isMatch = m.matches(); + if (!isMatch) { + Log.d(TAG, "请填入正确的手机号"); + } + return isMatch; + } + } + public static String appendCompleteURL(String url) { if (TextUtils.isEmpty(url)) { return ""; diff --git a/app/src/main/res/drawable-hdpi/normal.png b/app/src/main/res/drawable-hdpi/normal.png new file mode 100644 index 0000000..3feab7d --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-hdpi/normal_small.png b/app/src/main/res/drawable-hdpi/normal_small.png new file mode 100644 index 0000000..4387126 --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal.png b/app/src/main/res/drawable-ldpi/normal.png new file mode 100644 index 0000000..175184c --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal_small.png b/app/src/main/res/drawable-ldpi/normal_small.png new file mode 100644 index 0000000..5890a00 --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal_small.png Binary files differ diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); 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 865787a..fa17e1f 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,12 +1,14 @@ package com.casic.dcms.service; import android.content.Context; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.bean.PushResultBean; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; import com.casic.dcms.utils.StringHelper; @@ -64,6 +66,7 @@ // 通知到达,只有个推通道下发的通知会回调此方法 @Override public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + Log.d(TAG, "onNotificationMessageArrived: " + message.getContent()); /** * appid = DR9oeLL9va6aG3DYXy2w39 * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 @@ -79,8 +82,8 @@ }.getType()); NoticeBean noticeBean = new NoticeBean(); - noticeBean.setUserPhone(StringHelper.getUserPhone()); - noticeBean.setCaseId(resultBean.getId()); + noticeBean.setUserName(StringHelper.getUserName()); + noticeBean.setCaseId(resultBean.getData().getId()); noticeBean.setTitle(resultBean.getTitle()); noticeBean.setContent(resultBean.getContent()); noticeBean.setType(resultBean.getType()); @@ -101,7 +104,10 @@ PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { }.getType()); - String caseId = resultBean.getId(); + String caseId = resultBean.getData().getId(); Log.d(TAG, "onNotificationMessageClicked: " + caseId); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); } } 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 db7d9ca..a1bcef6 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -244,8 +244,6 @@ showShopDialog(featureBean.getBgid(), (String) feature.getAttributes().get("Note"), featureBean.getDutyname(), - featureBean.getTel(), - "暂无", String.valueOf(featureBean.getObjectid())); } }); @@ -269,10 +267,10 @@ /** * 三包 */ - private void showShopDialog(String gridId, String communityName, String shopName, String phoneNumber, String shopKeeper, String shopID) { + private void showShopDialog(String gridId, String communityName, String shopName, String shopID) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("已选择商户:" + shopName + "\r\n手机号:" + phoneNumber + "\r\n确认提交?") + .setMessage("已选择商户:" + shopName + "\r\n确认提交?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { @@ -281,8 +279,6 @@ dialog.dismiss(); Intent intent = new Intent(); intent.putExtra("shopName", shopName); - intent.putExtra("phoneNumber", phoneNumber); - intent.putExtra("shopKeeper", shopKeeper); intent.putExtra("shopID", shopID); intent.putExtra("latitude", clickPoint.getY()); intent.putExtra("longitude", clickPoint.getX()); diff --git a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java index 8e43b7e..3fa89ee 100644 --- a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java @@ -155,10 +155,6 @@ PublicKey publicKey = RSAUtils.keyStrToPublicKey(keyString); String userName = userNameView.getText().toString(); String userPassword = userPasswordView.getText().toString(); - if (rememberPasswordView.isChecked()) { - SaveKeyValues.putValue("name", userName); - SaveKeyValues.putValue("password", userPassword); - } if (autoLoginView.isChecked()) { SaveKeyValues.putValue("autoLogin", true); } else { @@ -172,6 +168,10 @@ ToastHelper.showToast("密码不能为空", ToastHelper.WARING); return; } + if (rememberPasswordView.isChecked()) { + SaveKeyValues.putValue("name", userName); + SaveKeyValues.putValue("password", userPassword); + } String dataByPublicKey = RSAUtils.encryptDataByPublicKey(userPassword.getBytes(), publicKey); //登录并获取Token,POST请求 loginPresenter.onReadyRetrofitRequest(userName, dataByPublicKey); diff --git a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java index dc5fc67..dad0718 100644 --- a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java @@ -56,6 +56,10 @@ EditText longitudeView; @BindView(R.id.latitudeView) EditText latitudeView; + @BindView(R.id.shopKeeperView) + EditText shopKeeperView; + @BindView(R.id.phoneNumberView) + EditText phoneNumberView; @BindView(R.id.caseLocationView) EditText caseLocationView; @BindView(R.id.caseDetailEditView) @@ -73,7 +77,7 @@ private QMUITipDialog submitDialog; private List realPaths = new ArrayList<>();//真是图片路径 private List mediaList = new ArrayList<>();//上传到服务器的数据集 - private String gridId, shopKeeper, phoneNumber, shopID; + private String gridId, shopID; @Override public int initLayoutView() { @@ -187,8 +191,6 @@ gridId = data.getStringExtra("gridId"); String community = data.getStringExtra("community"); String shopName = data.getStringExtra("shopName"); - phoneNumber = data.getStringExtra("phoneNumber"); - shopKeeper = data.getStringExtra("shopKeeper"); shopID = data.getStringExtra("shopID"); longitudeView.setText(String.valueOf(longitude)); @@ -212,28 +214,41 @@ ToastHelper.showToast("经纬度异常,请重新选择位置", ToastHelper.WARING); return; } - - String fieldIntro = caseLocationView.getText().toString(); - if (TextUtils.isEmpty(fieldIntro)) { - ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + String shopKeeper = shopKeeperView.getText().toString(); + if (TextUtils.isEmpty(shopKeeper)) { + ToastHelper.showToast("店主名还未填写", ToastHelper.WARING); return; } - String description = caseDetailEditView.getText().toString(); - if (TextUtils.isEmpty(description)) { - ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + String phoneNumber = phoneNumberView.getText().toString(); + if (TextUtils.isEmpty(phoneNumber)) { + ToastHelper.showToast("电话号码还未填写", ToastHelper.WARING); return; } - if (mediaList.size() != 2) { - ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); - return; + if (StringHelper.isPhoneNumber(phoneNumber)) { + String fieldIntro = caseLocationView.getText().toString(); + if (TextUtils.isEmpty(fieldIntro)) { + ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + return; + } + String description = caseDetailEditView.getText().toString(); + if (TextUtils.isEmpty(description)) { + ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + return; + } + if (mediaList.size() != 2) { + ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); + return; + } + shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, + "2", "1", + gridId.substring(0, 6), + gridId.substring(0, 9), + gridId.substring(0, 12), + gridId, description, fieldIntro, + StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); + } else { + ToastHelper.showToast("电话号码格式不对", ToastHelper.WARING); } - shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, - "2", "1", - gridId.substring(0, 6), - gridId.substring(0, 9), - gridId.substring(0, 12), - gridId, description, fieldIntro, - StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); } @Override 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 index 192b702..708f2a8 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -1,16 +1,30 @@ package com.casic.dcms.ui.fragment; +import android.content.BroadcastReceiver; import android.content.Context; -import android.widget.LinearLayout; +import android.content.Intent; +import android.text.TextUtils; +import android.view.ViewGroup; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.adapter.SwipeViewAdapter; +import com.casic.dcms.base.BaseApplication; import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; +import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.greendao.DaoSession; +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; import java.util.ArrayList; import java.util.List; @@ -19,17 +33,19 @@ public class NoticePageFragment extends BaseFragment { - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; + @BindView(R.id.swipeRecyclerView) + RecyclerView swipeRecyclerView; private Context context; + private List noticeBeans = new ArrayList<>(); + private SwipeViewAdapter swipeViewAdapter; + private BroadcastManager broadcastManager; + private Gson gson; + private DaoSession daoSession; @Override protected int initLayoutView() { - return R.layout.fragment_dashboard; + return R.layout.fragment_notice; } @Override @@ -39,20 +55,90 @@ @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)); + gson = new Gson(); + daoSession = BaseApplication.getDaoSession(); + swipeViewAdapter = new SwipeViewAdapter(context); + //根据userName加载历史数据 + String userName = StringHelper.getUserName(); + if (TextUtils.isEmpty(userName)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserName.eq(userName)).list(); + swipeViewAdapter.setData(noticeBeans); + + broadcastManager = BroadcastManager.getInstance(context); + broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + if (Constant.NOTICE_MSG.equals(action)) { + String data = intent.getStringExtra("data"); + assert data != null; + NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); + noticeBeans.add(noticeBean); + //更新数据 + swipeViewAdapter.setData(noticeBeans); + } + } + } + }); } @Override protected void initEvent() { + QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { + @Override + public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { + int position = viewHolder.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + @Override + public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { + return QMUIRVItemSwipeAction.SWIPE_LEFT; + } + + @Override + public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { + super.onClickAction(swipeAction, selected, action); + int position = selected.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + }); + swipeAction.attachToRecyclerView(swipeRecyclerView); + swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { + @Override + public RecyclerView.LayoutParams generateDefaultLayoutParams() { + return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + } + }); + swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); + swipeRecyclerView.setAdapter(swipeViewAdapter); + swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { + @Override + public void onClick(int position) { + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = noticeBeans.get(position); + noticeBean.setIsRead("0"); + daoSession.update(noticeBean); + swipeViewAdapter.notifyDataSetChanged(); + + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); + } + }); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (broadcastManager != null) { + broadcastManager.destroy(Constant.NOTICE_MSG); + } } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java deleted file mode 100644 index 7b1e1fb..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class ReadFragment extends BaseFragment { - @Override - protected int initLayoutView() { - return R.layout.fragment_read; - } - - @Override - protected void setupTopBarLayout() { - - } - - @Override - protected void initData() { - - } - - @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 deleted file mode 100644 index a0afe0f..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.text.TextUtils; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.DividerItemDecoration; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SwipeViewAdapter; -import com.casic.dcms.base.BaseApplication; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.greendao.DaoSession; -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; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class UnreadFragment extends BaseFragment { - - private static final String TAG = "UnreadFragment"; - @BindView(R.id.swipeRecyclerView) - RecyclerView swipeRecyclerView; - - private Context context; - private List noticeBeans = new ArrayList<>(); - private SwipeViewAdapter swipeViewAdapter; - private BroadcastManager broadcastManager; - private Gson gson; - private DaoSession daoSession; - - @Override - protected int initLayoutView() { - return R.layout.fragment_unread; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - gson = new Gson(); - daoSession = BaseApplication.getDaoSession(); - swipeViewAdapter = new SwipeViewAdapter(context); - //根据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); - broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.NOTICE_MSG.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); - noticeBeans.add(noticeBean); - //更新数据 - swipeViewAdapter.setData(noticeBeans); - } - } - } - }); - } - - protected void initEvent() { - QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { - @Override - public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { - int position = viewHolder.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - - @Override - public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { - return QMUIRVItemSwipeAction.SWIPE_LEFT; - } - - @Override - public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { - super.onClickAction(swipeAction, selected, action); - int position = selected.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - }); - swipeAction.attachToRecyclerView(swipeRecyclerView); - swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { - @Override - public RecyclerView.LayoutParams generateDefaultLayoutParams() { - return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - } - }); - swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); - swipeRecyclerView.setAdapter(swipeViewAdapter); - swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { - @Override - public void onClick(int position) { - //点击之后之后,未读消息变为已读消息 - NoticeBean noticeBean = new NoticeBean(); - noticeBean.setIsRead("0"); - daoSession.update(noticeBean); - - String caseId = noticeBeans.get(position).getCaseId(); - Intent intent = new Intent(context, CaseDetailActivity.class); - intent.putExtra("id", caseId); - startActivity(intent); - } - }); - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - broadcastManager.destroy(Constant.NOTICE_MSG); - } -} diff --git a/app/src/main/java/com/casic/dcms/utils/StringHelper.java b/app/src/main/java/com/casic/dcms/utils/StringHelper.java index f5d5acb..3947941 100644 --- a/app/src/main/java/com/casic/dcms/utils/StringHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/StringHelper.java @@ -6,6 +6,8 @@ import com.casic.dcms.R; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class StringHelper { @@ -56,6 +58,22 @@ return isDigit && isLetter; } + public static boolean isPhoneNumber(String number) { + String regExp = "^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$"; + if (number.length() != 11) { + Log.d(TAG, "手机号应为11位数"); + return false; + } else { + Pattern p = Pattern.compile(regExp); + Matcher m = p.matcher(number); + boolean isMatch = m.matches(); + if (!isMatch) { + Log.d(TAG, "请填入正确的手机号"); + } + return isMatch; + } + } + public static String appendCompleteURL(String url) { if (TextUtils.isEmpty(url)) { return ""; diff --git a/app/src/main/res/drawable-hdpi/normal.png b/app/src/main/res/drawable-hdpi/normal.png new file mode 100644 index 0000000..3feab7d --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-hdpi/normal_small.png b/app/src/main/res/drawable-hdpi/normal_small.png new file mode 100644 index 0000000..4387126 --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal.png b/app/src/main/res/drawable-ldpi/normal.png new file mode 100644 index 0000000..175184c --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal_small.png b/app/src/main/res/drawable-ldpi/normal_small.png new file mode 100644 index 0000000..5890a00 --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-mdpi/normal.png b/app/src/main/res/drawable-mdpi/normal.png new file mode 100644 index 0000000..7ee8b48 --- /dev/null +++ b/app/src/main/res/drawable-mdpi/normal.png Binary files differ diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); 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 865787a..fa17e1f 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,12 +1,14 @@ package com.casic.dcms.service; import android.content.Context; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.bean.PushResultBean; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; import com.casic.dcms.utils.StringHelper; @@ -64,6 +66,7 @@ // 通知到达,只有个推通道下发的通知会回调此方法 @Override public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + Log.d(TAG, "onNotificationMessageArrived: " + message.getContent()); /** * appid = DR9oeLL9va6aG3DYXy2w39 * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 @@ -79,8 +82,8 @@ }.getType()); NoticeBean noticeBean = new NoticeBean(); - noticeBean.setUserPhone(StringHelper.getUserPhone()); - noticeBean.setCaseId(resultBean.getId()); + noticeBean.setUserName(StringHelper.getUserName()); + noticeBean.setCaseId(resultBean.getData().getId()); noticeBean.setTitle(resultBean.getTitle()); noticeBean.setContent(resultBean.getContent()); noticeBean.setType(resultBean.getType()); @@ -101,7 +104,10 @@ PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { }.getType()); - String caseId = resultBean.getId(); + String caseId = resultBean.getData().getId(); Log.d(TAG, "onNotificationMessageClicked: " + caseId); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); } } 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 db7d9ca..a1bcef6 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -244,8 +244,6 @@ showShopDialog(featureBean.getBgid(), (String) feature.getAttributes().get("Note"), featureBean.getDutyname(), - featureBean.getTel(), - "暂无", String.valueOf(featureBean.getObjectid())); } }); @@ -269,10 +267,10 @@ /** * 三包 */ - private void showShopDialog(String gridId, String communityName, String shopName, String phoneNumber, String shopKeeper, String shopID) { + private void showShopDialog(String gridId, String communityName, String shopName, String shopID) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("已选择商户:" + shopName + "\r\n手机号:" + phoneNumber + "\r\n确认提交?") + .setMessage("已选择商户:" + shopName + "\r\n确认提交?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { @@ -281,8 +279,6 @@ dialog.dismiss(); Intent intent = new Intent(); intent.putExtra("shopName", shopName); - intent.putExtra("phoneNumber", phoneNumber); - intent.putExtra("shopKeeper", shopKeeper); intent.putExtra("shopID", shopID); intent.putExtra("latitude", clickPoint.getY()); intent.putExtra("longitude", clickPoint.getX()); diff --git a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java index 8e43b7e..3fa89ee 100644 --- a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java @@ -155,10 +155,6 @@ PublicKey publicKey = RSAUtils.keyStrToPublicKey(keyString); String userName = userNameView.getText().toString(); String userPassword = userPasswordView.getText().toString(); - if (rememberPasswordView.isChecked()) { - SaveKeyValues.putValue("name", userName); - SaveKeyValues.putValue("password", userPassword); - } if (autoLoginView.isChecked()) { SaveKeyValues.putValue("autoLogin", true); } else { @@ -172,6 +168,10 @@ ToastHelper.showToast("密码不能为空", ToastHelper.WARING); return; } + if (rememberPasswordView.isChecked()) { + SaveKeyValues.putValue("name", userName); + SaveKeyValues.putValue("password", userPassword); + } String dataByPublicKey = RSAUtils.encryptDataByPublicKey(userPassword.getBytes(), publicKey); //登录并获取Token,POST请求 loginPresenter.onReadyRetrofitRequest(userName, dataByPublicKey); diff --git a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java index dc5fc67..dad0718 100644 --- a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java @@ -56,6 +56,10 @@ EditText longitudeView; @BindView(R.id.latitudeView) EditText latitudeView; + @BindView(R.id.shopKeeperView) + EditText shopKeeperView; + @BindView(R.id.phoneNumberView) + EditText phoneNumberView; @BindView(R.id.caseLocationView) EditText caseLocationView; @BindView(R.id.caseDetailEditView) @@ -73,7 +77,7 @@ private QMUITipDialog submitDialog; private List realPaths = new ArrayList<>();//真是图片路径 private List mediaList = new ArrayList<>();//上传到服务器的数据集 - private String gridId, shopKeeper, phoneNumber, shopID; + private String gridId, shopID; @Override public int initLayoutView() { @@ -187,8 +191,6 @@ gridId = data.getStringExtra("gridId"); String community = data.getStringExtra("community"); String shopName = data.getStringExtra("shopName"); - phoneNumber = data.getStringExtra("phoneNumber"); - shopKeeper = data.getStringExtra("shopKeeper"); shopID = data.getStringExtra("shopID"); longitudeView.setText(String.valueOf(longitude)); @@ -212,28 +214,41 @@ ToastHelper.showToast("经纬度异常,请重新选择位置", ToastHelper.WARING); return; } - - String fieldIntro = caseLocationView.getText().toString(); - if (TextUtils.isEmpty(fieldIntro)) { - ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + String shopKeeper = shopKeeperView.getText().toString(); + if (TextUtils.isEmpty(shopKeeper)) { + ToastHelper.showToast("店主名还未填写", ToastHelper.WARING); return; } - String description = caseDetailEditView.getText().toString(); - if (TextUtils.isEmpty(description)) { - ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + String phoneNumber = phoneNumberView.getText().toString(); + if (TextUtils.isEmpty(phoneNumber)) { + ToastHelper.showToast("电话号码还未填写", ToastHelper.WARING); return; } - if (mediaList.size() != 2) { - ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); - return; + if (StringHelper.isPhoneNumber(phoneNumber)) { + String fieldIntro = caseLocationView.getText().toString(); + if (TextUtils.isEmpty(fieldIntro)) { + ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + return; + } + String description = caseDetailEditView.getText().toString(); + if (TextUtils.isEmpty(description)) { + ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + return; + } + if (mediaList.size() != 2) { + ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); + return; + } + shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, + "2", "1", + gridId.substring(0, 6), + gridId.substring(0, 9), + gridId.substring(0, 12), + gridId, description, fieldIntro, + StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); + } else { + ToastHelper.showToast("电话号码格式不对", ToastHelper.WARING); } - shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, - "2", "1", - gridId.substring(0, 6), - gridId.substring(0, 9), - gridId.substring(0, 12), - gridId, description, fieldIntro, - StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); } @Override 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 index 192b702..708f2a8 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -1,16 +1,30 @@ package com.casic.dcms.ui.fragment; +import android.content.BroadcastReceiver; import android.content.Context; -import android.widget.LinearLayout; +import android.content.Intent; +import android.text.TextUtils; +import android.view.ViewGroup; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.adapter.SwipeViewAdapter; +import com.casic.dcms.base.BaseApplication; import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; +import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.greendao.DaoSession; +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; import java.util.ArrayList; import java.util.List; @@ -19,17 +33,19 @@ public class NoticePageFragment extends BaseFragment { - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; + @BindView(R.id.swipeRecyclerView) + RecyclerView swipeRecyclerView; private Context context; + private List noticeBeans = new ArrayList<>(); + private SwipeViewAdapter swipeViewAdapter; + private BroadcastManager broadcastManager; + private Gson gson; + private DaoSession daoSession; @Override protected int initLayoutView() { - return R.layout.fragment_dashboard; + return R.layout.fragment_notice; } @Override @@ -39,20 +55,90 @@ @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)); + gson = new Gson(); + daoSession = BaseApplication.getDaoSession(); + swipeViewAdapter = new SwipeViewAdapter(context); + //根据userName加载历史数据 + String userName = StringHelper.getUserName(); + if (TextUtils.isEmpty(userName)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserName.eq(userName)).list(); + swipeViewAdapter.setData(noticeBeans); + + broadcastManager = BroadcastManager.getInstance(context); + broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + if (Constant.NOTICE_MSG.equals(action)) { + String data = intent.getStringExtra("data"); + assert data != null; + NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); + noticeBeans.add(noticeBean); + //更新数据 + swipeViewAdapter.setData(noticeBeans); + } + } + } + }); } @Override protected void initEvent() { + QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { + @Override + public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { + int position = viewHolder.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + @Override + public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { + return QMUIRVItemSwipeAction.SWIPE_LEFT; + } + + @Override + public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { + super.onClickAction(swipeAction, selected, action); + int position = selected.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + }); + swipeAction.attachToRecyclerView(swipeRecyclerView); + swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { + @Override + public RecyclerView.LayoutParams generateDefaultLayoutParams() { + return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + } + }); + swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); + swipeRecyclerView.setAdapter(swipeViewAdapter); + swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { + @Override + public void onClick(int position) { + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = noticeBeans.get(position); + noticeBean.setIsRead("0"); + daoSession.update(noticeBean); + swipeViewAdapter.notifyDataSetChanged(); + + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); + } + }); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (broadcastManager != null) { + broadcastManager.destroy(Constant.NOTICE_MSG); + } } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java deleted file mode 100644 index 7b1e1fb..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class ReadFragment extends BaseFragment { - @Override - protected int initLayoutView() { - return R.layout.fragment_read; - } - - @Override - protected void setupTopBarLayout() { - - } - - @Override - protected void initData() { - - } - - @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 deleted file mode 100644 index a0afe0f..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.text.TextUtils; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.DividerItemDecoration; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SwipeViewAdapter; -import com.casic.dcms.base.BaseApplication; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.greendao.DaoSession; -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; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class UnreadFragment extends BaseFragment { - - private static final String TAG = "UnreadFragment"; - @BindView(R.id.swipeRecyclerView) - RecyclerView swipeRecyclerView; - - private Context context; - private List noticeBeans = new ArrayList<>(); - private SwipeViewAdapter swipeViewAdapter; - private BroadcastManager broadcastManager; - private Gson gson; - private DaoSession daoSession; - - @Override - protected int initLayoutView() { - return R.layout.fragment_unread; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - gson = new Gson(); - daoSession = BaseApplication.getDaoSession(); - swipeViewAdapter = new SwipeViewAdapter(context); - //根据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); - broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.NOTICE_MSG.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); - noticeBeans.add(noticeBean); - //更新数据 - swipeViewAdapter.setData(noticeBeans); - } - } - } - }); - } - - protected void initEvent() { - QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { - @Override - public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { - int position = viewHolder.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - - @Override - public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { - return QMUIRVItemSwipeAction.SWIPE_LEFT; - } - - @Override - public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { - super.onClickAction(swipeAction, selected, action); - int position = selected.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - }); - swipeAction.attachToRecyclerView(swipeRecyclerView); - swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { - @Override - public RecyclerView.LayoutParams generateDefaultLayoutParams() { - return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - } - }); - swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); - swipeRecyclerView.setAdapter(swipeViewAdapter); - swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { - @Override - public void onClick(int position) { - //点击之后之后,未读消息变为已读消息 - NoticeBean noticeBean = new NoticeBean(); - noticeBean.setIsRead("0"); - daoSession.update(noticeBean); - - String caseId = noticeBeans.get(position).getCaseId(); - Intent intent = new Intent(context, CaseDetailActivity.class); - intent.putExtra("id", caseId); - startActivity(intent); - } - }); - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - broadcastManager.destroy(Constant.NOTICE_MSG); - } -} diff --git a/app/src/main/java/com/casic/dcms/utils/StringHelper.java b/app/src/main/java/com/casic/dcms/utils/StringHelper.java index f5d5acb..3947941 100644 --- a/app/src/main/java/com/casic/dcms/utils/StringHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/StringHelper.java @@ -6,6 +6,8 @@ import com.casic.dcms.R; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class StringHelper { @@ -56,6 +58,22 @@ return isDigit && isLetter; } + public static boolean isPhoneNumber(String number) { + String regExp = "^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$"; + if (number.length() != 11) { + Log.d(TAG, "手机号应为11位数"); + return false; + } else { + Pattern p = Pattern.compile(regExp); + Matcher m = p.matcher(number); + boolean isMatch = m.matches(); + if (!isMatch) { + Log.d(TAG, "请填入正确的手机号"); + } + return isMatch; + } + } + public static String appendCompleteURL(String url) { if (TextUtils.isEmpty(url)) { return ""; diff --git a/app/src/main/res/drawable-hdpi/normal.png b/app/src/main/res/drawable-hdpi/normal.png new file mode 100644 index 0000000..3feab7d --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-hdpi/normal_small.png b/app/src/main/res/drawable-hdpi/normal_small.png new file mode 100644 index 0000000..4387126 --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal.png b/app/src/main/res/drawable-ldpi/normal.png new file mode 100644 index 0000000..175184c --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal_small.png b/app/src/main/res/drawable-ldpi/normal_small.png new file mode 100644 index 0000000..5890a00 --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-mdpi/normal.png b/app/src/main/res/drawable-mdpi/normal.png new file mode 100644 index 0000000..7ee8b48 --- /dev/null +++ b/app/src/main/res/drawable-mdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-mdpi/normal_small.png b/app/src/main/res/drawable-mdpi/normal_small.png new file mode 100644 index 0000000..43aa9ec --- /dev/null +++ b/app/src/main/res/drawable-mdpi/normal_small.png Binary files differ diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); 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 865787a..fa17e1f 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,12 +1,14 @@ package com.casic.dcms.service; import android.content.Context; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.bean.PushResultBean; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; import com.casic.dcms.utils.StringHelper; @@ -64,6 +66,7 @@ // 通知到达,只有个推通道下发的通知会回调此方法 @Override public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + Log.d(TAG, "onNotificationMessageArrived: " + message.getContent()); /** * appid = DR9oeLL9va6aG3DYXy2w39 * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 @@ -79,8 +82,8 @@ }.getType()); NoticeBean noticeBean = new NoticeBean(); - noticeBean.setUserPhone(StringHelper.getUserPhone()); - noticeBean.setCaseId(resultBean.getId()); + noticeBean.setUserName(StringHelper.getUserName()); + noticeBean.setCaseId(resultBean.getData().getId()); noticeBean.setTitle(resultBean.getTitle()); noticeBean.setContent(resultBean.getContent()); noticeBean.setType(resultBean.getType()); @@ -101,7 +104,10 @@ PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { }.getType()); - String caseId = resultBean.getId(); + String caseId = resultBean.getData().getId(); Log.d(TAG, "onNotificationMessageClicked: " + caseId); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); } } 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 db7d9ca..a1bcef6 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -244,8 +244,6 @@ showShopDialog(featureBean.getBgid(), (String) feature.getAttributes().get("Note"), featureBean.getDutyname(), - featureBean.getTel(), - "暂无", String.valueOf(featureBean.getObjectid())); } }); @@ -269,10 +267,10 @@ /** * 三包 */ - private void showShopDialog(String gridId, String communityName, String shopName, String phoneNumber, String shopKeeper, String shopID) { + private void showShopDialog(String gridId, String communityName, String shopName, String shopID) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("已选择商户:" + shopName + "\r\n手机号:" + phoneNumber + "\r\n确认提交?") + .setMessage("已选择商户:" + shopName + "\r\n确认提交?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { @@ -281,8 +279,6 @@ dialog.dismiss(); Intent intent = new Intent(); intent.putExtra("shopName", shopName); - intent.putExtra("phoneNumber", phoneNumber); - intent.putExtra("shopKeeper", shopKeeper); intent.putExtra("shopID", shopID); intent.putExtra("latitude", clickPoint.getY()); intent.putExtra("longitude", clickPoint.getX()); diff --git a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java index 8e43b7e..3fa89ee 100644 --- a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java @@ -155,10 +155,6 @@ PublicKey publicKey = RSAUtils.keyStrToPublicKey(keyString); String userName = userNameView.getText().toString(); String userPassword = userPasswordView.getText().toString(); - if (rememberPasswordView.isChecked()) { - SaveKeyValues.putValue("name", userName); - SaveKeyValues.putValue("password", userPassword); - } if (autoLoginView.isChecked()) { SaveKeyValues.putValue("autoLogin", true); } else { @@ -172,6 +168,10 @@ ToastHelper.showToast("密码不能为空", ToastHelper.WARING); return; } + if (rememberPasswordView.isChecked()) { + SaveKeyValues.putValue("name", userName); + SaveKeyValues.putValue("password", userPassword); + } String dataByPublicKey = RSAUtils.encryptDataByPublicKey(userPassword.getBytes(), publicKey); //登录并获取Token,POST请求 loginPresenter.onReadyRetrofitRequest(userName, dataByPublicKey); diff --git a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java index dc5fc67..dad0718 100644 --- a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java @@ -56,6 +56,10 @@ EditText longitudeView; @BindView(R.id.latitudeView) EditText latitudeView; + @BindView(R.id.shopKeeperView) + EditText shopKeeperView; + @BindView(R.id.phoneNumberView) + EditText phoneNumberView; @BindView(R.id.caseLocationView) EditText caseLocationView; @BindView(R.id.caseDetailEditView) @@ -73,7 +77,7 @@ private QMUITipDialog submitDialog; private List realPaths = new ArrayList<>();//真是图片路径 private List mediaList = new ArrayList<>();//上传到服务器的数据集 - private String gridId, shopKeeper, phoneNumber, shopID; + private String gridId, shopID; @Override public int initLayoutView() { @@ -187,8 +191,6 @@ gridId = data.getStringExtra("gridId"); String community = data.getStringExtra("community"); String shopName = data.getStringExtra("shopName"); - phoneNumber = data.getStringExtra("phoneNumber"); - shopKeeper = data.getStringExtra("shopKeeper"); shopID = data.getStringExtra("shopID"); longitudeView.setText(String.valueOf(longitude)); @@ -212,28 +214,41 @@ ToastHelper.showToast("经纬度异常,请重新选择位置", ToastHelper.WARING); return; } - - String fieldIntro = caseLocationView.getText().toString(); - if (TextUtils.isEmpty(fieldIntro)) { - ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + String shopKeeper = shopKeeperView.getText().toString(); + if (TextUtils.isEmpty(shopKeeper)) { + ToastHelper.showToast("店主名还未填写", ToastHelper.WARING); return; } - String description = caseDetailEditView.getText().toString(); - if (TextUtils.isEmpty(description)) { - ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + String phoneNumber = phoneNumberView.getText().toString(); + if (TextUtils.isEmpty(phoneNumber)) { + ToastHelper.showToast("电话号码还未填写", ToastHelper.WARING); return; } - if (mediaList.size() != 2) { - ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); - return; + if (StringHelper.isPhoneNumber(phoneNumber)) { + String fieldIntro = caseLocationView.getText().toString(); + if (TextUtils.isEmpty(fieldIntro)) { + ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + return; + } + String description = caseDetailEditView.getText().toString(); + if (TextUtils.isEmpty(description)) { + ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + return; + } + if (mediaList.size() != 2) { + ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); + return; + } + shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, + "2", "1", + gridId.substring(0, 6), + gridId.substring(0, 9), + gridId.substring(0, 12), + gridId, description, fieldIntro, + StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); + } else { + ToastHelper.showToast("电话号码格式不对", ToastHelper.WARING); } - shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, - "2", "1", - gridId.substring(0, 6), - gridId.substring(0, 9), - gridId.substring(0, 12), - gridId, description, fieldIntro, - StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); } @Override 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 index 192b702..708f2a8 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -1,16 +1,30 @@ package com.casic.dcms.ui.fragment; +import android.content.BroadcastReceiver; import android.content.Context; -import android.widget.LinearLayout; +import android.content.Intent; +import android.text.TextUtils; +import android.view.ViewGroup; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.adapter.SwipeViewAdapter; +import com.casic.dcms.base.BaseApplication; import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; +import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.greendao.DaoSession; +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; import java.util.ArrayList; import java.util.List; @@ -19,17 +33,19 @@ public class NoticePageFragment extends BaseFragment { - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; + @BindView(R.id.swipeRecyclerView) + RecyclerView swipeRecyclerView; private Context context; + private List noticeBeans = new ArrayList<>(); + private SwipeViewAdapter swipeViewAdapter; + private BroadcastManager broadcastManager; + private Gson gson; + private DaoSession daoSession; @Override protected int initLayoutView() { - return R.layout.fragment_dashboard; + return R.layout.fragment_notice; } @Override @@ -39,20 +55,90 @@ @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)); + gson = new Gson(); + daoSession = BaseApplication.getDaoSession(); + swipeViewAdapter = new SwipeViewAdapter(context); + //根据userName加载历史数据 + String userName = StringHelper.getUserName(); + if (TextUtils.isEmpty(userName)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserName.eq(userName)).list(); + swipeViewAdapter.setData(noticeBeans); + + broadcastManager = BroadcastManager.getInstance(context); + broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + if (Constant.NOTICE_MSG.equals(action)) { + String data = intent.getStringExtra("data"); + assert data != null; + NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); + noticeBeans.add(noticeBean); + //更新数据 + swipeViewAdapter.setData(noticeBeans); + } + } + } + }); } @Override protected void initEvent() { + QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { + @Override + public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { + int position = viewHolder.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + @Override + public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { + return QMUIRVItemSwipeAction.SWIPE_LEFT; + } + + @Override + public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { + super.onClickAction(swipeAction, selected, action); + int position = selected.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + }); + swipeAction.attachToRecyclerView(swipeRecyclerView); + swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { + @Override + public RecyclerView.LayoutParams generateDefaultLayoutParams() { + return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + } + }); + swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); + swipeRecyclerView.setAdapter(swipeViewAdapter); + swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { + @Override + public void onClick(int position) { + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = noticeBeans.get(position); + noticeBean.setIsRead("0"); + daoSession.update(noticeBean); + swipeViewAdapter.notifyDataSetChanged(); + + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); + } + }); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (broadcastManager != null) { + broadcastManager.destroy(Constant.NOTICE_MSG); + } } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java deleted file mode 100644 index 7b1e1fb..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class ReadFragment extends BaseFragment { - @Override - protected int initLayoutView() { - return R.layout.fragment_read; - } - - @Override - protected void setupTopBarLayout() { - - } - - @Override - protected void initData() { - - } - - @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 deleted file mode 100644 index a0afe0f..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.text.TextUtils; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.DividerItemDecoration; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SwipeViewAdapter; -import com.casic.dcms.base.BaseApplication; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.greendao.DaoSession; -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; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class UnreadFragment extends BaseFragment { - - private static final String TAG = "UnreadFragment"; - @BindView(R.id.swipeRecyclerView) - RecyclerView swipeRecyclerView; - - private Context context; - private List noticeBeans = new ArrayList<>(); - private SwipeViewAdapter swipeViewAdapter; - private BroadcastManager broadcastManager; - private Gson gson; - private DaoSession daoSession; - - @Override - protected int initLayoutView() { - return R.layout.fragment_unread; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - gson = new Gson(); - daoSession = BaseApplication.getDaoSession(); - swipeViewAdapter = new SwipeViewAdapter(context); - //根据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); - broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.NOTICE_MSG.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); - noticeBeans.add(noticeBean); - //更新数据 - swipeViewAdapter.setData(noticeBeans); - } - } - } - }); - } - - protected void initEvent() { - QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { - @Override - public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { - int position = viewHolder.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - - @Override - public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { - return QMUIRVItemSwipeAction.SWIPE_LEFT; - } - - @Override - public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { - super.onClickAction(swipeAction, selected, action); - int position = selected.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - }); - swipeAction.attachToRecyclerView(swipeRecyclerView); - swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { - @Override - public RecyclerView.LayoutParams generateDefaultLayoutParams() { - return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - } - }); - swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); - swipeRecyclerView.setAdapter(swipeViewAdapter); - swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { - @Override - public void onClick(int position) { - //点击之后之后,未读消息变为已读消息 - NoticeBean noticeBean = new NoticeBean(); - noticeBean.setIsRead("0"); - daoSession.update(noticeBean); - - String caseId = noticeBeans.get(position).getCaseId(); - Intent intent = new Intent(context, CaseDetailActivity.class); - intent.putExtra("id", caseId); - startActivity(intent); - } - }); - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - broadcastManager.destroy(Constant.NOTICE_MSG); - } -} diff --git a/app/src/main/java/com/casic/dcms/utils/StringHelper.java b/app/src/main/java/com/casic/dcms/utils/StringHelper.java index f5d5acb..3947941 100644 --- a/app/src/main/java/com/casic/dcms/utils/StringHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/StringHelper.java @@ -6,6 +6,8 @@ import com.casic.dcms.R; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class StringHelper { @@ -56,6 +58,22 @@ return isDigit && isLetter; } + public static boolean isPhoneNumber(String number) { + String regExp = "^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$"; + if (number.length() != 11) { + Log.d(TAG, "手机号应为11位数"); + return false; + } else { + Pattern p = Pattern.compile(regExp); + Matcher m = p.matcher(number); + boolean isMatch = m.matches(); + if (!isMatch) { + Log.d(TAG, "请填入正确的手机号"); + } + return isMatch; + } + } + public static String appendCompleteURL(String url) { if (TextUtils.isEmpty(url)) { return ""; diff --git a/app/src/main/res/drawable-hdpi/normal.png b/app/src/main/res/drawable-hdpi/normal.png new file mode 100644 index 0000000..3feab7d --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-hdpi/normal_small.png b/app/src/main/res/drawable-hdpi/normal_small.png new file mode 100644 index 0000000..4387126 --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal.png b/app/src/main/res/drawable-ldpi/normal.png new file mode 100644 index 0000000..175184c --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal_small.png b/app/src/main/res/drawable-ldpi/normal_small.png new file mode 100644 index 0000000..5890a00 --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-mdpi/normal.png b/app/src/main/res/drawable-mdpi/normal.png new file mode 100644 index 0000000..7ee8b48 --- /dev/null +++ b/app/src/main/res/drawable-mdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-mdpi/normal_small.png b/app/src/main/res/drawable-mdpi/normal_small.png new file mode 100644 index 0000000..43aa9ec --- /dev/null +++ b/app/src/main/res/drawable-mdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-xhdpi/normal.png b/app/src/main/res/drawable-xhdpi/normal.png new file mode 100644 index 0000000..5bd5a01 --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/normal.png Binary files differ diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); 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 865787a..fa17e1f 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,12 +1,14 @@ package com.casic.dcms.service; import android.content.Context; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.bean.PushResultBean; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; import com.casic.dcms.utils.StringHelper; @@ -64,6 +66,7 @@ // 通知到达,只有个推通道下发的通知会回调此方法 @Override public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + Log.d(TAG, "onNotificationMessageArrived: " + message.getContent()); /** * appid = DR9oeLL9va6aG3DYXy2w39 * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 @@ -79,8 +82,8 @@ }.getType()); NoticeBean noticeBean = new NoticeBean(); - noticeBean.setUserPhone(StringHelper.getUserPhone()); - noticeBean.setCaseId(resultBean.getId()); + noticeBean.setUserName(StringHelper.getUserName()); + noticeBean.setCaseId(resultBean.getData().getId()); noticeBean.setTitle(resultBean.getTitle()); noticeBean.setContent(resultBean.getContent()); noticeBean.setType(resultBean.getType()); @@ -101,7 +104,10 @@ PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { }.getType()); - String caseId = resultBean.getId(); + String caseId = resultBean.getData().getId(); Log.d(TAG, "onNotificationMessageClicked: " + caseId); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); } } 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 db7d9ca..a1bcef6 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -244,8 +244,6 @@ showShopDialog(featureBean.getBgid(), (String) feature.getAttributes().get("Note"), featureBean.getDutyname(), - featureBean.getTel(), - "暂无", String.valueOf(featureBean.getObjectid())); } }); @@ -269,10 +267,10 @@ /** * 三包 */ - private void showShopDialog(String gridId, String communityName, String shopName, String phoneNumber, String shopKeeper, String shopID) { + private void showShopDialog(String gridId, String communityName, String shopName, String shopID) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("已选择商户:" + shopName + "\r\n手机号:" + phoneNumber + "\r\n确认提交?") + .setMessage("已选择商户:" + shopName + "\r\n确认提交?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { @@ -281,8 +279,6 @@ dialog.dismiss(); Intent intent = new Intent(); intent.putExtra("shopName", shopName); - intent.putExtra("phoneNumber", phoneNumber); - intent.putExtra("shopKeeper", shopKeeper); intent.putExtra("shopID", shopID); intent.putExtra("latitude", clickPoint.getY()); intent.putExtra("longitude", clickPoint.getX()); diff --git a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java index 8e43b7e..3fa89ee 100644 --- a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java @@ -155,10 +155,6 @@ PublicKey publicKey = RSAUtils.keyStrToPublicKey(keyString); String userName = userNameView.getText().toString(); String userPassword = userPasswordView.getText().toString(); - if (rememberPasswordView.isChecked()) { - SaveKeyValues.putValue("name", userName); - SaveKeyValues.putValue("password", userPassword); - } if (autoLoginView.isChecked()) { SaveKeyValues.putValue("autoLogin", true); } else { @@ -172,6 +168,10 @@ ToastHelper.showToast("密码不能为空", ToastHelper.WARING); return; } + if (rememberPasswordView.isChecked()) { + SaveKeyValues.putValue("name", userName); + SaveKeyValues.putValue("password", userPassword); + } String dataByPublicKey = RSAUtils.encryptDataByPublicKey(userPassword.getBytes(), publicKey); //登录并获取Token,POST请求 loginPresenter.onReadyRetrofitRequest(userName, dataByPublicKey); diff --git a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java index dc5fc67..dad0718 100644 --- a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java @@ -56,6 +56,10 @@ EditText longitudeView; @BindView(R.id.latitudeView) EditText latitudeView; + @BindView(R.id.shopKeeperView) + EditText shopKeeperView; + @BindView(R.id.phoneNumberView) + EditText phoneNumberView; @BindView(R.id.caseLocationView) EditText caseLocationView; @BindView(R.id.caseDetailEditView) @@ -73,7 +77,7 @@ private QMUITipDialog submitDialog; private List realPaths = new ArrayList<>();//真是图片路径 private List mediaList = new ArrayList<>();//上传到服务器的数据集 - private String gridId, shopKeeper, phoneNumber, shopID; + private String gridId, shopID; @Override public int initLayoutView() { @@ -187,8 +191,6 @@ gridId = data.getStringExtra("gridId"); String community = data.getStringExtra("community"); String shopName = data.getStringExtra("shopName"); - phoneNumber = data.getStringExtra("phoneNumber"); - shopKeeper = data.getStringExtra("shopKeeper"); shopID = data.getStringExtra("shopID"); longitudeView.setText(String.valueOf(longitude)); @@ -212,28 +214,41 @@ ToastHelper.showToast("经纬度异常,请重新选择位置", ToastHelper.WARING); return; } - - String fieldIntro = caseLocationView.getText().toString(); - if (TextUtils.isEmpty(fieldIntro)) { - ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + String shopKeeper = shopKeeperView.getText().toString(); + if (TextUtils.isEmpty(shopKeeper)) { + ToastHelper.showToast("店主名还未填写", ToastHelper.WARING); return; } - String description = caseDetailEditView.getText().toString(); - if (TextUtils.isEmpty(description)) { - ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + String phoneNumber = phoneNumberView.getText().toString(); + if (TextUtils.isEmpty(phoneNumber)) { + ToastHelper.showToast("电话号码还未填写", ToastHelper.WARING); return; } - if (mediaList.size() != 2) { - ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); - return; + if (StringHelper.isPhoneNumber(phoneNumber)) { + String fieldIntro = caseLocationView.getText().toString(); + if (TextUtils.isEmpty(fieldIntro)) { + ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + return; + } + String description = caseDetailEditView.getText().toString(); + if (TextUtils.isEmpty(description)) { + ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + return; + } + if (mediaList.size() != 2) { + ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); + return; + } + shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, + "2", "1", + gridId.substring(0, 6), + gridId.substring(0, 9), + gridId.substring(0, 12), + gridId, description, fieldIntro, + StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); + } else { + ToastHelper.showToast("电话号码格式不对", ToastHelper.WARING); } - shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, - "2", "1", - gridId.substring(0, 6), - gridId.substring(0, 9), - gridId.substring(0, 12), - gridId, description, fieldIntro, - StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); } @Override 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 index 192b702..708f2a8 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -1,16 +1,30 @@ package com.casic.dcms.ui.fragment; +import android.content.BroadcastReceiver; import android.content.Context; -import android.widget.LinearLayout; +import android.content.Intent; +import android.text.TextUtils; +import android.view.ViewGroup; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.adapter.SwipeViewAdapter; +import com.casic.dcms.base.BaseApplication; import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; +import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.greendao.DaoSession; +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; import java.util.ArrayList; import java.util.List; @@ -19,17 +33,19 @@ public class NoticePageFragment extends BaseFragment { - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; + @BindView(R.id.swipeRecyclerView) + RecyclerView swipeRecyclerView; private Context context; + private List noticeBeans = new ArrayList<>(); + private SwipeViewAdapter swipeViewAdapter; + private BroadcastManager broadcastManager; + private Gson gson; + private DaoSession daoSession; @Override protected int initLayoutView() { - return R.layout.fragment_dashboard; + return R.layout.fragment_notice; } @Override @@ -39,20 +55,90 @@ @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)); + gson = new Gson(); + daoSession = BaseApplication.getDaoSession(); + swipeViewAdapter = new SwipeViewAdapter(context); + //根据userName加载历史数据 + String userName = StringHelper.getUserName(); + if (TextUtils.isEmpty(userName)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserName.eq(userName)).list(); + swipeViewAdapter.setData(noticeBeans); + + broadcastManager = BroadcastManager.getInstance(context); + broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + if (Constant.NOTICE_MSG.equals(action)) { + String data = intent.getStringExtra("data"); + assert data != null; + NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); + noticeBeans.add(noticeBean); + //更新数据 + swipeViewAdapter.setData(noticeBeans); + } + } + } + }); } @Override protected void initEvent() { + QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { + @Override + public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { + int position = viewHolder.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + @Override + public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { + return QMUIRVItemSwipeAction.SWIPE_LEFT; + } + + @Override + public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { + super.onClickAction(swipeAction, selected, action); + int position = selected.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + }); + swipeAction.attachToRecyclerView(swipeRecyclerView); + swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { + @Override + public RecyclerView.LayoutParams generateDefaultLayoutParams() { + return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + } + }); + swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); + swipeRecyclerView.setAdapter(swipeViewAdapter); + swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { + @Override + public void onClick(int position) { + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = noticeBeans.get(position); + noticeBean.setIsRead("0"); + daoSession.update(noticeBean); + swipeViewAdapter.notifyDataSetChanged(); + + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); + } + }); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (broadcastManager != null) { + broadcastManager.destroy(Constant.NOTICE_MSG); + } } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java deleted file mode 100644 index 7b1e1fb..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class ReadFragment extends BaseFragment { - @Override - protected int initLayoutView() { - return R.layout.fragment_read; - } - - @Override - protected void setupTopBarLayout() { - - } - - @Override - protected void initData() { - - } - - @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 deleted file mode 100644 index a0afe0f..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.text.TextUtils; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.DividerItemDecoration; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SwipeViewAdapter; -import com.casic.dcms.base.BaseApplication; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.greendao.DaoSession; -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; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class UnreadFragment extends BaseFragment { - - private static final String TAG = "UnreadFragment"; - @BindView(R.id.swipeRecyclerView) - RecyclerView swipeRecyclerView; - - private Context context; - private List noticeBeans = new ArrayList<>(); - private SwipeViewAdapter swipeViewAdapter; - private BroadcastManager broadcastManager; - private Gson gson; - private DaoSession daoSession; - - @Override - protected int initLayoutView() { - return R.layout.fragment_unread; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - gson = new Gson(); - daoSession = BaseApplication.getDaoSession(); - swipeViewAdapter = new SwipeViewAdapter(context); - //根据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); - broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.NOTICE_MSG.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); - noticeBeans.add(noticeBean); - //更新数据 - swipeViewAdapter.setData(noticeBeans); - } - } - } - }); - } - - protected void initEvent() { - QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { - @Override - public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { - int position = viewHolder.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - - @Override - public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { - return QMUIRVItemSwipeAction.SWIPE_LEFT; - } - - @Override - public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { - super.onClickAction(swipeAction, selected, action); - int position = selected.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - }); - swipeAction.attachToRecyclerView(swipeRecyclerView); - swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { - @Override - public RecyclerView.LayoutParams generateDefaultLayoutParams() { - return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - } - }); - swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); - swipeRecyclerView.setAdapter(swipeViewAdapter); - swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { - @Override - public void onClick(int position) { - //点击之后之后,未读消息变为已读消息 - NoticeBean noticeBean = new NoticeBean(); - noticeBean.setIsRead("0"); - daoSession.update(noticeBean); - - String caseId = noticeBeans.get(position).getCaseId(); - Intent intent = new Intent(context, CaseDetailActivity.class); - intent.putExtra("id", caseId); - startActivity(intent); - } - }); - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - broadcastManager.destroy(Constant.NOTICE_MSG); - } -} diff --git a/app/src/main/java/com/casic/dcms/utils/StringHelper.java b/app/src/main/java/com/casic/dcms/utils/StringHelper.java index f5d5acb..3947941 100644 --- a/app/src/main/java/com/casic/dcms/utils/StringHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/StringHelper.java @@ -6,6 +6,8 @@ import com.casic.dcms.R; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class StringHelper { @@ -56,6 +58,22 @@ return isDigit && isLetter; } + public static boolean isPhoneNumber(String number) { + String regExp = "^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$"; + if (number.length() != 11) { + Log.d(TAG, "手机号应为11位数"); + return false; + } else { + Pattern p = Pattern.compile(regExp); + Matcher m = p.matcher(number); + boolean isMatch = m.matches(); + if (!isMatch) { + Log.d(TAG, "请填入正确的手机号"); + } + return isMatch; + } + } + public static String appendCompleteURL(String url) { if (TextUtils.isEmpty(url)) { return ""; diff --git a/app/src/main/res/drawable-hdpi/normal.png b/app/src/main/res/drawable-hdpi/normal.png new file mode 100644 index 0000000..3feab7d --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-hdpi/normal_small.png b/app/src/main/res/drawable-hdpi/normal_small.png new file mode 100644 index 0000000..4387126 --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal.png b/app/src/main/res/drawable-ldpi/normal.png new file mode 100644 index 0000000..175184c --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal_small.png b/app/src/main/res/drawable-ldpi/normal_small.png new file mode 100644 index 0000000..5890a00 --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-mdpi/normal.png b/app/src/main/res/drawable-mdpi/normal.png new file mode 100644 index 0000000..7ee8b48 --- /dev/null +++ b/app/src/main/res/drawable-mdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-mdpi/normal_small.png b/app/src/main/res/drawable-mdpi/normal_small.png new file mode 100644 index 0000000..43aa9ec --- /dev/null +++ b/app/src/main/res/drawable-mdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-xhdpi/normal.png b/app/src/main/res/drawable-xhdpi/normal.png new file mode 100644 index 0000000..5bd5a01 --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-xhdpi/normal_small.png b/app/src/main/res/drawable-xhdpi/normal_small.png new file mode 100644 index 0000000..51497fe --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/normal_small.png Binary files differ diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); 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 865787a..fa17e1f 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,12 +1,14 @@ package com.casic.dcms.service; import android.content.Context; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.bean.PushResultBean; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; import com.casic.dcms.utils.StringHelper; @@ -64,6 +66,7 @@ // 通知到达,只有个推通道下发的通知会回调此方法 @Override public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + Log.d(TAG, "onNotificationMessageArrived: " + message.getContent()); /** * appid = DR9oeLL9va6aG3DYXy2w39 * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 @@ -79,8 +82,8 @@ }.getType()); NoticeBean noticeBean = new NoticeBean(); - noticeBean.setUserPhone(StringHelper.getUserPhone()); - noticeBean.setCaseId(resultBean.getId()); + noticeBean.setUserName(StringHelper.getUserName()); + noticeBean.setCaseId(resultBean.getData().getId()); noticeBean.setTitle(resultBean.getTitle()); noticeBean.setContent(resultBean.getContent()); noticeBean.setType(resultBean.getType()); @@ -101,7 +104,10 @@ PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { }.getType()); - String caseId = resultBean.getId(); + String caseId = resultBean.getData().getId(); Log.d(TAG, "onNotificationMessageClicked: " + caseId); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); } } 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 db7d9ca..a1bcef6 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -244,8 +244,6 @@ showShopDialog(featureBean.getBgid(), (String) feature.getAttributes().get("Note"), featureBean.getDutyname(), - featureBean.getTel(), - "暂无", String.valueOf(featureBean.getObjectid())); } }); @@ -269,10 +267,10 @@ /** * 三包 */ - private void showShopDialog(String gridId, String communityName, String shopName, String phoneNumber, String shopKeeper, String shopID) { + private void showShopDialog(String gridId, String communityName, String shopName, String shopID) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("已选择商户:" + shopName + "\r\n手机号:" + phoneNumber + "\r\n确认提交?") + .setMessage("已选择商户:" + shopName + "\r\n确认提交?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { @@ -281,8 +279,6 @@ dialog.dismiss(); Intent intent = new Intent(); intent.putExtra("shopName", shopName); - intent.putExtra("phoneNumber", phoneNumber); - intent.putExtra("shopKeeper", shopKeeper); intent.putExtra("shopID", shopID); intent.putExtra("latitude", clickPoint.getY()); intent.putExtra("longitude", clickPoint.getX()); diff --git a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java index 8e43b7e..3fa89ee 100644 --- a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java @@ -155,10 +155,6 @@ PublicKey publicKey = RSAUtils.keyStrToPublicKey(keyString); String userName = userNameView.getText().toString(); String userPassword = userPasswordView.getText().toString(); - if (rememberPasswordView.isChecked()) { - SaveKeyValues.putValue("name", userName); - SaveKeyValues.putValue("password", userPassword); - } if (autoLoginView.isChecked()) { SaveKeyValues.putValue("autoLogin", true); } else { @@ -172,6 +168,10 @@ ToastHelper.showToast("密码不能为空", ToastHelper.WARING); return; } + if (rememberPasswordView.isChecked()) { + SaveKeyValues.putValue("name", userName); + SaveKeyValues.putValue("password", userPassword); + } String dataByPublicKey = RSAUtils.encryptDataByPublicKey(userPassword.getBytes(), publicKey); //登录并获取Token,POST请求 loginPresenter.onReadyRetrofitRequest(userName, dataByPublicKey); diff --git a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java index dc5fc67..dad0718 100644 --- a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java @@ -56,6 +56,10 @@ EditText longitudeView; @BindView(R.id.latitudeView) EditText latitudeView; + @BindView(R.id.shopKeeperView) + EditText shopKeeperView; + @BindView(R.id.phoneNumberView) + EditText phoneNumberView; @BindView(R.id.caseLocationView) EditText caseLocationView; @BindView(R.id.caseDetailEditView) @@ -73,7 +77,7 @@ private QMUITipDialog submitDialog; private List realPaths = new ArrayList<>();//真是图片路径 private List mediaList = new ArrayList<>();//上传到服务器的数据集 - private String gridId, shopKeeper, phoneNumber, shopID; + private String gridId, shopID; @Override public int initLayoutView() { @@ -187,8 +191,6 @@ gridId = data.getStringExtra("gridId"); String community = data.getStringExtra("community"); String shopName = data.getStringExtra("shopName"); - phoneNumber = data.getStringExtra("phoneNumber"); - shopKeeper = data.getStringExtra("shopKeeper"); shopID = data.getStringExtra("shopID"); longitudeView.setText(String.valueOf(longitude)); @@ -212,28 +214,41 @@ ToastHelper.showToast("经纬度异常,请重新选择位置", ToastHelper.WARING); return; } - - String fieldIntro = caseLocationView.getText().toString(); - if (TextUtils.isEmpty(fieldIntro)) { - ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + String shopKeeper = shopKeeperView.getText().toString(); + if (TextUtils.isEmpty(shopKeeper)) { + ToastHelper.showToast("店主名还未填写", ToastHelper.WARING); return; } - String description = caseDetailEditView.getText().toString(); - if (TextUtils.isEmpty(description)) { - ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + String phoneNumber = phoneNumberView.getText().toString(); + if (TextUtils.isEmpty(phoneNumber)) { + ToastHelper.showToast("电话号码还未填写", ToastHelper.WARING); return; } - if (mediaList.size() != 2) { - ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); - return; + if (StringHelper.isPhoneNumber(phoneNumber)) { + String fieldIntro = caseLocationView.getText().toString(); + if (TextUtils.isEmpty(fieldIntro)) { + ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + return; + } + String description = caseDetailEditView.getText().toString(); + if (TextUtils.isEmpty(description)) { + ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + return; + } + if (mediaList.size() != 2) { + ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); + return; + } + shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, + "2", "1", + gridId.substring(0, 6), + gridId.substring(0, 9), + gridId.substring(0, 12), + gridId, description, fieldIntro, + StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); + } else { + ToastHelper.showToast("电话号码格式不对", ToastHelper.WARING); } - shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, - "2", "1", - gridId.substring(0, 6), - gridId.substring(0, 9), - gridId.substring(0, 12), - gridId, description, fieldIntro, - StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); } @Override 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 index 192b702..708f2a8 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -1,16 +1,30 @@ package com.casic.dcms.ui.fragment; +import android.content.BroadcastReceiver; import android.content.Context; -import android.widget.LinearLayout; +import android.content.Intent; +import android.text.TextUtils; +import android.view.ViewGroup; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.adapter.SwipeViewAdapter; +import com.casic.dcms.base.BaseApplication; import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; +import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.greendao.DaoSession; +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; import java.util.ArrayList; import java.util.List; @@ -19,17 +33,19 @@ public class NoticePageFragment extends BaseFragment { - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; + @BindView(R.id.swipeRecyclerView) + RecyclerView swipeRecyclerView; private Context context; + private List noticeBeans = new ArrayList<>(); + private SwipeViewAdapter swipeViewAdapter; + private BroadcastManager broadcastManager; + private Gson gson; + private DaoSession daoSession; @Override protected int initLayoutView() { - return R.layout.fragment_dashboard; + return R.layout.fragment_notice; } @Override @@ -39,20 +55,90 @@ @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)); + gson = new Gson(); + daoSession = BaseApplication.getDaoSession(); + swipeViewAdapter = new SwipeViewAdapter(context); + //根据userName加载历史数据 + String userName = StringHelper.getUserName(); + if (TextUtils.isEmpty(userName)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserName.eq(userName)).list(); + swipeViewAdapter.setData(noticeBeans); + + broadcastManager = BroadcastManager.getInstance(context); + broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + if (Constant.NOTICE_MSG.equals(action)) { + String data = intent.getStringExtra("data"); + assert data != null; + NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); + noticeBeans.add(noticeBean); + //更新数据 + swipeViewAdapter.setData(noticeBeans); + } + } + } + }); } @Override protected void initEvent() { + QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { + @Override + public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { + int position = viewHolder.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + @Override + public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { + return QMUIRVItemSwipeAction.SWIPE_LEFT; + } + + @Override + public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { + super.onClickAction(swipeAction, selected, action); + int position = selected.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + }); + swipeAction.attachToRecyclerView(swipeRecyclerView); + swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { + @Override + public RecyclerView.LayoutParams generateDefaultLayoutParams() { + return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + } + }); + swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); + swipeRecyclerView.setAdapter(swipeViewAdapter); + swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { + @Override + public void onClick(int position) { + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = noticeBeans.get(position); + noticeBean.setIsRead("0"); + daoSession.update(noticeBean); + swipeViewAdapter.notifyDataSetChanged(); + + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); + } + }); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (broadcastManager != null) { + broadcastManager.destroy(Constant.NOTICE_MSG); + } } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java deleted file mode 100644 index 7b1e1fb..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class ReadFragment extends BaseFragment { - @Override - protected int initLayoutView() { - return R.layout.fragment_read; - } - - @Override - protected void setupTopBarLayout() { - - } - - @Override - protected void initData() { - - } - - @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 deleted file mode 100644 index a0afe0f..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.text.TextUtils; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.DividerItemDecoration; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SwipeViewAdapter; -import com.casic.dcms.base.BaseApplication; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.greendao.DaoSession; -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; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class UnreadFragment extends BaseFragment { - - private static final String TAG = "UnreadFragment"; - @BindView(R.id.swipeRecyclerView) - RecyclerView swipeRecyclerView; - - private Context context; - private List noticeBeans = new ArrayList<>(); - private SwipeViewAdapter swipeViewAdapter; - private BroadcastManager broadcastManager; - private Gson gson; - private DaoSession daoSession; - - @Override - protected int initLayoutView() { - return R.layout.fragment_unread; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - gson = new Gson(); - daoSession = BaseApplication.getDaoSession(); - swipeViewAdapter = new SwipeViewAdapter(context); - //根据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); - broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.NOTICE_MSG.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); - noticeBeans.add(noticeBean); - //更新数据 - swipeViewAdapter.setData(noticeBeans); - } - } - } - }); - } - - protected void initEvent() { - QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { - @Override - public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { - int position = viewHolder.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - - @Override - public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { - return QMUIRVItemSwipeAction.SWIPE_LEFT; - } - - @Override - public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { - super.onClickAction(swipeAction, selected, action); - int position = selected.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - }); - swipeAction.attachToRecyclerView(swipeRecyclerView); - swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { - @Override - public RecyclerView.LayoutParams generateDefaultLayoutParams() { - return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - } - }); - swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); - swipeRecyclerView.setAdapter(swipeViewAdapter); - swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { - @Override - public void onClick(int position) { - //点击之后之后,未读消息变为已读消息 - NoticeBean noticeBean = new NoticeBean(); - noticeBean.setIsRead("0"); - daoSession.update(noticeBean); - - String caseId = noticeBeans.get(position).getCaseId(); - Intent intent = new Intent(context, CaseDetailActivity.class); - intent.putExtra("id", caseId); - startActivity(intent); - } - }); - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - broadcastManager.destroy(Constant.NOTICE_MSG); - } -} diff --git a/app/src/main/java/com/casic/dcms/utils/StringHelper.java b/app/src/main/java/com/casic/dcms/utils/StringHelper.java index f5d5acb..3947941 100644 --- a/app/src/main/java/com/casic/dcms/utils/StringHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/StringHelper.java @@ -6,6 +6,8 @@ import com.casic.dcms.R; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class StringHelper { @@ -56,6 +58,22 @@ return isDigit && isLetter; } + public static boolean isPhoneNumber(String number) { + String regExp = "^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$"; + if (number.length() != 11) { + Log.d(TAG, "手机号应为11位数"); + return false; + } else { + Pattern p = Pattern.compile(regExp); + Matcher m = p.matcher(number); + boolean isMatch = m.matches(); + if (!isMatch) { + Log.d(TAG, "请填入正确的手机号"); + } + return isMatch; + } + } + public static String appendCompleteURL(String url) { if (TextUtils.isEmpty(url)) { return ""; diff --git a/app/src/main/res/drawable-hdpi/normal.png b/app/src/main/res/drawable-hdpi/normal.png new file mode 100644 index 0000000..3feab7d --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-hdpi/normal_small.png b/app/src/main/res/drawable-hdpi/normal_small.png new file mode 100644 index 0000000..4387126 --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal.png b/app/src/main/res/drawable-ldpi/normal.png new file mode 100644 index 0000000..175184c --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal_small.png b/app/src/main/res/drawable-ldpi/normal_small.png new file mode 100644 index 0000000..5890a00 --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-mdpi/normal.png b/app/src/main/res/drawable-mdpi/normal.png new file mode 100644 index 0000000..7ee8b48 --- /dev/null +++ b/app/src/main/res/drawable-mdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-mdpi/normal_small.png b/app/src/main/res/drawable-mdpi/normal_small.png new file mode 100644 index 0000000..43aa9ec --- /dev/null +++ b/app/src/main/res/drawable-mdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-xhdpi/normal.png b/app/src/main/res/drawable-xhdpi/normal.png new file mode 100644 index 0000000..5bd5a01 --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-xhdpi/normal_small.png b/app/src/main/res/drawable-xhdpi/normal_small.png new file mode 100644 index 0000000..51497fe --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-xxhdpi/normal.png b/app/src/main/res/drawable-xxhdpi/normal.png new file mode 100644 index 0000000..f4d0b34 --- /dev/null +++ b/app/src/main/res/drawable-xxhdpi/normal.png Binary files differ diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); 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 865787a..fa17e1f 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,12 +1,14 @@ package com.casic.dcms.service; import android.content.Context; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.bean.PushResultBean; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; import com.casic.dcms.utils.StringHelper; @@ -64,6 +66,7 @@ // 通知到达,只有个推通道下发的通知会回调此方法 @Override public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + Log.d(TAG, "onNotificationMessageArrived: " + message.getContent()); /** * appid = DR9oeLL9va6aG3DYXy2w39 * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 @@ -79,8 +82,8 @@ }.getType()); NoticeBean noticeBean = new NoticeBean(); - noticeBean.setUserPhone(StringHelper.getUserPhone()); - noticeBean.setCaseId(resultBean.getId()); + noticeBean.setUserName(StringHelper.getUserName()); + noticeBean.setCaseId(resultBean.getData().getId()); noticeBean.setTitle(resultBean.getTitle()); noticeBean.setContent(resultBean.getContent()); noticeBean.setType(resultBean.getType()); @@ -101,7 +104,10 @@ PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { }.getType()); - String caseId = resultBean.getId(); + String caseId = resultBean.getData().getId(); Log.d(TAG, "onNotificationMessageClicked: " + caseId); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); } } 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 db7d9ca..a1bcef6 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -244,8 +244,6 @@ showShopDialog(featureBean.getBgid(), (String) feature.getAttributes().get("Note"), featureBean.getDutyname(), - featureBean.getTel(), - "暂无", String.valueOf(featureBean.getObjectid())); } }); @@ -269,10 +267,10 @@ /** * 三包 */ - private void showShopDialog(String gridId, String communityName, String shopName, String phoneNumber, String shopKeeper, String shopID) { + private void showShopDialog(String gridId, String communityName, String shopName, String shopID) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("已选择商户:" + shopName + "\r\n手机号:" + phoneNumber + "\r\n确认提交?") + .setMessage("已选择商户:" + shopName + "\r\n确认提交?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { @@ -281,8 +279,6 @@ dialog.dismiss(); Intent intent = new Intent(); intent.putExtra("shopName", shopName); - intent.putExtra("phoneNumber", phoneNumber); - intent.putExtra("shopKeeper", shopKeeper); intent.putExtra("shopID", shopID); intent.putExtra("latitude", clickPoint.getY()); intent.putExtra("longitude", clickPoint.getX()); diff --git a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java index 8e43b7e..3fa89ee 100644 --- a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java @@ -155,10 +155,6 @@ PublicKey publicKey = RSAUtils.keyStrToPublicKey(keyString); String userName = userNameView.getText().toString(); String userPassword = userPasswordView.getText().toString(); - if (rememberPasswordView.isChecked()) { - SaveKeyValues.putValue("name", userName); - SaveKeyValues.putValue("password", userPassword); - } if (autoLoginView.isChecked()) { SaveKeyValues.putValue("autoLogin", true); } else { @@ -172,6 +168,10 @@ ToastHelper.showToast("密码不能为空", ToastHelper.WARING); return; } + if (rememberPasswordView.isChecked()) { + SaveKeyValues.putValue("name", userName); + SaveKeyValues.putValue("password", userPassword); + } String dataByPublicKey = RSAUtils.encryptDataByPublicKey(userPassword.getBytes(), publicKey); //登录并获取Token,POST请求 loginPresenter.onReadyRetrofitRequest(userName, dataByPublicKey); diff --git a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java index dc5fc67..dad0718 100644 --- a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java @@ -56,6 +56,10 @@ EditText longitudeView; @BindView(R.id.latitudeView) EditText latitudeView; + @BindView(R.id.shopKeeperView) + EditText shopKeeperView; + @BindView(R.id.phoneNumberView) + EditText phoneNumberView; @BindView(R.id.caseLocationView) EditText caseLocationView; @BindView(R.id.caseDetailEditView) @@ -73,7 +77,7 @@ private QMUITipDialog submitDialog; private List realPaths = new ArrayList<>();//真是图片路径 private List mediaList = new ArrayList<>();//上传到服务器的数据集 - private String gridId, shopKeeper, phoneNumber, shopID; + private String gridId, shopID; @Override public int initLayoutView() { @@ -187,8 +191,6 @@ gridId = data.getStringExtra("gridId"); String community = data.getStringExtra("community"); String shopName = data.getStringExtra("shopName"); - phoneNumber = data.getStringExtra("phoneNumber"); - shopKeeper = data.getStringExtra("shopKeeper"); shopID = data.getStringExtra("shopID"); longitudeView.setText(String.valueOf(longitude)); @@ -212,28 +214,41 @@ ToastHelper.showToast("经纬度异常,请重新选择位置", ToastHelper.WARING); return; } - - String fieldIntro = caseLocationView.getText().toString(); - if (TextUtils.isEmpty(fieldIntro)) { - ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + String shopKeeper = shopKeeperView.getText().toString(); + if (TextUtils.isEmpty(shopKeeper)) { + ToastHelper.showToast("店主名还未填写", ToastHelper.WARING); return; } - String description = caseDetailEditView.getText().toString(); - if (TextUtils.isEmpty(description)) { - ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + String phoneNumber = phoneNumberView.getText().toString(); + if (TextUtils.isEmpty(phoneNumber)) { + ToastHelper.showToast("电话号码还未填写", ToastHelper.WARING); return; } - if (mediaList.size() != 2) { - ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); - return; + if (StringHelper.isPhoneNumber(phoneNumber)) { + String fieldIntro = caseLocationView.getText().toString(); + if (TextUtils.isEmpty(fieldIntro)) { + ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + return; + } + String description = caseDetailEditView.getText().toString(); + if (TextUtils.isEmpty(description)) { + ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + return; + } + if (mediaList.size() != 2) { + ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); + return; + } + shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, + "2", "1", + gridId.substring(0, 6), + gridId.substring(0, 9), + gridId.substring(0, 12), + gridId, description, fieldIntro, + StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); + } else { + ToastHelper.showToast("电话号码格式不对", ToastHelper.WARING); } - shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, - "2", "1", - gridId.substring(0, 6), - gridId.substring(0, 9), - gridId.substring(0, 12), - gridId, description, fieldIntro, - StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); } @Override 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 index 192b702..708f2a8 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -1,16 +1,30 @@ package com.casic.dcms.ui.fragment; +import android.content.BroadcastReceiver; import android.content.Context; -import android.widget.LinearLayout; +import android.content.Intent; +import android.text.TextUtils; +import android.view.ViewGroup; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.adapter.SwipeViewAdapter; +import com.casic.dcms.base.BaseApplication; import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; +import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.greendao.DaoSession; +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; import java.util.ArrayList; import java.util.List; @@ -19,17 +33,19 @@ public class NoticePageFragment extends BaseFragment { - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; + @BindView(R.id.swipeRecyclerView) + RecyclerView swipeRecyclerView; private Context context; + private List noticeBeans = new ArrayList<>(); + private SwipeViewAdapter swipeViewAdapter; + private BroadcastManager broadcastManager; + private Gson gson; + private DaoSession daoSession; @Override protected int initLayoutView() { - return R.layout.fragment_dashboard; + return R.layout.fragment_notice; } @Override @@ -39,20 +55,90 @@ @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)); + gson = new Gson(); + daoSession = BaseApplication.getDaoSession(); + swipeViewAdapter = new SwipeViewAdapter(context); + //根据userName加载历史数据 + String userName = StringHelper.getUserName(); + if (TextUtils.isEmpty(userName)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserName.eq(userName)).list(); + swipeViewAdapter.setData(noticeBeans); + + broadcastManager = BroadcastManager.getInstance(context); + broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + if (Constant.NOTICE_MSG.equals(action)) { + String data = intent.getStringExtra("data"); + assert data != null; + NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); + noticeBeans.add(noticeBean); + //更新数据 + swipeViewAdapter.setData(noticeBeans); + } + } + } + }); } @Override protected void initEvent() { + QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { + @Override + public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { + int position = viewHolder.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + @Override + public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { + return QMUIRVItemSwipeAction.SWIPE_LEFT; + } + + @Override + public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { + super.onClickAction(swipeAction, selected, action); + int position = selected.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + }); + swipeAction.attachToRecyclerView(swipeRecyclerView); + swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { + @Override + public RecyclerView.LayoutParams generateDefaultLayoutParams() { + return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + } + }); + swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); + swipeRecyclerView.setAdapter(swipeViewAdapter); + swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { + @Override + public void onClick(int position) { + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = noticeBeans.get(position); + noticeBean.setIsRead("0"); + daoSession.update(noticeBean); + swipeViewAdapter.notifyDataSetChanged(); + + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); + } + }); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (broadcastManager != null) { + broadcastManager.destroy(Constant.NOTICE_MSG); + } } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java deleted file mode 100644 index 7b1e1fb..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class ReadFragment extends BaseFragment { - @Override - protected int initLayoutView() { - return R.layout.fragment_read; - } - - @Override - protected void setupTopBarLayout() { - - } - - @Override - protected void initData() { - - } - - @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 deleted file mode 100644 index a0afe0f..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.text.TextUtils; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.DividerItemDecoration; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SwipeViewAdapter; -import com.casic.dcms.base.BaseApplication; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.greendao.DaoSession; -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; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class UnreadFragment extends BaseFragment { - - private static final String TAG = "UnreadFragment"; - @BindView(R.id.swipeRecyclerView) - RecyclerView swipeRecyclerView; - - private Context context; - private List noticeBeans = new ArrayList<>(); - private SwipeViewAdapter swipeViewAdapter; - private BroadcastManager broadcastManager; - private Gson gson; - private DaoSession daoSession; - - @Override - protected int initLayoutView() { - return R.layout.fragment_unread; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - gson = new Gson(); - daoSession = BaseApplication.getDaoSession(); - swipeViewAdapter = new SwipeViewAdapter(context); - //根据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); - broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.NOTICE_MSG.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); - noticeBeans.add(noticeBean); - //更新数据 - swipeViewAdapter.setData(noticeBeans); - } - } - } - }); - } - - protected void initEvent() { - QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { - @Override - public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { - int position = viewHolder.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - - @Override - public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { - return QMUIRVItemSwipeAction.SWIPE_LEFT; - } - - @Override - public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { - super.onClickAction(swipeAction, selected, action); - int position = selected.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - }); - swipeAction.attachToRecyclerView(swipeRecyclerView); - swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { - @Override - public RecyclerView.LayoutParams generateDefaultLayoutParams() { - return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - } - }); - swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); - swipeRecyclerView.setAdapter(swipeViewAdapter); - swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { - @Override - public void onClick(int position) { - //点击之后之后,未读消息变为已读消息 - NoticeBean noticeBean = new NoticeBean(); - noticeBean.setIsRead("0"); - daoSession.update(noticeBean); - - String caseId = noticeBeans.get(position).getCaseId(); - Intent intent = new Intent(context, CaseDetailActivity.class); - intent.putExtra("id", caseId); - startActivity(intent); - } - }); - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - broadcastManager.destroy(Constant.NOTICE_MSG); - } -} diff --git a/app/src/main/java/com/casic/dcms/utils/StringHelper.java b/app/src/main/java/com/casic/dcms/utils/StringHelper.java index f5d5acb..3947941 100644 --- a/app/src/main/java/com/casic/dcms/utils/StringHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/StringHelper.java @@ -6,6 +6,8 @@ import com.casic.dcms.R; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class StringHelper { @@ -56,6 +58,22 @@ return isDigit && isLetter; } + public static boolean isPhoneNumber(String number) { + String regExp = "^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$"; + if (number.length() != 11) { + Log.d(TAG, "手机号应为11位数"); + return false; + } else { + Pattern p = Pattern.compile(regExp); + Matcher m = p.matcher(number); + boolean isMatch = m.matches(); + if (!isMatch) { + Log.d(TAG, "请填入正确的手机号"); + } + return isMatch; + } + } + public static String appendCompleteURL(String url) { if (TextUtils.isEmpty(url)) { return ""; diff --git a/app/src/main/res/drawable-hdpi/normal.png b/app/src/main/res/drawable-hdpi/normal.png new file mode 100644 index 0000000..3feab7d --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-hdpi/normal_small.png b/app/src/main/res/drawable-hdpi/normal_small.png new file mode 100644 index 0000000..4387126 --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal.png b/app/src/main/res/drawable-ldpi/normal.png new file mode 100644 index 0000000..175184c --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal_small.png b/app/src/main/res/drawable-ldpi/normal_small.png new file mode 100644 index 0000000..5890a00 --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-mdpi/normal.png b/app/src/main/res/drawable-mdpi/normal.png new file mode 100644 index 0000000..7ee8b48 --- /dev/null +++ b/app/src/main/res/drawable-mdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-mdpi/normal_small.png b/app/src/main/res/drawable-mdpi/normal_small.png new file mode 100644 index 0000000..43aa9ec --- /dev/null +++ b/app/src/main/res/drawable-mdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-xhdpi/normal.png b/app/src/main/res/drawable-xhdpi/normal.png new file mode 100644 index 0000000..5bd5a01 --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-xhdpi/normal_small.png b/app/src/main/res/drawable-xhdpi/normal_small.png new file mode 100644 index 0000000..51497fe --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-xxhdpi/normal.png b/app/src/main/res/drawable-xxhdpi/normal.png new file mode 100644 index 0000000..f4d0b34 --- /dev/null +++ b/app/src/main/res/drawable-xxhdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-xxhdpi/normal_small.png b/app/src/main/res/drawable-xxhdpi/normal_small.png new file mode 100644 index 0000000..66352a6 --- /dev/null +++ b/app/src/main/res/drawable-xxhdpi/normal_small.png Binary files differ diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); 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 865787a..fa17e1f 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,12 +1,14 @@ package com.casic.dcms.service; import android.content.Context; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.bean.PushResultBean; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; import com.casic.dcms.utils.StringHelper; @@ -64,6 +66,7 @@ // 通知到达,只有个推通道下发的通知会回调此方法 @Override public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + Log.d(TAG, "onNotificationMessageArrived: " + message.getContent()); /** * appid = DR9oeLL9va6aG3DYXy2w39 * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 @@ -79,8 +82,8 @@ }.getType()); NoticeBean noticeBean = new NoticeBean(); - noticeBean.setUserPhone(StringHelper.getUserPhone()); - noticeBean.setCaseId(resultBean.getId()); + noticeBean.setUserName(StringHelper.getUserName()); + noticeBean.setCaseId(resultBean.getData().getId()); noticeBean.setTitle(resultBean.getTitle()); noticeBean.setContent(resultBean.getContent()); noticeBean.setType(resultBean.getType()); @@ -101,7 +104,10 @@ PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { }.getType()); - String caseId = resultBean.getId(); + String caseId = resultBean.getData().getId(); Log.d(TAG, "onNotificationMessageClicked: " + caseId); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); } } 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 db7d9ca..a1bcef6 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -244,8 +244,6 @@ showShopDialog(featureBean.getBgid(), (String) feature.getAttributes().get("Note"), featureBean.getDutyname(), - featureBean.getTel(), - "暂无", String.valueOf(featureBean.getObjectid())); } }); @@ -269,10 +267,10 @@ /** * 三包 */ - private void showShopDialog(String gridId, String communityName, String shopName, String phoneNumber, String shopKeeper, String shopID) { + private void showShopDialog(String gridId, String communityName, String shopName, String shopID) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("已选择商户:" + shopName + "\r\n手机号:" + phoneNumber + "\r\n确认提交?") + .setMessage("已选择商户:" + shopName + "\r\n确认提交?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { @@ -281,8 +279,6 @@ dialog.dismiss(); Intent intent = new Intent(); intent.putExtra("shopName", shopName); - intent.putExtra("phoneNumber", phoneNumber); - intent.putExtra("shopKeeper", shopKeeper); intent.putExtra("shopID", shopID); intent.putExtra("latitude", clickPoint.getY()); intent.putExtra("longitude", clickPoint.getX()); diff --git a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java index 8e43b7e..3fa89ee 100644 --- a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java @@ -155,10 +155,6 @@ PublicKey publicKey = RSAUtils.keyStrToPublicKey(keyString); String userName = userNameView.getText().toString(); String userPassword = userPasswordView.getText().toString(); - if (rememberPasswordView.isChecked()) { - SaveKeyValues.putValue("name", userName); - SaveKeyValues.putValue("password", userPassword); - } if (autoLoginView.isChecked()) { SaveKeyValues.putValue("autoLogin", true); } else { @@ -172,6 +168,10 @@ ToastHelper.showToast("密码不能为空", ToastHelper.WARING); return; } + if (rememberPasswordView.isChecked()) { + SaveKeyValues.putValue("name", userName); + SaveKeyValues.putValue("password", userPassword); + } String dataByPublicKey = RSAUtils.encryptDataByPublicKey(userPassword.getBytes(), publicKey); //登录并获取Token,POST请求 loginPresenter.onReadyRetrofitRequest(userName, dataByPublicKey); diff --git a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java index dc5fc67..dad0718 100644 --- a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java @@ -56,6 +56,10 @@ EditText longitudeView; @BindView(R.id.latitudeView) EditText latitudeView; + @BindView(R.id.shopKeeperView) + EditText shopKeeperView; + @BindView(R.id.phoneNumberView) + EditText phoneNumberView; @BindView(R.id.caseLocationView) EditText caseLocationView; @BindView(R.id.caseDetailEditView) @@ -73,7 +77,7 @@ private QMUITipDialog submitDialog; private List realPaths = new ArrayList<>();//真是图片路径 private List mediaList = new ArrayList<>();//上传到服务器的数据集 - private String gridId, shopKeeper, phoneNumber, shopID; + private String gridId, shopID; @Override public int initLayoutView() { @@ -187,8 +191,6 @@ gridId = data.getStringExtra("gridId"); String community = data.getStringExtra("community"); String shopName = data.getStringExtra("shopName"); - phoneNumber = data.getStringExtra("phoneNumber"); - shopKeeper = data.getStringExtra("shopKeeper"); shopID = data.getStringExtra("shopID"); longitudeView.setText(String.valueOf(longitude)); @@ -212,28 +214,41 @@ ToastHelper.showToast("经纬度异常,请重新选择位置", ToastHelper.WARING); return; } - - String fieldIntro = caseLocationView.getText().toString(); - if (TextUtils.isEmpty(fieldIntro)) { - ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + String shopKeeper = shopKeeperView.getText().toString(); + if (TextUtils.isEmpty(shopKeeper)) { + ToastHelper.showToast("店主名还未填写", ToastHelper.WARING); return; } - String description = caseDetailEditView.getText().toString(); - if (TextUtils.isEmpty(description)) { - ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + String phoneNumber = phoneNumberView.getText().toString(); + if (TextUtils.isEmpty(phoneNumber)) { + ToastHelper.showToast("电话号码还未填写", ToastHelper.WARING); return; } - if (mediaList.size() != 2) { - ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); - return; + if (StringHelper.isPhoneNumber(phoneNumber)) { + String fieldIntro = caseLocationView.getText().toString(); + if (TextUtils.isEmpty(fieldIntro)) { + ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + return; + } + String description = caseDetailEditView.getText().toString(); + if (TextUtils.isEmpty(description)) { + ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + return; + } + if (mediaList.size() != 2) { + ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); + return; + } + shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, + "2", "1", + gridId.substring(0, 6), + gridId.substring(0, 9), + gridId.substring(0, 12), + gridId, description, fieldIntro, + StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); + } else { + ToastHelper.showToast("电话号码格式不对", ToastHelper.WARING); } - shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, - "2", "1", - gridId.substring(0, 6), - gridId.substring(0, 9), - gridId.substring(0, 12), - gridId, description, fieldIntro, - StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); } @Override 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 index 192b702..708f2a8 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -1,16 +1,30 @@ package com.casic.dcms.ui.fragment; +import android.content.BroadcastReceiver; import android.content.Context; -import android.widget.LinearLayout; +import android.content.Intent; +import android.text.TextUtils; +import android.view.ViewGroup; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.adapter.SwipeViewAdapter; +import com.casic.dcms.base.BaseApplication; import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; +import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.greendao.DaoSession; +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; import java.util.ArrayList; import java.util.List; @@ -19,17 +33,19 @@ public class NoticePageFragment extends BaseFragment { - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; + @BindView(R.id.swipeRecyclerView) + RecyclerView swipeRecyclerView; private Context context; + private List noticeBeans = new ArrayList<>(); + private SwipeViewAdapter swipeViewAdapter; + private BroadcastManager broadcastManager; + private Gson gson; + private DaoSession daoSession; @Override protected int initLayoutView() { - return R.layout.fragment_dashboard; + return R.layout.fragment_notice; } @Override @@ -39,20 +55,90 @@ @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)); + gson = new Gson(); + daoSession = BaseApplication.getDaoSession(); + swipeViewAdapter = new SwipeViewAdapter(context); + //根据userName加载历史数据 + String userName = StringHelper.getUserName(); + if (TextUtils.isEmpty(userName)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserName.eq(userName)).list(); + swipeViewAdapter.setData(noticeBeans); + + broadcastManager = BroadcastManager.getInstance(context); + broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + if (Constant.NOTICE_MSG.equals(action)) { + String data = intent.getStringExtra("data"); + assert data != null; + NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); + noticeBeans.add(noticeBean); + //更新数据 + swipeViewAdapter.setData(noticeBeans); + } + } + } + }); } @Override protected void initEvent() { + QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { + @Override + public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { + int position = viewHolder.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + @Override + public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { + return QMUIRVItemSwipeAction.SWIPE_LEFT; + } + + @Override + public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { + super.onClickAction(swipeAction, selected, action); + int position = selected.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + }); + swipeAction.attachToRecyclerView(swipeRecyclerView); + swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { + @Override + public RecyclerView.LayoutParams generateDefaultLayoutParams() { + return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + } + }); + swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); + swipeRecyclerView.setAdapter(swipeViewAdapter); + swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { + @Override + public void onClick(int position) { + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = noticeBeans.get(position); + noticeBean.setIsRead("0"); + daoSession.update(noticeBean); + swipeViewAdapter.notifyDataSetChanged(); + + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); + } + }); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (broadcastManager != null) { + broadcastManager.destroy(Constant.NOTICE_MSG); + } } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java deleted file mode 100644 index 7b1e1fb..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class ReadFragment extends BaseFragment { - @Override - protected int initLayoutView() { - return R.layout.fragment_read; - } - - @Override - protected void setupTopBarLayout() { - - } - - @Override - protected void initData() { - - } - - @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 deleted file mode 100644 index a0afe0f..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.text.TextUtils; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.DividerItemDecoration; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SwipeViewAdapter; -import com.casic.dcms.base.BaseApplication; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.greendao.DaoSession; -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; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class UnreadFragment extends BaseFragment { - - private static final String TAG = "UnreadFragment"; - @BindView(R.id.swipeRecyclerView) - RecyclerView swipeRecyclerView; - - private Context context; - private List noticeBeans = new ArrayList<>(); - private SwipeViewAdapter swipeViewAdapter; - private BroadcastManager broadcastManager; - private Gson gson; - private DaoSession daoSession; - - @Override - protected int initLayoutView() { - return R.layout.fragment_unread; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - gson = new Gson(); - daoSession = BaseApplication.getDaoSession(); - swipeViewAdapter = new SwipeViewAdapter(context); - //根据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); - broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.NOTICE_MSG.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); - noticeBeans.add(noticeBean); - //更新数据 - swipeViewAdapter.setData(noticeBeans); - } - } - } - }); - } - - protected void initEvent() { - QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { - @Override - public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { - int position = viewHolder.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - - @Override - public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { - return QMUIRVItemSwipeAction.SWIPE_LEFT; - } - - @Override - public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { - super.onClickAction(swipeAction, selected, action); - int position = selected.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - }); - swipeAction.attachToRecyclerView(swipeRecyclerView); - swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { - @Override - public RecyclerView.LayoutParams generateDefaultLayoutParams() { - return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - } - }); - swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); - swipeRecyclerView.setAdapter(swipeViewAdapter); - swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { - @Override - public void onClick(int position) { - //点击之后之后,未读消息变为已读消息 - NoticeBean noticeBean = new NoticeBean(); - noticeBean.setIsRead("0"); - daoSession.update(noticeBean); - - String caseId = noticeBeans.get(position).getCaseId(); - Intent intent = new Intent(context, CaseDetailActivity.class); - intent.putExtra("id", caseId); - startActivity(intent); - } - }); - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - broadcastManager.destroy(Constant.NOTICE_MSG); - } -} diff --git a/app/src/main/java/com/casic/dcms/utils/StringHelper.java b/app/src/main/java/com/casic/dcms/utils/StringHelper.java index f5d5acb..3947941 100644 --- a/app/src/main/java/com/casic/dcms/utils/StringHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/StringHelper.java @@ -6,6 +6,8 @@ import com.casic.dcms.R; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class StringHelper { @@ -56,6 +58,22 @@ return isDigit && isLetter; } + public static boolean isPhoneNumber(String number) { + String regExp = "^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$"; + if (number.length() != 11) { + Log.d(TAG, "手机号应为11位数"); + return false; + } else { + Pattern p = Pattern.compile(regExp); + Matcher m = p.matcher(number); + boolean isMatch = m.matches(); + if (!isMatch) { + Log.d(TAG, "请填入正确的手机号"); + } + return isMatch; + } + } + public static String appendCompleteURL(String url) { if (TextUtils.isEmpty(url)) { return ""; diff --git a/app/src/main/res/drawable-hdpi/normal.png b/app/src/main/res/drawable-hdpi/normal.png new file mode 100644 index 0000000..3feab7d --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-hdpi/normal_small.png b/app/src/main/res/drawable-hdpi/normal_small.png new file mode 100644 index 0000000..4387126 --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal.png b/app/src/main/res/drawable-ldpi/normal.png new file mode 100644 index 0000000..175184c --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal_small.png b/app/src/main/res/drawable-ldpi/normal_small.png new file mode 100644 index 0000000..5890a00 --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-mdpi/normal.png b/app/src/main/res/drawable-mdpi/normal.png new file mode 100644 index 0000000..7ee8b48 --- /dev/null +++ b/app/src/main/res/drawable-mdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-mdpi/normal_small.png b/app/src/main/res/drawable-mdpi/normal_small.png new file mode 100644 index 0000000..43aa9ec --- /dev/null +++ b/app/src/main/res/drawable-mdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-xhdpi/normal.png b/app/src/main/res/drawable-xhdpi/normal.png new file mode 100644 index 0000000..5bd5a01 --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-xhdpi/normal_small.png b/app/src/main/res/drawable-xhdpi/normal_small.png new file mode 100644 index 0000000..51497fe --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-xxhdpi/normal.png b/app/src/main/res/drawable-xxhdpi/normal.png new file mode 100644 index 0000000..f4d0b34 --- /dev/null +++ b/app/src/main/res/drawable-xxhdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-xxhdpi/normal_small.png b/app/src/main/res/drawable-xxhdpi/normal_small.png new file mode 100644 index 0000000..66352a6 --- /dev/null +++ b/app/src/main/res/drawable-xxhdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable/bg_text_tag.xml b/app/src/main/res/drawable/bg_text_tag.xml new file mode 100644 index 0000000..d887d85 --- /dev/null +++ b/app/src/main/res/drawable/bg_text_tag.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); 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 865787a..fa17e1f 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,12 +1,14 @@ package com.casic.dcms.service; import android.content.Context; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.bean.PushResultBean; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; import com.casic.dcms.utils.StringHelper; @@ -64,6 +66,7 @@ // 通知到达,只有个推通道下发的通知会回调此方法 @Override public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + Log.d(TAG, "onNotificationMessageArrived: " + message.getContent()); /** * appid = DR9oeLL9va6aG3DYXy2w39 * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 @@ -79,8 +82,8 @@ }.getType()); NoticeBean noticeBean = new NoticeBean(); - noticeBean.setUserPhone(StringHelper.getUserPhone()); - noticeBean.setCaseId(resultBean.getId()); + noticeBean.setUserName(StringHelper.getUserName()); + noticeBean.setCaseId(resultBean.getData().getId()); noticeBean.setTitle(resultBean.getTitle()); noticeBean.setContent(resultBean.getContent()); noticeBean.setType(resultBean.getType()); @@ -101,7 +104,10 @@ PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { }.getType()); - String caseId = resultBean.getId(); + String caseId = resultBean.getData().getId(); Log.d(TAG, "onNotificationMessageClicked: " + caseId); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); } } 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 db7d9ca..a1bcef6 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -244,8 +244,6 @@ showShopDialog(featureBean.getBgid(), (String) feature.getAttributes().get("Note"), featureBean.getDutyname(), - featureBean.getTel(), - "暂无", String.valueOf(featureBean.getObjectid())); } }); @@ -269,10 +267,10 @@ /** * 三包 */ - private void showShopDialog(String gridId, String communityName, String shopName, String phoneNumber, String shopKeeper, String shopID) { + private void showShopDialog(String gridId, String communityName, String shopName, String shopID) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("已选择商户:" + shopName + "\r\n手机号:" + phoneNumber + "\r\n确认提交?") + .setMessage("已选择商户:" + shopName + "\r\n确认提交?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { @@ -281,8 +279,6 @@ dialog.dismiss(); Intent intent = new Intent(); intent.putExtra("shopName", shopName); - intent.putExtra("phoneNumber", phoneNumber); - intent.putExtra("shopKeeper", shopKeeper); intent.putExtra("shopID", shopID); intent.putExtra("latitude", clickPoint.getY()); intent.putExtra("longitude", clickPoint.getX()); diff --git a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java index 8e43b7e..3fa89ee 100644 --- a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java @@ -155,10 +155,6 @@ PublicKey publicKey = RSAUtils.keyStrToPublicKey(keyString); String userName = userNameView.getText().toString(); String userPassword = userPasswordView.getText().toString(); - if (rememberPasswordView.isChecked()) { - SaveKeyValues.putValue("name", userName); - SaveKeyValues.putValue("password", userPassword); - } if (autoLoginView.isChecked()) { SaveKeyValues.putValue("autoLogin", true); } else { @@ -172,6 +168,10 @@ ToastHelper.showToast("密码不能为空", ToastHelper.WARING); return; } + if (rememberPasswordView.isChecked()) { + SaveKeyValues.putValue("name", userName); + SaveKeyValues.putValue("password", userPassword); + } String dataByPublicKey = RSAUtils.encryptDataByPublicKey(userPassword.getBytes(), publicKey); //登录并获取Token,POST请求 loginPresenter.onReadyRetrofitRequest(userName, dataByPublicKey); diff --git a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java index dc5fc67..dad0718 100644 --- a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java @@ -56,6 +56,10 @@ EditText longitudeView; @BindView(R.id.latitudeView) EditText latitudeView; + @BindView(R.id.shopKeeperView) + EditText shopKeeperView; + @BindView(R.id.phoneNumberView) + EditText phoneNumberView; @BindView(R.id.caseLocationView) EditText caseLocationView; @BindView(R.id.caseDetailEditView) @@ -73,7 +77,7 @@ private QMUITipDialog submitDialog; private List realPaths = new ArrayList<>();//真是图片路径 private List mediaList = new ArrayList<>();//上传到服务器的数据集 - private String gridId, shopKeeper, phoneNumber, shopID; + private String gridId, shopID; @Override public int initLayoutView() { @@ -187,8 +191,6 @@ gridId = data.getStringExtra("gridId"); String community = data.getStringExtra("community"); String shopName = data.getStringExtra("shopName"); - phoneNumber = data.getStringExtra("phoneNumber"); - shopKeeper = data.getStringExtra("shopKeeper"); shopID = data.getStringExtra("shopID"); longitudeView.setText(String.valueOf(longitude)); @@ -212,28 +214,41 @@ ToastHelper.showToast("经纬度异常,请重新选择位置", ToastHelper.WARING); return; } - - String fieldIntro = caseLocationView.getText().toString(); - if (TextUtils.isEmpty(fieldIntro)) { - ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + String shopKeeper = shopKeeperView.getText().toString(); + if (TextUtils.isEmpty(shopKeeper)) { + ToastHelper.showToast("店主名还未填写", ToastHelper.WARING); return; } - String description = caseDetailEditView.getText().toString(); - if (TextUtils.isEmpty(description)) { - ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + String phoneNumber = phoneNumberView.getText().toString(); + if (TextUtils.isEmpty(phoneNumber)) { + ToastHelper.showToast("电话号码还未填写", ToastHelper.WARING); return; } - if (mediaList.size() != 2) { - ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); - return; + if (StringHelper.isPhoneNumber(phoneNumber)) { + String fieldIntro = caseLocationView.getText().toString(); + if (TextUtils.isEmpty(fieldIntro)) { + ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + return; + } + String description = caseDetailEditView.getText().toString(); + if (TextUtils.isEmpty(description)) { + ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + return; + } + if (mediaList.size() != 2) { + ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); + return; + } + shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, + "2", "1", + gridId.substring(0, 6), + gridId.substring(0, 9), + gridId.substring(0, 12), + gridId, description, fieldIntro, + StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); + } else { + ToastHelper.showToast("电话号码格式不对", ToastHelper.WARING); } - shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, - "2", "1", - gridId.substring(0, 6), - gridId.substring(0, 9), - gridId.substring(0, 12), - gridId, description, fieldIntro, - StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); } @Override 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 index 192b702..708f2a8 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -1,16 +1,30 @@ package com.casic.dcms.ui.fragment; +import android.content.BroadcastReceiver; import android.content.Context; -import android.widget.LinearLayout; +import android.content.Intent; +import android.text.TextUtils; +import android.view.ViewGroup; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.adapter.SwipeViewAdapter; +import com.casic.dcms.base.BaseApplication; import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; +import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.greendao.DaoSession; +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; import java.util.ArrayList; import java.util.List; @@ -19,17 +33,19 @@ public class NoticePageFragment extends BaseFragment { - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; + @BindView(R.id.swipeRecyclerView) + RecyclerView swipeRecyclerView; private Context context; + private List noticeBeans = new ArrayList<>(); + private SwipeViewAdapter swipeViewAdapter; + private BroadcastManager broadcastManager; + private Gson gson; + private DaoSession daoSession; @Override protected int initLayoutView() { - return R.layout.fragment_dashboard; + return R.layout.fragment_notice; } @Override @@ -39,20 +55,90 @@ @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)); + gson = new Gson(); + daoSession = BaseApplication.getDaoSession(); + swipeViewAdapter = new SwipeViewAdapter(context); + //根据userName加载历史数据 + String userName = StringHelper.getUserName(); + if (TextUtils.isEmpty(userName)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserName.eq(userName)).list(); + swipeViewAdapter.setData(noticeBeans); + + broadcastManager = BroadcastManager.getInstance(context); + broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + if (Constant.NOTICE_MSG.equals(action)) { + String data = intent.getStringExtra("data"); + assert data != null; + NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); + noticeBeans.add(noticeBean); + //更新数据 + swipeViewAdapter.setData(noticeBeans); + } + } + } + }); } @Override protected void initEvent() { + QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { + @Override + public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { + int position = viewHolder.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + @Override + public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { + return QMUIRVItemSwipeAction.SWIPE_LEFT; + } + + @Override + public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { + super.onClickAction(swipeAction, selected, action); + int position = selected.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + }); + swipeAction.attachToRecyclerView(swipeRecyclerView); + swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { + @Override + public RecyclerView.LayoutParams generateDefaultLayoutParams() { + return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + } + }); + swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); + swipeRecyclerView.setAdapter(swipeViewAdapter); + swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { + @Override + public void onClick(int position) { + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = noticeBeans.get(position); + noticeBean.setIsRead("0"); + daoSession.update(noticeBean); + swipeViewAdapter.notifyDataSetChanged(); + + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); + } + }); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (broadcastManager != null) { + broadcastManager.destroy(Constant.NOTICE_MSG); + } } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java deleted file mode 100644 index 7b1e1fb..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class ReadFragment extends BaseFragment { - @Override - protected int initLayoutView() { - return R.layout.fragment_read; - } - - @Override - protected void setupTopBarLayout() { - - } - - @Override - protected void initData() { - - } - - @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 deleted file mode 100644 index a0afe0f..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.text.TextUtils; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.DividerItemDecoration; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SwipeViewAdapter; -import com.casic.dcms.base.BaseApplication; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.greendao.DaoSession; -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; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class UnreadFragment extends BaseFragment { - - private static final String TAG = "UnreadFragment"; - @BindView(R.id.swipeRecyclerView) - RecyclerView swipeRecyclerView; - - private Context context; - private List noticeBeans = new ArrayList<>(); - private SwipeViewAdapter swipeViewAdapter; - private BroadcastManager broadcastManager; - private Gson gson; - private DaoSession daoSession; - - @Override - protected int initLayoutView() { - return R.layout.fragment_unread; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - gson = new Gson(); - daoSession = BaseApplication.getDaoSession(); - swipeViewAdapter = new SwipeViewAdapter(context); - //根据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); - broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.NOTICE_MSG.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); - noticeBeans.add(noticeBean); - //更新数据 - swipeViewAdapter.setData(noticeBeans); - } - } - } - }); - } - - protected void initEvent() { - QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { - @Override - public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { - int position = viewHolder.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - - @Override - public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { - return QMUIRVItemSwipeAction.SWIPE_LEFT; - } - - @Override - public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { - super.onClickAction(swipeAction, selected, action); - int position = selected.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - }); - swipeAction.attachToRecyclerView(swipeRecyclerView); - swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { - @Override - public RecyclerView.LayoutParams generateDefaultLayoutParams() { - return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - } - }); - swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); - swipeRecyclerView.setAdapter(swipeViewAdapter); - swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { - @Override - public void onClick(int position) { - //点击之后之后,未读消息变为已读消息 - NoticeBean noticeBean = new NoticeBean(); - noticeBean.setIsRead("0"); - daoSession.update(noticeBean); - - String caseId = noticeBeans.get(position).getCaseId(); - Intent intent = new Intent(context, CaseDetailActivity.class); - intent.putExtra("id", caseId); - startActivity(intent); - } - }); - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - broadcastManager.destroy(Constant.NOTICE_MSG); - } -} diff --git a/app/src/main/java/com/casic/dcms/utils/StringHelper.java b/app/src/main/java/com/casic/dcms/utils/StringHelper.java index f5d5acb..3947941 100644 --- a/app/src/main/java/com/casic/dcms/utils/StringHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/StringHelper.java @@ -6,6 +6,8 @@ import com.casic.dcms.R; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class StringHelper { @@ -56,6 +58,22 @@ return isDigit && isLetter; } + public static boolean isPhoneNumber(String number) { + String regExp = "^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$"; + if (number.length() != 11) { + Log.d(TAG, "手机号应为11位数"); + return false; + } else { + Pattern p = Pattern.compile(regExp); + Matcher m = p.matcher(number); + boolean isMatch = m.matches(); + if (!isMatch) { + Log.d(TAG, "请填入正确的手机号"); + } + return isMatch; + } + } + public static String appendCompleteURL(String url) { if (TextUtils.isEmpty(url)) { return ""; diff --git a/app/src/main/res/drawable-hdpi/normal.png b/app/src/main/res/drawable-hdpi/normal.png new file mode 100644 index 0000000..3feab7d --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-hdpi/normal_small.png b/app/src/main/res/drawable-hdpi/normal_small.png new file mode 100644 index 0000000..4387126 --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal.png b/app/src/main/res/drawable-ldpi/normal.png new file mode 100644 index 0000000..175184c --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal_small.png b/app/src/main/res/drawable-ldpi/normal_small.png new file mode 100644 index 0000000..5890a00 --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-mdpi/normal.png b/app/src/main/res/drawable-mdpi/normal.png new file mode 100644 index 0000000..7ee8b48 --- /dev/null +++ b/app/src/main/res/drawable-mdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-mdpi/normal_small.png b/app/src/main/res/drawable-mdpi/normal_small.png new file mode 100644 index 0000000..43aa9ec --- /dev/null +++ b/app/src/main/res/drawable-mdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-xhdpi/normal.png b/app/src/main/res/drawable-xhdpi/normal.png new file mode 100644 index 0000000..5bd5a01 --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-xhdpi/normal_small.png b/app/src/main/res/drawable-xhdpi/normal_small.png new file mode 100644 index 0000000..51497fe --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-xxhdpi/normal.png b/app/src/main/res/drawable-xxhdpi/normal.png new file mode 100644 index 0000000..f4d0b34 --- /dev/null +++ b/app/src/main/res/drawable-xxhdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-xxhdpi/normal_small.png b/app/src/main/res/drawable-xxhdpi/normal_small.png new file mode 100644 index 0000000..66352a6 --- /dev/null +++ b/app/src/main/res/drawable-xxhdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable/bg_text_tag.xml b/app/src/main/res/drawable/bg_text_tag.xml new file mode 100644 index 0000000..d887d85 --- /dev/null +++ b/app/src/main/res/drawable/bg_text_tag.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_package.xml b/app/src/main/res/layout/activity_package.xml index 2374740..0a5ea98 100644 --- a/app/src/main/res/layout/activity_package.xml +++ b/app/src/main/res/layout/activity_package.xml @@ -123,6 +123,54 @@ android:layout_height="wrap_content" android:layout_centerVertical="true" android:drawableEnd="@mipmap/point" + android:text="店\u3000\u3000主" + android:textSize="@dimen/textFontSize" /> + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); 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 865787a..fa17e1f 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,12 +1,14 @@ package com.casic.dcms.service; import android.content.Context; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.bean.PushResultBean; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; import com.casic.dcms.utils.StringHelper; @@ -64,6 +66,7 @@ // 通知到达,只有个推通道下发的通知会回调此方法 @Override public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + Log.d(TAG, "onNotificationMessageArrived: " + message.getContent()); /** * appid = DR9oeLL9va6aG3DYXy2w39 * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 @@ -79,8 +82,8 @@ }.getType()); NoticeBean noticeBean = new NoticeBean(); - noticeBean.setUserPhone(StringHelper.getUserPhone()); - noticeBean.setCaseId(resultBean.getId()); + noticeBean.setUserName(StringHelper.getUserName()); + noticeBean.setCaseId(resultBean.getData().getId()); noticeBean.setTitle(resultBean.getTitle()); noticeBean.setContent(resultBean.getContent()); noticeBean.setType(resultBean.getType()); @@ -101,7 +104,10 @@ PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { }.getType()); - String caseId = resultBean.getId(); + String caseId = resultBean.getData().getId(); Log.d(TAG, "onNotificationMessageClicked: " + caseId); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); } } 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 db7d9ca..a1bcef6 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -244,8 +244,6 @@ showShopDialog(featureBean.getBgid(), (String) feature.getAttributes().get("Note"), featureBean.getDutyname(), - featureBean.getTel(), - "暂无", String.valueOf(featureBean.getObjectid())); } }); @@ -269,10 +267,10 @@ /** * 三包 */ - private void showShopDialog(String gridId, String communityName, String shopName, String phoneNumber, String shopKeeper, String shopID) { + private void showShopDialog(String gridId, String communityName, String shopName, String shopID) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("已选择商户:" + shopName + "\r\n手机号:" + phoneNumber + "\r\n确认提交?") + .setMessage("已选择商户:" + shopName + "\r\n确认提交?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { @@ -281,8 +279,6 @@ dialog.dismiss(); Intent intent = new Intent(); intent.putExtra("shopName", shopName); - intent.putExtra("phoneNumber", phoneNumber); - intent.putExtra("shopKeeper", shopKeeper); intent.putExtra("shopID", shopID); intent.putExtra("latitude", clickPoint.getY()); intent.putExtra("longitude", clickPoint.getX()); diff --git a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java index 8e43b7e..3fa89ee 100644 --- a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java @@ -155,10 +155,6 @@ PublicKey publicKey = RSAUtils.keyStrToPublicKey(keyString); String userName = userNameView.getText().toString(); String userPassword = userPasswordView.getText().toString(); - if (rememberPasswordView.isChecked()) { - SaveKeyValues.putValue("name", userName); - SaveKeyValues.putValue("password", userPassword); - } if (autoLoginView.isChecked()) { SaveKeyValues.putValue("autoLogin", true); } else { @@ -172,6 +168,10 @@ ToastHelper.showToast("密码不能为空", ToastHelper.WARING); return; } + if (rememberPasswordView.isChecked()) { + SaveKeyValues.putValue("name", userName); + SaveKeyValues.putValue("password", userPassword); + } String dataByPublicKey = RSAUtils.encryptDataByPublicKey(userPassword.getBytes(), publicKey); //登录并获取Token,POST请求 loginPresenter.onReadyRetrofitRequest(userName, dataByPublicKey); diff --git a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java index dc5fc67..dad0718 100644 --- a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java @@ -56,6 +56,10 @@ EditText longitudeView; @BindView(R.id.latitudeView) EditText latitudeView; + @BindView(R.id.shopKeeperView) + EditText shopKeeperView; + @BindView(R.id.phoneNumberView) + EditText phoneNumberView; @BindView(R.id.caseLocationView) EditText caseLocationView; @BindView(R.id.caseDetailEditView) @@ -73,7 +77,7 @@ private QMUITipDialog submitDialog; private List realPaths = new ArrayList<>();//真是图片路径 private List mediaList = new ArrayList<>();//上传到服务器的数据集 - private String gridId, shopKeeper, phoneNumber, shopID; + private String gridId, shopID; @Override public int initLayoutView() { @@ -187,8 +191,6 @@ gridId = data.getStringExtra("gridId"); String community = data.getStringExtra("community"); String shopName = data.getStringExtra("shopName"); - phoneNumber = data.getStringExtra("phoneNumber"); - shopKeeper = data.getStringExtra("shopKeeper"); shopID = data.getStringExtra("shopID"); longitudeView.setText(String.valueOf(longitude)); @@ -212,28 +214,41 @@ ToastHelper.showToast("经纬度异常,请重新选择位置", ToastHelper.WARING); return; } - - String fieldIntro = caseLocationView.getText().toString(); - if (TextUtils.isEmpty(fieldIntro)) { - ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + String shopKeeper = shopKeeperView.getText().toString(); + if (TextUtils.isEmpty(shopKeeper)) { + ToastHelper.showToast("店主名还未填写", ToastHelper.WARING); return; } - String description = caseDetailEditView.getText().toString(); - if (TextUtils.isEmpty(description)) { - ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + String phoneNumber = phoneNumberView.getText().toString(); + if (TextUtils.isEmpty(phoneNumber)) { + ToastHelper.showToast("电话号码还未填写", ToastHelper.WARING); return; } - if (mediaList.size() != 2) { - ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); - return; + if (StringHelper.isPhoneNumber(phoneNumber)) { + String fieldIntro = caseLocationView.getText().toString(); + if (TextUtils.isEmpty(fieldIntro)) { + ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + return; + } + String description = caseDetailEditView.getText().toString(); + if (TextUtils.isEmpty(description)) { + ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + return; + } + if (mediaList.size() != 2) { + ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); + return; + } + shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, + "2", "1", + gridId.substring(0, 6), + gridId.substring(0, 9), + gridId.substring(0, 12), + gridId, description, fieldIntro, + StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); + } else { + ToastHelper.showToast("电话号码格式不对", ToastHelper.WARING); } - shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, - "2", "1", - gridId.substring(0, 6), - gridId.substring(0, 9), - gridId.substring(0, 12), - gridId, description, fieldIntro, - StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); } @Override 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 index 192b702..708f2a8 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -1,16 +1,30 @@ package com.casic.dcms.ui.fragment; +import android.content.BroadcastReceiver; import android.content.Context; -import android.widget.LinearLayout; +import android.content.Intent; +import android.text.TextUtils; +import android.view.ViewGroup; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.adapter.SwipeViewAdapter; +import com.casic.dcms.base.BaseApplication; import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; +import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.greendao.DaoSession; +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; import java.util.ArrayList; import java.util.List; @@ -19,17 +33,19 @@ public class NoticePageFragment extends BaseFragment { - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; + @BindView(R.id.swipeRecyclerView) + RecyclerView swipeRecyclerView; private Context context; + private List noticeBeans = new ArrayList<>(); + private SwipeViewAdapter swipeViewAdapter; + private BroadcastManager broadcastManager; + private Gson gson; + private DaoSession daoSession; @Override protected int initLayoutView() { - return R.layout.fragment_dashboard; + return R.layout.fragment_notice; } @Override @@ -39,20 +55,90 @@ @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)); + gson = new Gson(); + daoSession = BaseApplication.getDaoSession(); + swipeViewAdapter = new SwipeViewAdapter(context); + //根据userName加载历史数据 + String userName = StringHelper.getUserName(); + if (TextUtils.isEmpty(userName)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserName.eq(userName)).list(); + swipeViewAdapter.setData(noticeBeans); + + broadcastManager = BroadcastManager.getInstance(context); + broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + if (Constant.NOTICE_MSG.equals(action)) { + String data = intent.getStringExtra("data"); + assert data != null; + NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); + noticeBeans.add(noticeBean); + //更新数据 + swipeViewAdapter.setData(noticeBeans); + } + } + } + }); } @Override protected void initEvent() { + QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { + @Override + public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { + int position = viewHolder.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + @Override + public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { + return QMUIRVItemSwipeAction.SWIPE_LEFT; + } + + @Override + public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { + super.onClickAction(swipeAction, selected, action); + int position = selected.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + }); + swipeAction.attachToRecyclerView(swipeRecyclerView); + swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { + @Override + public RecyclerView.LayoutParams generateDefaultLayoutParams() { + return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + } + }); + swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); + swipeRecyclerView.setAdapter(swipeViewAdapter); + swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { + @Override + public void onClick(int position) { + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = noticeBeans.get(position); + noticeBean.setIsRead("0"); + daoSession.update(noticeBean); + swipeViewAdapter.notifyDataSetChanged(); + + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); + } + }); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (broadcastManager != null) { + broadcastManager.destroy(Constant.NOTICE_MSG); + } } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java deleted file mode 100644 index 7b1e1fb..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class ReadFragment extends BaseFragment { - @Override - protected int initLayoutView() { - return R.layout.fragment_read; - } - - @Override - protected void setupTopBarLayout() { - - } - - @Override - protected void initData() { - - } - - @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 deleted file mode 100644 index a0afe0f..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.text.TextUtils; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.DividerItemDecoration; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SwipeViewAdapter; -import com.casic.dcms.base.BaseApplication; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.greendao.DaoSession; -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; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class UnreadFragment extends BaseFragment { - - private static final String TAG = "UnreadFragment"; - @BindView(R.id.swipeRecyclerView) - RecyclerView swipeRecyclerView; - - private Context context; - private List noticeBeans = new ArrayList<>(); - private SwipeViewAdapter swipeViewAdapter; - private BroadcastManager broadcastManager; - private Gson gson; - private DaoSession daoSession; - - @Override - protected int initLayoutView() { - return R.layout.fragment_unread; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - gson = new Gson(); - daoSession = BaseApplication.getDaoSession(); - swipeViewAdapter = new SwipeViewAdapter(context); - //根据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); - broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.NOTICE_MSG.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); - noticeBeans.add(noticeBean); - //更新数据 - swipeViewAdapter.setData(noticeBeans); - } - } - } - }); - } - - protected void initEvent() { - QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { - @Override - public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { - int position = viewHolder.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - - @Override - public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { - return QMUIRVItemSwipeAction.SWIPE_LEFT; - } - - @Override - public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { - super.onClickAction(swipeAction, selected, action); - int position = selected.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - }); - swipeAction.attachToRecyclerView(swipeRecyclerView); - swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { - @Override - public RecyclerView.LayoutParams generateDefaultLayoutParams() { - return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - } - }); - swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); - swipeRecyclerView.setAdapter(swipeViewAdapter); - swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { - @Override - public void onClick(int position) { - //点击之后之后,未读消息变为已读消息 - NoticeBean noticeBean = new NoticeBean(); - noticeBean.setIsRead("0"); - daoSession.update(noticeBean); - - String caseId = noticeBeans.get(position).getCaseId(); - Intent intent = new Intent(context, CaseDetailActivity.class); - intent.putExtra("id", caseId); - startActivity(intent); - } - }); - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - broadcastManager.destroy(Constant.NOTICE_MSG); - } -} diff --git a/app/src/main/java/com/casic/dcms/utils/StringHelper.java b/app/src/main/java/com/casic/dcms/utils/StringHelper.java index f5d5acb..3947941 100644 --- a/app/src/main/java/com/casic/dcms/utils/StringHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/StringHelper.java @@ -6,6 +6,8 @@ import com.casic.dcms.R; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class StringHelper { @@ -56,6 +58,22 @@ return isDigit && isLetter; } + public static boolean isPhoneNumber(String number) { + String regExp = "^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$"; + if (number.length() != 11) { + Log.d(TAG, "手机号应为11位数"); + return false; + } else { + Pattern p = Pattern.compile(regExp); + Matcher m = p.matcher(number); + boolean isMatch = m.matches(); + if (!isMatch) { + Log.d(TAG, "请填入正确的手机号"); + } + return isMatch; + } + } + public static String appendCompleteURL(String url) { if (TextUtils.isEmpty(url)) { return ""; diff --git a/app/src/main/res/drawable-hdpi/normal.png b/app/src/main/res/drawable-hdpi/normal.png new file mode 100644 index 0000000..3feab7d --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-hdpi/normal_small.png b/app/src/main/res/drawable-hdpi/normal_small.png new file mode 100644 index 0000000..4387126 --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal.png b/app/src/main/res/drawable-ldpi/normal.png new file mode 100644 index 0000000..175184c --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal_small.png b/app/src/main/res/drawable-ldpi/normal_small.png new file mode 100644 index 0000000..5890a00 --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-mdpi/normal.png b/app/src/main/res/drawable-mdpi/normal.png new file mode 100644 index 0000000..7ee8b48 --- /dev/null +++ b/app/src/main/res/drawable-mdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-mdpi/normal_small.png b/app/src/main/res/drawable-mdpi/normal_small.png new file mode 100644 index 0000000..43aa9ec --- /dev/null +++ b/app/src/main/res/drawable-mdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-xhdpi/normal.png b/app/src/main/res/drawable-xhdpi/normal.png new file mode 100644 index 0000000..5bd5a01 --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-xhdpi/normal_small.png b/app/src/main/res/drawable-xhdpi/normal_small.png new file mode 100644 index 0000000..51497fe --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-xxhdpi/normal.png b/app/src/main/res/drawable-xxhdpi/normal.png new file mode 100644 index 0000000..f4d0b34 --- /dev/null +++ b/app/src/main/res/drawable-xxhdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-xxhdpi/normal_small.png b/app/src/main/res/drawable-xxhdpi/normal_small.png new file mode 100644 index 0000000..66352a6 --- /dev/null +++ b/app/src/main/res/drawable-xxhdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable/bg_text_tag.xml b/app/src/main/res/drawable/bg_text_tag.xml new file mode 100644 index 0000000..d887d85 --- /dev/null +++ b/app/src/main/res/drawable/bg_text_tag.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_package.xml b/app/src/main/res/layout/activity_package.xml index 2374740..0a5ea98 100644 --- a/app/src/main/res/layout/activity_package.xml +++ b/app/src/main/res/layout/activity_package.xml @@ -123,6 +123,54 @@ android:layout_height="wrap_content" android:layout_centerVertical="true" android:drawableEnd="@mipmap/point" + android:text="店\u3000\u3000主" + android:textSize="@dimen/textFontSize" /> + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_dashboard.xml b/app/src/main/res/layout/fragment_dashboard.xml deleted file mode 100644 index 1e51cd8..0000000 --- a/app/src/main/res/layout/fragment_dashboard.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); 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 865787a..fa17e1f 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,12 +1,14 @@ package com.casic.dcms.service; import android.content.Context; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.bean.PushResultBean; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; import com.casic.dcms.utils.StringHelper; @@ -64,6 +66,7 @@ // 通知到达,只有个推通道下发的通知会回调此方法 @Override public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + Log.d(TAG, "onNotificationMessageArrived: " + message.getContent()); /** * appid = DR9oeLL9va6aG3DYXy2w39 * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 @@ -79,8 +82,8 @@ }.getType()); NoticeBean noticeBean = new NoticeBean(); - noticeBean.setUserPhone(StringHelper.getUserPhone()); - noticeBean.setCaseId(resultBean.getId()); + noticeBean.setUserName(StringHelper.getUserName()); + noticeBean.setCaseId(resultBean.getData().getId()); noticeBean.setTitle(resultBean.getTitle()); noticeBean.setContent(resultBean.getContent()); noticeBean.setType(resultBean.getType()); @@ -101,7 +104,10 @@ PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { }.getType()); - String caseId = resultBean.getId(); + String caseId = resultBean.getData().getId(); Log.d(TAG, "onNotificationMessageClicked: " + caseId); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); } } 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 db7d9ca..a1bcef6 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -244,8 +244,6 @@ showShopDialog(featureBean.getBgid(), (String) feature.getAttributes().get("Note"), featureBean.getDutyname(), - featureBean.getTel(), - "暂无", String.valueOf(featureBean.getObjectid())); } }); @@ -269,10 +267,10 @@ /** * 三包 */ - private void showShopDialog(String gridId, String communityName, String shopName, String phoneNumber, String shopKeeper, String shopID) { + private void showShopDialog(String gridId, String communityName, String shopName, String shopID) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("已选择商户:" + shopName + "\r\n手机号:" + phoneNumber + "\r\n确认提交?") + .setMessage("已选择商户:" + shopName + "\r\n确认提交?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { @@ -281,8 +279,6 @@ dialog.dismiss(); Intent intent = new Intent(); intent.putExtra("shopName", shopName); - intent.putExtra("phoneNumber", phoneNumber); - intent.putExtra("shopKeeper", shopKeeper); intent.putExtra("shopID", shopID); intent.putExtra("latitude", clickPoint.getY()); intent.putExtra("longitude", clickPoint.getX()); diff --git a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java index 8e43b7e..3fa89ee 100644 --- a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java @@ -155,10 +155,6 @@ PublicKey publicKey = RSAUtils.keyStrToPublicKey(keyString); String userName = userNameView.getText().toString(); String userPassword = userPasswordView.getText().toString(); - if (rememberPasswordView.isChecked()) { - SaveKeyValues.putValue("name", userName); - SaveKeyValues.putValue("password", userPassword); - } if (autoLoginView.isChecked()) { SaveKeyValues.putValue("autoLogin", true); } else { @@ -172,6 +168,10 @@ ToastHelper.showToast("密码不能为空", ToastHelper.WARING); return; } + if (rememberPasswordView.isChecked()) { + SaveKeyValues.putValue("name", userName); + SaveKeyValues.putValue("password", userPassword); + } String dataByPublicKey = RSAUtils.encryptDataByPublicKey(userPassword.getBytes(), publicKey); //登录并获取Token,POST请求 loginPresenter.onReadyRetrofitRequest(userName, dataByPublicKey); diff --git a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java index dc5fc67..dad0718 100644 --- a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java @@ -56,6 +56,10 @@ EditText longitudeView; @BindView(R.id.latitudeView) EditText latitudeView; + @BindView(R.id.shopKeeperView) + EditText shopKeeperView; + @BindView(R.id.phoneNumberView) + EditText phoneNumberView; @BindView(R.id.caseLocationView) EditText caseLocationView; @BindView(R.id.caseDetailEditView) @@ -73,7 +77,7 @@ private QMUITipDialog submitDialog; private List realPaths = new ArrayList<>();//真是图片路径 private List mediaList = new ArrayList<>();//上传到服务器的数据集 - private String gridId, shopKeeper, phoneNumber, shopID; + private String gridId, shopID; @Override public int initLayoutView() { @@ -187,8 +191,6 @@ gridId = data.getStringExtra("gridId"); String community = data.getStringExtra("community"); String shopName = data.getStringExtra("shopName"); - phoneNumber = data.getStringExtra("phoneNumber"); - shopKeeper = data.getStringExtra("shopKeeper"); shopID = data.getStringExtra("shopID"); longitudeView.setText(String.valueOf(longitude)); @@ -212,28 +214,41 @@ ToastHelper.showToast("经纬度异常,请重新选择位置", ToastHelper.WARING); return; } - - String fieldIntro = caseLocationView.getText().toString(); - if (TextUtils.isEmpty(fieldIntro)) { - ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + String shopKeeper = shopKeeperView.getText().toString(); + if (TextUtils.isEmpty(shopKeeper)) { + ToastHelper.showToast("店主名还未填写", ToastHelper.WARING); return; } - String description = caseDetailEditView.getText().toString(); - if (TextUtils.isEmpty(description)) { - ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + String phoneNumber = phoneNumberView.getText().toString(); + if (TextUtils.isEmpty(phoneNumber)) { + ToastHelper.showToast("电话号码还未填写", ToastHelper.WARING); return; } - if (mediaList.size() != 2) { - ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); - return; + if (StringHelper.isPhoneNumber(phoneNumber)) { + String fieldIntro = caseLocationView.getText().toString(); + if (TextUtils.isEmpty(fieldIntro)) { + ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + return; + } + String description = caseDetailEditView.getText().toString(); + if (TextUtils.isEmpty(description)) { + ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + return; + } + if (mediaList.size() != 2) { + ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); + return; + } + shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, + "2", "1", + gridId.substring(0, 6), + gridId.substring(0, 9), + gridId.substring(0, 12), + gridId, description, fieldIntro, + StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); + } else { + ToastHelper.showToast("电话号码格式不对", ToastHelper.WARING); } - shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, - "2", "1", - gridId.substring(0, 6), - gridId.substring(0, 9), - gridId.substring(0, 12), - gridId, description, fieldIntro, - StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); } @Override 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 index 192b702..708f2a8 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -1,16 +1,30 @@ package com.casic.dcms.ui.fragment; +import android.content.BroadcastReceiver; import android.content.Context; -import android.widget.LinearLayout; +import android.content.Intent; +import android.text.TextUtils; +import android.view.ViewGroup; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.adapter.SwipeViewAdapter; +import com.casic.dcms.base.BaseApplication; import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; +import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.greendao.DaoSession; +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; import java.util.ArrayList; import java.util.List; @@ -19,17 +33,19 @@ public class NoticePageFragment extends BaseFragment { - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; + @BindView(R.id.swipeRecyclerView) + RecyclerView swipeRecyclerView; private Context context; + private List noticeBeans = new ArrayList<>(); + private SwipeViewAdapter swipeViewAdapter; + private BroadcastManager broadcastManager; + private Gson gson; + private DaoSession daoSession; @Override protected int initLayoutView() { - return R.layout.fragment_dashboard; + return R.layout.fragment_notice; } @Override @@ -39,20 +55,90 @@ @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)); + gson = new Gson(); + daoSession = BaseApplication.getDaoSession(); + swipeViewAdapter = new SwipeViewAdapter(context); + //根据userName加载历史数据 + String userName = StringHelper.getUserName(); + if (TextUtils.isEmpty(userName)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserName.eq(userName)).list(); + swipeViewAdapter.setData(noticeBeans); + + broadcastManager = BroadcastManager.getInstance(context); + broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + if (Constant.NOTICE_MSG.equals(action)) { + String data = intent.getStringExtra("data"); + assert data != null; + NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); + noticeBeans.add(noticeBean); + //更新数据 + swipeViewAdapter.setData(noticeBeans); + } + } + } + }); } @Override protected void initEvent() { + QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { + @Override + public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { + int position = viewHolder.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + @Override + public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { + return QMUIRVItemSwipeAction.SWIPE_LEFT; + } + + @Override + public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { + super.onClickAction(swipeAction, selected, action); + int position = selected.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + }); + swipeAction.attachToRecyclerView(swipeRecyclerView); + swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { + @Override + public RecyclerView.LayoutParams generateDefaultLayoutParams() { + return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + } + }); + swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); + swipeRecyclerView.setAdapter(swipeViewAdapter); + swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { + @Override + public void onClick(int position) { + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = noticeBeans.get(position); + noticeBean.setIsRead("0"); + daoSession.update(noticeBean); + swipeViewAdapter.notifyDataSetChanged(); + + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); + } + }); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (broadcastManager != null) { + broadcastManager.destroy(Constant.NOTICE_MSG); + } } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java deleted file mode 100644 index 7b1e1fb..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class ReadFragment extends BaseFragment { - @Override - protected int initLayoutView() { - return R.layout.fragment_read; - } - - @Override - protected void setupTopBarLayout() { - - } - - @Override - protected void initData() { - - } - - @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 deleted file mode 100644 index a0afe0f..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.text.TextUtils; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.DividerItemDecoration; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SwipeViewAdapter; -import com.casic.dcms.base.BaseApplication; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.greendao.DaoSession; -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; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class UnreadFragment extends BaseFragment { - - private static final String TAG = "UnreadFragment"; - @BindView(R.id.swipeRecyclerView) - RecyclerView swipeRecyclerView; - - private Context context; - private List noticeBeans = new ArrayList<>(); - private SwipeViewAdapter swipeViewAdapter; - private BroadcastManager broadcastManager; - private Gson gson; - private DaoSession daoSession; - - @Override - protected int initLayoutView() { - return R.layout.fragment_unread; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - gson = new Gson(); - daoSession = BaseApplication.getDaoSession(); - swipeViewAdapter = new SwipeViewAdapter(context); - //根据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); - broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.NOTICE_MSG.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); - noticeBeans.add(noticeBean); - //更新数据 - swipeViewAdapter.setData(noticeBeans); - } - } - } - }); - } - - protected void initEvent() { - QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { - @Override - public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { - int position = viewHolder.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - - @Override - public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { - return QMUIRVItemSwipeAction.SWIPE_LEFT; - } - - @Override - public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { - super.onClickAction(swipeAction, selected, action); - int position = selected.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - }); - swipeAction.attachToRecyclerView(swipeRecyclerView); - swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { - @Override - public RecyclerView.LayoutParams generateDefaultLayoutParams() { - return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - } - }); - swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); - swipeRecyclerView.setAdapter(swipeViewAdapter); - swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { - @Override - public void onClick(int position) { - //点击之后之后,未读消息变为已读消息 - NoticeBean noticeBean = new NoticeBean(); - noticeBean.setIsRead("0"); - daoSession.update(noticeBean); - - String caseId = noticeBeans.get(position).getCaseId(); - Intent intent = new Intent(context, CaseDetailActivity.class); - intent.putExtra("id", caseId); - startActivity(intent); - } - }); - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - broadcastManager.destroy(Constant.NOTICE_MSG); - } -} diff --git a/app/src/main/java/com/casic/dcms/utils/StringHelper.java b/app/src/main/java/com/casic/dcms/utils/StringHelper.java index f5d5acb..3947941 100644 --- a/app/src/main/java/com/casic/dcms/utils/StringHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/StringHelper.java @@ -6,6 +6,8 @@ import com.casic.dcms.R; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class StringHelper { @@ -56,6 +58,22 @@ return isDigit && isLetter; } + public static boolean isPhoneNumber(String number) { + String regExp = "^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$"; + if (number.length() != 11) { + Log.d(TAG, "手机号应为11位数"); + return false; + } else { + Pattern p = Pattern.compile(regExp); + Matcher m = p.matcher(number); + boolean isMatch = m.matches(); + if (!isMatch) { + Log.d(TAG, "请填入正确的手机号"); + } + return isMatch; + } + } + public static String appendCompleteURL(String url) { if (TextUtils.isEmpty(url)) { return ""; diff --git a/app/src/main/res/drawable-hdpi/normal.png b/app/src/main/res/drawable-hdpi/normal.png new file mode 100644 index 0000000..3feab7d --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-hdpi/normal_small.png b/app/src/main/res/drawable-hdpi/normal_small.png new file mode 100644 index 0000000..4387126 --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal.png b/app/src/main/res/drawable-ldpi/normal.png new file mode 100644 index 0000000..175184c --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal_small.png b/app/src/main/res/drawable-ldpi/normal_small.png new file mode 100644 index 0000000..5890a00 --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-mdpi/normal.png b/app/src/main/res/drawable-mdpi/normal.png new file mode 100644 index 0000000..7ee8b48 --- /dev/null +++ b/app/src/main/res/drawable-mdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-mdpi/normal_small.png b/app/src/main/res/drawable-mdpi/normal_small.png new file mode 100644 index 0000000..43aa9ec --- /dev/null +++ b/app/src/main/res/drawable-mdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-xhdpi/normal.png b/app/src/main/res/drawable-xhdpi/normal.png new file mode 100644 index 0000000..5bd5a01 --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-xhdpi/normal_small.png b/app/src/main/res/drawable-xhdpi/normal_small.png new file mode 100644 index 0000000..51497fe --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-xxhdpi/normal.png b/app/src/main/res/drawable-xxhdpi/normal.png new file mode 100644 index 0000000..f4d0b34 --- /dev/null +++ b/app/src/main/res/drawable-xxhdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-xxhdpi/normal_small.png b/app/src/main/res/drawable-xxhdpi/normal_small.png new file mode 100644 index 0000000..66352a6 --- /dev/null +++ b/app/src/main/res/drawable-xxhdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable/bg_text_tag.xml b/app/src/main/res/drawable/bg_text_tag.xml new file mode 100644 index 0000000..d887d85 --- /dev/null +++ b/app/src/main/res/drawable/bg_text_tag.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_package.xml b/app/src/main/res/layout/activity_package.xml index 2374740..0a5ea98 100644 --- a/app/src/main/res/layout/activity_package.xml +++ b/app/src/main/res/layout/activity_package.xml @@ -123,6 +123,54 @@ android:layout_height="wrap_content" android:layout_centerVertical="true" android:drawableEnd="@mipmap/point" + android:text="店\u3000\u3000主" + android:textSize="@dimen/textFontSize" /> + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_dashboard.xml b/app/src/main/res/layout/fragment_dashboard.xml deleted file mode 100644 index 1e51cd8..0000000 --- a/app/src/main/res/layout/fragment_dashboard.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_notice.xml b/app/src/main/res/layout/fragment_notice.xml new file mode 100644 index 0000000..cf20840 --- /dev/null +++ b/app/src/main/res/layout/fragment_notice.xml @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java index 60d5e18..88bebd1 100644 --- a/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/ProcessLineAdapter.java @@ -47,8 +47,6 @@ return super.getItemViewType(position); } - private static final String TAG = "ProcessLineAdapter"; - @Override public int getItemCount() { return mProcessList.size(); 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 03c4b3f..61a8b1d 100644 --- a/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java +++ b/app/src/main/java/com/casic/dcms/adapter/SwipeViewAdapter.java @@ -65,11 +65,17 @@ TextView noticeTitleView = holder.itemView.findViewById(R.id.noticeTitleView); TextView noticeDateView = holder.itemView.findViewById(R.id.noticeDateView); TextView noticeContentView = holder.itemView.findViewById(R.id.noticeContentView); + TextView messageTagView = holder.itemView.findViewById(R.id.messageTagView); NoticeBean noticeBean = mData.get(position); noticeTitleView.setText(noticeBean.getTitle()); noticeDateView.setText(noticeBean.getPushDate()); noticeContentView.setText(noticeBean.getContent()); + if (noticeBean.getIsRead().equals("0")) { + messageTagView.setVisibility(View.GONE); + } else { + messageTagView.setVisibility(View.VISIBLE); + } 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 1510cef..1cfda9d 100644 --- a/app/src/main/java/com/casic/dcms/bean/NoticeBean.java +++ b/app/src/main/java/com/casic/dcms/bean/NoticeBean.java @@ -17,7 +17,7 @@ @Id(autoincrement = true) private Long id;//主键ID - private String userPhone;//用户手机号 + private String userName;//用户名 private String caseId;//案卷id private String title;//案卷标题 private String content;//案卷简介 @@ -25,11 +25,11 @@ private String type;//推送类型 private String isRead;//0-已读;1-未读 - @Generated(hash = 1624806914) - public NoticeBean(Long id, String userPhone, String caseId, String title, + @Generated(hash = 2013153901) + public NoticeBean(Long id, String userName, String caseId, String title, String content, String pushDate, String type, String isRead) { this.id = id; - this.userPhone = userPhone; + this.userName = userName; this.caseId = caseId; this.title = title; this.content = content; @@ -50,12 +50,12 @@ this.id = id; } - public String getUserPhone() { - return this.userPhone; + public String getUserName() { + return this.userName; } - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; + public void setUserName(String userName) { + this.userName = userName; } public String getCaseId() { diff --git a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java index 017a37e..9979796 100644 --- a/app/src/main/java/com/casic/dcms/bean/PushResultBean.java +++ b/app/src/main/java/com/casic/dcms/bean/PushResultBean.java @@ -12,7 +12,7 @@ private String content; private DataBean data; - private String id; + private String id;//消息id private String title; private String type; @@ -61,7 +61,7 @@ * id : 1393113365064245250 */ - private String id; + private String id;//案卷id public String getId() { return 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 c118368..a733f25 100644 --- a/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java +++ b/app/src/main/java/com/casic/dcms/greendao/NoticeBeanDao.java @@ -25,7 +25,7 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property UserPhone = new Property(1, String.class, "userPhone", false, "USER_PHONE"); + public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 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"); @@ -48,7 +48,7 @@ String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"NOTICE_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"USER_PHONE\" TEXT," + // 1: userPhone + "\"USER_NAME\" TEXT," + // 1: userName "\"CASE_ID\" TEXT," + // 2: caseId "\"TITLE\" TEXT," + // 3: title "\"CONTENT\" TEXT," + // 4: content @@ -72,9 +72,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -117,9 +117,9 @@ stmt.bindLong(1, id); } - String userPhone = entity.getUserPhone(); - if (userPhone != null) { - stmt.bindString(2, userPhone); + String userName = entity.getUserName(); + if (userName != null) { + stmt.bindString(2, userName); } String caseId = entity.getCaseId(); @@ -162,7 +162,7 @@ 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), // userPhone + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userName 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 @@ -176,7 +176,7 @@ @Override public void readEntity(Cursor cursor, NoticeBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setUserPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setUserName(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)); 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 865787a..fa17e1f 100644 --- a/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java +++ b/app/src/main/java/com/casic/dcms/service/GeTuiIntentService.java @@ -1,12 +1,14 @@ package com.casic.dcms.service; import android.content.Context; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.casic.dcms.base.BaseApplication; import com.casic.dcms.bean.NoticeBean; import com.casic.dcms.bean.PushResultBean; +import com.casic.dcms.ui.CaseDetailActivity; import com.casic.dcms.utils.BroadcastManager; import com.casic.dcms.utils.Constant; import com.casic.dcms.utils.StringHelper; @@ -64,6 +66,7 @@ // 通知到达,只有个推通道下发的通知会回调此方法 @Override public void onNotificationMessageArrived(Context context, GTNotificationMessage message) { + Log.d(TAG, "onNotificationMessageArrived: " + message.getContent()); /** * appid = DR9oeLL9va6aG3DYXy2w39 * taskid = OSL-0514_xL4fPj7kqQ6tknVoQt3Mf6 @@ -79,8 +82,8 @@ }.getType()); NoticeBean noticeBean = new NoticeBean(); - noticeBean.setUserPhone(StringHelper.getUserPhone()); - noticeBean.setCaseId(resultBean.getId()); + noticeBean.setUserName(StringHelper.getUserName()); + noticeBean.setCaseId(resultBean.getData().getId()); noticeBean.setTitle(resultBean.getTitle()); noticeBean.setContent(resultBean.getContent()); noticeBean.setType(resultBean.getType()); @@ -101,7 +104,10 @@ PushResultBean resultBean = gson.fromJson(messageContent, new TypeToken() { }.getType()); - String caseId = resultBean.getId(); + String caseId = resultBean.getData().getId(); Log.d(TAG, "onNotificationMessageClicked: " + caseId); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); } } 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 db7d9ca..a1bcef6 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -244,8 +244,6 @@ showShopDialog(featureBean.getBgid(), (String) feature.getAttributes().get("Note"), featureBean.getDutyname(), - featureBean.getTel(), - "暂无", String.valueOf(featureBean.getObjectid())); } }); @@ -269,10 +267,10 @@ /** * 三包 */ - private void showShopDialog(String gridId, String communityName, String shopName, String phoneNumber, String shopKeeper, String shopID) { + private void showShopDialog(String gridId, String communityName, String shopName, String shopID) { new QMUIDialog.MessageDialogBuilder(this) .setTitle("提示") - .setMessage("已选择商户:" + shopName + "\r\n手机号:" + phoneNumber + "\r\n确认提交?") + .setMessage("已选择商户:" + shopName + "\r\n确认提交?") .setCanceledOnTouchOutside(false) .addAction("取消", (dialog, index) -> dialog.dismiss()) .addAction("确定", new QMUIDialogAction.ActionListener() { @@ -281,8 +279,6 @@ dialog.dismiss(); Intent intent = new Intent(); intent.putExtra("shopName", shopName); - intent.putExtra("phoneNumber", phoneNumber); - intent.putExtra("shopKeeper", shopKeeper); intent.putExtra("shopID", shopID); intent.putExtra("latitude", clickPoint.getY()); intent.putExtra("longitude", clickPoint.getX()); diff --git a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java index 8e43b7e..3fa89ee 100644 --- a/app/src/main/java/com/casic/dcms/ui/LoginActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/LoginActivity.java @@ -155,10 +155,6 @@ PublicKey publicKey = RSAUtils.keyStrToPublicKey(keyString); String userName = userNameView.getText().toString(); String userPassword = userPasswordView.getText().toString(); - if (rememberPasswordView.isChecked()) { - SaveKeyValues.putValue("name", userName); - SaveKeyValues.putValue("password", userPassword); - } if (autoLoginView.isChecked()) { SaveKeyValues.putValue("autoLogin", true); } else { @@ -172,6 +168,10 @@ ToastHelper.showToast("密码不能为空", ToastHelper.WARING); return; } + if (rememberPasswordView.isChecked()) { + SaveKeyValues.putValue("name", userName); + SaveKeyValues.putValue("password", userPassword); + } String dataByPublicKey = RSAUtils.encryptDataByPublicKey(userPassword.getBytes(), publicKey); //登录并获取Token,POST请求 loginPresenter.onReadyRetrofitRequest(userName, dataByPublicKey); diff --git a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java index dc5fc67..dad0718 100644 --- a/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ThreePackageUploadActivity.java @@ -56,6 +56,10 @@ EditText longitudeView; @BindView(R.id.latitudeView) EditText latitudeView; + @BindView(R.id.shopKeeperView) + EditText shopKeeperView; + @BindView(R.id.phoneNumberView) + EditText phoneNumberView; @BindView(R.id.caseLocationView) EditText caseLocationView; @BindView(R.id.caseDetailEditView) @@ -73,7 +77,7 @@ private QMUITipDialog submitDialog; private List realPaths = new ArrayList<>();//真是图片路径 private List mediaList = new ArrayList<>();//上传到服务器的数据集 - private String gridId, shopKeeper, phoneNumber, shopID; + private String gridId, shopID; @Override public int initLayoutView() { @@ -187,8 +191,6 @@ gridId = data.getStringExtra("gridId"); String community = data.getStringExtra("community"); String shopName = data.getStringExtra("shopName"); - phoneNumber = data.getStringExtra("phoneNumber"); - shopKeeper = data.getStringExtra("shopKeeper"); shopID = data.getStringExtra("shopID"); longitudeView.setText(String.valueOf(longitude)); @@ -212,28 +214,41 @@ ToastHelper.showToast("经纬度异常,请重新选择位置", ToastHelper.WARING); return; } - - String fieldIntro = caseLocationView.getText().toString(); - if (TextUtils.isEmpty(fieldIntro)) { - ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + String shopKeeper = shopKeeperView.getText().toString(); + if (TextUtils.isEmpty(shopKeeper)) { + ToastHelper.showToast("店主名还未填写", ToastHelper.WARING); return; } - String description = caseDetailEditView.getText().toString(); - if (TextUtils.isEmpty(description)) { - ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + String phoneNumber = phoneNumberView.getText().toString(); + if (TextUtils.isEmpty(phoneNumber)) { + ToastHelper.showToast("电话号码还未填写", ToastHelper.WARING); return; } - if (mediaList.size() != 2) { - ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); - return; + if (StringHelper.isPhoneNumber(phoneNumber)) { + String fieldIntro = caseLocationView.getText().toString(); + if (TextUtils.isEmpty(fieldIntro)) { + ToastHelper.showToast("案卷地点还未填写", ToastHelper.WARING); + return; + } + String description = caseDetailEditView.getText().toString(); + if (TextUtils.isEmpty(description)) { + ToastHelper.showToast("案卷情况还未填写", ToastHelper.WARING); + return; + } + if (mediaList.size() != 2) { + ToastHelper.showToast("必须选择两张图片", ToastHelper.WARING); + return; + } + shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, + "2", "1", + gridId.substring(0, 6), + gridId.substring(0, 9), + gridId.substring(0, 12), + gridId, description, fieldIntro, + StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); + } else { + ToastHelper.showToast("电话号码格式不对", ToastHelper.WARING); } - shopCaseSubmitPresenter.onReadyRetrofitRequest("0", "0", longitude, latitude, - "2", "1", - gridId.substring(0, 6), - gridId.substring(0, 9), - gridId.substring(0, 12), - gridId, description, fieldIntro, - StringHelper.reformatURL(mediaList), 0, 0, shopID, shopKeeper, phoneNumber); } @Override 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 index 192b702..708f2a8 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/NoticePageFragment.java @@ -1,16 +1,30 @@ package com.casic.dcms.ui.fragment; +import android.content.BroadcastReceiver; import android.content.Context; -import android.widget.LinearLayout; +import android.content.Intent; +import android.text.TextUtils; +import android.view.ViewGroup; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import com.casic.dcms.R; -import com.casic.dcms.adapter.SubViewPagerAdapter; +import com.casic.dcms.adapter.SwipeViewAdapter; +import com.casic.dcms.base.BaseApplication; import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.widgets.NoScrollViewPager; -import com.google.android.material.tabs.TabLayout; +import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.greendao.DaoSession; +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; import java.util.ArrayList; import java.util.List; @@ -19,17 +33,19 @@ public class NoticePageFragment extends BaseFragment { - private static final String[] pageTitles = {"未读消息", "已读消息"}; - @BindView(R.id.topTabLayout) - TabLayout topTabLayout; - @BindView(R.id.dashboardViewPager) - NoScrollViewPager dashboardViewPager; + @BindView(R.id.swipeRecyclerView) + RecyclerView swipeRecyclerView; private Context context; + private List noticeBeans = new ArrayList<>(); + private SwipeViewAdapter swipeViewAdapter; + private BroadcastManager broadcastManager; + private Gson gson; + private DaoSession daoSession; @Override protected int initLayoutView() { - return R.layout.fragment_dashboard; + return R.layout.fragment_notice; } @Override @@ -39,20 +55,90 @@ @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)); + gson = new Gson(); + daoSession = BaseApplication.getDaoSession(); + swipeViewAdapter = new SwipeViewAdapter(context); + //根据userName加载历史数据 + String userName = StringHelper.getUserName(); + if (TextUtils.isEmpty(userName)) { + return; + } + noticeBeans = daoSession.queryBuilder(NoticeBean.class).where(NoticeBeanDao.Properties.UserName.eq(userName)).list(); + swipeViewAdapter.setData(noticeBeans); + + broadcastManager = BroadcastManager.getInstance(context); + broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + if (Constant.NOTICE_MSG.equals(action)) { + String data = intent.getStringExtra("data"); + assert data != null; + NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); + noticeBeans.add(noticeBean); + //更新数据 + swipeViewAdapter.setData(noticeBeans); + } + } + } + }); } @Override protected void initEvent() { + QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { + @Override + public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { + int position = viewHolder.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + @Override + public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { + return QMUIRVItemSwipeAction.SWIPE_LEFT; + } + + @Override + public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { + super.onClickAction(swipeAction, selected, action); + int position = selected.getAdapterPosition(); + daoSession.delete(noticeBeans.get(position)); + swipeViewAdapter.remove(position); + } + }); + swipeAction.attachToRecyclerView(swipeRecyclerView); + swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { + @Override + public RecyclerView.LayoutParams generateDefaultLayoutParams() { + return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + } + }); + swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); + swipeRecyclerView.setAdapter(swipeViewAdapter); + swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { + @Override + public void onClick(int position) { + //点击之后之后,未读消息变为已读消息 + NoticeBean noticeBean = noticeBeans.get(position); + noticeBean.setIsRead("0"); + daoSession.update(noticeBean); + swipeViewAdapter.notifyDataSetChanged(); + + String caseId = noticeBeans.get(position).getCaseId(); + Intent intent = new Intent(context, CaseDetailActivity.class); + intent.putExtra("id", caseId); + startActivity(intent); + } + }); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (broadcastManager != null) { + broadcastManager.destroy(Constant.NOTICE_MSG); + } } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java deleted file mode 100644 index 7b1e1fb..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/ReadFragment.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class ReadFragment extends BaseFragment { - @Override - protected int initLayoutView() { - return R.layout.fragment_read; - } - - @Override - protected void setupTopBarLayout() { - - } - - @Override - protected void initData() { - - } - - @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 deleted file mode 100644 index a0afe0f..0000000 --- a/app/src/main/java/com/casic/dcms/ui/fragment/UnreadFragment.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.casic.dcms.ui.fragment; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.text.TextUtils; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.DividerItemDecoration; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.casic.dcms.R; -import com.casic.dcms.adapter.SwipeViewAdapter; -import com.casic.dcms.base.BaseApplication; -import com.casic.dcms.base.BaseFragment; -import com.casic.dcms.bean.NoticeBean; -import com.casic.dcms.greendao.DaoSession; -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; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; - -/** - * @author : Pengxh - * @time : 2021/4/15 9:33 - * @email : 290677893@qq.com - **/ -public class UnreadFragment extends BaseFragment { - - private static final String TAG = "UnreadFragment"; - @BindView(R.id.swipeRecyclerView) - RecyclerView swipeRecyclerView; - - private Context context; - private List noticeBeans = new ArrayList<>(); - private SwipeViewAdapter swipeViewAdapter; - private BroadcastManager broadcastManager; - private Gson gson; - private DaoSession daoSession; - - @Override - protected int initLayoutView() { - return R.layout.fragment_unread; - } - - @Override - protected void setupTopBarLayout() { - context = getContext(); - } - - @Override - protected void initData() { - gson = new Gson(); - daoSession = BaseApplication.getDaoSession(); - swipeViewAdapter = new SwipeViewAdapter(context); - //根据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); - broadcastManager.addAction(Constant.NOTICE_MSG, new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Constant.NOTICE_MSG.equals(action)) { - String data = intent.getStringExtra("data"); - assert data != null; - NoticeBean noticeBean = gson.fromJson(data, NoticeBean.class); - noticeBeans.add(noticeBean); - //更新数据 - swipeViewAdapter.setData(noticeBeans); - } - } - } - }); - } - - protected void initEvent() { - QMUIRVItemSwipeAction swipeAction = new QMUIRVItemSwipeAction(true, new QMUIRVItemSwipeAction.Callback() { - @Override - public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { - int position = viewHolder.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - - @Override - public int getSwipeDirection(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { - return QMUIRVItemSwipeAction.SWIPE_LEFT; - } - - @Override - public void onClickAction(QMUIRVItemSwipeAction swipeAction, RecyclerView.ViewHolder selected, QMUISwipeAction action) { - super.onClickAction(swipeAction, selected, action); - int position = selected.getAdapterPosition(); - daoSession.delete(noticeBeans.get(position)); - swipeViewAdapter.remove(position); - } - }); - swipeAction.attachToRecyclerView(swipeRecyclerView); - swipeRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { - @Override - public RecyclerView.LayoutParams generateDefaultLayoutParams() { - return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - } - }); - swipeRecyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); - swipeRecyclerView.setAdapter(swipeViewAdapter); - swipeViewAdapter.setOnItemClickListener(new SwipeViewAdapter.OnItemClickListener() { - @Override - public void onClick(int position) { - //点击之后之后,未读消息变为已读消息 - NoticeBean noticeBean = new NoticeBean(); - noticeBean.setIsRead("0"); - daoSession.update(noticeBean); - - String caseId = noticeBeans.get(position).getCaseId(); - Intent intent = new Intent(context, CaseDetailActivity.class); - intent.putExtra("id", caseId); - startActivity(intent); - } - }); - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - broadcastManager.destroy(Constant.NOTICE_MSG); - } -} diff --git a/app/src/main/java/com/casic/dcms/utils/StringHelper.java b/app/src/main/java/com/casic/dcms/utils/StringHelper.java index f5d5acb..3947941 100644 --- a/app/src/main/java/com/casic/dcms/utils/StringHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/StringHelper.java @@ -6,6 +6,8 @@ import com.casic.dcms.R; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class StringHelper { @@ -56,6 +58,22 @@ return isDigit && isLetter; } + public static boolean isPhoneNumber(String number) { + String regExp = "^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$"; + if (number.length() != 11) { + Log.d(TAG, "手机号应为11位数"); + return false; + } else { + Pattern p = Pattern.compile(regExp); + Matcher m = p.matcher(number); + boolean isMatch = m.matches(); + if (!isMatch) { + Log.d(TAG, "请填入正确的手机号"); + } + return isMatch; + } + } + public static String appendCompleteURL(String url) { if (TextUtils.isEmpty(url)) { return ""; diff --git a/app/src/main/res/drawable-hdpi/normal.png b/app/src/main/res/drawable-hdpi/normal.png new file mode 100644 index 0000000..3feab7d --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-hdpi/normal_small.png b/app/src/main/res/drawable-hdpi/normal_small.png new file mode 100644 index 0000000..4387126 --- /dev/null +++ b/app/src/main/res/drawable-hdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal.png b/app/src/main/res/drawable-ldpi/normal.png new file mode 100644 index 0000000..175184c --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-ldpi/normal_small.png b/app/src/main/res/drawable-ldpi/normal_small.png new file mode 100644 index 0000000..5890a00 --- /dev/null +++ b/app/src/main/res/drawable-ldpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-mdpi/normal.png b/app/src/main/res/drawable-mdpi/normal.png new file mode 100644 index 0000000..7ee8b48 --- /dev/null +++ b/app/src/main/res/drawable-mdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-mdpi/normal_small.png b/app/src/main/res/drawable-mdpi/normal_small.png new file mode 100644 index 0000000..43aa9ec --- /dev/null +++ b/app/src/main/res/drawable-mdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-xhdpi/normal.png b/app/src/main/res/drawable-xhdpi/normal.png new file mode 100644 index 0000000..5bd5a01 --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-xhdpi/normal_small.png b/app/src/main/res/drawable-xhdpi/normal_small.png new file mode 100644 index 0000000..51497fe --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable-xxhdpi/normal.png b/app/src/main/res/drawable-xxhdpi/normal.png new file mode 100644 index 0000000..f4d0b34 --- /dev/null +++ b/app/src/main/res/drawable-xxhdpi/normal.png Binary files differ diff --git a/app/src/main/res/drawable-xxhdpi/normal_small.png b/app/src/main/res/drawable-xxhdpi/normal_small.png new file mode 100644 index 0000000..66352a6 --- /dev/null +++ b/app/src/main/res/drawable-xxhdpi/normal_small.png Binary files differ diff --git a/app/src/main/res/drawable/bg_text_tag.xml b/app/src/main/res/drawable/bg_text_tag.xml new file mode 100644 index 0000000..d887d85 --- /dev/null +++ b/app/src/main/res/drawable/bg_text_tag.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_package.xml b/app/src/main/res/layout/activity_package.xml index 2374740..0a5ea98 100644 --- a/app/src/main/res/layout/activity_package.xml +++ b/app/src/main/res/layout/activity_package.xml @@ -123,6 +123,54 @@ android:layout_height="wrap_content" android:layout_centerVertical="true" android:drawableEnd="@mipmap/point" + android:text="店\u3000\u3000主" + android:textSize="@dimen/textFontSize" /> + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_dashboard.xml b/app/src/main/res/layout/fragment_dashboard.xml deleted file mode 100644 index 1e51cd8..0000000 --- a/app/src/main/res/layout/fragment_dashboard.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_notice.xml b/app/src/main/res/layout/fragment_notice.xml new file mode 100644 index 0000000..cf20840 --- /dev/null +++ b/app/src/main/res/layout/fragment_notice.xml @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_notice_list.xml b/app/src/main/res/layout/item_notice_list.xml index 753003e..66a3154 100644 --- a/app/src/main/res/layout/item_notice_list.xml +++ b/app/src/main/res/layout/item_notice_list.xml @@ -1,33 +1,59 @@ - + android:orientation="vertical" + android:padding="@dimen/padding_10dp"> - + + + + + + + + android:layout_marginTop="5dp"> - + - - \ No newline at end of file + + + \ No newline at end of file