diff --git a/common/src/main/java/com/yunbao/common/dialog/SlideSettingsDialog.java b/common/src/main/java/com/yunbao/common/dialog/SlideSettingsDialog.java new file mode 100644 index 000000000..99538ac1b --- /dev/null +++ b/common/src/main/java/com/yunbao/common/dialog/SlideSettingsDialog.java @@ -0,0 +1,83 @@ +package com.yunbao.common.dialog; + +import android.os.Bundle; +import android.view.Gravity; +import android.view.Window; +import android.view.WindowManager; +import android.widget.ImageView; + +import com.yunbao.common.R; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.manager.IMLoginManager; +import com.yunbao.common.views.weight.ViewClicksAntiShake; + +/** + * 滑动设置 + */ +public class SlideSettingsDialog extends AbsDialogFragment { + private ImageView slideSwitch; + private boolean slide; + + @Override + protected int getLayoutId() { + return R.layout.view_slide_settings; + } + + @Override + protected int getDialogStyle() { + return R.style.dialog2; + } + + @Override + protected boolean canCancel() { + return true; + } + + + @Override + protected void setWindowAttributes(Window window) { + window.setWindowAnimations(R.style.bottomToTopAnim); + WindowManager.LayoutParams params = window.getAttributes(); + params.width = WindowManager.LayoutParams.MATCH_PARENT; + params.height = WindowManager.LayoutParams.WRAP_CONTENT; + params.gravity = Gravity.BOTTOM; + window.setAttributes(params); + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + slideSwitch = (ImageView) findViewById(R.id.slide_switch); + slide = IMLoginManager.get(getActivity()).isSlide(); + if (slide) { + ImgLoader.display(getContext(), R.mipmap.special_icon_on, slideSwitch); + } else { + ImgLoader.display(getContext(), R.mipmap.special_icon_off, slideSwitch); + } + //滑动设置 + ViewClicksAntiShake.clicksAntiShake(slideSwitch, () -> { + slide = !slide; + if (slide) { + ImgLoader.display(getContext(), R.mipmap.special_icon_on, slideSwitch); + } else { + ImgLoader.display(getContext(), R.mipmap.special_icon_off, slideSwitch); + } + //滑动设置 + IMLoginManager.get(getContext()).initSlide(slide); + if (callBack != null) { + callBack.initSlide(slide); + } + }); + } + + private SlideSettingsCallBack callBack; + + public SlideSettingsDialog setCallBack(SlideSettingsCallBack callBack) { + this.callBack = callBack; + return this; + } + + public interface SlideSettingsCallBack { + void initSlide(boolean slide); + } +} diff --git a/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java b/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java index 576350fb8..ef6fc179c 100644 --- a/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java +++ b/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java @@ -30,6 +30,7 @@ public class IMLoginManager extends BaseCacheManager { private final static String GiftEffect = "giftEffect"; private final static String MountEffect = "mountEffect"; private final static String IS_CHAT = "isChat"; + private final static String IS_SLIDE = "isSlide"; /** * @param isChat 是否隐藏聊天列表 is_chat 1:开启 0:关闭 @@ -38,6 +39,24 @@ public class IMLoginManager extends BaseCacheManager { put(IS_CHAT, isChat); } + /** + * 设置直播间是否滚动 + * + * @param isSlide 滚动 + */ + public void initSlide(boolean isSlide) { + put(IS_SLIDE, isSlide); + } + + /** + * 获取之比肩是否滚动 + * + * @return + */ + public boolean isSlide() { + return getBoolean(IS_SLIDE, true); + } + /** * 是否隐藏聊天列表 * diff --git a/common/src/main/res/layout/view_live_total.xml b/common/src/main/res/layout/view_live_total.xml index 5e7855974..5ffcfb799 100644 --- a/common/src/main/res/layout/view_live_total.xml +++ b/common/src/main/res/layout/view_live_total.xml @@ -245,6 +245,28 @@ android:textSize="12sp" /> + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/mipmap-xxhdpi/live_more_icon_sliding.png b/common/src/main/res/mipmap-xxhdpi/live_more_icon_sliding.png new file mode 100644 index 000000000..a5eaa1edd Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/live_more_icon_sliding.png differ diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 99bf1b7c7..676a36515 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -912,6 +912,8 @@ 订单查询中 订单无异常 登錄失效,請重新登錄 + 滑動設置 + 上下滑動切換直播間 diff --git a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java index 9981da43a..c01cf2387 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java @@ -153,7 +153,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); mCoinName = CommonAppConfig.getInstance().getCoinName(); mIsAnchor = this instanceof LiveAnchorActivity; - mPageContainer = (ViewGroup) findViewById(R.id.page_container); + mPageContainer = findViewById(R.id.page_container); EventBus.getDefault().register(this); mDialogFragmentSet = new HashSet<>(); //解压 美颜模型 @@ -271,7 +271,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL @Override public void onEnterRoom(LiveEnterRoomBean bean) { if (mLiveRoomViewHolder != null) { - LiveUserGiftBean u = bean.getUserBean(); if (!bean.getUserBean().getCar().getWords().equals("")) { bean.getLiveChatBean().setContent(bean.getUserBean().getCar().getWords()); } @@ -286,9 +285,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL */ @Override public void onLeaveRoom(UserBean bean) { - if (mLiveRoomViewHolder != null) { -// mLiveRoomViewHolder.removeUser(bean.getId()); - } if (mLiveLinkMicPresenter != null) { mLiveLinkMicPresenter.onAudienceLeaveRoom(bean); } diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index 1cb2b35f2..d09ee190c 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -1,5 +1,7 @@ package com.yunbao.live.activity; +import static com.yunbao.live.views.LivePlayRyViewHolder.Micing; + import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; @@ -35,6 +37,7 @@ import com.yunbao.common.bean.SlideInfoModel; import com.yunbao.common.bean.UserBean; import com.yunbao.common.dialog.EffectsSettingsDialog; import com.yunbao.common.dialog.LiveChargeDialogFragment; +import com.yunbao.common.dialog.SlideSettingsDialog; import com.yunbao.common.event.FollowEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.CommonHttpConsts; @@ -80,8 +83,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import static com.yunbao.live.views.LivePlayRyViewHolder.Micing; - /** * Created by cxf on 2018/10/10. * 看直播 @@ -160,6 +161,9 @@ public class LiveAudienceActivity extends LiveActivity { private void initView() { // 竖直滑动 ViewPager verticalViewPager = findViewById(R.id.view_pager); + + verticalViewPager.setEnableScroll(IMLoginManager.get(mContext).isSlide()); + } public void setBackIndex(int backIndex) { @@ -197,7 +201,9 @@ public class LiveAudienceActivity extends LiveActivity { manager.micIngTypeTwo(mLiveBean, mLiveType, mLiveTypeVal); } else { - verticalViewPager.setEnableScroll(true); + if (IMLoginManager.get(mContext).isSlide()){ + verticalViewPager.setEnableScroll(true); + } mCurrentItem = position; Log.e(TAG, "mCurrentItem:" + mCurrentItem); if (mCurrentItem == itemModelList.size() - 1) { @@ -331,19 +337,17 @@ public class LiveAudienceActivity extends LiveActivity { * 打开礼物窗口 */ public void openGiftWindow() { - new Handler(Looper.getMainLooper()).post(new Runnable() { - public void run() { - if (TextUtils.isEmpty(mLiveUid) || TextUtils.isEmpty(mStream)) { - return; - } - LiveGiftDialogFragment fragment = new LiveGiftDialogFragment(); - fragment.setLiveGuardInfo(mLiveGuardInfo); - Bundle bundle = new Bundle(); - bundle.putString(Constants.LIVE_UID, mLiveUid); - bundle.putString(Constants.LIVE_STREAM, mStream); - fragment.setArguments(bundle); - fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment"); + new Handler(Looper.getMainLooper()).post(() -> { + if (TextUtils.isEmpty(mLiveUid) || TextUtils.isEmpty(mStream)) { + return; } + LiveGiftDialogFragment fragment = new LiveGiftDialogFragment(); + fragment.setLiveGuardInfo(mLiveGuardInfo); + Bundle bundle = new Bundle(); + bundle.putString(Constants.LIVE_UID, mLiveUid); + bundle.putString(Constants.LIVE_STREAM, mStream); + fragment.setArguments(bundle); + fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment"); }); } @@ -365,20 +369,18 @@ public class LiveAudienceActivity extends LiveActivity { if (TextUtils.isEmpty(mLiveUid) || TextUtils.isEmpty(mStream)) { return; } - new Handler(Looper.getMainLooper()).post(new Runnable() { - public void run() { - LiveGiftDialogFragment fragment = new LiveGiftDialogFragment(); - fragment.setLiveGuardInfo(mLiveGuardInfo); - Bundle bundle = new Bundle(); - bundle.putString(Constants.LIVE_UID, mLiveUid); - bundle.putString(Constants.LIVE_STREAM, mStream); - bundle.putString(Constants.LIVE_WISH_GIFTID, giftId); - if (for_by.equals("1")) { - bundle.putString("by", "1"); - } - fragment.setArguments(bundle); - fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment"); + new Handler(Looper.getMainLooper()).post(() -> { + LiveGiftDialogFragment fragment = new LiveGiftDialogFragment(); + fragment.setLiveGuardInfo(mLiveGuardInfo); + Bundle bundle = new Bundle(); + bundle.putString(Constants.LIVE_UID, mLiveUid); + bundle.putString(Constants.LIVE_STREAM, mStream); + bundle.putString(Constants.LIVE_WISH_GIFTID, giftId); + if (for_by.equals("1")) { + bundle.putString("by", "1"); } + fragment.setArguments(bundle); + fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment"); }); } @@ -485,6 +487,7 @@ public class LiveAudienceActivity extends LiveActivity { super.onPause(); manager.onPause(); } + /** * 点亮 */ @@ -815,6 +818,16 @@ public class LiveAudienceActivity extends LiveActivity { manager.onChat(chatBean, 1); break; + case SLIDE_SETTINGS: + SlideSettingsDialog slideSettingsDialog = new SlideSettingsDialog(); + slideSettingsDialog.show(getSupportFragmentManager(), "SlideSettingsDialog"); + slideSettingsDialog.setCallBack(new SlideSettingsDialog.SlideSettingsCallBack() { + @Override + public void initSlide(boolean slide) { + verticalViewPager.setEnableScroll(slide); + } + }); + break; } @@ -890,7 +903,6 @@ public class LiveAudienceActivity extends LiveActivity { } - /** * 获取侧边栏数据 */ diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveTotalDialog.java b/live/src/main/java/com/yunbao/live/dialog/LiveTotalDialog.java index b680d8eea..2dd565291 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveTotalDialog.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveTotalDialog.java @@ -9,13 +9,13 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.yunbao.common.R; -import com.yunbao.live.adapter.FunGamesAdapter; import com.yunbao.common.bean.ActiveModel; import com.yunbao.common.dialog.AbsDialogFragment; import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.utils.Bus; import com.yunbao.common.views.weight.ViewClicksAntiShake; +import com.yunbao.live.adapter.FunGamesAdapter; import com.yunbao.live.bean.LiveBean; import com.yunbao.live.event.LiveAudienceEvent; @@ -144,6 +144,11 @@ public class LiveTotalDialog extends AbsDialogFragment { .setType(LiveAudienceEvent.LiveAudienceType.ONLINE)); dismiss(); }); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.slide_settings_layout), () -> { + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.SLIDE_SETTINGS)); + dismiss(); + }); } @Override diff --git a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java index 58b195025..eee6cca27 100644 --- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java +++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java @@ -130,7 +130,9 @@ public class LiveAudienceEvent extends BaseModel { NOTICE(18, "系统通知"), ONLINE(19, "在线客服"), TRUMPET_NOTIFY(20, "全服喇叭"), - RECOMMEND_CARD_NOTIFY(21, "贵族推荐通知"); + RECOMMEND_CARD_NOTIFY(21, "贵族推荐通知"), + SLIDE_SETTINGS(22, "滑動設置") + ; private int type; private String name;