直播间滑动设置

This commit is contained in:
18401019693 2022-10-06 13:06:46 +08:00
parent 39b4a52ade
commit 72dd63355e
10 changed files with 219 additions and 36 deletions

View File

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

View File

@ -30,6 +30,7 @@ public class IMLoginManager extends BaseCacheManager {
private final static String GiftEffect = "giftEffect"; private final static String GiftEffect = "giftEffect";
private final static String MountEffect = "mountEffect"; private final static String MountEffect = "mountEffect";
private final static String IS_CHAT = "isChat"; private final static String IS_CHAT = "isChat";
private final static String IS_SLIDE = "isSlide";
/** /**
* @param isChat 是否隐藏聊天列表 is_chat 1开启 0关闭 * @param isChat 是否隐藏聊天列表 is_chat 1开启 0关闭
@ -38,6 +39,24 @@ public class IMLoginManager extends BaseCacheManager {
put(IS_CHAT, isChat); put(IS_CHAT, isChat);
} }
/**
* 设置直播间是否滚动
*
* @param isSlide 滚动
*/
public void initSlide(boolean isSlide) {
put(IS_SLIDE, isSlide);
}
/**
* 获取之比肩是否滚动
*
* @return
*/
public boolean isSlide() {
return getBoolean(IS_SLIDE, true);
}
/** /**
* 是否隐藏聊天列表 * 是否隐藏聊天列表
* *

View File

@ -245,6 +245,28 @@
android:textSize="12sp" /> android:textSize="12sp" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/slide_settings_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="23dp"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@mipmap/live_more_icon_sliding" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="@string/slide_settings"
android:textColor="#FF9A9A9A"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/system_notice" android:id="@+id/system_notice"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -0,0 +1,42 @@
<?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="wrap_content"
android:background="@drawable/bg_live_tota"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:text="@string/slide_settings"
android:textColor="#FFF6F7FB"
android:textSize="17sp" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="24dp"
android:layout_marginBottom="21dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/up_slide_settings"
android:textColor="#FF9A9A9A"
android:textSize="15sp" />
<ImageView
android:id="@+id/slide_switch"
android:layout_width="40.8dp"
android:layout_height="24.8dp"
android:layout_gravity="end|center_vertical"
android:src="@mipmap/special_icon_off" />
</FrameLayout>
</LinearLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

@ -912,6 +912,8 @@
<string name="order_query">订单查询中</string> <string name="order_query">订单查询中</string>
<string name="order_query_success">订单无异常</string> <string name="order_query_success">订单无异常</string>
<string name="login_invalid">登錄失效,請重新登錄</string> <string name="login_invalid">登錄失效,請重新登錄</string>
<string name="slide_settings">滑動設置</string>
<string name="up_slide_settings">上下滑動切換直播間</string>
</resources> </resources>

View File

@ -152,7 +152,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
mCoinName = CommonAppConfig.getInstance().getCoinName(); mCoinName = CommonAppConfig.getInstance().getCoinName();
mIsAnchor = this instanceof LiveAnchorActivity; mIsAnchor = this instanceof LiveAnchorActivity;
mPageContainer = (ViewGroup) findViewById(R.id.page_container); mPageContainer = findViewById(R.id.page_container);
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
mDialogFragmentSet = new HashSet<>(); mDialogFragmentSet = new HashSet<>();
//解压 美颜模型 //解压 美颜模型
@ -270,7 +270,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
@Override @Override
public void onEnterRoom(LiveEnterRoomBean bean) { public void onEnterRoom(LiveEnterRoomBean bean) {
if (mLiveRoomViewHolder != null) { if (mLiveRoomViewHolder != null) {
LiveUserGiftBean u = bean.getUserBean();
if (!bean.getUserBean().getCar().getWords().equals("")) { if (!bean.getUserBean().getCar().getWords().equals("")) {
bean.getLiveChatBean().setContent(bean.getUserBean().getCar().getWords()); bean.getLiveChatBean().setContent(bean.getUserBean().getCar().getWords());
} }
@ -285,9 +284,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
*/ */
@Override @Override
public void onLeaveRoom(UserBean bean) { public void onLeaveRoom(UserBean bean) {
if (mLiveRoomViewHolder != null) {
// mLiveRoomViewHolder.removeUser(bean.getId());
}
if (mLiveLinkMicPresenter != null) { if (mLiveLinkMicPresenter != null) {
mLiveLinkMicPresenter.onAudienceLeaveRoom(bean); mLiveLinkMicPresenter.onAudienceLeaveRoom(bean);
} }

View File

@ -1,5 +1,7 @@
package com.yunbao.live.activity; package com.yunbao.live.activity;
import static com.yunbao.live.views.LivePlayRyViewHolder.Micing;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -35,6 +37,7 @@ import com.yunbao.common.bean.SlideInfoModel;
import com.yunbao.common.bean.UserBean; import com.yunbao.common.bean.UserBean;
import com.yunbao.common.dialog.EffectsSettingsDialog; import com.yunbao.common.dialog.EffectsSettingsDialog;
import com.yunbao.common.dialog.LiveChargeDialogFragment; import com.yunbao.common.dialog.LiveChargeDialogFragment;
import com.yunbao.common.dialog.SlideSettingsDialog;
import com.yunbao.common.event.FollowEvent; import com.yunbao.common.event.FollowEvent;
import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.CommonHttpConsts;
@ -80,8 +83,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import static com.yunbao.live.views.LivePlayRyViewHolder.Micing;
/** /**
* Created by cxf on 2018/10/10. * Created by cxf on 2018/10/10.
* 看直播 * 看直播
@ -160,6 +161,9 @@ public class LiveAudienceActivity extends LiveActivity {
private void initView() { private void initView() {
// 竖直滑动 ViewPager // 竖直滑动 ViewPager
verticalViewPager = findViewById(R.id.view_pager); verticalViewPager = findViewById(R.id.view_pager);
verticalViewPager.setEnableScroll(IMLoginManager.get(mContext).isSlide());
} }
public void setBackIndex(int backIndex) { public void setBackIndex(int backIndex) {
@ -197,7 +201,9 @@ public class LiveAudienceActivity extends LiveActivity {
manager.micIngTypeTwo(mLiveBean, mLiveType, mLiveTypeVal); manager.micIngTypeTwo(mLiveBean, mLiveType, mLiveTypeVal);
} else { } else {
verticalViewPager.setEnableScroll(true); if (IMLoginManager.get(mContext).isSlide()){
verticalViewPager.setEnableScroll(true);
}
mCurrentItem = position; mCurrentItem = position;
Log.e(TAG, "mCurrentItem:" + mCurrentItem); Log.e(TAG, "mCurrentItem:" + mCurrentItem);
if (mCurrentItem == itemModelList.size() - 1) { if (mCurrentItem == itemModelList.size() - 1) {
@ -331,19 +337,17 @@ public class LiveAudienceActivity extends LiveActivity {
* 打开礼物窗口 * 打开礼物窗口
*/ */
public void openGiftWindow() { public void openGiftWindow() {
new Handler(Looper.getMainLooper()).post(new Runnable() { new Handler(Looper.getMainLooper()).post(() -> {
public void run() { if (TextUtils.isEmpty(mLiveUid) || TextUtils.isEmpty(mStream)) {
if (TextUtils.isEmpty(mLiveUid) || TextUtils.isEmpty(mStream)) { return;
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");
} }
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)) { if (TextUtils.isEmpty(mLiveUid) || TextUtils.isEmpty(mStream)) {
return; return;
} }
new Handler(Looper.getMainLooper()).post(new Runnable() { new Handler(Looper.getMainLooper()).post(() -> {
public void run() { LiveGiftDialogFragment fragment = new LiveGiftDialogFragment();
LiveGiftDialogFragment fragment = new LiveGiftDialogFragment(); fragment.setLiveGuardInfo(mLiveGuardInfo);
fragment.setLiveGuardInfo(mLiveGuardInfo); Bundle bundle = new Bundle();
Bundle bundle = new Bundle(); bundle.putString(Constants.LIVE_UID, mLiveUid);
bundle.putString(Constants.LIVE_UID, mLiveUid); bundle.putString(Constants.LIVE_STREAM, mStream);
bundle.putString(Constants.LIVE_STREAM, mStream); bundle.putString(Constants.LIVE_WISH_GIFTID, giftId);
bundle.putString(Constants.LIVE_WISH_GIFTID, giftId); if (for_by.equals("1")) {
if (for_by.equals("1")) { bundle.putString("by", "1");
bundle.putString("by", "1");
}
fragment.setArguments(bundle);
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment");
} }
fragment.setArguments(bundle);
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment");
}); });
} }
@ -485,6 +487,7 @@ public class LiveAudienceActivity extends LiveActivity {
super.onPause(); super.onPause();
manager.onPause(); manager.onPause();
} }
/** /**
* 点亮 * 点亮
*/ */
@ -815,6 +818,16 @@ public class LiveAudienceActivity extends LiveActivity {
manager.onChat(chatBean, 1); manager.onChat(chatBean, 1);
break; 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 {
} }
/** /**
* 获取侧边栏数据 * 获取侧边栏数据
*/ */

View File

@ -9,13 +9,13 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.R; import com.yunbao.common.R;
import com.yunbao.live.adapter.FunGamesAdapter;
import com.yunbao.common.bean.ActiveModel; import com.yunbao.common.bean.ActiveModel;
import com.yunbao.common.dialog.AbsDialogFragment; import com.yunbao.common.dialog.AbsDialogFragment;
import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.Bus;
import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.common.views.weight.ViewClicksAntiShake;
import com.yunbao.live.adapter.FunGamesAdapter;
import com.yunbao.live.bean.LiveBean; import com.yunbao.live.bean.LiveBean;
import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.event.LiveAudienceEvent;
@ -144,6 +144,11 @@ public class LiveTotalDialog extends AbsDialogFragment {
.setType(LiveAudienceEvent.LiveAudienceType.ONLINE)); .setType(LiveAudienceEvent.LiveAudienceType.ONLINE));
dismiss(); dismiss();
}); });
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.slide_settings_layout), () -> {
Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.SLIDE_SETTINGS));
dismiss();
});
} }
@Override @Override

View File

@ -130,7 +130,9 @@ public class LiveAudienceEvent extends BaseModel {
NOTICE(18, "系统通知"), NOTICE(18, "系统通知"),
ONLINE(19, "在线客服"), ONLINE(19, "在线客服"),
TRUMPET_NOTIFY(20, "全服喇叭"), TRUMPET_NOTIFY(20, "全服喇叭"),
RECOMMEND_CARD_NOTIFY(21, "贵族推荐通知"); RECOMMEND_CARD_NOTIFY(21, "贵族推荐通知"),
SLIDE_SETTINGS(22, "滑動設置")
;
private int type; private int type;
private String name; private String name;