消息中心引导页面,清除全部未读数
This commit is contained in:
parent
f1d49653b5
commit
52363a887d
@ -189,7 +189,6 @@ public interface PDLiveApi {
|
||||
|
||||
/**
|
||||
* 获取推送关注的开关和关注列表
|
||||
*
|
||||
*/
|
||||
@GET("/api/public/?service=Tx.offlineMsgSwitchDetail")
|
||||
Observable<ResponseModel<MsgSwitchDetailModel>> getMsgSwitchDetail();
|
||||
@ -198,18 +197,25 @@ public interface PDLiveApi {
|
||||
* 推送关注的开关设置
|
||||
*/
|
||||
@GET("/api/public/?service=Tx.setMsgMasterSwitch")
|
||||
Observable<ResponseModel<BaseModel>> setMsgMasterSwitch(@Query("status") String status,@Query("type") String type);
|
||||
Observable<ResponseModel<BaseModel>> setMsgMasterSwitch(@Query("status") String status, @Query("type") String type);
|
||||
|
||||
/**
|
||||
*开播推送设置开关
|
||||
* 开播推送设置开关
|
||||
*/
|
||||
@GET("/api/public/?service=Tx.setBeginShowMsgSwitch")
|
||||
Observable<ResponseModel<List<BaseModel>>> setBeginShowMsgSwitch(@Query("status") String status,@Query("isAll") String isAll,@Query("liveuid") String liveuid);
|
||||
Observable<ResponseModel<List<BaseModel>>> setBeginShowMsgSwitch(@Query("status") String status, @Query("isAll") String isAll, @Query("liveuid") String liveuid);
|
||||
|
||||
/**
|
||||
* 小时榜接口
|
||||
*
|
||||
* @param liveuid 直播间id
|
||||
*/
|
||||
@GET("/api/public/?service=Live.getHourChartRank")
|
||||
Observable<ResponseModel<List<HourRank>>> getHourChartRank(@Query("liveuid")String liveuid);
|
||||
Observable<ResponseModel<List<HourRank>>> getHourChartRank(@Query("liveuid") String liveuid);
|
||||
|
||||
/**
|
||||
* 清除系统消息的未读数
|
||||
*/
|
||||
@GET("/api/public/?service=Message.setMessageReadAll")
|
||||
Observable<ResponseModel<List<String>>> setMessageReadAll();
|
||||
}
|
||||
|
@ -153,4 +153,23 @@ public class LiveNetManager {
|
||||
callback.onError(throwable.getMessage());
|
||||
}).isDisposed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除系统消息的未读数
|
||||
*/
|
||||
public void setMessageReadAll(HttpCallback<String> callback) {
|
||||
API.get().pdLiveApi(mContext).setMessageReadAll()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(listResponseModel -> {
|
||||
if (callback != null)
|
||||
callback.onSuccess(null);
|
||||
}, new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
if (callback != null)
|
||||
callback.onError(throwable.getMessage());
|
||||
}
|
||||
}).isDisposed();
|
||||
}
|
||||
}
|
||||
|
@ -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'
|
||||
}
|
||||
|
BIN
main/src/main/assets/guide.svga
Normal file
BIN
main/src/main/assets/guide.svga
Normal file
Binary file not shown.
@ -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<ImUserBean> 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);
|
||||
@ -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<String>() {
|
||||
@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);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
@ -272,5 +277,52 @@ public class ConversationIMListManager {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
private long timeStamp = 0;
|
||||
|
||||
/**
|
||||
* 获取新手指导员账号
|
||||
*/
|
||||
public void getConversationListByPage(boolean clearMessages) {
|
||||
RongIMClient.getInstance().getConversationListByPage(new RongIMClient.ResultCallback<List<Conversation>>() {
|
||||
@Override
|
||||
public void onSuccess(List<Conversation> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -35,6 +35,7 @@
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/top_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
19
main/src/main/res/layout/view_message_guide.xml
Normal file
19
main/src/main/res/layout/view_message_guide.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/guide_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/political_instructor"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@mipmap/img_bg" />
|
||||
|
||||
<com.opensource.svgaplayer.SVGAImageView
|
||||
android:id="@+id/guide_svga"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_gravity="center" />
|
||||
</LinearLayout>
|
BIN
main/src/main/res/mipmap-xxhdpi/img_bg.png
Normal file
BIN
main/src/main/res/mipmap-xxhdpi/img_bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 328 KiB |
Loading…
Reference in New Issue
Block a user