直播结束,悬浮窗
This commit is contained in:
parent
814e45952c
commit
842ef05dc7
@ -11,6 +11,16 @@ public class LiveFloatEvent extends BaseModel {
|
||||
private int mLiveType;
|
||||
private int mLiveSDK;
|
||||
private int mLiveTypeVal;
|
||||
private boolean isTime = true;
|
||||
|
||||
public boolean isTime() {
|
||||
return isTime;
|
||||
}
|
||||
|
||||
public LiveFloatEvent setTime(boolean time) {
|
||||
isTime = time;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LiveBean getmLiveBean() {
|
||||
return mLiveBean;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.yunbao.live.views;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
@ -46,12 +47,15 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void builderFloat(Activity mContext, String url) {
|
||||
public void builderFloat(Activity mContext, String url,String tag) {
|
||||
if (TextUtils.isEmpty(tag)){
|
||||
tag = TAG;
|
||||
}
|
||||
liveOnInvokeView = new LiveOnInvokeView();
|
||||
this.mContext = mContext;
|
||||
this.url = url;
|
||||
EasyFloat.with(mContext)
|
||||
.setTag(TAG)
|
||||
.setTag(tag)
|
||||
.setLayout(R.layout.view_flaot_live, liveOnInvokeView)
|
||||
.setShowPattern(ShowPattern.CURRENT_ACTIVITY)
|
||||
.setGravity(Gravity.END | Gravity.CENTER_VERTICAL, 0, 200)
|
||||
@ -88,15 +92,20 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
|
||||
if (callback != null) {
|
||||
callback.invoke(aBoolean);
|
||||
}
|
||||
builder.dismiss(new Function0<Unit>() {
|
||||
@Override
|
||||
public Unit invoke() {
|
||||
if (mPlayer != null && mPlayer.isPlaying() == 1) {
|
||||
mPlayer.stopPlay();
|
||||
}
|
||||
return null;
|
||||
builder.dismiss(() -> {
|
||||
if (mPlayer != null && mPlayer.isPlaying() == 1) {
|
||||
mPlayer.stopPlay();
|
||||
}
|
||||
return null;
|
||||
});
|
||||
builder.hide(view12 -> {
|
||||
if (mPlayer != null && mPlayer.isPlaying() == 1) {
|
||||
mPlayer.pauseAudio();
|
||||
mPlayer.pauseVideo();
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
return null;
|
||||
});
|
||||
return null;
|
||||
|
@ -384,7 +384,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
mContext.finish();
|
||||
} else {
|
||||
EventBus.getDefault()
|
||||
.post(new LiveFloatEvent()
|
||||
.postSticky(new LiveFloatEvent()
|
||||
.setmLiveBean(mLiveBean)
|
||||
.setmLiveSDK(mLiveSDK)
|
||||
.setmLiveType(mLiveType)
|
||||
@ -400,7 +400,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
@Override
|
||||
public void onCancel() {
|
||||
EventBus.getDefault()
|
||||
.post(new LiveFloatEvent()
|
||||
.postSticky(new LiveFloatEvent()
|
||||
.setmLiveBean(mLiveBean)
|
||||
.setmLiveSDK(mLiveSDK)
|
||||
.setmLiveType(mLiveType)
|
||||
|
@ -2,6 +2,10 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.yunbao.main">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:theme="@style/AppTheme">
|
||||
|
@ -40,6 +40,7 @@ import com.google.firebase.messaging.FirebaseMessaging;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.jakewharton.rxbinding3.view.RxView;
|
||||
import com.lzf.easyfloat.EasyFloat;
|
||||
import com.tencent.imsdk.v2.V2TIMCallback;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMSDKConfig;
|
||||
@ -111,6 +112,7 @@ import com.yunbao.main.views.MainHomeShopViewHolder;
|
||||
import com.yunbao.main.views.MainHomeVideoViewHolder;
|
||||
import com.yunbao.main.views.MainHomeViewHolder;
|
||||
import com.yunbao.main.views.MainMeViewHolder;
|
||||
import com.yunbao.main.views.MainMessageViewHolder;
|
||||
import com.yunbao.video.utils.VideoStorge;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
@ -148,6 +150,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
private MainHomeLiveViewHolder mHomeLiveViewHolder;
|
||||
private MainHomeViewHolder mainHomeViewHolder;
|
||||
private MainHomeCommunityViewHolder mMainHomeCommunityViewHolder;
|
||||
private MainMessageViewHolder mainMessageViewHolder;
|
||||
private MainHomeVideoViewHolder mainHomeVideoViewHolder;
|
||||
private MainHomeShopViewHolder mListShopViewHolder;
|
||||
private ChatListViewHolder mChatListViewHolder;
|
||||
@ -252,10 +255,9 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
});
|
||||
} else if (getIntent().getStringExtra("type") != null && getIntent().getStringExtra("type").equals("2")) {
|
||||
//跳转消息列表
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(PDLiveConversationListActivity.MESSAGENUMBER, messageNumber);
|
||||
bundle.putInt(PDLiveConversationListActivity.NUMBERME, numberMe);
|
||||
ConversationIMListManager.get(this).jumpConversationList(bundle);
|
||||
mViewPager.setCurrentItem(2);
|
||||
mTabButtonGroup.setCurPosition(2);
|
||||
|
||||
} else if (getIntent().getStringExtra("type") != null && getIntent().getStringExtra("type").equals("8")) {
|
||||
WebViewActivity.forward(mContext, getIntent().getStringExtra("activityUrl"), true);
|
||||
}
|
||||
@ -450,9 +452,8 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
|
||||
//选中监听
|
||||
mTabButtonGroup.addTabButtonGroupChangeListener((view, index) -> {
|
||||
|
||||
if (index == 0) {
|
||||
// floatBanner.setVisibility(View.VISIBLE);
|
||||
// findViewById(R.id.banner_click).setVisibility(View.VISIBLE);
|
||||
isfloatBannernet = true;
|
||||
initAnchorRecommendBanner();
|
||||
} else {
|
||||
@ -934,11 +935,8 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
mMainHomeCommunityViewHolder = new MainHomeCommunityViewHolder(mContext, parent, this);//社区
|
||||
vh = mMainHomeCommunityViewHolder;
|
||||
} else if (position == 2) {
|
||||
//跳转消息列表
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(PDLiveConversationListActivity.MESSAGENUMBER, messageNumber);
|
||||
bundle.putInt(PDLiveConversationListActivity.NUMBERME, numberMe);
|
||||
ConversationIMListManager.get(this).jumpConversationList(bundle);
|
||||
mainMessageViewHolder = new MainMessageViewHolder(this, parent);
|
||||
vh = mainMessageViewHolder;
|
||||
} else if (position == 3) {
|
||||
mMeViewHolder = new MainMeViewHolder(mContext, parent);
|
||||
vh = mMeViewHolder;
|
||||
@ -1110,6 +1108,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onPDLiveConversationListEvent(PDLiveConversationListEvent event) {
|
||||
|
||||
if (event.getPage() == 11) {
|
||||
finish();
|
||||
} else if (event.getPage() == 17) {
|
||||
@ -1183,11 +1182,9 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onInstructorOperationEvent(InstructorOperationEvent event) {
|
||||
//跳转消息列表
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(PDLiveConversationListActivity.MESSAGENUMBER, messageNumber);
|
||||
bundle.putInt(PDLiveConversationListActivity.NUMBERME, numberMe);
|
||||
bundle.putString(PDLiveConversationListActivity.POP, NoviceInstructorManager.get(this).getHomeZdyPop());
|
||||
ConversationIMListManager.get(mContext).jumpConversationList(bundle);
|
||||
mViewPager.setCurrentItem(2);
|
||||
mTabButtonGroup.setCurPosition(2);
|
||||
mainMessageViewHolder.setHomeZdyPop(NoviceInstructorManager.get(this).getHomeZdyPop());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1218,10 +1215,8 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//跳转消息列表
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(PDLiveConversationListActivity.MESSAGENUMBER, messageNumber);
|
||||
bundle.putInt(PDLiveConversationListActivity.NUMBERME, numberMe);
|
||||
ConversationIMListManager.get(mContext).jumpConversationList(bundle);
|
||||
mViewPager.setCurrentItem(2);
|
||||
mTabButtonGroup.setCurPosition(2);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@ -1248,24 +1243,16 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onLiveFloatEvent(LiveFloatEvent event) {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LiveFloatView.getInstance()
|
||||
.setCallback(new LiveFloatView.LiveFloatViewCallback() {
|
||||
@Override
|
||||
public void invoke(Boolean aBoolean) {
|
||||
// if (aBoolean) {
|
||||
// mContext.finish();
|
||||
// } else {
|
||||
// ToastUtil.show("未打开悬浮窗权限");
|
||||
// }
|
||||
}
|
||||
})
|
||||
.cacheLiveData(event.getmLiveBean(), event.getmLiveType(), event.getmLiveSDK(), event.getmLiveTypeVal())
|
||||
.builderFloat(mContext, event.getmLiveBean().getPull());
|
||||
}
|
||||
},1500);
|
||||
if (event.isTime()) {
|
||||
new Handler().postDelayed(() -> LiveFloatView.getInstance()
|
||||
.cacheLiveData(event.getmLiveBean(), event.getmLiveType(), event.getmLiveSDK(), event.getmLiveTypeVal())
|
||||
.builderFloat(mContext, event.getmLiveBean().getPull(), "Main"), 1500);
|
||||
} else {
|
||||
new Handler().post(() -> LiveFloatView.getInstance()
|
||||
.cacheLiveData(event.getmLiveBean(), event.getmLiveType(), event.getmLiveSDK(), event.getmLiveTypeVal())
|
||||
.builderFloat(mContext, event.getmLiveBean().getPull(), "Main"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ import com.binioter.guideview.Guide;
|
||||
import com.binioter.guideview.GuideBuilder;
|
||||
import com.facebook.appevents.AppEventsLogger;
|
||||
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||
import com.lzf.easyfloat.EasyFloat;
|
||||
import com.opensource.svgaplayer.SVGADrawable;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
@ -35,7 +36,9 @@ import com.opensource.svgaplayer.SVGAVideoEntity;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.activity.WebViewActivity;
|
||||
import com.yunbao.common.bean.ImUserInfoModel;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.custom.TabButtonGroup;
|
||||
import com.yunbao.common.event.LiveFloatEvent;
|
||||
import com.yunbao.common.event.MessageIMEvent;
|
||||
import com.yunbao.common.event.UpdateTablePointMe;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
@ -54,11 +57,11 @@ import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.live.activity.LiveAudienceActivity;
|
||||
import com.yunbao.live.activity.SystemMessageActivity;
|
||||
import com.yunbao.live.bean.ImUserBean;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.live.event.RecommendLiveRoomEvent;
|
||||
import com.yunbao.live.http.ImHttpUtil;
|
||||
import com.yunbao.live.http.LiveHttpUtil;
|
||||
import com.yunbao.live.presenter.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.live.views.LiveFloatView;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.adapter.SystemMessageAdapter;
|
||||
import com.yunbao.main.dialog.MainStartDialogFragment;
|
||||
@ -91,8 +94,8 @@ public class PDLiveConversationListActivity extends AbsActivity implements View.
|
||||
private TextView redPoint;
|
||||
private View redpointMe;
|
||||
private SystemMessageAdapter messageAdapter;
|
||||
private ProcessResultUtil mProcessResultUtil;
|
||||
private TextView textNewsNotice, textNewsInteraction, textNewsOnline;
|
||||
private ProcessResultUtil mProcessResultUtil;
|
||||
private ImageView newsIconClearance;
|
||||
private Handler netHandler = new Handler();
|
||||
private String type = null;
|
||||
@ -146,7 +149,7 @@ public class PDLiveConversationListActivity extends AbsActivity implements View.
|
||||
public void onComplete(SVGAVideoEntity videoItem) {
|
||||
SVGADrawable drawable = new SVGADrawable(videoItem);
|
||||
guidSvga.setImageDrawable(drawable);
|
||||
SVGAViewUtils.playEndClear(guidSvga,false);
|
||||
SVGAViewUtils.playEndClear(guidSvga, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -192,25 +195,26 @@ public class PDLiveConversationListActivity extends AbsActivity implements View.
|
||||
mTabButtonGroup.addTabButtonGroupChangeListener((view, index) -> {
|
||||
Log.e(CLASSNAME, "onPageSelected:" + index);
|
||||
if (index != 2) {
|
||||
EasyFloat.hide("PDLiveConversationList");
|
||||
//打开主页菜单,关闭消息中心
|
||||
EventBus.getDefault().post(new PDLiveConversationListEvent().setPage(index));
|
||||
//防止重新加载多个
|
||||
startActivity(new Intent(mContext, MainActivity.class));
|
||||
|
||||
}
|
||||
});
|
||||
newsIconClearance.setOnClickListener(this);
|
||||
container.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String homeZdyPop = getIntent().getStringExtra(POP);
|
||||
if (TextUtils.equals(homeZdyPop, "1")) {
|
||||
showGuideView();
|
||||
NoviceInstructorManager.get(mContext).setHomeZdyPop("");
|
||||
}
|
||||
|
||||
container.post(() -> {
|
||||
String homeZdyPop = getIntent().getStringExtra(POP);
|
||||
if (TextUtils.equals(homeZdyPop, "1")) {
|
||||
showGuideView();
|
||||
NoviceInstructorManager.get(mContext).setHomeZdyPop("");
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
if (EasyFloat.isShow("LiveFloatView")) {
|
||||
EasyFloat.show("LiveFloatView");
|
||||
}
|
||||
}
|
||||
|
||||
private void showStartDialog() {
|
||||
@ -440,7 +444,6 @@ 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
|
||||
@ -455,7 +458,6 @@ public class PDLiveConversationListActivity extends AbsActivity implements View.
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
// IMCenter.getInstance().clearMessagesUnreadStatus();
|
||||
MessageIMManager.get(mContext).setSystemNumber(0);
|
||||
EventBus.getDefault().post(new MessageIMEvent().setNumber(0));
|
||||
}
|
||||
@ -631,5 +633,11 @@ public class PDLiveConversationListActivity extends AbsActivity implements View.
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
|
||||
public void onLiveFloatEvent(LiveFloatEvent event) {
|
||||
new Handler().post(() -> LiveFloatView.getInstance()
|
||||
.cacheLiveData(event.getmLiveBean(), event.getmLiveType(), event.getmLiveSDK(), event.getmLiveTypeVal())
|
||||
.builderFloat(mContext, event.getmLiveBean().getPull(),"PDLiveConversationList"));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,403 @@
|
||||
package com.yunbao.main.views;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
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.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
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.WebViewActivity;
|
||||
import com.yunbao.common.bean.ImUserInfoModel;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.NoviceInstructorManager;
|
||||
import com.yunbao.common.manager.imrongcloud.MessageIMManager;
|
||||
import com.yunbao.common.utils.DeviceUtils;
|
||||
import com.yunbao.common.utils.SVGAViewUtils;
|
||||
import com.yunbao.common.views.AbsMainViewHolder;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.live.activity.SystemMessageActivity;
|
||||
import com.yunbao.live.bean.ImUserBean;
|
||||
import com.yunbao.live.http.ImHttpUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.activity.MainActivity;
|
||||
import com.yunbao.main.adapter.SystemMessageAdapter;
|
||||
import com.yunbao.main.manager.imrongcloud.ConversationIMListManager;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import io.rong.imkit.conversationlist.ConversationListFragment;
|
||||
|
||||
/**
|
||||
* 消息中心
|
||||
*/
|
||||
public class MainMessageViewHolder extends AbsMainViewHolder {
|
||||
|
||||
private ConversationListFragment conversationListFragment;
|
||||
private FrameLayout container;
|
||||
private SystemMessageAdapter messageAdapter;
|
||||
private TextView textNewsNotice, textNewsInteraction, textNewsOnline;
|
||||
private String type = null;
|
||||
private List<ImUserBean> listUserBean = new ArrayList<>();
|
||||
private LinearLayout topLayout, ltNodataMsg;
|
||||
private ImageView imgNewsNotice, imgNewsInteraction, imgNewsOnline;
|
||||
private Handler netHandler;
|
||||
private MainActivity mContext;
|
||||
|
||||
private String homeZdyPop;
|
||||
|
||||
public MainMessageViewHolder setHomeZdyPop(String homeZdyPop) {
|
||||
this.homeZdyPop = homeZdyPop;
|
||||
if (TextUtils.equals(homeZdyPop, "1")) {
|
||||
showGuideView();
|
||||
NoviceInstructorManager.get(mContext).setHomeZdyPop("");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public MainMessageViewHolder(MainActivity context, ViewGroup parentView) {
|
||||
super(context, parentView);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.view_main_message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
EventBus.getDefault().register(this);
|
||||
//菜单
|
||||
container = (FrameLayout) findViewById(R.id.container);
|
||||
textNewsNotice = (TextView) findViewById(R.id.text_news_notice);
|
||||
textNewsInteraction = (TextView) findViewById(R.id.text_news_interaction);
|
||||
textNewsOnline = (TextView) findViewById(R.id.text_news_online);
|
||||
topLayout = (LinearLayout) findViewById(R.id.top_layout);
|
||||
ltNodataMsg = (LinearLayout) findViewById(R.id.lt_nodata_msg);
|
||||
imgNewsNotice = (ImageView) findViewById(R.id.img_news_notice);
|
||||
imgNewsInteraction = (ImageView) findViewById(R.id.img_news_interaction);
|
||||
imgNewsOnline = (ImageView) findViewById(R.id.img_news_online);
|
||||
netHandler = new Handler();
|
||||
initData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
super.release();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
//展示引导层
|
||||
private void showGuideView() {
|
||||
MessageGuideView guideView = new MessageGuideView((Activity) mContext);
|
||||
//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((Activity) mContext);
|
||||
//引导界面设置
|
||||
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((Activity) 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);
|
||||
SVGAViewUtils.playEndClear(guidSvga, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
Log.e("errqs", "errl");
|
||||
}
|
||||
}, null);
|
||||
//点击事件
|
||||
ViewClicksAntiShake.clicksAntiShake(politicalInstructor, () -> {
|
||||
String targetId = ConversationIMListManager.get(mContext).getTargetId();
|
||||
if (!TextUtils.isEmpty(targetId)) {
|
||||
ConversationIMListManager.get(mContext).jumpConversation((Activity) mContext, targetId);
|
||||
guide.dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
private void initData() {
|
||||
IMLoginManager.get(mContext).checkInstructor();
|
||||
container.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
netHandler.post(imUserInfoRunnable);
|
||||
}
|
||||
});
|
||||
if (IMLoginManager.get(mContext).hintChat()) {
|
||||
container.setVisibility(View.GONE);
|
||||
ltNodataMsg.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
container.setVisibility(View.VISIBLE);
|
||||
ltNodataMsg.setVisibility(View.GONE);
|
||||
//展示会话列表
|
||||
conversationListFragment = new ConversationListFragment();
|
||||
FragmentManager manager = ((FragmentActivity) mContext).getSupportFragmentManager();
|
||||
FragmentTransaction transaction = manager.beginTransaction();
|
||||
transaction.replace(R.id.container, conversationListFragment);
|
||||
transaction.commit();
|
||||
//自定义空数据背景View
|
||||
conversationListFragment.setEmptyView(com.yunbao.live.R.layout.view_layout_msg);
|
||||
//刷新列表内用户信息
|
||||
ConversationIMListManager.get(mContext).addUserInfoProvider();
|
||||
}
|
||||
//获取一下系统通知
|
||||
MessageIMManager.get(mContext).getSystemMessages();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 系統消息獲取
|
||||
*/
|
||||
private Runnable imUserInfoRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//获取系统消息列表
|
||||
ImHttpUtil.getImUserInfo("", new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
mContext.runOnUiThread(() -> {
|
||||
listUserBean = JSON.parseArray(Arrays.toString(info), ImUserBean.class);
|
||||
for (ImUserBean userBean : listUserBean) {
|
||||
switch (userBean.getType()) {
|
||||
//官方通知
|
||||
case "1":
|
||||
if (TextUtils.isEmpty(userBean.getNum()) || TextUtils.equals("0", userBean.getNum())) {
|
||||
textNewsNotice.setVisibility(View.GONE);
|
||||
} else {
|
||||
textNewsNotice.setVisibility(View.VISIBLE);
|
||||
textNewsNotice.setText(userBean.getNum());
|
||||
}
|
||||
ImgLoader.display(mContext, userBean.getNewImage(), imgNewsNotice);
|
||||
ViewClicksAntiShake.clicksAntiShake(imgNewsNotice, () -> {
|
||||
type = userBean.getType();
|
||||
netHandler.post(systemNumberRunnable);
|
||||
mContext.startActivity(new Intent(mContext, SystemMessageActivity.class)
|
||||
.putExtra("type", userBean.getType())
|
||||
.putExtra("uid", "")
|
||||
.putExtra("title", userBean.getTitle())
|
||||
.putExtra("headImg", ""));
|
||||
});
|
||||
break;
|
||||
//互動消息
|
||||
case "2":
|
||||
if (TextUtils.isEmpty(userBean.getNum()) || TextUtils.equals("0", userBean.getNum())) {
|
||||
textNewsInteraction.setVisibility(View.GONE);
|
||||
} else {
|
||||
textNewsInteraction.setVisibility(View.VISIBLE);
|
||||
textNewsInteraction.setText(userBean.getNum());
|
||||
}
|
||||
ImgLoader.display(mContext, userBean.getNewImage(), imgNewsInteraction);
|
||||
ViewClicksAntiShake.clicksAntiShake(imgNewsInteraction, () -> {
|
||||
type = userBean.getType();
|
||||
netHandler.post(systemNumberRunnable);
|
||||
mContext.startActivity(new Intent(mContext, SystemMessageActivity.class)
|
||||
.putExtra("type", userBean.getType())
|
||||
.putExtra("uid", "")
|
||||
.putExtra("title", userBean.getTitle())
|
||||
.putExtra("headImg", ""));
|
||||
});
|
||||
break;
|
||||
//在線客服
|
||||
case "3":
|
||||
if (TextUtils.isEmpty(userBean.getNum()) || TextUtils.equals("0", userBean.getNum())) {
|
||||
textNewsOnline.setVisibility(View.GONE);
|
||||
} else {
|
||||
textNewsOnline.setVisibility(View.VISIBLE);
|
||||
textNewsOnline.setText(userBean.getNum());
|
||||
}
|
||||
ImgLoader.display(mContext, userBean.getNewImage(), imgNewsOnline);
|
||||
ViewClicksAntiShake.clicksAntiShake(imgNewsOnline, () -> {
|
||||
type = userBean.getType();
|
||||
netHandler.post(systemNumberRunnable);
|
||||
FirebaseAnalytics.getInstance(mContext).logEvent("FS_customer_service", null);
|
||||
AppEventsLogger.newLogger(mContext).logEvent("FB_customer_service");
|
||||
AdjustEvent adjustEvent1 = new AdjustEvent("ww5z2p");
|
||||
Adjust.trackEvent(adjustEvent1);
|
||||
if (userBean.getLink() != null && !"".equals(userBean.getLink())) {
|
||||
WebViewActivity.forward(mContext, userBean.getLink());
|
||||
} else {
|
||||
mContext.startActivity(new Intent(mContext, SystemMessageActivity.class)
|
||||
.putExtra("type", userBean.getType())
|
||||
.putExtra("uid", "")
|
||||
.putExtra("title", userBean.getTitle())
|
||||
.putExtra("headImg", ""));
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
//修改小紅點
|
||||
private Runnable systemNumberRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mContext.runOnUiThread(() -> {
|
||||
int systemNumber = 0;
|
||||
for (ImUserBean userBean : listUserBean) {
|
||||
//未读消息数
|
||||
String number = userBean.getNum();
|
||||
|
||||
switch (userBean.getType()) {
|
||||
//官方通知
|
||||
case "1":
|
||||
if (TextUtils.equals(type, userBean.getType())) {
|
||||
number = null;
|
||||
textNewsNotice.setVisibility(View.GONE);
|
||||
}
|
||||
break;
|
||||
//互動消息
|
||||
case "2":
|
||||
if (TextUtils.equals(type, userBean.getType())) {
|
||||
number = null;
|
||||
textNewsInteraction.setVisibility(View.GONE);
|
||||
}
|
||||
break;
|
||||
//在線客服
|
||||
case "3":
|
||||
if (TextUtils.equals(type, userBean.getType())) {
|
||||
number = null;
|
||||
textNewsOnline.setVisibility(View.GONE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//未读消息不为空并且大于0
|
||||
try {
|
||||
if (!TextUtils.isEmpty(number) && Integer.parseInt(number) > 0) {
|
||||
systemNumber = Integer.parseInt(number) + systemNumber;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
systemNumber = systemNumber + 0;
|
||||
}
|
||||
|
||||
}
|
||||
type = null;
|
||||
MessageIMManager.get(mContext).setSystemNumber(systemNumber);
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
//更新系統消息
|
||||
@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);
|
||||
|
||||
}
|
||||
}
|
143
main/src/main/res/layout/view_main_message.xml
Normal file
143
main/src/main/res/layout/view_main_message.xml
Normal file
@ -0,0 +1,143 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/top_noback"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="18dp"
|
||||
android:text="@string/message"
|
||||
android:textColor="#ff161616"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/news_icon_clearance"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="end|bottom"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:src="@mipmap/news_icon_clearance"
|
||||
android:visibility="gone" />
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/top_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<RelativeLayout
|
||||
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img_news_notice"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="130dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@mipmap/img_news_notice" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_news_notice"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginEnd="9dp"
|
||||
android:background="@drawable/background_system_message"
|
||||
android:gravity="center"
|
||||
android:text="7"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="12sp"
|
||||
android:visibility="gone" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img_news_interaction"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="130dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@mipmap/img_news_interaction" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_news_interaction"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginEnd="17dp"
|
||||
android:background="@drawable/background_system_message"
|
||||
android:gravity="center"
|
||||
android:text="7"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="12sp"
|
||||
android:visibility="gone" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img_news_online"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="130dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@mipmap/img_news_online" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_news_online"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginEnd="17dp"
|
||||
android:background="@drawable/background_system_message"
|
||||
android:gravity="center"
|
||||
android:text="7"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="12sp"
|
||||
android:visibility="gone" />
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
<!-- 此容器用于动态放置 fragment-->
|
||||
<FrameLayout
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/lt_nodata_msg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@mipmap/img_no_new" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user