新增短剧页面的开播提醒浮窗

This commit is contained in:
zlzw 2024-02-17 13:43:30 +08:00
parent 6f71a825b5
commit df735af252

View File

@ -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<AnchorStartLiveBean> 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();
}
}
}