diff --git a/common/src/main/java/com/yunbao/common/bean/NoviceInstructorModel.java b/common/src/main/java/com/yunbao/common/bean/NoviceInstructorModel.java index 549b59f61..f8ec9204e 100644 --- a/common/src/main/java/com/yunbao/common/bean/NoviceInstructorModel.java +++ b/common/src/main/java/com/yunbao/common/bean/NoviceInstructorModel.java @@ -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; - } - - } diff --git a/common/src/main/java/com/yunbao/common/manager/NoviceInstructorManager.java b/common/src/main/java/com/yunbao/common/manager/NoviceInstructorManager.java index 2681961b2..653744765 100644 --- a/common/src/main/java/com/yunbao/common/manager/NoviceInstructorManager.java +++ b/common/src/main/java/com/yunbao/common/manager/NoviceInstructorManager.java @@ -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"))); } }; } diff --git a/config.gradle b/config.gradle index eddca7244..53e2161f5 100644 --- a/config.gradle +++ b/config.gradle @@ -9,9 +9,9 @@ ext { ] manifestPlaceholders = [ //正式 - serverHost : "https://napi.yaoulive.com", +// serverHost : "https://napi.yaoulive.com", //測試 -// serverHost : "https://ceshi.yaoulive.com", + serverHost : "https://ceshi.yaoulive.com", //腾讯地图 txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB", diff --git a/live/src/main/java/com/yunbao/live/activity/PDLiveConversationActivity.java b/live/src/main/java/com/yunbao/live/activity/PDLiveConversationActivity.java index eaf92435d..d450ed4c8 100644 --- a/live/src/main/java/com/yunbao/live/activity/PDLiveConversationActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/PDLiveConversationActivity.java @@ -22,7 +22,9 @@ import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.activity.SelectImageActivity; import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.ImageEntity; +import com.yunbao.common.bean.NoviceInstructorModel; import com.yunbao.common.manager.IMLoginManager; +import com.yunbao.common.manager.NoviceInstructorManager; import com.yunbao.common.manager.imrongcloud.MessageIMManager; import com.yunbao.live.R; import com.yunbao.live.bean.SearchUserBean; @@ -81,11 +83,15 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl */ private void initData() { targetId = getIntent().getStringExtra("targetId"); + NoviceInstructorModel model = NoviceInstructorManager.get(this).getNoviceInstructor(); + if (model != null && !TextUtils.isEmpty(model.getMsgZdySendText())) { + inputPanel.setPresetInformation(model.getMsgZdySendText()); + } //绑定聊天用户id inputPanel.setTargetId(targetId); //获取用户信息 UserInfo userInfo = RongUserInfoManager.getInstance().getUserInfo(targetId); - if (null!=userInfo){ + if (null != userInfo) { titleView.setText(userInfo.getName()); if (!TextUtils.isEmpty(userInfo.getExtra())) { SearchUserBean userBean = GsonUtils.fromJson(userInfo.getExtra(), SearchUserBean.class); @@ -99,7 +105,7 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl } Log.e("PDLiveConversation", userInfo.getExtra()); } - }else { + } else { titleView.setText("系統消息"); inputPanel.setVisibility(View.GONE); } @@ -122,14 +128,7 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl titleView = findViewById(R.id.titleView); imgMore = findViewById(R.id.img_more); imBack = findViewById(R.id.btn_back); - findViewById(R.id.root_layout).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - InputMethodManager imm = (InputMethodManager) - getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(v.getWindowToken(), 0); - } - }); + imgMore.setOnClickListener(this); imBack.setOnClickListener(this); diff --git a/live/src/main/java/com/yunbao/live/views/InputPanelViewHolder.java b/live/src/main/java/com/yunbao/live/views/InputPanelViewHolder.java index 499c9e6ab..549146b62 100644 --- a/live/src/main/java/com/yunbao/live/views/InputPanelViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/InputPanelViewHolder.java @@ -23,8 +23,6 @@ import com.yunbao.common.utils.ToastUtil; import com.yunbao.live.R; import com.yunbao.live.utils.FileSizeUtil; -import org.greenrobot.eventbus.EventBus; - import io.rong.imkit.IMCenter; import io.rong.imlib.IRongCallback; import io.rong.imlib.RongIMClient; @@ -47,7 +45,14 @@ public class InputPanelViewHolder extends LinearLayout implements View.OnClickLi //是否可以发送消息 private boolean isSend = false; private LinearLayout pluginList; + //接口返回预置信息 + private String presetInformation = ""; + public InputPanelViewHolder setPresetInformation(String presetInformation) { + this.presetInformation = presetInformation; + editBtn.setText(presetInformation); + return this; + } /** * 必传字段 @@ -163,8 +168,9 @@ public class InputPanelViewHolder extends LinearLayout implements View.OnClickLi } else { ToastUtil.show("不可以发送空消息"); } + //发送以后删除相应标志 - NoviceInstructorManager.get(getContext()).removeNoviceInstructor(); + NoviceInstructorManager.get(getContext()).removeNoviceInstructor(targetId); } private TextWatcher mEditTextWatcher = new TextWatcher() { @@ -240,7 +246,7 @@ public class InputPanelViewHolder extends LinearLayout implements View.OnClickLi } }); //发送以后删除相应标志 - NoviceInstructorManager.get(getContext()).removeNoviceInstructor(); + NoviceInstructorManager.get(getContext()).removeNoviceInstructor(targetId); } public void sendVideoFile(String filePath) { @@ -300,7 +306,7 @@ public class InputPanelViewHolder extends LinearLayout implements View.OnClickLi } });// //发送以后删除相应标志 - NoviceInstructorManager.get(getContext()).removeNoviceInstructor(); + NoviceInstructorManager.get(getContext()).removeNoviceInstructor(targetId); } /** @@ -346,7 +352,7 @@ public class InputPanelViewHolder extends LinearLayout implements View.OnClickLi } }); //发送以后删除相应标志 - NoviceInstructorManager.get(getContext()).removeNoviceInstructor(); + NoviceInstructorManager.get(getContext()).removeNoviceInstructor(targetId); } /** diff --git a/live/src/main/res/layout/rc_conversationlist_item.xml b/live/src/main/res/layout/rc_conversationlist_item.xml index 0631d8c53..0ace63645 100644 --- a/live/src/main/res/layout/rc_conversationlist_item.xml +++ b/live/src/main/res/layout/rc_conversationlist_item.xml @@ -11,18 +11,18 @@ diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index f957f8d2e..c0eb9618e 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -558,6 +558,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene fragment.show(getSupportFragmentManager(), "SigninDialog"); } if (obj.containsKey("msg_zdy_send") && obj.containsKey("msg_zdy_send_text")) { + Log.e("MainActivity333", info[0]); NoviceInstructorManager.get(mContext).getNetNoviceInstructor(info[0]); } } diff --git a/main/src/main/res/layout/view_system_message_item.xml b/main/src/main/res/layout/view_system_message_item.xml index dfc6855ff..6f9f208e9 100644 --- a/main/src/main/res/layout/view_system_message_item.xml +++ b/main/src/main/res/layout/view_system_message_item.xml @@ -60,7 +60,7 @@ android:layout_alignParentRight="true" android:layout_marginTop="5dp" android:layout_marginRight="10dp" - android:background="@drawable/background_ff50715" + android:background="@drawable/rc_unread_count_bg_normal" android:gravity="center" android:includeFontPadding="false" android:minWidth="14dp"