feat(api): 增强通知功能及新增站点用户信息上报
- 新增通知详情接口,查询通知详情时异步增加阅读次数 - 小铃铛列表支持展开通知时异步增加通知阅读次数并刷新列表 - 通知列表查询接口增加isScheduler参数 - MessageInfo新增接收和阅读次数字段 - MyNotifyListAdapter新增通知展开事件监听,显示真实阅读次数 - MainActivity新增localStorage用户信息轮询机制,自动抓取并净化用户信息 - 实现用户信息去重上报,只对未上报过的用户信息调用上报接口 - 处理用户信息抓取结果,支持手机号多字段提取及本地缓存 - 允许自定义轮询间隔,登录状态下每日复查一次,未登录时每30秒一次 - 完善错误处理,用户信息上报失败时清除本地去重缓存支持重试 - 配置更新及新增模块titanplayz和amazy,调整版本号与命名规范
This commit is contained in:
@@ -38,13 +38,6 @@ public interface ApiService {
|
||||
@PUT("api/statistics/use")
|
||||
Observable<Result> totalTongJi(@Body Map<String, Object> map);
|
||||
|
||||
/**
|
||||
* 统计通知
|
||||
*/
|
||||
@POST("api/push/statistics")
|
||||
Observable<Result> totalNotify(@Body Map<String, Object> map);
|
||||
|
||||
|
||||
/**
|
||||
* 获取通知列表
|
||||
* @param userid
|
||||
@@ -53,7 +46,18 @@ public interface ApiService {
|
||||
* @return
|
||||
*/
|
||||
@GET("api/push/pushRecords")
|
||||
Observable<Result<ResultDataInfo<MessageInfo>>> getNotifyList(@Query("userId") int userid, @Query("page") int page, @Query("size") int size);
|
||||
Observable<Result<ResultDataInfo<MessageInfo>>> getNotifyList(
|
||||
@Query("userId") int userid,
|
||||
@Query("page") int page,
|
||||
@Query("size") int size,
|
||||
@Query("isScheduler") int isScheduler
|
||||
);
|
||||
|
||||
/**
|
||||
* 获取通知详情。查询成功后,后端会异步将该通知的阅读次数加一。
|
||||
*/
|
||||
@GET("api/push/client/pushRecord/{id}")
|
||||
Observable<Result<MessageInfo>> getNotifyDetail(@Path("id") int pushId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -547,7 +547,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
public void getNotifyList() {
|
||||
|
||||
Api.getInstance().getNotifyList(userId, 1, 1)
|
||||
Api.getInstance().getNotifyList(userId, 1, 1, 0)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
@@ -814,14 +814,15 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
public void recordNotify(int pushId) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("pushId", pushId);
|
||||
Api.getInstance().totalNotify(map)
|
||||
if (pushId <= 0) {
|
||||
return;
|
||||
}
|
||||
Api.getInstance().getNotifyDetail(pushId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
.subscribe(new BaseObserver<Result<MessageInfo>>() {
|
||||
@Override
|
||||
public void onSuccess(Result o) {
|
||||
public void onSuccess(Result<MessageInfo> o) {
|
||||
|
||||
}
|
||||
|
||||
@@ -830,7 +831,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError2(Result o) {
|
||||
public void onError2(Result<MessageInfo> o) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -10,6 +10,8 @@ public class MessageInfo implements Serializable {
|
||||
private int pushId;
|
||||
private String createTime;
|
||||
private int recordId;
|
||||
private long receiveTimes;
|
||||
private long readTimes;
|
||||
public int status;
|
||||
private String jumpUrl;
|
||||
private boolean isShowAll = false;
|
||||
@@ -30,6 +32,22 @@ public class MessageInfo implements Serializable {
|
||||
this.recordId = recordId;
|
||||
}
|
||||
|
||||
public long getReceiveTimes() {
|
||||
return receiveTimes;
|
||||
}
|
||||
|
||||
public void setReceiveTimes(long receiveTimes) {
|
||||
this.receiveTimes = receiveTimes;
|
||||
}
|
||||
|
||||
public long getReadTimes() {
|
||||
return readTimes;
|
||||
}
|
||||
|
||||
public void setReadTimes(long readTimes) {
|
||||
this.readTimes = readTimes;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ public class MyNotifyListAdapter extends RecyclerView.Adapter<MyNotifyListAdapte
|
||||
|
||||
private List<MessageInfo> listdata;
|
||||
private onItemClickPostionListener itemClickPostionListener;
|
||||
private onItemExpandListener itemExpandListener;
|
||||
private Context context;
|
||||
private MessageInfo messageItem;
|
||||
|
||||
@@ -49,6 +50,10 @@ public class MyNotifyListAdapter extends RecyclerView.Adapter<MyNotifyListAdapte
|
||||
this.itemClickPostionListener = onItemClick;
|
||||
}
|
||||
|
||||
public void setOnItemExpand(onItemExpandListener onItemExpand) {
|
||||
this.itemExpandListener = onItemExpand;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
@@ -103,7 +108,8 @@ public class MyNotifyListAdapter extends RecyclerView.Adapter<MyNotifyListAdapte
|
||||
holder.itemNotifyListBinding.tvMsgTime.setText(messageInfo.getCreateTime());
|
||||
holder.itemNotifyListBinding.ivNotifyjumpclick.setVisibility(View.GONE);
|
||||
|
||||
holder.itemNotifyListBinding.lookIv.setText(longTime(messageInfo.getCreateTime()));
|
||||
// 左下角眼睛图标显示后端返回的真实阅读次数
|
||||
holder.itemNotifyListBinding.lookIv.setText(String.valueOf(messageInfo.getReadTimes()));
|
||||
if (!TextUtils.isEmpty(messageInfo.getImage())) {
|
||||
LogUtils.i("地址是啥:"+messageInfo.getImage());
|
||||
holder.itemNotifyListBinding.ivNotifyimage.setVisibility(View.VISIBLE);
|
||||
@@ -126,7 +132,11 @@ public class MyNotifyListAdapter extends RecyclerView.Adapter<MyNotifyListAdapte
|
||||
holder.itemNotifyListBinding.layoutMore.setVisibility(View.GONE);
|
||||
}
|
||||
holder.itemView.setOnClickListener(view -> {
|
||||
messageInfo.setShowAll(!messageInfo.isShowAll());
|
||||
boolean willExpand = !messageInfo.isShowAll();
|
||||
messageInfo.setShowAll(willExpand);
|
||||
if (willExpand && itemExpandListener != null) {
|
||||
itemExpandListener.item(messageInfo);
|
||||
}
|
||||
notifyItemChanged(position);
|
||||
});
|
||||
|
||||
@@ -167,4 +177,8 @@ public class MyNotifyListAdapter extends RecyclerView.Adapter<MyNotifyListAdapte
|
||||
void item(int position);
|
||||
}
|
||||
|
||||
public interface onItemExpandListener {
|
||||
void item(MessageInfo messageInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ public class NotifyListActivity extends AppCompatActivity {
|
||||
adapter.setOnItemClick(position -> {
|
||||
try{
|
||||
MessageInfo messageInfo = listdata.get(position);
|
||||
recordNotify(messageInfo);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(messageInfo.getJumpUrl()));
|
||||
startActivity(intent);
|
||||
}catch (Exception e){
|
||||
@@ -89,8 +90,44 @@ public class NotifyListActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
});
|
||||
adapter.setOnItemExpand(this::recordNotify);
|
||||
getNotifyList();
|
||||
}
|
||||
|
||||
/** 小铃铛列表中用户展开通知时,按文档查询详情并异步增加阅读次数。 */
|
||||
private void recordNotify(MessageInfo messageInfo) {
|
||||
if (messageInfo == null) {
|
||||
return;
|
||||
}
|
||||
int pushId = messageInfo.getPushId() > 0 ? messageInfo.getPushId() : messageInfo.getRecordId();
|
||||
if (pushId <= 0) {
|
||||
return;
|
||||
}
|
||||
Api.getInstance().getNotifyDetail(pushId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<Result<MessageInfo>>() {
|
||||
@Override
|
||||
public void onSuccess(Result<MessageInfo> o) {
|
||||
// 后端采用异步最终一致,详情响应可能仍是加一前的值;稍后刷新列表读取最终值。
|
||||
if (o != null && o.data != null && o.data.getReadTimes() > messageInfo.getReadTimes()) {
|
||||
messageInfo.setReadTimes(o.data.getReadTimes());
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
activityNotifylistBinding.recyclerNofity.postDelayed(() -> getNotifyList(), 1200L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
LogUtils.i("阅读次数上报失败 pushId=" + pushId + ", error=" + msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError2(Result<MessageInfo> o) {
|
||||
LogUtils.i("阅读次数上报失败 pushId=" + pushId);
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 启用Edge-to-Edge模式(核心方法)
|
||||
*
|
||||
@@ -121,7 +158,7 @@ public class NotifyListActivity extends AppCompatActivity {
|
||||
|
||||
public void getNotifyList() {
|
||||
//通知列表
|
||||
Api.getInstance().getNotifyList(userId, page, 10)
|
||||
Api.getInstance().getNotifyList(userId, page, 10, 0)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
|
||||
Reference in New Issue
Block a user