调整注册后首次弹窗时间
This commit is contained in:
@@ -12,6 +12,16 @@ public class MessageSayHiBean extends BaseModel{
|
||||
@SerializedName("status")
|
||||
private int status;
|
||||
|
||||
private int oldTime;
|
||||
|
||||
public int getOldTime() {
|
||||
return oldTime;
|
||||
}
|
||||
|
||||
public void setOldTime(int oldTime) {
|
||||
this.oldTime = oldTime;
|
||||
}
|
||||
|
||||
public MessageUserInfoBean getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ public class MessageSayHiNotifyManager {
|
||||
hiBean = new MessageSayHiBean();
|
||||
hiBean.setModel("init");
|
||||
hiBean.setNextTime(data.getNextTime());
|
||||
hiBean.setOldTime(data.getNextTime());
|
||||
Log.i(TAG, "onSuccess: 初始化定时器,第一轮时间:" + data.getNextTime());
|
||||
}
|
||||
|
||||
@@ -87,8 +88,10 @@ public class MessageSayHiNotifyManager {
|
||||
timer.schedule(createTask(), data.getNextTime() * 1000L);
|
||||
return;
|
||||
}
|
||||
data.setOldTime(hiBean.getNextTime());
|
||||
hiBean = data;
|
||||
showDialog(data);
|
||||
Log.i(TAG, "onSuccess: 展示弹框时间:" + data);
|
||||
showDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,49 +100,7 @@ public class MessageSayHiNotifyManager {
|
||||
|
||||
}
|
||||
|
||||
void showDialog(MessageSayHiBean bean) {
|
||||
if (isShowDialog) {
|
||||
Log.i(TAG, "showDialog: 展示对话框中");
|
||||
return;
|
||||
}
|
||||
if (isStopShow) {
|
||||
Log.i(TAG, "showDialog: 非目标页面,停止展示");
|
||||
lastActivity = null;
|
||||
isRun = false;
|
||||
return;
|
||||
}
|
||||
String simpleName = AppManager.getInstance().getLastActivity().getClass().getSimpleName();
|
||||
if (simpleName.equals(lastActivity)) {
|
||||
Log.i(TAG, "showDialog: 与上次触发是同一个页面,不展示");
|
||||
isRun = false;
|
||||
return;
|
||||
}
|
||||
isShowDialog = true;
|
||||
Log.i(TAG, "showDialog: 打开本轮打招呼弹框 " + bean);
|
||||
lastActivity = AppManager.getInstance().getLastActivity().getClass().getSimpleName();
|
||||
new MessageSayHiNotifyDialog(AppManager.getInstance().getLastActivity(), bean.getUser()).setOnDismissListener((userId, position) ->
|
||||
{
|
||||
Log.i(TAG, "showDialog: 关闭打招呼弹窗,uid:" + userId + ",是否点击打招呼:" + (position == 2));
|
||||
isShowDialog = false;
|
||||
LiveNetManager.get(AppManager.getInstance().getLastActivity())
|
||||
.callBackMessageSayHiTimer(userId, position, new HttpCallback<List<BaseModel>>() {
|
||||
@Override
|
||||
public void onSuccess(List<BaseModel> data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Log.i(TAG, "onSuccess: 启动定时器,下一轮时间:" + bean.getNextTime() + "秒");
|
||||
timer = new Timer();
|
||||
timer.schedule(createTask(), bean.getNextTime() * 1000L);
|
||||
}).setCancelable(isCancelDialog)
|
||||
.showDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -149,13 +110,18 @@ public class MessageSayHiNotifyManager {
|
||||
return;
|
||||
}
|
||||
if (hiBean == null) return;
|
||||
Log.i(TAG, "reload: 重载定时器,当前Activity:" + AppManager.getInstance().getLastActivity());
|
||||
Log.i(TAG, "reload: 重载定时器,当前Activity:" + AppManager.getInstance().getLastActivity() + "|等待:" + hiBean.getNextTime());
|
||||
isStopShow = false;
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
}
|
||||
timer = new Timer();
|
||||
timer.schedule(createTask(), hiBean.getNextTime() * 1000L);
|
||||
if (hiBean.getStatus() == -2) {
|
||||
Log.i(TAG, "reload: -2的bean = " + hiBean);
|
||||
timer.schedule(createTask(), hiBean.getOldTime() * 1000L);
|
||||
} else {
|
||||
timer.schedule(createTask(), hiBean.getNextTime() * 1000L);
|
||||
}
|
||||
}
|
||||
|
||||
public void resetActivity() {
|
||||
@@ -169,6 +135,9 @@ public class MessageSayHiNotifyManager {
|
||||
public void stop() {
|
||||
Log.i(TAG, "stop: 停止定时器,当前Activity:" + AppManager.getInstance().getLastActivity());
|
||||
isStopShow = true;
|
||||
if(hiBean!=null) {
|
||||
hiBean.setStatus(-2);
|
||||
}
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
timer = null;
|
||||
@@ -184,6 +153,10 @@ public class MessageSayHiNotifyManager {
|
||||
timer.cancel();
|
||||
}
|
||||
cancel();
|
||||
if (hiBean.getStatus() == -2) {
|
||||
showDialog();
|
||||
return;
|
||||
}
|
||||
Log.i(TAG, "run: 定时器到点,启动下一轮");
|
||||
next();
|
||||
}
|
||||
@@ -220,6 +193,54 @@ public class MessageSayHiNotifyManager {
|
||||
}
|
||||
}
|
||||
|
||||
void showDialog() {
|
||||
if (isShowDialog) {
|
||||
Log.i(TAG, "showDialog: 展示对话框中");
|
||||
hiBean.setStatus(-2);
|
||||
return;
|
||||
}
|
||||
if (isStopShow) {
|
||||
Log.i(TAG, "showDialog: 非目标页面,停止展示");
|
||||
hiBean.setStatus(-2);
|
||||
lastActivity = null;
|
||||
isRun = false;
|
||||
return;
|
||||
}
|
||||
String simpleName = AppManager.getInstance().getLastActivity().getClass().getSimpleName();
|
||||
if (simpleName.equals(lastActivity)) {
|
||||
Log.i(TAG, "showDialog: 与上次触发是同一个页面,不展示");
|
||||
isRun = false;
|
||||
hiBean.setStatus(-2);
|
||||
return;
|
||||
}
|
||||
isShowDialog = true;
|
||||
Log.i(TAG, "showDialog: 打开本轮打招呼弹框 " + hiBean);
|
||||
lastActivity = AppManager.getInstance().getLastActivity().getClass().getSimpleName();
|
||||
new MessageSayHiNotifyDialog(AppManager.getInstance().getLastActivity(), hiBean.getUser()).setOnDismissListener((userId, position) ->
|
||||
{
|
||||
Log.i(TAG, "showDialog: 关闭打招呼弹窗,uid:" + userId + ",是否点击打招呼:" + (position == 2));
|
||||
isShowDialog = false;
|
||||
LiveNetManager.get(AppManager.getInstance().getLastActivity())
|
||||
.callBackMessageSayHiTimer(userId, position, new HttpCallback<List<BaseModel>>() {
|
||||
@Override
|
||||
public void onSuccess(List<BaseModel> data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Log.i(TAG, "onSuccess: 启动定时器,下一轮时间:" + hiBean.getNextTime() + "秒");
|
||||
hiBean.setStatus(1);
|
||||
timer = new Timer();
|
||||
timer.schedule(createTask(), hiBean.getNextTime() * 1000L);
|
||||
}).setCancelable(isCancelDialog)
|
||||
.showDialog();
|
||||
}
|
||||
|
||||
public synchronized void push(Context mContext, String targetId, String content) {
|
||||
LiveNetManager.get(mContext)
|
||||
.getOtherInfo(targetId, new HttpCallback<MessageUserInfoBean>() {
|
||||
|
||||
Reference in New Issue
Block a user