This commit is contained in:
18401019693
2022-07-26 18:28:47 +08:00
parent a4153da415
commit f00fcac663
8 changed files with 91 additions and 68 deletions

View File

@@ -1,19 +1,33 @@
package com.yunbao.common.bean;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
/**
* 用户面向指导员的数据类
*/
public class NoviceInstructorModel extends BaseModel {
@SerializedName("sendFirstMessage")
private String sendFirstMessage = "";
@SerializedName("msg_zdy_send")
private String msgZdySend = "";
@SerializedName("msg_zdy_send_text")
private String msgZdySendText = "";
/**
* msg_zdy_send : 1
* msg_zdy_send_text : 您好
*/
@SerializedName("home_zdy_pop")
private String homeZdyPop = "";
private int homeZdyPop;
@SerializedName("msg_zdy_send")
private String msgZdySend;
@SerializedName("msg_zdy_send_text")
private String msgZdySendText;
public int getHomeZdyPop() {
return homeZdyPop;
}
public NoviceInstructorModel setHomeZdyPop(int homeZdyPop) {
this.homeZdyPop = homeZdyPop;
return this;
}
public String getMsgZdySend() {
return msgZdySend;
@@ -32,24 +46,4 @@ public class NoviceInstructorModel extends BaseModel {
this.msgZdySendText = msgZdySendText;
return this;
}
public String getHomeZdyPop() {
return homeZdyPop;
}
public NoviceInstructorModel setHomeZdyPop(String homeZdyPop) {
this.homeZdyPop = homeZdyPop;
return this;
}
public String getSendFirstMessage() {
return sendFirstMessage;
}
public NoviceInstructorModel setSendFirstMessage(String sendFirstMessage) {
this.sendFirstMessage = sendFirstMessage;
return this;
}
}

View File

@@ -2,10 +2,13 @@ package com.yunbao.common.manager;
import android.content.Context;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.NoviceInstructorModel;
import com.yunbao.common.event.NoviceInstructorEvent;
@@ -15,6 +18,9 @@ import com.yunbao.common.manager.base.BaseCacheManager;
import org.greenrobot.eventbus.EventBus;
import io.rong.imkit.userinfo.RongUserInfoManager;
import io.rong.imlib.model.UserInfo;
/***
* 新手指导员管理引导
*/
@@ -52,6 +58,8 @@ public class NoviceInstructorManager extends BaseCacheManager {
public NoviceInstructorModel getNoviceInstructor() {
if (null == model) {
model = new Gson().fromJson(getString(KEY_NOVICE_INSTRUCTOR), NoviceInstructorModel.class);
} else {
netHandler.post(instructorOperationRunnable);
}
return model;
@@ -70,27 +78,42 @@ public class NoviceInstructorManager extends BaseCacheManager {
/**
* 清除相关信息
*/
public void removeNoviceInstructor() {
IMLoginModel userInfo = IMLoginManager.get(context).getUserInfo();
HttpClient.getInstance().get("Message.setZdyMsg", "setZdyMsg")
.params("uid", userInfo.getId())
.execute(new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
}
});
model = null;
deleteByKey(KEY_NOVICE_INSTRUCTOR);
EventBus.getDefault().post(new NoviceInstructorEvent().setShowHomeIcon(false));
public void removeNoviceInstructor(String targetId) {
//只有和指导员对话才可以清除信息
UserInfo model1 = RongUserInfoManager.getInstance().getUserInfo(targetId);
IMLoginModel userModel = new Gson().fromJson(model1.getExtra(), IMLoginModel.class);
if (TextUtils.equals(userModel.getIsAdmin(), "1")) {
IMLoginModel userInfo = IMLoginManager.get(context).getUserInfo();
HttpClient.getInstance().get("Message.setZdyMsg", "setZdyMsg")
.params("uid", userInfo.getId())
.execute(new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
model = null;
deleteByKey(KEY_NOVICE_INSTRUCTOR);
EventBus.getDefault().post(new NoviceInstructorEvent().setShowHomeIcon(false));
}
});
}
}
/**
* 请求接口获取是否展示
*/
public void getNetNoviceInstructor(String info) {
model = new Gson().fromJson(info, NoviceInstructorModel.class);
setNoviceInstructor(model);
IMLoginModel userInfo = IMLoginManager.get(context).getUserInfo();
//非指导员用户才启用该逻辑
if (!TextUtils.equals(userInfo.getIsAdmin(), "1")) {
try {
Log.e("MainActivity", "getNetNoviceInstructor:" + info);
model = new Gson().fromJson(info, NoviceInstructorModel.class);
setNoviceInstructor(model);
if (model != null) {
netHandler.post(instructorOperationRunnable);
}
} catch (JsonSyntaxException ignored) {
}
}
}
@@ -102,7 +125,7 @@ public class NoviceInstructorManager extends BaseCacheManager {
@Override
public void run() {
//展示指引弹窗
EventBus.getDefault().post(new NoviceInstructorEvent().setShowHomeIcon(true));
EventBus.getDefault().post(new NoviceInstructorEvent().setShowHomeIcon(TextUtils.equals(model.getMsgZdySend(), "1")));
}
};
}