一、新增消息时间显示
1.定义:当用户处于消息界面,接受到新消息时,消息是否展示
2.过程
2.1收到第1条消息,此条消息展示时间(第一条消息一定展示时间,
标记一个当前展示时间的指针index1 = time1;
markNum = 1;
2.2收到第2条消息,如果此消息时间 index2 = time2,
if index2-index1 >=5 minues then show time2
else markNum++; // don’t show;
2.3 收到第3条消息,如果消息时间 index3 = time3,
if index3-index2 >=5minues then show time3
else markNum++; //don’t show
2.4 ………..//依次类推,消息均未展示
2.5 收到第20条消息 此时消息 index20 = time20;
If index20-index19 >=5minues then show time20 //show
else if markNum>=20 then show time20 //show
else markNum++; //don’t show
二、 已有时间显示
1.定义:用户处于消息界面以外状态,当点击到消息界面,已经存在的消息如何展示时间
2.过程
2.1 获取20条消息数据,
第一条显示时间show time1
第二条 if time2-time1>5分钟 then show time2 else don’t show
第三条 if time3-time2>5分钟 then show time3 else don’t show
第四条 if time4-time3>5分钟 then show time4 else don’t show
。。。。。。
第20条 if time20-time19>5分钟 then show time20 else don’t show
2.2 当收到新消息
newtime = timeN;
markNum=0;//每次切换到消息帧,设置为0
if timeN-time(N-1) > 5分钟 show timeN else don’t show