diff --git a/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java b/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java index bf70d3ca4..06a13aee5 100644 --- a/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java +++ b/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java @@ -32,9 +32,9 @@ import static com.yunbao.common.CommonAppContext.isReady; */ public class RongcloudIMManager { //融云开发者平台注册app唯一识别符 -// public static final String RONG_IM_KEY = "uwd1c0sxu1p71"; + public static final String RONG_IM_KEY = "uwd1c0sxu1p71"; //测试环境 - public static final String RONG_IM_KEY = "pvxdm17jpd3hr"; +// public static final String RONG_IM_KEY = "pvxdm17jpd3hr"; private static final String CLASSNAME = "RongcloudIMManager"; 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 171199895..d3458c640 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -29,7 +29,6 @@ import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.UserBean; import com.yunbao.common.dialog.EffectsSettingsDialog; import com.yunbao.common.dialog.LiveChargeDialogFragment; -import com.yunbao.live.dialog.LiveTotalDialog; import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; @@ -52,6 +51,7 @@ import com.yunbao.live.dialog.LiveGiftDialogFragment; import com.yunbao.live.dialog.LiveGuardDialogFragment; import com.yunbao.live.dialog.LiveHDDialogFragment; import com.yunbao.live.dialog.LiveMicUserDialogFragment; +import com.yunbao.live.dialog.LiveTotalDialog; import com.yunbao.live.dialog.LiveWishListDialogFragment4Audience; import com.yunbao.live.dialog.SidebarLiveAudience; import com.yunbao.live.event.LinkMicTxAccEvent; @@ -63,6 +63,7 @@ import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; import com.yunbao.live.socket.SocketSendBean; import com.yunbao.live.utils.LiveImDeletUtil; import com.yunbao.live.views.LiveRoomPlayViewHolder; +import com.yunbao.live.views.LoadingView; import com.yunbao.live.views.PortraitLiveManager; import org.greenrobot.eventbus.Subscribe; @@ -119,6 +120,7 @@ public class LiveAudienceActivity extends LiveActivity { private int mLastPosition = -1; private ViewGroup mViewGroup; + private LoadingView loadingView; @Override @@ -147,7 +149,11 @@ public class LiveAudienceActivity extends LiveActivity { mLiveBean = intent.getParcelableExtra(Constants.LIVE_BEAN); mLiveUid = mLiveBean.getUid(); mStream = mLiveBean.getStream(); - + if (getIntent().getIntExtra("isry", 0) == 1) { + isRy = true; + } else { + isRy = false; + } setVolumeControlStream(AudioManager.STREAM_MUSIC); manager = new PortraitLiveManager(this, intent); initView(); @@ -160,7 +166,8 @@ public class LiveAudienceActivity extends LiveActivity { private void initView() { // 竖直滑动 ViewPager verticalViewPager = findViewById(R.id.view_pager); - + loadingView = findViewById(R.id.loading); + loadingView.show(); } public void setBackIndex(int backIndex) { @@ -202,6 +209,7 @@ public class LiveAudienceActivity extends LiveActivity { } mPagerAdapter = new VerticalPagerAdapter(itemModelList, mContext); verticalViewPager.setAdapter(mPagerAdapter); + loadingView.hide(); } @Override @@ -298,6 +306,7 @@ public class LiveAudienceActivity extends LiveActivity { mLiveUid = mLiveBean.getUid(); mStream = mLiveBean.getStream(); mAncherName = liveBean.getUserNiceName(); + Log.e("收到socket--->", "mLiveUid--------------------------->" + mLiveUid); //加载当前页面数据 View rootView = manager.getRootView(); diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java index 37bc83310..b639182f8 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java @@ -3,12 +3,9 @@ package com.yunbao.live.adapter; import android.annotation.SuppressLint; import android.content.Context; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.GridLayoutManager; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; import android.text.Spannable; import android.text.SpannableStringBuilder; +import android.text.TextUtils; import android.text.style.ForegroundColorSpan; import android.view.LayoutInflater; import android.view.View; @@ -17,6 +14,11 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + import com.makeramen.roundedimageview.RoundedImageView; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; @@ -278,23 +280,46 @@ public class LiveChatAdapter extends RecyclerView.Adapter { mTextView.setText(builder); } else if (bean.getType() == -10) { mBg.setBackground(null); -// mTextView.setVisibility(View.GONE); } else if (bean.getType() == LiveChatBean.SYSTEM) { - mTextView.setTextColor(0xffffffff); - mBg.setBackground(null); - mTextView.setText(bean.getContent()); + boolean isContains = false; + for (LiveChatBean model : mList) { + if (!TextUtils.isEmpty(model.getContent())&&model.getContent().contains("堅決維護青少年群體精神文明健康")) { + isContains = true; + } + } + if (isContains) { + mTextView.setTextColor(0xffffffff); + mBg.setBackground(null); + mTextView.setText(bean.getContent()); + } } else if (bean.getType() == -1) {//自动消息,关注 - mBg.setBackground(null); - mTextView.setVisibility(View.GONE); - view_follow.setVisibility(View.VISIBLE); - ImgLoader.display(mContext, bean.getId(), avatar); - bean.setHeart(position); + boolean isContains = false; + for (LiveChatBean model : mList) { + if (bean.getType() == -1) { + isContains = true; + } + } + if (isContains) { + mBg.setBackground(null); + mTextView.setVisibility(View.GONE); + view_follow.setVisibility(View.VISIBLE); + ImgLoader.display(mContext, bean.getId(), avatar); + bean.setHeart(position); + } + } else if (bean.getType() == -2) {//自动消息,点击发言 - mBg.setBackgroundResource(R.drawable.bg_chat_automatic_item); - mTextView.setText(R.string.automatic_chat); - bean.setHeart(position); + boolean isContains = false; + for (LiveChatBean model : mList) { + if (bean.getType() == -2) { + isContains = true; + } + } + if (isContains) { + mBg.setBackgroundResource(R.drawable.bg_chat_automatic_item); + mTextView.setText(R.string.automatic_chat); + bean.setHeart(position); + } } else { -// LoadDian9TuUtil.loadDian9Tu(mContext, mBg, "https://qny.shayucm.com/huangdi-new-qipao.png"); if (bean.getBubble() != null && !bean.getBubble().equals("")) { //加载.9图聊天气泡 LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getBubble(), 1); @@ -306,23 +331,7 @@ public class LiveChatAdapter extends RecyclerView.Adapter { } else { mTextView.setTextColor(0xffffffff); } -// Log.e("tag",bean.getContent().length()+""); -// RecyclerView.LayoutParams linearParams = (RecyclerView.LayoutParams) mBg.getLayoutParams(); -// linearParams.height = RecyclerView.LayoutParams.WRAP_CONTENT; -// // 控件的宽强制设成40 -// mBg.setLayoutParams(linearParams); //使设置好的布局参数应用到控件 -// if(bean.getContent().length()<=7) { -// RecyclerView.LayoutParams linearParams1 = (RecyclerView.LayoutParams) mBg.getLayoutParams(); -// linearParams1.height = mContext.getResources().getDimensionPixelOffset(R.dimen.live_chat1); -// // 控件的宽强制设成40 -// mBg.setLayoutParams(linearParams1); //使设置好的布局参数应用到控件 -// } -// else if(bean.getContent().length()<=20){ -// RecyclerView.LayoutParams linearParams = (RecyclerView.LayoutParams) mBg.getLayoutParams(); -// linearParams.height = mContext.getResources().getDimensionPixelOffset(R.dimen.live_chat2); -// // 控件的宽强制设成40 -// mBg.setLayoutParams(linearParams); //使设置好的布局参数应用到控件 -// } + LiveTextRender.render(mContext, mTextView, bean); } } diff --git a/live/src/main/java/com/yunbao/live/bean/LiveBean.java b/live/src/main/java/com/yunbao/live/bean/LiveBean.java index cd1df88a8..c47c04d95 100644 --- a/live/src/main/java/com/yunbao/live/bean/LiveBean.java +++ b/live/src/main/java/com/yunbao/live/bean/LiveBean.java @@ -5,7 +5,6 @@ import android.os.Parcelable; import android.text.TextUtils; import com.alibaba.fastjson.annotation.JSONField; -import com.google.gson.annotations.SerializedName; import com.yunbao.common.bean.WeekListBean; import com.yunbao.common.utils.WordUtil; import com.yunbao.live.R; @@ -203,6 +202,7 @@ public class LiveBean implements Parcelable { @JSONField(name = "user_nicename") public String getUserNiceName() { + return userNiceName; } @@ -328,6 +328,7 @@ public class LiveBean implements Parcelable { public String getIslive() { return islive; } + public void setIslive(String islive) { this.islive = islive; } diff --git a/live/src/main/java/com/yunbao/live/dialog/SidebarLiveAudience.java b/live/src/main/java/com/yunbao/live/dialog/SidebarLiveAudience.java index df43c3bbd..6385c8aca 100644 --- a/live/src/main/java/com/yunbao/live/dialog/SidebarLiveAudience.java +++ b/live/src/main/java/com/yunbao/live/dialog/SidebarLiveAudience.java @@ -1,8 +1,10 @@ package com.yunbao.live.dialog; +import android.os.Build; import android.os.Bundle; import android.view.Display; import android.view.Gravity; +import android.view.View; import android.view.Window; import android.view.WindowManager; import android.widget.ImageView; @@ -134,7 +136,12 @@ public class SidebarLiveAudience extends AbsDialogFragment { @Override protected void setWindowAttributes(Window window) { - + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); + window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); + window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); + window.setStatusBarColor(0); + } window.setWindowAnimations(com.yunbao.common.R.style.RightLeftToAnim); WindowManager.LayoutParams params = window.getAttributes(); params.width = DeviceUtils.getScreenWidth(getActivity()) / 3 * 2; @@ -143,6 +150,8 @@ public class SidebarLiveAudience extends AbsDialogFragment { window.setAttributes(params); } + + /** * 前往直播间 */ diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveRoomCheckLivePresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveRoomCheckLivePresenter.java index 0bfe5ac2c..5c816a916 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveRoomCheckLivePresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveRoomCheckLivePresenter.java @@ -31,6 +31,8 @@ public class LiveRoomCheckLivePresenter { private LiveBean mLiveBean; private ActionListener mActionListener; private int mLiveSdk; + //搜索页面不提示密码 + public static boolean isSearch = false; public LiveRoomCheckLivePresenter(Context context, ActionListener actionListener) { mContext = context; @@ -46,7 +48,6 @@ public class LiveRoomCheckLivePresenter { } - private HttpCallback mCheckLiveCallback = new HttpCallback() { @Override public void onSuccess(int code, String msg, String[] info) { @@ -101,22 +102,28 @@ public class LiveRoomCheckLivePresenter { * 前往密码房间 */ private void forwardPwdRoom() { - DialogUitl.showSimpleInputDialog(mContext, WordUtil.getString(R.string.live_input_password), DialogUitl.INPUT_TYPE_NUMBER_PASSWORD, new DialogUitl.SimpleCallback() { - @Override - public void onConfirmClick(Dialog dialog, String content) { - if (TextUtils.isEmpty(content)) { - ToastUtil.show(WordUtil.getString(R.string.live_input_password)); - return; + if (!isSearch) { + DialogUitl.showSimpleInputDialog(mContext, WordUtil.getString(R.string.live_input_password), DialogUitl.INPUT_TYPE_NUMBER_PASSWORD, new DialogUitl.SimpleCallback() { + @Override + public void onConfirmClick(Dialog dialog, String content) { + if (TextUtils.isEmpty(content)) { + ToastUtil.show(WordUtil.getString(R.string.live_input_password)); + return; + } + String password = MD5Util.getMD5(content); + if (mLiveTypeMsg.equalsIgnoreCase(password)) { + dialog.dismiss(); + enterLiveRoom(); + } else { + ToastUtil.show(WordUtil.getString(R.string.live_password_error)); + } } - String password = MD5Util.getMD5(content); - if (mLiveTypeMsg.equalsIgnoreCase(password)) { - dialog.dismiss(); - enterLiveRoom(); - } else { - ToastUtil.show(WordUtil.getString(R.string.live_password_error)); - } - } - }); + }); + }else { + enterLiveRoom(); + isSearch = false; + } + } /** diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index ce08437e5..3399f1d06 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -45,7 +45,6 @@ import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.bean.LevelBean; import com.yunbao.common.bean.UserBean; -import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.CommonHttpUtil; @@ -86,6 +85,7 @@ import com.yunbao.live.custom.TopGradual; import com.yunbao.live.dialog.LiveFansMedalDialogFragment; import com.yunbao.live.dialog.LiveHDDialogFragment; import com.yunbao.live.dialog.LiveUserDialogFragment; +import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.http.LiveHttpConsts; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.presenter.LiveDanmuPresenter; @@ -1025,7 +1025,11 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis */ public void setName(String name) { if (mName != null) { + mNameText = name; + if (name.length() > 4) { + name = name.substring(0, 4) + "..."; + } mName.setText(name); EventBus.getDefault().post("name_true"); } diff --git a/live/src/main/java/com/yunbao/live/views/LoadingView.java b/live/src/main/java/com/yunbao/live/views/LoadingView.java new file mode 100644 index 000000000..6f8d7209c --- /dev/null +++ b/live/src/main/java/com/yunbao/live/views/LoadingView.java @@ -0,0 +1,61 @@ +package com.yunbao.live.views; + +import android.content.Context; +import android.graphics.drawable.AnimationDrawable; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.FrameLayout; +import android.widget.ImageView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.yunbao.live.R; + + +public class LoadingView extends FrameLayout { + + private Context mContext; + private ImageView mIvLoading; + + public LoadingView(@NonNull Context context) { + super(context); + init(context); + } + + public LoadingView(@NonNull Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + init(context); + } + + public LoadingView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + init(context); + } + + private void init(Context context) { + this.mContext = context; + View view = LayoutInflater.from(mContext).inflate(R.layout.layout_portrait_live_item, this, true); + mIvLoading = view.findViewById(R.id.iv_loading); + } + + + public void show() { + // 加载动画 + ImageView ivLoading = mIvLoading.findViewById(R.id.iv_loading); + AnimationDrawable frameAnimation = (AnimationDrawable) ivLoading.getBackground(); + frameAnimation.start(); + + setVisibility(VISIBLE); + } + + public void hide() { + // 加载动画 + ImageView ivLoading = mIvLoading.findViewById(R.id.iv_loading); + AnimationDrawable frameAnimation = (AnimationDrawable) ivLoading.getBackground(); + frameAnimation.stop(); + setVisibility(GONE); + } + +} diff --git a/live/src/main/res/layout/activity_live_detail.xml b/live/src/main/res/layout/activity_live_detail.xml index 4eedf5c79..bf7edf6a4 100644 --- a/live/src/main/res/layout/activity_live_detail.xml +++ b/live/src/main/res/layout/activity_live_detail.xml @@ -9,5 +9,10 @@ android:layout_height="match_parent" android:overScrollMode="never" /> + \ No newline at end of file diff --git a/live/src/main/res/layout/view_sidebar_live_audience.xml b/live/src/main/res/layout/view_sidebar_live_audience.xml index 779f68da4..ca028ef11 100644 --- a/live/src/main/res/layout/view_sidebar_live_audience.xml +++ b/live/src/main/res/layout/view_sidebar_live_audience.xml @@ -27,7 +27,7 @@ android:layout_height="match_parent" android:orientation="vertical" android:paddingStart="8dp" - android:paddingTop="56dp" + android:paddingTop="10dp" android:paddingEnd="8dp"> diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index aa3a7ae0d..6ff5f2677 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -303,7 +303,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene Log.d(TAG, token); PushManager.getInstance() .onReceiveToken(MainActivity.this, PushType.GOOGLE_FCM, token); - Toast.makeText(MainActivity.this, token, Toast.LENGTH_SHORT).show(); +// Toast.makeText(MainActivity.this, token, Toast.LENGTH_SHORT).show(); } }); boolean showInvite = getIntent().getBooleanExtra(Constants.SHOW_INVITE, false); diff --git a/main/src/main/java/com/yunbao/main/activity/SearchActivity.java b/main/src/main/java/com/yunbao/main/activity/SearchActivity.java index def94578b..443534e67 100644 --- a/main/src/main/java/com/yunbao/main/activity/SearchActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/SearchActivity.java @@ -18,6 +18,7 @@ import androidx.fragment.app.FragmentTransaction; import com.alibaba.fastjson.JSON; import com.yunbao.common.activity.AbsActivity; +import com.yunbao.common.event.CloseEvent; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.manager.SearchHistoryRecordManager; import com.yunbao.common.utils.Bus; @@ -27,7 +28,6 @@ import com.yunbao.live.bean.LiveBean; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; import com.yunbao.main.R; -import com.yunbao.common.event.CloseEvent; import com.yunbao.main.event.JumpUserHomeEvent; import com.yunbao.main.fragment.SearchRecommendFragment; import com.yunbao.main.fragment.SearchResultsFragment; @@ -175,16 +175,13 @@ public class SearchActivity extends AbsActivity { if (code == 0 && info.length > 0) { LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class); - - LiveRoomCheckLivePresenter mCheckLivePresenter = new LiveRoomCheckLivePresenter(mContext, new LiveRoomCheckLivePresenter.ActionListener() { - @Override - public void onLiveRoomChanged(LiveBean liveBean, int liveType, int liveTypeVal, int liveSdk) { - if (liveBean == null) { - return; - } - LiveAudienceActivity.forward(mContext, liveBean, liveType, liveTypeVal, "", 0, liveSdk); - + LiveRoomCheckLivePresenter.isSearch = true; + LiveRoomCheckLivePresenter mCheckLivePresenter = new LiveRoomCheckLivePresenter(mContext, (liveBean1, liveType, liveTypeVal, liveSdk) -> { + if (liveBean1 == null) { + return; } + LiveAudienceActivity.forward(mContext, liveBean1, liveType, liveTypeVal, "", 0, liveSdk); + }); mCheckLivePresenter.checkLive(liveBean);