diff --git a/main/src/main/java/com/yunbao/main/activity/MainHomeCommunityActivity.java b/main/src/main/java/com/yunbao/main/activity/MainHomeCommunityActivity.java index ab211b57e..4820b1b65 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainHomeCommunityActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainHomeCommunityActivity.java @@ -10,25 +10,35 @@ import androidx.fragment.app.FragmentTransaction; import com.alibaba.android.arouter.facade.annotation.Route; import com.lzf.easyfloat.EasyFloat; import com.yunbao.common.activity.AbsActivity; +import com.yunbao.common.bean.AnchorStartLiveBean; +import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.L; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.views.floatingview.APPEasyFloat; import com.yunbao.main.R; +import com.yunbao.main.dialog.AnchorStartLiveNotifyDialog; import com.yunbao.main.fragment.MainHomeCommunityVideoFragment; +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.ArrayList; +import java.util.List; + /** * 短剧 */ @Route(path = RouteUtil.PATH_COMMUNITY_Activity) public class MainHomeCommunityActivity extends AbsActivity { - + private List startListNotifyList = new ArrayList<>(); @Override protected int getLayoutId() { return R.layout.activity_main_home_community; } - @Override protected void main() { + EventBus.getDefault().register(this); Window window = getWindow(); window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); @@ -49,6 +59,28 @@ public class MainHomeCommunityActivity extends AbsActivity { @Override public void onDestroy() { super.onDestroy(); + EventBus.getDefault().unregister(this); } + @Subscribe(threadMode = ThreadMode.MAIN) + public void onNotifyAnchorLive(AnchorStartLiveBean bean) { + if (!IMLoginManager.get(mContext).isLiveNotifySettings()) return; + if (startListNotifyList.isEmpty()) { + startListNotifyList.add(bean); + notifyLiveFlot(); + } else { + startListNotifyList.add(bean); + } + } + private void notifyLiveFlot() { + if (startListNotifyList.iterator().hasNext()) { + AnchorStartLiveBean bean = startListNotifyList.iterator().next(); + new AnchorStartLiveNotifyDialog(mContext, bean).setOnDismissListener(dialog -> { + startListNotifyList.remove(bean); + if (startListNotifyList.iterator().hasNext()) { + notifyLiveFlot(); + } + }).showDialog(); + } + } }