diff --git a/common/src/main/java/com/yunbao/common/CommonAppContext.java b/common/src/main/java/com/yunbao/common/CommonAppContext.java index 453490b55..269464e41 100644 --- a/common/src/main/java/com/yunbao/common/CommonAppContext.java +++ b/common/src/main/java/com/yunbao/common/CommonAppContext.java @@ -56,9 +56,7 @@ public class CommonAppContext extends MultiDexApplication { //设置新加坡融云服务器 有时候国内收不到推送是因为这个 RongIMClient.setServerInfo("navsg01.cn.ronghub.com", null); //谷歌推送 - PushConfig gconfig = new PushConfig.Builder() - .enableFCM(true) - .build(); + PushConfig gconfig = new PushConfig.Builder().enableFCM(true).build(); RongPushClient.setPushConfig(gconfig); //初始化友盟统计 // UMConfigure.init(this, UMConfigure.DEVICE_TYPE_PHONE, null); @@ -86,6 +84,9 @@ public class CommonAppContext extends MultiDexApplication { } public static Activity getTopActivity() { + if (activityWeakReference == null) { + return null; + } return activityWeakReference.get(); } diff --git a/common/src/main/java/com/yunbao/common/bean/EnterRoomNewModel.java b/common/src/main/java/com/yunbao/common/bean/EnterRoomNewModel.java index e45947c1d..35d6b7295 100644 --- a/common/src/main/java/com/yunbao/common/bean/EnterRoomNewModel.java +++ b/common/src/main/java/com/yunbao/common/bean/EnterRoomNewModel.java @@ -37,6 +37,17 @@ public class EnterRoomNewModel extends BaseModel { private String sudGameRoomStatus; @SerializedName("sud_game_room_name") private String sudGameRoomName; + @SerializedName("sud_gameDate") + private SudGameDateModel sudGameDateModel; + + public SudGameDateModel getSudGameDateModel() { + return sudGameDateModel; + } + + public EnterRoomNewModel setSudGameDateModel(SudGameDateModel sudGameDateModel) { + this.sudGameDateModel = sudGameDateModel; + return this; + } public String getSudGameRoomName() { return sudGameRoomName; diff --git a/common/src/main/java/com/yunbao/common/bean/SudGameDateModel.java b/common/src/main/java/com/yunbao/common/bean/SudGameDateModel.java new file mode 100644 index 000000000..eb28839e4 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/SudGameDateModel.java @@ -0,0 +1,175 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.SerializedName; + +public class SudGameDateModel extends BaseModel{ + + @SerializedName("room_holder_id") + private String roomHolderId; + @SerializedName("sex") + private String sex; + @SerializedName("golden_bean_number") + private String goldenBeanNumber; + + @SerializedName("room_holder_type") + private String roomHolderType; + @SerializedName("sud_game_id") + private String sudGameId; + @SerializedName("room_status") + private String roomStatus; + @SerializedName("sud_game_name") + private String sudGameName; + @SerializedName("room_name") + private String roomName; + @SerializedName("player_total") + private String playerTotal; + @SerializedName("sud_game_icon") + private String sudGameIcon; + @SerializedName("room_holder_name") + private String roomHolderName; + @SerializedName("sud_game_room_id") + private String sudGameRoomId; + @SerializedName("ob_total") + private String obTotal; + @SerializedName("avatar") + private String avatar; + @SerializedName("liveuid") + private String liveuid; + + public String getRoomHolderId() { + return roomHolderId; + } + + public SudGameDateModel setRoomHolderId(String roomHolderId) { + this.roomHolderId = roomHolderId; + return this; + } + + public String getSex() { + return sex; + } + + public SudGameDateModel setSex(String sex) { + this.sex = sex; + return this; + } + + public String getGoldenBeanNumber() { + return goldenBeanNumber; + } + + public SudGameDateModel setGoldenBeanNumber(String goldenBeanNumber) { + this.goldenBeanNumber = goldenBeanNumber; + return this; + } + + + + public String getRoomHolderType() { + return roomHolderType; + } + + public SudGameDateModel setRoomHolderType(String roomHolderType) { + this.roomHolderType = roomHolderType; + return this; + } + + public String getSudGameId() { + return sudGameId; + } + + public SudGameDateModel setSudGameId(String sudGameId) { + this.sudGameId = sudGameId; + return this; + } + + public String getRoomStatus() { + return roomStatus; + } + + public SudGameDateModel setRoomStatus(String roomStatus) { + this.roomStatus = roomStatus; + return this; + } + + public String getSudGameName() { + return sudGameName; + } + + public SudGameDateModel setSudGameName(String sudGameName) { + this.sudGameName = sudGameName; + return this; + } + + public String getRoomName() { + return roomName; + } + + public SudGameDateModel setRoomName(String roomName) { + this.roomName = roomName; + return this; + } + + public String getPlayerTotal() { + return playerTotal; + } + + public SudGameDateModel setPlayerTotal(String playerTotal) { + this.playerTotal = playerTotal; + return this; + } + + public String getSudGameIcon() { + return sudGameIcon; + } + + public SudGameDateModel setSudGameIcon(String sudGameIcon) { + this.sudGameIcon = sudGameIcon; + return this; + } + + public String getRoomHolderName() { + return roomHolderName; + } + + public SudGameDateModel setRoomHolderName(String roomHolderName) { + this.roomHolderName = roomHolderName; + return this; + } + + public String getSudGameRoomId() { + return sudGameRoomId; + } + + public SudGameDateModel setSudGameRoomId(String sudGameRoomId) { + this.sudGameRoomId = sudGameRoomId; + return this; + } + + public String getObTotal() { + return obTotal; + } + + public SudGameDateModel setObTotal(String obTotal) { + this.obTotal = obTotal; + return this; + } + + public String getAvatar() { + return avatar; + } + + public SudGameDateModel setAvatar(String avatar) { + this.avatar = avatar; + return this; + } + + public String getLiveuid() { + return liveuid; + } + + public SudGameDateModel setLiveuid(String liveuid) { + this.liveuid = liveuid; + return this; + } +} diff --git a/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java b/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java index f573f278c..c90987dff 100644 --- a/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java +++ b/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java @@ -262,7 +262,7 @@ public class CommonHttpUtil { } }).build().show(); } else { - ToastUtil.show(CommonAppContext.getTopActivity().getString(R.string.net_error) + "code:" + code + " msg:" + msg); + ToastUtil.show(context.getString(R.string.net_error) + "code:" + code + " msg:" + msg); } } diff --git a/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java b/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java index b9e967df9..7d64a092c 100644 --- a/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java +++ b/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java @@ -1,5 +1,6 @@ package com.yunbao.common.manager; +import android.content.Context; import android.os.Handler; import android.os.Looper; import android.util.Log; @@ -52,29 +53,32 @@ public class OpenAdManager { if (list != null && list.isEmpty()) { return; } - if(CommonAppContext.getTopActivity()==null){ + Context context = CommonAppContext.getTopActivity(); + if (context == null) { + context = CommonAppContext.sInstance; + } + if (context == null) { return; } - LiveNetManager.get(CommonAppContext.getTopActivity()) - .activityPopup(new HttpCallback>() { - @Override - public void onSuccess(List data) { - if (data == null || data.isEmpty()) { - Log.i(TAG, "onSuccess: 没有数据"); - list = new ArrayList<>(); - return; - } - list = data; - if (isShow) { - show(TYPE_HOME, false); - } - } + LiveNetManager.get(context).activityPopup(new HttpCallback>() { + @Override + public void onSuccess(List data) { + if (data == null || data.isEmpty()) { + Log.i(TAG, "onSuccess: 没有数据"); + list = new ArrayList<>(); + return; + } + list = data; + if (isShow) { + show(TYPE_HOME, false); + } + } - @Override - public void onError(String error) { - System.err.println("弹框列表:" + error); - } - }); + @Override + public void onError(String error) { + System.err.println("弹框列表:" + error); + } + }); } @@ -163,15 +167,11 @@ public class OpenAdManager { } showMap.put(model.getId(), true); if (model.getModel() == OpenAdModel.MODEL_BOTTOM) { - new OpenAdBottomDialogPopup(CommonAppContext.getTopActivity(), model) - .setListener((bean, position) -> { - }) - .showDialog(); + new OpenAdBottomDialogPopup(CommonAppContext.getTopActivity(), model).setListener((bean, position) -> { + }).showDialog(); } else { - new OpenAdCenterDialogPopup(CommonAppContext.getTopActivity(), model) - .setListener((bean, position) -> { - }) - .showDialog(); + new OpenAdCenterDialogPopup(CommonAppContext.getTopActivity(), model).setListener((bean, position) -> { + }).showDialog(); } } } diff --git a/common/src/main/java/com/yunbao/common/utils/ToastUtil.java b/common/src/main/java/com/yunbao/common/utils/ToastUtil.java index 80304292f..e0808c4af 100644 --- a/common/src/main/java/com/yunbao/common/utils/ToastUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/ToastUtil.java @@ -60,11 +60,19 @@ public class ToastUtil { /** * 显示黑底白字的提示 * - * @param content 内容 + * @param content 内容 * @param delayMillis 显示时间 毫秒 */ public static void showStyle(String content, long delayMillis) { - Dialog dialog = new Dialog(CommonAppContext.getTopActivity(), R.style.dialog); + Context context = CommonAppContext.getTopActivity(); + if (context == null) { + context = CommonAppContext.sInstance; + } + if (context == null) { + return; + } + + Dialog dialog = new Dialog(context, R.style.dialog); dialog.setContentView(R.layout.dialog_toast); dialog.setCancelable(false); dialog.setCanceledOnTouchOutside(false); @@ -79,14 +87,16 @@ public class ToastUtil { dialog.show(); new Handler(Looper.getMainLooper()).postDelayed(dialog::dismiss, delayMillis); } - public static void showDebug(String s){ - if(BuildConfig.DEBUG){ - show("开发模式:"+s); + + public static void showDebug(String s) { + if (BuildConfig.DEBUG) { + show("开发模式:" + s); } } - public static void showDebug(int s){ - if(BuildConfig.DEBUG){ - show("开发模式:"+s); + + public static void showDebug(int s) { + if (BuildConfig.DEBUG) { + show("开发模式:" + s); } } @@ -94,10 +104,10 @@ public class ToastUtil { if (TextUtils.isEmpty(s)) { return; } - Log.i("Toast", "Toast show: "+s); - Log.i("ts","ll"); - Toast.makeText(CommonAppContext.sInstance,s,Toast.LENGTH_SHORT).show(); - Log.i("ts","22"); + Log.i("Toast", "Toast show: " + s); + Log.i("ts", "ll"); + Toast.makeText(CommonAppContext.sInstance, s, Toast.LENGTH_SHORT).show(); + Log.i("ts", "22"); // long curTime = System.currentTimeMillis(); // if (curTime - sLastTime > 2000) { diff --git a/common/src/main/res/drawable/background_live_sud_hint.png b/common/src/main/res/drawable/background_live_sud_hint.png new file mode 100644 index 000000000..9b11c5af2 Binary files /dev/null and b/common/src/main/res/drawable/background_live_sud_hint.png differ diff --git a/config.gradle b/config.gradle index a4c1d2a21..808d3435f 100644 --- a/config.gradle +++ b/config.gradle @@ -9,9 +9,9 @@ ext { ] manifestPlaceholders = [ //正式、 - serverHost : "https://napi.yaoulive.com", +// serverHost : "https://napi.yaoulive.com", // 测试 -// serverHost : " https://ceshi.yaoulive.com", + serverHost : " https://ceshi.yaoulive.com", 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 ba2bc9010..3712281bc 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -777,9 +777,9 @@ public class LiveAudienceActivity extends LiveActivity { @Subscribe(threadMode = ThreadMode.MAIN) public void onLiveRoomChangeEvent(LiveRoomChangeEvent e) { - if (manager!=null&&manager.getsudGameMin()){ - ToastUtil.show(WordUtil.isNewZh()?"小遊戲進行中,無法切換直播間":"Game in progress, unable to switch to live room"); - }else { + if (manager != null && manager.getsudGameMin()) { + ToastUtil.show(WordUtil.isNewZh() ? "小遊戲進行中,無法切換直播間" : "Game in progress, unable to switch to live room"); + } else { LiveBean liveBean = e.getLiveBean(); if (TextUtils.equals(mLiveUid, liveBean.getUid())) { ToastUtil.show(mContext.getString(R.string.current_live_room)); @@ -808,7 +808,6 @@ public class LiveAudienceActivity extends LiveActivity { } - } @Override @@ -1542,7 +1541,7 @@ public class LiveAudienceActivity extends LiveActivity { break; case SUD_GAME_CREATE_ROOM: if (manager != null) { - manager.setSudName(event.getAvatar()); + manager.setSudName(event.getAvatar(), event.getCreateSudRoomModel()); } break; 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 653cf3dd2..fbffbf9d8 100644 --- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java +++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java @@ -5,11 +5,13 @@ import com.yunbao.common.bean.ActiveModel; import com.yunbao.common.bean.AiAutomaticSpeechModel; import com.yunbao.common.bean.AnchorRecommendItemModel; import com.yunbao.common.bean.BaseModel; +import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.MsgModel; import com.yunbao.common.bean.OlineUserlistModel; import com.yunbao.common.bean.RedPacketInfoModel; import com.yunbao.common.bean.RedPacketModel; +import com.yunbao.common.bean.SudGameDateModel; import com.yunbao.common.bean.WishModel; import com.yunbao.common.bean.XydCompleteModel; import com.yunbao.common.event.AllServerNotifyEvent; @@ -56,6 +58,25 @@ public class LiveAudienceEvent extends BaseModel { private boolean isPk; public String mStream; public String mLiveUid, giftId; + public SudGameDateModel createSudRoomModel; + + public SudGameDateModel getCreateSudRoomModel() { + return createSudRoomModel; + } + + public LiveAudienceEvent setCreateSudRoomModel(SudGameDateModel createSudRoomModel) { + this.createSudRoomModel = createSudRoomModel; + return this; + } + + public boolean isContactGift() { + return isContactGift; + } + + public LiveAudienceEvent setContactGift(boolean contactGift) { + isContactGift = contactGift; + return this; + } public String getGiftId() { return giftId; diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java index 6d72f9f58..ada6fc712 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java @@ -31,6 +31,7 @@ import com.yunbao.common.bean.PkRankBean; import com.yunbao.common.bean.RedPacketInfoModel; import com.yunbao.common.bean.RedPacketModel; import com.yunbao.common.bean.SocketModel; +import com.yunbao.common.bean.SudGameDateModel; import com.yunbao.common.bean.UserBean; import com.yunbao.common.bean.WishModel; import com.yunbao.common.bean.XydCompleteModel; @@ -753,7 +754,8 @@ public class SocketRyClient { case "SudGameCreateRoom": Bus.get().post(new LiveAudienceEvent() .setType(LiveAudienceEvent.LiveAudienceType.SUD_GAME_CREATE_ROOM) - .setAvatar(map.getString("room_name"))); + .setAvatar(map.getString("room_name")) + .setCreateSudRoomModel(GsonUtils.fromJson(map.toString(), SudGameDateModel.class))); break; } 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 569ca21f7..240a922f9 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -67,6 +67,7 @@ import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.bean.AiAutomaticSpeechModel; import com.yunbao.common.bean.BannerBean; import com.yunbao.common.bean.BaseModel; +import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.FansCheckRed; import com.yunbao.common.bean.GiftModel; import com.yunbao.common.bean.GuardUserModel; @@ -90,6 +91,7 @@ import com.yunbao.common.bean.RedPacketInfoModel; import com.yunbao.common.bean.RedPacketModel; import com.yunbao.common.bean.RewardAllModel; import com.yunbao.common.bean.StarChallengeStatusModel; +import com.yunbao.common.bean.SudGameDateModel; import com.yunbao.common.bean.TaskModel; import com.yunbao.common.bean.UserBean; import com.yunbao.common.bean.WishModel; @@ -128,6 +130,7 @@ import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.common.utils.formatBigNum; import com.yunbao.common.views.AbsViewHolder; +import com.yunbao.common.views.LiveSudGamePopup; import com.yunbao.common.views.weight.ClipPathCircleImage; import com.yunbao.common.views.weight.FullServiceNotificationView; import com.yunbao.common.views.weight.NobleNoticeView; @@ -636,26 +639,39 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } private TextView sud_text_name; + private LinearLayout sud_layout_name; private Handler sudNameHandler = new Handler(); private Runnable sudNameRunnable = new Runnable() { @Override public void run() { - if (sud_text_name != null) { - sud_text_name.setVisibility(View.GONE); + if (sud_layout_name != null) { + sud_layout_name.setVisibility(View.GONE); } } }; - public void setSudName(String sudName) { - sud_text_name = (TextView) findViewById(com.yunbao.common.R.id.sud_text_name); + public void setSudName(String sudName, SudGameDateModel sudGameDateModel) { + sud_text_name = (TextView) findViewById(R.id.sud_text_name); + sud_layout_name = (LinearLayout) findViewById(R.id.sud_layout_name); sud_text_name.setText(WordUtil.isNewZh() ? String.format("主播创建了【%s】房间,快来与主播同玩~", sudName) : String.format("The anchor has created a 【%s】 room. Come and play with the anchor~", sudName)); - sud_text_name.setVisibility(View.VISIBLE); - ViewClicksAntiShake.clicksAntiShake(sud_text_name, new ViewClicksAntiShake.ViewClicksCallBack() { + sud_layout_name.setVisibility(View.VISIBLE); + ViewClicksAntiShake.clicksAntiShake(sud_layout_name, new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { - sud_text_name.setVisibility(View.GONE); + CreateSudRoomModel createSudRoomModel = new CreateSudRoomModel(); + createSudRoomModel.setSudGameId(sudGameDateModel.getSudGameId()); + createSudRoomModel.setSudGameRoomId(sudGameDateModel.getSudGameRoomId()); + createSudRoomModel.setAvatar(sudGameDateModel.getAvatar()); + createSudRoomModel.setRoomName(sudGameDateModel.getRoomName()); + createSudRoomModel.setSudGameName(sudGameDateModel.getSudGameName()); + new XPopup.Builder(mContext) + .enableDrag(false) + .dismissOnTouchOutside(false) + .dismissOnBackPressed(false) + .asCustom(new LiveSudGamePopup(mContext, createSudRoomModel)) + .show(); } }); sudNameHandler.removeCallbacks(sudNameRunnable); diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index 67d42ffbf..4264096d6 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -45,6 +45,7 @@ import com.yunbao.common.bean.MsgModel; import com.yunbao.common.bean.RedPacketInfoModel; import com.yunbao.common.bean.RedPacketModel; import com.yunbao.common.bean.StarChallengeStatusModel; +import com.yunbao.common.bean.SudGameDateModel; import com.yunbao.common.bean.UserBean; import com.yunbao.common.bean.WishModel; import com.yunbao.common.bean.XydCompleteModel; @@ -721,7 +722,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveRoomViewHolder.hindeRedPacket(); } if (TextUtils.equals(data.getSudGameRoomStatus(), "1")) { - mLiveRoomViewHolder.setSudName(data.getSudGameRoomName()); + mLiveRoomViewHolder.setSudName(data.getSudGameRoomName(), data.getSudGameDateModel()); } } @@ -1968,9 +1969,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } } - public void setSudName(String sudName) { + public void setSudName(String sudName, SudGameDateModel sudGameDateModel) { if (mLiveRoomViewHolder != null) { - mLiveRoomViewHolder.setSudName(sudName); + mLiveRoomViewHolder.setSudName(sudName, sudGameDateModel); } } diff --git a/live/src/main/res/layout/view_live_room.xml b/live/src/main/res/layout/view_live_room.xml index 2995e1eb0..556ee4257 100644 --- a/live/src/main/res/layout/view_live_room.xml +++ b/live/src/main/res/layout/view_live_room.xml @@ -2478,21 +2478,31 @@ android:layout_marginTop="80dp" app:autoPlay="true" /> - + android:layout_marginEnd="42dp" + android:paddingStart="21dp" + android:visibility="gone" + android:paddingEnd="15dp"> + + + +