diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index 70716c535..1aca32221 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -189,7 +189,6 @@ public interface PDLiveApi { /** * 获取推送关注的开关和关注列表 - * */ @GET("/api/public/?service=Tx.offlineMsgSwitchDetail") Observable> getMsgSwitchDetail(); @@ -198,18 +197,25 @@ public interface PDLiveApi { * 推送关注的开关设置 */ @GET("/api/public/?service=Tx.setMsgMasterSwitch") - Observable> setMsgMasterSwitch(@Query("status") String status,@Query("type") String type); + Observable> setMsgMasterSwitch(@Query("status") String status, @Query("type") String type); /** - *开播推送设置开关 + * 开播推送设置开关 */ @GET("/api/public/?service=Tx.setBeginShowMsgSwitch") - Observable>> setBeginShowMsgSwitch(@Query("status") String status,@Query("isAll") String isAll,@Query("liveuid") String liveuid); + Observable>> setBeginShowMsgSwitch(@Query("status") String status, @Query("isAll") String isAll, @Query("liveuid") String liveuid); /** * 小时榜接口 + * * @param liveuid 直播间id */ @GET("/api/public/?service=Live.getHourChartRank") - Observable>> getHourChartRank(@Query("liveuid")String liveuid); + Observable>> getHourChartRank(@Query("liveuid") String liveuid); + + /** + * 清除系统消息的未读数 + */ + @GET("/api/public/?service=Message.setMessageReadAll") + Observable>> setMessageReadAll(); } diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index 72d1e8942..f1cdf7b41 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -153,4 +153,23 @@ public class LiveNetManager { callback.onError(throwable.getMessage()); }).isDisposed(); } + + /** + * 清除系统消息的未读数 + */ + public void setMessageReadAll(HttpCallback callback) { + API.get().pdLiveApi(mContext).setMessageReadAll() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(listResponseModel -> { + if (callback != null) + callback.onSuccess(null); + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) + callback.onError(throwable.getMessage()); + } + }).isDisposed(); + } } diff --git a/main/build.gradle b/main/build.gradle index 5664cbc1c..d022937e0 100644 --- a/main/build.gradle +++ b/main/build.gradle @@ -81,4 +81,6 @@ dependencies { implementation 'com.google.android.gms:play-services-auth:15.0.0' //Google 繁體簡體轉換庫 implementation files('libs/jcc-bate-0.7.3.jar') + //引导层 + implementation 'com.binioter:guideview:1.0.0' } diff --git a/main/src/main/assets/guide.svga b/main/src/main/assets/guide.svga new file mode 100644 index 000000000..671adb78d Binary files /dev/null and b/main/src/main/assets/guide.svga differ diff --git a/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java b/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java index 33ed1aaa7..52838be86 100644 --- a/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java @@ -8,8 +8,10 @@ import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.View; +import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.TextView; import androidx.fragment.app.FragmentManager; @@ -20,8 +22,14 @@ import androidx.recyclerview.widget.RecyclerView; import com.adjust.sdk.Adjust; import com.adjust.sdk.AdjustEvent; import com.alibaba.fastjson.JSON; +import com.binioter.guideview.Guide; +import com.binioter.guideview.GuideBuilder; import com.facebook.appevents.AppEventsLogger; import com.google.firebase.analytics.FirebaseAnalytics; +import com.opensource.svgaplayer.SVGADrawable; +import com.opensource.svgaplayer.SVGAImageView; +import com.opensource.svgaplayer.SVGAParser; +import com.opensource.svgaplayer.SVGAVideoEntity; import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.activity.WebViewActivity; import com.yunbao.common.bean.ImUserInfoModel; @@ -29,8 +37,10 @@ import com.yunbao.common.custom.TabButtonGroup; import com.yunbao.common.event.MessageIMEvent; import com.yunbao.common.event.UpdateTablePointMe; import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.imrongcloud.MessageIMManager; +import com.yunbao.common.utils.DeviceUtils; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.ProcessResultUtil; import com.yunbao.common.utils.ToastUtil; @@ -43,6 +53,7 @@ import com.yunbao.main.adapter.SystemMessageAdapter; import com.yunbao.main.dialog.MainStartDialogFragment; import com.yunbao.main.event.PDLiveConversationListEvent; import com.yunbao.main.manager.imrongcloud.ConversationIMListManager; +import com.yunbao.main.views.MessageGuideView; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -77,6 +88,7 @@ public class PDLiveConversationListActivity extends AbsActivity implements View. private Handler netHandler = new Handler(); private String type = null; private List listUserBean = new ArrayList<>(); + private LinearLayout topLayout; @Override @@ -91,6 +103,60 @@ public class PDLiveConversationListActivity extends AbsActivity implements View. mContext = this; initView(); initData(); + + } + + //展示引导层 + private void showGuideView() { + MessageGuideView guideView = new MessageGuideView(this); + //top_noback + GuideBuilder builder = new GuideBuilder(); + builder.setTargetView(topLayout) + .setAlpha(180) + .setHighTargetCorner(20) + .setHighTargetPadding(10); + builder.setOverlayTarget(true); + builder.setAutoDismiss(false); + + builder.addComponent(guideView); + Guide guide = builder.createGuide(); + guide.show(this); + //引导界面设置 + View container = guideView.getContainer(); + SVGAImageView guidSvga = container.findViewById(R.id.guide_svga); + LinearLayout guideLayout = container.findViewById(R.id.guide_layout); + ImageView politicalInstructor = container.findViewById(R.id.political_instructor); + //设置界面宽度 + ViewGroup.LayoutParams layoutParams = guideLayout.getLayoutParams(); + layoutParams.width = DeviceUtils.getScreenWidth(mContext); + guideLayout.setLayoutParams(layoutParams); + //设置svga动图 + new SVGAParser(mContext).decodeFromAssets("guide.svga", new SVGAParser.ParseCompletion() { + @Override + public void onComplete(SVGAVideoEntity videoItem) { + SVGADrawable drawable = new SVGADrawable(videoItem); + guidSvga.setImageDrawable(drawable); + guidSvga.startAnimation(); + } + + @Override + public void onError() { + Log.e("errqs", "errl"); + } + }, null); + //点击事件 + politicalInstructor.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ViewClicksAntiShake.clicksAntiShake(v, () -> { + String targetId = ConversationIMListManager.get(mContext).getTargetId(); + if (!TextUtils.isEmpty(targetId)) { + ConversationIMListManager.get(mContext).jumpConversation(mContext, targetId); + guide.dismiss(); + } + }); + } + }); } /** @@ -106,7 +172,7 @@ public class PDLiveConversationListActivity extends AbsActivity implements View. textNewsInteraction = findViewById(R.id.text_news_interaction); textNewsOnline = findViewById(R.id.text_news_online); newsIconClearance = findViewById(R.id.news_icon_clearance); - + topLayout = findViewById(R.id.top_layout); mTabButtonGroup.setCurPosition(2); findViewById(R.id.btn_start).setOnClickListener(v -> { //防止重新加载多个 @@ -123,6 +189,12 @@ public class PDLiveConversationListActivity extends AbsActivity implements View. } }); newsIconClearance.setOnClickListener(this); + container.post(new Runnable() { + @Override + public void run() { + showGuideView(); + } + }); } private void showStartDialog() { @@ -140,6 +212,7 @@ public class PDLiveConversationListActivity extends AbsActivity implements View. * 初始化数据 */ private void initData() { + ConversationIMListManager.get(mContext).getConversationListByPage(false); IMLoginManager.get(mContext).checkInstructor(); mProcessResultUtil = new ProcessResultUtil(this); netHandler.post(imUserInfoRunnable); @@ -279,7 +352,7 @@ public class PDLiveConversationListActivity extends AbsActivity implements View. break; //在線客服 case "3": - if (TextUtils.equals(type, userBean.getType())) { + if (TextUtils.equals(type, userBean.getType())) { number = null; textNewsOnline.setVisibility(View.GONE); } @@ -340,6 +413,19 @@ public class PDLiveConversationListActivity extends AbsActivity implements View. DialogUitl.showSimpleDialog(mContext, null, getString(R.string.clear_unread_messages), false, new DialogUitl.SimpleCallback3() { @Override public void onConfirmClick(Dialog dialog) { + ConversationIMListManager.get(mContext).getConversationListByPage(true); + LiveNetManager.get(mContext) + .setMessageReadAll(new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(String data) { + + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); // IMCenter.getInstance().clearMessagesUnreadStatus(); } @@ -424,9 +510,9 @@ public class PDLiveConversationListActivity extends AbsActivity implements View. public void onUpdateFieldEvent(UpdateTablePointMe updateTablePointMe) { if (redpointMe == null) return; if (updateTablePointMe.getPoint() == 0) { - redpointMe.setVisibility(View.VISIBLE); - } else { redpointMe.setVisibility(View.GONE); + } else { + redpointMe.setVisibility(View.VISIBLE); } } @@ -434,5 +520,62 @@ public class PDLiveConversationListActivity extends AbsActivity implements View. @Subscribe(threadMode = ThreadMode.MAIN) public void onImUserInfoModel(ImUserInfoModel model) { messageAdapter.upDataMessage(model); + int systemNumber = 0; + for (ImUserBean userBean : listUserBean) { + //未读消息数 + String number = userBean.getNum(); + //未读消息不为空并且大于0 + try { + if (!TextUtils.isEmpty(number) && Integer.parseInt(number) > 0) { + systemNumber = Integer.parseInt(number) + systemNumber; + } + } catch (NumberFormatException e) { + systemNumber = systemNumber + 0; + } + } + switch (model.getType()) { + //官方通知 + case "1": + if (textNewsNotice.getVisibility() == View.GONE) { + textNewsNotice.setVisibility(View.GONE); + textNewsNotice.setText(""); + } else { + String number = textNewsNotice.getText().toString().trim(); + int numberInt = Integer.parseInt(number) + 1; + textNewsNotice.setVisibility(View.VISIBLE); + textNewsNotice.setText(String.valueOf(numberInt)); + } + + break; + //互動消息 + case "2": + if (textNewsInteraction.getVisibility() == View.GONE) { + textNewsInteraction.setVisibility(View.GONE); + textNewsInteraction.setText(""); + } else { + String number = textNewsInteraction.getText().toString().trim(); + int numberInt = Integer.parseInt(number) + 1; + textNewsInteraction.setVisibility(View.VISIBLE); + textNewsInteraction.setText(String.valueOf(numberInt)); + } + + + break; + //在線客服 + case "3": + if (textNewsOnline.getVisibility() == View.GONE) { + textNewsOnline.setVisibility(View.GONE); + textNewsOnline.setText(""); + } else { + String number = textNewsOnline.getText().toString().trim(); + int numberInt = Integer.parseInt(number) + 1; + textNewsOnline.setVisibility(View.VISIBLE); + textNewsOnline.setText(String.valueOf(numberInt)); + } + break; + } + systemNumber = systemNumber + 1; + MessageIMManager.get(mContext).setSystemNumber(systemNumber); + } } diff --git a/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java b/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java index 21db96328..427d2f77d 100644 --- a/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java +++ b/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java @@ -688,7 +688,16 @@ public class MainHttpUtil { HttpClient.getInstance().get("User.isInstructor", MainHttpConsts.ISINSTRUCTOR) .execute(callback); } + // + public static void setMessageReadAll(){ + HttpClient.getInstance().get("Message.setMessageReadAll","") + .execute(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + } + }); + } } diff --git a/main/src/main/java/com/yunbao/main/manager/imrongcloud/ConversationIMListManager.java b/main/src/main/java/com/yunbao/main/manager/imrongcloud/ConversationIMListManager.java index 8d6231e22..3fd397107 100644 --- a/main/src/main/java/com/yunbao/main/manager/imrongcloud/ConversationIMListManager.java +++ b/main/src/main/java/com/yunbao/main/manager/imrongcloud/ConversationIMListManager.java @@ -17,7 +17,6 @@ import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.manager.InstructorRemarkManager; import com.yunbao.common.utils.RouteUtil; -import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.live.activity.PDLIiveChatActivity; import com.yunbao.live.activity.PDLiveConversationActivity; import com.yunbao.live.bean.SearchUserBean; @@ -27,6 +26,8 @@ import com.yunbao.main.utils.PDLiveCustomConversationProvider; import com.yunbao.main.utils.PDLiveMessageProcessor; import com.yunbao.main.utils.PDSightMessageItemProvider; +import java.util.List; + import io.rong.imkit.IMCenter; import io.rong.imkit.RongIM; import io.rong.imkit.config.ConversationListBehaviorListener; @@ -38,6 +39,7 @@ import io.rong.imkit.conversationlist.provider.PrivateConversationProvider; import io.rong.imkit.userinfo.RongUserInfoManager; import io.rong.imkit.utils.RouteUtils; import io.rong.imkit.widget.adapter.ProviderManager; +import io.rong.imlib.RongIMClient; import io.rong.imlib.model.Conversation; import io.rong.imlib.model.UserInfo; import io.rong.sight.SightExtensionModule; @@ -48,6 +50,8 @@ import io.rong.sight.SightExtensionModule; public class ConversationIMListManager { private static ConversationIMListManager manager; private Context mContext; + //指导员ID + private String targetId; private ConversationIMListManager(Context context) { mContext = context; @@ -198,6 +202,7 @@ public class ConversationIMListManager { RongUserInfoManager.getInstance().setUserInfoProvider(s -> { RongUserInfoManager.getInstance().refreshUserInfoCache(userInfo); if (TextUtils.equals(userBean.getIs_admin(), "1")) { + targetId = userId; setConversationToTop(userInfo.getUserId()); } return null; @@ -268,9 +273,56 @@ public class ConversationIMListManager { */ @Override public boolean onConversationClick(Context context, View view, BaseUiConversation baseUiConversation) { - jumpConversation((Activity) context, baseUiConversation.mCore.getTargetId()); + jumpConversation((Activity) context, baseUiConversation.mCore.getTargetId()); return true; } }; + private long timeStamp = 0; + + /** + * 获取新手指导员账号 + */ + public void getConversationListByPage(boolean clearMessages) { + RongIMClient.getInstance().getConversationListByPage(new RongIMClient.ResultCallback>() { + @Override + public void onSuccess(List conversations) { + if (conversations.size() < 10) { + if (!clearMessages) { + for (Conversation conversation : conversations) { + UserInfo userInfo = RongUserInfoManager.getInstance().getUserInfo(conversation.getTargetId()); + if (!TextUtils.isEmpty(userInfo.getExtra())) { + IMLoginModel model = GsonUtils.fromJson(userInfo.getExtra(), IMLoginModel.class); + if (TextUtils.equals(model.getIsAdmin(), "1")) { + targetId = userInfo.getUserId(); + } + } + } + } else { + for (Conversation conversation : conversations) { + RongIMClient.getInstance() + .clearMessagesUnreadStatus( + Conversation.ConversationType.PRIVATE, + conversation.getTargetId(), + conversation.getSentTime(), null); + } + } + + } else { + Conversation conversation = conversations.get(9); + timeStamp = conversation.getSentTime(); + } + } + + @Override + public void onError(RongIMClient.ErrorCode errorCode) { + + } + }, timeStamp, 10, Conversation.ConversationType.PRIVATE); + } + + + public String getTargetId() { + return targetId; + } } diff --git a/main/src/main/java/com/yunbao/main/views/MessageGuideView.java b/main/src/main/java/com/yunbao/main/views/MessageGuideView.java new file mode 100644 index 000000000..e02c6d7b5 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/views/MessageGuideView.java @@ -0,0 +1,54 @@ +package com.yunbao.main.views; + +import android.app.Activity; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.LinearLayout; + +import com.binioter.guideview.Component; +import com.yunbao.common.utils.DeviceUtils; +import com.yunbao.main.R; + +/** + * 消息中心引导层 + */ +public class MessageGuideView implements Component { + private LinearLayout rootView; + private Activity mContext; + + public MessageGuideView(Activity mContext) { + this.mContext = mContext; + } + + public View getContainer() { + + return rootView; + } + + @Override + public View getView(LayoutInflater inflater) { + rootView = (LinearLayout) inflater.inflate(R.layout.view_message_guide, null); + + return rootView; + } + + @Override + public int getAnchor() { + return Component.ANCHOR_BOTTOM; + } + + @Override + public int getFitPosition() { + return Component.FIT_END; + } + + @Override + public int getXOffset() { + return 0; + } + + @Override + public int getYOffset() { + return 0; + } +} diff --git a/main/src/main/res/layout/activity_conversation_list.xml b/main/src/main/res/layout/activity_conversation_list.xml index 97dab5ba0..933f5e9fd 100644 --- a/main/src/main/res/layout/activity_conversation_list.xml +++ b/main/src/main/res/layout/activity_conversation_list.xml @@ -35,6 +35,7 @@ diff --git a/main/src/main/res/layout/view_message_guide.xml b/main/src/main/res/layout/view_message_guide.xml new file mode 100644 index 000000000..cac17d2da --- /dev/null +++ b/main/src/main/res/layout/view_message_guide.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/main/src/main/res/mipmap-xxhdpi/img_bg.png b/main/src/main/res/mipmap-xxhdpi/img_bg.png new file mode 100644 index 000000000..4cfd81109 Binary files /dev/null and b/main/src/main/res/mipmap-xxhdpi/img_bg.png differ