diff --git a/app/build.gradle b/app/build.gradle index 22fa13570..86c0d5ed6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -111,7 +111,7 @@ android { applicationVariants.all { variant -> println "清空build文件夹"; for (final def project in rootProject.getAllprojects()) { - delete project.buildDir +// delete project.buildDir println project.buildDir } String variantName = variant.name.capitalize() diff --git a/app/src/main/java/com/shayu/phonelive/AppContext.java b/app/src/main/java/com/shayu/phonelive/AppContext.java index 695b8c42e..6dea8b7ed 100644 --- a/app/src/main/java/com/shayu/phonelive/AppContext.java +++ b/app/src/main/java/com/shayu/phonelive/AppContext.java @@ -19,6 +19,8 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.alibaba.android.arouter.launcher.ARouter; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.blankj.utilcode.util.Utils; import com.facebook.appevents.AppEventsLogger; import com.fm.openinstall.OpenInstall; @@ -34,6 +36,7 @@ import com.yunbao.common.BuildConfig; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppContext; import com.yunbao.common.Constants; +import com.yunbao.common.bean.AnchorStartLiveBean; import com.yunbao.common.bean.CrashSaveBean; import com.yunbao.common.manager.imrongcloud.InstructorSendReward; import com.yunbao.common.manager.imrongcloud.InstructorSendRewardProvider; @@ -44,6 +47,7 @@ import com.yunbao.common.utils.AppManager; import com.yunbao.common.utils.L; import com.yunbao.common.utils.SpUtil; import com.yunbao.common.utils.ToastUtil; +import com.yunbao.live.socket.SocketReceiveBean; import com.yunbao.live.socket.SocketRyClient; import com.yunbao.live.utils.LiveImDeletUtil; import com.yunbao.live.views.PortraitLiveManager; @@ -201,11 +205,16 @@ public class AppContext extends CommonAppContext { && (TextUtils.equals("__system__", message.getTargetId()) || ("g" + PortraitLiveManager.liveID).contains(message.getTargetId()))) { SocketRyClient.mSocketHandler.sendMessage(msg); + } else if (content.getContent().contains("LivePK_anchorStartLiveNotify")) {//开播通知 + SocketReceiveBean received = JSON.parseObject(content.getContent(), SocketReceiveBean.class); + JSONObject map = received.getMsg().getJSONObject(0); + sendStartAnchorLive(map); } //主播页面 if (TextUtils.isEmpty(PortraitLiveManager.liveID) && SocketRyClient.mSocketHandler != null) { SocketRyClient.mSocketHandler.sendMessage(msg); } + } else if (message.getConversationType() == Conversation.ConversationType.PRIVATE) {//私聊信息 EventBus.getDefault().post(message); } @@ -215,6 +224,14 @@ public class AppContext extends CommonAppContext { } return false; } + + private void sendStartAnchorLive(JSONObject map) { + AnchorStartLiveBean bean = new AnchorStartLiveBean(); + bean.setAnchorName(map.getString("anchorName")); + bean.setRoomId(map.getString("roomid")); + bean.setAvatar(map.getString("avatar")); + EventBus.getDefault().post(bean); + } }); diff --git a/common/src/main/java/com/yunbao/common/bean/AnchorStartLiveBean.java b/common/src/main/java/com/yunbao/common/bean/AnchorStartLiveBean.java new file mode 100644 index 000000000..ab3160f99 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/AnchorStartLiveBean.java @@ -0,0 +1,31 @@ +package com.yunbao.common.bean; + +public class AnchorStartLiveBean extends BaseModel{ + private String anchorName; + private String avatar; + private String roomId; + + public String getAnchorName() { + return anchorName; + } + + public void setAnchorName(String anchorName) { + this.anchorName = anchorName; + } + + public String getAvatar() { + return avatar; + } + + public void setAvatar(String avatar) { + this.avatar = avatar; + } + + public String getRoomId() { + return roomId; + } + + public void setRoomId(String roomId) { + this.roomId = roomId; + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/FansGroupGiftPack.java b/common/src/main/java/com/yunbao/common/bean/FansGroupGiftPack.java new file mode 100644 index 000000000..963525449 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/FansGroupGiftPack.java @@ -0,0 +1,81 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.SerializedName; + +public class FansGroupGiftPack extends BaseModel{ + @SerializedName("id") + private int id; + @SerializedName("quantity") + private int quantity; + @SerializedName("end_time") + private String endTime; + @SerializedName("giftname") + private String giftName; + @SerializedName("needcoin") + private String needCoin; + @SerializedName("gifticon") + private String icon; + + public FansGroupGiftPack() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getQuantity() { + return quantity; + } + + public void setQuantity(int quantity) { + this.quantity = quantity; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getGiftName() { + return giftName; + } + + public void setGiftName(String giftName) { + this.giftName = giftName; + } + + public String getNeedCoin() { + return needCoin; + } + + public void setNeedCoin(String needCoin) { + this.needCoin = needCoin; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + @Override + public String toString() { + return "FansGroupGiftPack{" + + "id=" + id + + ", quantity=" + quantity + + ", endTime='" + endTime + '\'' + + ", giftName='" + giftName + '\'' + + ", needCoin='" + needCoin + '\'' + + ", icon='" + icon + '\'' + + '}'; + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/FansGroupGiftPackInfo.java b/common/src/main/java/com/yunbao/common/bean/FansGroupGiftPackInfo.java new file mode 100644 index 000000000..c1a132ead --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/FansGroupGiftPackInfo.java @@ -0,0 +1,150 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +public class FansGroupGiftPackInfo extends BaseModel { + @SerializedName("id") + private int id; + @SerializedName("description") + private String description; + @SerializedName("coin") + private String coin; + @SerializedName("data") + private List data; + + public FansGroupGiftPackInfo() { + } + + public int getId() { + return id; + } + + public String getCoin() { + return coin; + } + + public void setCoin(String coin) { + this.coin = coin; + } + + public void setId(int id) { + this.id = id; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + @Override + public String toString() { + return "FansGroupGiftPack{" + + "id=" + id + + ", description='" + description + '\'' + + ", coin='" + coin + '\'' + + ", data=" + data + + '}'; + } + + public static class Gift { + @SerializedName("id") + private int id; + @SerializedName("name") + private String giftName; + @SerializedName("needcoin") + private String needCoin; + @SerializedName("src") + private String giftIcon; + @SerializedName("quantity") + private String quantity; + @SerializedName("restrict") + private int restrict; + @SerializedName("type") + private int type; + + public Gift() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getGiftName() { + return giftName; + } + + public void setGiftName(String giftName) { + this.giftName = giftName; + } + + public String getNeedCoin() { + return needCoin; + } + + public void setNeedCoin(String needCoin) { + this.needCoin = needCoin; + } + + public String getGiftIcon() { + return giftIcon; + } + + public void setGiftIcon(String giftIcon) { + this.giftIcon = giftIcon; + } + + public String getQuantity() { + return quantity; + } + + public void setQuantity(String quantity) { + this.quantity = quantity; + } + + public int getRestrict() { + return restrict; + } + + public void setRestrict(int restrict) { + this.restrict = restrict; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + @Override + public String toString() { + return "Gift{" + + "id=" + id + + ", giftName='" + giftName + '\'' + + ", needCoin='" + needCoin + '\'' + + ", giftIcon='" + giftIcon + '\'' + + ", quantity='" + quantity + '\'' + + ", restrict='" + restrict + '\'' + + ", type=" + type + + '}'; + } + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/LiveGiftBean.java b/common/src/main/java/com/yunbao/common/bean/LiveGiftBean.java index 5047d7c1b..dbeebfe14 100644 --- a/common/src/main/java/com/yunbao/common/bean/LiveGiftBean.java +++ b/common/src/main/java/com/yunbao/common/bean/LiveGiftBean.java @@ -191,6 +191,16 @@ public class LiveGiftBean { return this; } + private int fansGiftLevel=0;//粉丝团礼物等级要求 + + public int getFansGiftLevel() { + return fansGiftLevel; + } + + public void setFansGiftLevel(int fansGiftLevel) { + this.fansGiftLevel = fansGiftLevel; + } + public int getBlind_box_type() { return blind_box_type; } diff --git a/common/src/main/java/com/yunbao/common/bean/UserAvatarSelectBean.java b/common/src/main/java/com/yunbao/common/bean/UserAvatarSelectBean.java new file mode 100644 index 000000000..632dbc21a --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/UserAvatarSelectBean.java @@ -0,0 +1,46 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.SerializedName; + +public class UserAvatarSelectBean extends BaseModel { + @SerializedName("id") + private int id; + @SerializedName("name") + private String name; + @SerializedName("path") + private String path; + @SerializedName("checked") + private int checked; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public int getChecked() { + return checked; + } + + public void setChecked(int checked) { + this.checked = checked; + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/UserBean.java b/common/src/main/java/com/yunbao/common/bean/UserBean.java index 0577d6263..ca4c91489 100644 --- a/common/src/main/java/com/yunbao/common/bean/UserBean.java +++ b/common/src/main/java/com/yunbao/common/bean/UserBean.java @@ -68,6 +68,10 @@ public class UserBean implements Parcelable { private String mRankPkImgUrl; //是否填写完整资料 private int user_info_complete; + //粉丝团等级 + private int fansLevel; + //粉丝团进场皮肤 + private String fansEnterRoomUrl; public int getUserInfoComplete() { return user_info_complete; @@ -78,6 +82,22 @@ public class UserBean implements Parcelable { return this; } + public int getFansLevel() { + return fansLevel; + } + + public void setFansLevel(int fansLevel) { + this.fansLevel = fansLevel; + } + + public String getFansEnterRoomUrl() { + return fansEnterRoomUrl; + } + + public void setFansEnterRoomUrl(String fansEnterRoomUrl) { + this.fansEnterRoomUrl = fansEnterRoomUrl; + } + public boolean isRandomPk() { return randomPk; } diff --git a/common/src/main/java/com/yunbao/common/dialog/AbsDialogCenterPopupWindow.java b/common/src/main/java/com/yunbao/common/dialog/AbsDialogCenterPopupWindow.java new file mode 100644 index 000000000..b0b894576 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/dialog/AbsDialogCenterPopupWindow.java @@ -0,0 +1,39 @@ +package com.yunbao.common.dialog; + +import android.content.Context; + +import androidx.annotation.NonNull; + +import com.lxj.xpopup.XPopup; +import com.lxj.xpopup.core.CenterPopupView; + +/** + * 居中弹窗 + */ +public abstract class AbsDialogCenterPopupWindow extends CenterPopupView { + public final Context mContext; + + public AbsDialogCenterPopupWindow(@NonNull Context context) { + super(context); + this.mContext = context; + } + + /** + * 参考配置 + */ + public abstract void buildDialog(XPopup.Builder builder); + public abstract int bindLayoutId(); + + @Override + protected int getImplLayoutId() { + return bindLayoutId(); + } + + public void showDialog() { + XPopup.Builder builder = new XPopup.Builder(mContext); + builder.isDestroyOnDismiss(true); + builder.enableDrag(false); + buildDialog(builder); + builder.asCustom(this).show(); + } +} diff --git a/common/src/main/java/com/yunbao/common/dialog/AbsDialogPopupWindow.java b/common/src/main/java/com/yunbao/common/dialog/AbsDialogPopupWindow.java index c74e3ea45..be1adad33 100644 --- a/common/src/main/java/com/yunbao/common/dialog/AbsDialogPopupWindow.java +++ b/common/src/main/java/com/yunbao/common/dialog/AbsDialogPopupWindow.java @@ -7,9 +7,11 @@ import androidx.annotation.NonNull; import com.lxj.xpopup.XPopup; import com.lxj.xpopup.core.BottomPopupView; - +/** + * 底部弹窗 + */ public abstract class AbsDialogPopupWindow extends BottomPopupView { - private final Context mContext; + public final Context mContext; public AbsDialogPopupWindow(@NonNull Context context) { super(context); diff --git a/common/src/main/java/com/yunbao/common/dialog/AbsDialogPositionPopupWindow.java b/common/src/main/java/com/yunbao/common/dialog/AbsDialogPositionPopupWindow.java new file mode 100644 index 000000000..ad87d8f7a --- /dev/null +++ b/common/src/main/java/com/yunbao/common/dialog/AbsDialogPositionPopupWindow.java @@ -0,0 +1,39 @@ +package com.yunbao.common.dialog; + +import android.content.Context; + +import androidx.annotation.NonNull; + +import com.lxj.xpopup.XPopup; +import com.lxj.xpopup.core.PositionPopupView; + +/** + * 自定义位置弹窗 + */ +public abstract class AbsDialogPositionPopupWindow extends PositionPopupView { + public final Context mContext; + + public AbsDialogPositionPopupWindow(@NonNull Context context) { + super(context); + this.mContext = context; + } + + /** + * 参考配置 + */ + public abstract void buildDialog(XPopup.Builder builder); + public abstract int bindLayoutId(); + + @Override + protected int getImplLayoutId() { + return bindLayoutId(); + } + + public void showDialog() { + XPopup.Builder builder = new XPopup.Builder(mContext); + builder.isDestroyOnDismiss(true); + builder.enableDrag(false); + buildDialog(builder); + builder.asCustom(this).show(); + } +} diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index 4ba053a05..8779c4866 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -12,6 +12,8 @@ import com.yunbao.common.bean.CustomSidebarInfoModel; import com.yunbao.common.bean.DiscountsModel; import com.yunbao.common.bean.EnterRoomNewModel; import com.yunbao.common.bean.FaceBookUpModel; +import com.yunbao.common.bean.FansGroupGiftPack; +import com.yunbao.common.bean.FansGroupGiftPackInfo; import com.yunbao.common.bean.GiftAlreadyWallModel; import com.yunbao.common.bean.GiftGuideModel; import com.yunbao.common.bean.GiftWallGiftDetail; @@ -50,6 +52,7 @@ import com.yunbao.common.bean.SetAttentsModel; import com.yunbao.common.bean.SlideInBannerModel; import com.yunbao.common.bean.StarChallengeStatusModel; import com.yunbao.common.bean.UserAreaBean; +import com.yunbao.common.bean.UserAvatarSelectBean; import com.yunbao.common.bean.VipModel; import com.yunbao.common.bean.WishListGiftConfModel; import com.yunbao.common.bean.WishListModel; @@ -835,6 +838,22 @@ public interface PDLiveApi { @Query("red_packet_id") String redPacketId ); + /** + * 获取系统默认头像列表 + */ + @GET("/api/public/?service=Userhome.getDefaultAvatarList") + Observable>> getSystemUserAvatar(); + + /** + * 设置系统默认头像 + * + * @param id 头像id + */ + @GET("/api/public/?service=Userhome.setAvatar") + Observable> setSystemUserAvatar( + @Query("avatar_id") int id + ); + /** * 礼物墙已点亮 */ @@ -897,6 +916,32 @@ public interface PDLiveApi { Observable> getUserMedalList(@Query("to_uid") String toUid); @GET("/api/public/?service=Gift.getLiveMedalList") - Observable> getLiveMedalList( @Query("liveuid") String liveUid); + Observable> getLiveMedalList(@Query("liveuid") String liveUid); + + /** + * 获取粉丝团礼物信息 + * @param packId 礼包id + */ + @GET("/api/public/?service=Fans.getFansExclusivePack") + Observable> getFansExclusivePack(@Query("liveuid") String liveUid, + @Query("pack_id") String packId + ); + + /** + * 购买粉丝团礼包 + * @param packId 礼包id + */ + @GET("/api/public/?service=Fans.buyFansExclusivePack") + Observable> buyFansExclusivePack(@Query("liveuid") String liveUid, + @Query("pack_id") String packId, + @Query("stream") String stream + ); + + /** + * 获取粉丝团礼物包裹 + */ + @GET("/api/public/?service=Fans.userFansExclusivePackList") + Observable>> userFansExclusivePackList(@Query("liveuid") String liveUid); + } diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index da51979a1..aeeb32a15 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -13,6 +13,8 @@ import com.yunbao.common.bean.CheckLiveModel; import com.yunbao.common.bean.CustomSidebarInfoModel; import com.yunbao.common.bean.DiscountsModel; import com.yunbao.common.bean.EnterRoomNewModel; +import com.yunbao.common.bean.FansGroupGiftPack; +import com.yunbao.common.bean.FansGroupGiftPackInfo; import com.yunbao.common.bean.GiftAlreadyWallModel; import com.yunbao.common.bean.GiftGuideModel; import com.yunbao.common.bean.GiftWallGiftDetail; @@ -46,6 +48,7 @@ import com.yunbao.common.bean.RedPacketListBean; import com.yunbao.common.bean.SetAttentsModel; import com.yunbao.common.bean.StarChallengeStatusModel; import com.yunbao.common.bean.UserAreaBean; +import com.yunbao.common.bean.UserAvatarSelectBean; import com.yunbao.common.bean.VipModel; import com.yunbao.common.bean.WishListGiftConfModel; import com.yunbao.common.bean.WishListModel; @@ -63,7 +66,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.functions.Consumer; import io.reactivex.schedulers.Schedulers; -import retrofit2.http.Query; /** @@ -1802,6 +1804,54 @@ public class LiveNetManager { }).isDisposed(); } + public void getSystemUserAvatar(HttpCallback> callback) { + API.get().pdLiveApi(mContext) + .getSystemUserAvatar() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>>() { + @Override + public void accept(ResponseModel> objectResponseModel) throws Exception { + if (objectResponseModel.getData().getCode() == 0) { + callback.onSuccess(objectResponseModel.getData().getInfo()); + } else { + callback.onError(objectResponseModel.getData().getMsg()); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + + public void setSystemUserAvatar(int id, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .setSystemUserAvatar(id) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>() { + @Override + public void accept(ResponseModel objectResponseModel) throws Exception { + if (objectResponseModel.getData().getCode() == 0) { + callback.onSuccess(objectResponseModel.getData().getMsg()); + } else { + callback.onError(objectResponseModel.getData().getMsg()); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + public void giftAlreadyWall(String liveUid, String toUid, HttpCallback callback) { API.get().pdLiveApi(mContext) .giftAlreadyWall(liveUid, toUid) @@ -1978,7 +2028,7 @@ public class LiveNetManager { }).isDisposed(); } - public void getLiveMedalList( String liveUid,HttpCallback callback) { + public void getLiveMedalList(String liveUid, HttpCallback callback) { API.get().pdLiveApi(mContext) .getLiveMedalList(liveUid) .subscribeOn(Schedulers.io()) @@ -2000,6 +2050,72 @@ public class LiveNetManager { }).isDisposed(); } + public void getFansExclusivePack(String liveUid, String packId, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .getFansExclusivePack(liveUid, packId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>() { + @Override + public void accept(ResponseModel listResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(listResponseModel.getData().getInfo()); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + + public void buyFansExclusivePack(String liveUid, String packId,String stream, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .buyFansExclusivePack(liveUid, packId,stream) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>() { + @Override + public void accept(ResponseModel listResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(listResponseModel.getData().getInfo()); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + + public void userFansExclusivePackList(String liveUid, HttpCallback> callback) { + API.get().pdLiveApi(mContext) + .userFansExclusivePackList(liveUid) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>>() { + @Override + public void accept(ResponseModel> listResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(listResponseModel.getData().getInfo()); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + /** * 直播间取消网络请求 */ 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 0b00dabcf..73ea85e0c 100644 --- a/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java +++ b/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java @@ -47,6 +47,7 @@ public class IMLoginManager extends BaseCacheManager { private final String keyDefaultBubbleUrl = "defaultBubbleUrl"; private final String STATUS_ANCHOR_SAY = "anchorSay"; private final String STATUS_ANCHOR_CALL = "anchorCallMe"; + private final String LIVE_NOTIFY_SETTINGS = "liveNotifySettings";//开播通知 private final String KEY_LANGUAGE = "language"; @@ -354,6 +355,14 @@ public class IMLoginManager extends BaseCacheManager { return getBoolean(GiftEffect, !(Build.VERSION.SDK_INT < Build.VERSION_CODES.O)); } + public void setLiveNotifySettings(boolean isTrue) { + put(LIVE_NOTIFY_SETTINGS, isTrue); + } + + public boolean isLiveNotifySettings() { + return getBoolean(LIVE_NOTIFY_SETTINGS, true); + } + /** * 重新请求管理员身份信息 */ diff --git a/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java b/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java index 41e336e9f..5d2a9412e 100644 --- a/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java +++ b/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java @@ -548,6 +548,21 @@ public class JavascriptInterfaceUtils { Bus.get().post(new JavascriptInterfaceEvent() .setMethod("clickLogOffAccount")); } + @JavascriptInterface + public void androidFansGroupBuy(String id){ + Bus.get().post(new JavascriptInterfaceEvent() + .setMethod("androidFansGroupBuy").setUserId(id)); + } + @JavascriptInterface + public void androidFansGroupPack(){ + Bus.get().post(new JavascriptInterfaceEvent() + .setMethod("androidFansGroupPack")); + } + @JavascriptInterface + public void androidFansGroupInfo(){ + Bus.get().post(new JavascriptInterfaceEvent() + .setMethod("androidFansGroupInfo")); + } @JavascriptInterface public void toGiftNamingAlertAllPageView(String mAnchorName, String mLiveUid, String mAvatarUrl,int isAnchor ) { diff --git a/common/src/main/java/com/yunbao/common/utils/RouteUtil.java b/common/src/main/java/com/yunbao/common/utils/RouteUtil.java index 6f4a5d408..79eb53702 100644 --- a/common/src/main/java/com/yunbao/common/utils/RouteUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/RouteUtil.java @@ -44,6 +44,7 @@ public class RouteUtil { public static final String PATH_RED_PACKET_LIST = "/main/RedPacketListActivity"; public static final String PATH_RED_PACKET_INFO = "/main/RedPacketInfoActivity"; public static final String PATH_RED_PACKET_USER = "/main/RedPacketUsersActivity"; + public static final String PATH_SELECT_AVATAR="/main/UserAvatarSelectActivity"; public static void forwardFansActivity(String uid) { ARouter.getInstance().build(PATH_FANSACTIVITY) @@ -306,4 +307,12 @@ public class RouteUtil { .withInt("id", id) .navigation(); } + + /** + * 系统头像选择 + */ + public static void forwardUserAvatarSelect(){ + ARouter.getInstance().build(PATH_SELECT_AVATAR) + .navigation(); + } } diff --git a/common/src/main/res/values-en-rUS/string.xml b/common/src/main/res/values-en-rUS/string.xml index 27efda746..4092efa4c 100644 --- a/common/src/main/res/values-en-rUS/string.xml +++ b/common/src/main/res/values-en-rUS/string.xml @@ -62,7 +62,7 @@ ModifyName Modify remarks Please enter comments~ - Signature modification + Signature autograph Binding phone TASK1 @@ -754,8 +754,8 @@ Encourage the author of this dynamic article Confirm encouragement - Dynamic encouragement - Encouraging records + Rewards + Records The author hasn\'t given encouragement yet T_T @@ -1249,6 +1249,11 @@ Limited ride And limited avatar frame %s drew %s in the lucky red envelope number Red successfully + Select System Avatar + This function needs to be used to use it after lv.5, please work hard to upgrade ~ + No matter where you are, I am waiting for you in the live broadcast room ~ + Watch + LiveNotify %s experience upgrade,%s receive rewards You have reached the highest level! There\'s nothing in the package yet diff --git a/common/src/main/res/values-zh-rHK/strings.xml b/common/src/main/res/values-zh-rHK/strings.xml index 09981e324..779e9508f 100644 --- a/common/src/main/res/values-zh-rHK/strings.xml +++ b/common/src/main/res/values-zh-rHK/strings.xml @@ -1244,6 +1244,12 @@ " %s 在 好運紅包 中抽到了 %s" 数量 红包发布成功 + 選擇系統頭像 + 該功能需升至Lv.5后使用,請努力升級吧~ + 無論你在哪裏,我都在直播間等你~ + 围观 + 開播通知 + 升級還需%s經驗值,升至%s即可領取獎勵 恭喜,你已達到最高等級 包裹中暫無物品哦 diff --git a/common/src/main/res/values-zh-rTW/strings.xml b/common/src/main/res/values-zh-rTW/strings.xml index 8858a2d4e..d8411b0e9 100644 --- a/common/src/main/res/values-zh-rTW/strings.xml +++ b/common/src/main/res/values-zh-rTW/strings.xml @@ -1243,6 +1243,12 @@ " %s 在 好運紅包 中抽到了 %s" 数量 红包发布成功 + 選擇系統頭像 + 該功能需升至Lv.5后使用,請努力升級吧~ + 無論你在哪裏,我都在直播間等你~ + 围观 + 開播通知 + 升級還需%s經驗值,升至%s即可領取獎勵 恭喜,你已達到最高等級 包裹中暫無物品哦 diff --git a/common/src/main/res/values-zh/strings.xml b/common/src/main/res/values-zh/strings.xml index 204907bf2..76445da00 100644 --- a/common/src/main/res/values-zh/strings.xml +++ b/common/src/main/res/values-zh/strings.xml @@ -1244,6 +1244,11 @@ " %s 在 好運紅包 中抽到了 %s" 数量 红包发布成功 + 選擇系統頭像 + 該功能需升至Lv.5后使用,請努力升級吧~ + 無論你在哪裏,我都在直播間等你~ + 围观 + 開播通知 升級還需%s經驗值,升至%s即可領取獎勵 恭喜,你已達到最高等級 包裹中暫無物品哦 diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index febbf66d5..44867ace4 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -62,7 +62,7 @@ ModifyName Modify remarks Please enter comments~ - Signature modification + Signature autograph Binding phone TASK1 @@ -754,8 +754,8 @@ Encourage the author of this dynamic article Confirm encouragement - Dynamic encouragement - Encouraging records + Rewards + Records The author hasn\'t given encouragement yet T_T @@ -1250,6 +1250,11 @@ Limited ride And limited avatar frame %s drew %s in the lucky red envelope number >Red successfully + Select System Avatar + This function needs to be used to use it after lv.5, please work hard to upgrade ~ + No matter where you are, I am waiting for you in the live broadcast room ~ + Watch + LiveNotify %s experience upgrade,%s receive rewards There\'s nothing in the package yet You have reached the highest level! 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 84dd06664..dd8c9d1a0 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java @@ -926,7 +926,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL if (!mIsAnchor) { UserBean u = CommonAppConfig.getInstance().getUserBean(); if (u != null && u.getLevel() < mDanMuLevel) { - ToastUtil.show(String.format(mContext.getString(R.string.live_level_danmu_limit), mDanMuLevel)); + ToastUtil.show(String.format(mContext.getString(R.string.live_level_danmu_limit), mDanMuLevel+"")); return; } } @@ -947,7 +947,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL onCoinChanged(coin); } String[] data = new String[]{obj.getString("barragetoken")}; - SocketRyChatUtil.sendDanmuMessage(mLiveUid, contents); + SocketRyChatUtil.sendDanmuMessage(mLiveUid, contents,obj.getIntValue("level_fans")); } else { ToastUtil.show(msg); } @@ -963,7 +963,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL if (!mIsAnchor) { UserBean u = CommonAppConfig.getInstance().getUserBean(); if (u != null && u.getLevel() < mChatLevel) { - ToastUtil.show(String.format(mContext.getString(R.string.live_level_chat_limit), mChatLevel)); + ToastUtil.show(String.format(mContext.getString(R.string.live_level_chat_limit), mChatLevel+"")); return; } } @@ -1277,6 +1277,9 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL } else { bundle.putString(Constants.URL, CommonAppConfig.HOST + "/h5/live/fansClub.html" + "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + uid); } + bundle.putString("liveUid",mLiveUid); + bundle.putString("anchorName",mAncherName); + bundle.putString("mStream",mStream); fragment.setArguments(bundle); fragment.show(getSupportFragmentManager(), "LiveGuardDialogFragment"); } 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 64b2b5eb4..3f9a323a4 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -1068,6 +1068,9 @@ public class LiveAudienceActivity extends LiveActivity { "?uid=" + userInfo.getId() + "&token=" + userInfo.getToken() + "&anchorUid=" + mLiveUid); } + bundle.putString("liveUid",mLiveUid); + bundle.putString("anchorName",mAncherName); + bundle.putString("mStream",mStream); liveFansFragment.setArguments(bundle); liveFansFragment.show(getSupportFragmentManager(), "LiveGuardDialogFragment"); break; 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 2ebb8c568..8d62f2e11 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java @@ -49,6 +49,7 @@ import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.SpUtil; +import com.yunbao.common.utils.StringUtil; import com.yunbao.common.views.weight.ClipPathCircleImage; import com.yunbao.live.R; import com.yunbao.live.activity.LiveAudienceActivity; @@ -499,6 +500,9 @@ public class LiveChatAdapter extends RecyclerView.Adapter { } } else if (bean.getType() == SYSTEM3_COLOR) { mTextView.setText(Html.fromHtml(bean.getContent())); + if (!StringUtil.isEmpty(bean.getBubble())) { + new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getBubble(), 1); + } } else { if (bean.getBubble() != null && !bean.getBubble().equals("")) { //加载.9图聊天气泡 diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveFansGroupBuyAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveFansGroupBuyAdapter.java new file mode 100644 index 000000000..7b09e750e --- /dev/null +++ b/live/src/main/java/com/yunbao/live/adapter/LiveFansGroupBuyAdapter.java @@ -0,0 +1,85 @@ +package com.yunbao.live.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.bean.FansGroupGiftPackInfo; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.live.R; + +import java.util.ArrayList; +import java.util.List; + +public class LiveFansGroupBuyAdapter extends RecyclerView.Adapter { + Context mContext; + List list = new ArrayList<>(); + + public LiveFansGroupBuyAdapter(Context mContext) { + this.mContext = mContext; + } + + public void setList(List list) { + this.list.clear(); + this.list = list; + notifyDataSetChanged(); + } + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_fans_group_buy_list, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + holder.setData(list.get(position)); + } + + @Override + public int getItemCount() { + return list.size(); + } + + public class ViewHolder extends RecyclerView.ViewHolder { + private ImageView giftIcon; + private TextView day; + private TextView title; + private TextView introduce; + private ImageView diamondIcon; + + public ViewHolder(@NonNull View itemView) { + super(itemView); + giftIcon = itemView.findViewById(R.id.giftIcon); + day = itemView.findViewById(R.id.day); + title = itemView.findViewById(R.id.title); + introduce = itemView.findViewById(R.id.introduce); + diamondIcon = itemView.findViewById(R.id.diamondIcon); + } + + public void setData(FansGroupGiftPackInfo.Gift gift) { + title.setText(gift.getGiftName()); + introduce.setText(gift.getNeedCoin()); + if (gift.getRestrict() > 0) { + day.setText(gift.getRestrict() + mContext.getString(R.string.bonus_day)); + day.setVisibility(View.VISIBLE); + }else{ + day.setVisibility(View.GONE); + } + try { + int i = Integer.parseInt(gift.getNeedCoin()); + diamondIcon.setVisibility(View.VISIBLE); + } catch (Exception e) { + diamondIcon.setVisibility(View.GONE); + } + + ImgLoader.display(mContext, gift.getGiftIcon(), giftIcon); + } + } +} diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveFansGroupSendGiftAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveFansGroupSendGiftAdapter.java new file mode 100644 index 000000000..2ec7d9ac5 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/adapter/LiveFansGroupSendGiftAdapter.java @@ -0,0 +1,88 @@ +package com.yunbao.live.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.bean.FansGroupGiftPack; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.views.weight.ViewClicksAntiShake; +import com.yunbao.live.R; +import com.yunbao.live.http.LiveHttpUtil; + +import java.util.ArrayList; +import java.util.List; + +public class LiveFansGroupSendGiftAdapter extends RecyclerView.Adapter { + Context mContext; + List list = new ArrayList<>(); + private OnItemClickListener onItemClickListener; + + + public LiveFansGroupSendGiftAdapter(Context mContext) { + this.mContext = mContext; + } + + public void setList(List list) { + this.list.clear(); + this.list = list; + notifyDataSetChanged(); + } + + public void setOnItemClickListener(OnItemClickListener onItemClickListener) { + this.onItemClickListener = onItemClickListener; + } + + @NonNull + @Override + public LiveFansGroupSendGiftAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new LiveFansGroupSendGiftAdapter.ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_fans_group_package_list, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull LiveFansGroupSendGiftAdapter.ViewHolder holder, int position) { + holder.setData(list.get(position)); + } + + @Override + public int getItemCount() { + return list.size(); + } + + + public class ViewHolder extends RecyclerView.ViewHolder { + private ImageView giftIcon; + private TextView day; + private TextView title; + private TextView send; + + public ViewHolder(@NonNull View itemView) { + super(itemView); + giftIcon = itemView.findViewById(R.id.giftIcon); + day = itemView.findViewById(R.id.day); + title = itemView.findViewById(R.id.title); + send = itemView.findViewById(R.id.send); + } + + public void setData(FansGroupGiftPack pack) { + if (pack.getQuantity() > 0) { + title.setText(pack.getGiftName()+" *"+pack.getQuantity()); + } else { + title.setText(pack.getGiftName()); + } + ImgLoader.display(mContext, pack.getIcon(), giftIcon); + ViewClicksAntiShake.clicksAntiShake(send, () -> { + if (onItemClickListener != null) { + onItemClickListener.onItemClick(pack, 0); + } + }); + } + } +} diff --git a/live/src/main/java/com/yunbao/live/bean/LiveDanMuBean.java b/live/src/main/java/com/yunbao/live/bean/LiveDanMuBean.java index 0394506cd..63bb433b8 100644 --- a/live/src/main/java/com/yunbao/live/bean/LiveDanMuBean.java +++ b/live/src/main/java/com/yunbao/live/bean/LiveDanMuBean.java @@ -15,6 +15,7 @@ public class LiveDanMuBean { private String userNiceName; private String avatar; private String content; + private int fensLevel; public String getUid() { return uid; @@ -64,4 +65,12 @@ public class LiveDanMuBean { public void setContent(String content) { this.content = content; } + + public int getFensLevel() { + return fensLevel; + } + + public void setFensLevel(int fensLevel) { + this.fensLevel = fensLevel; + } } diff --git a/live/src/main/java/com/yunbao/live/dialog/HighNobilityDialog.java b/live/src/main/java/com/yunbao/live/dialog/HighNobilityDialog.java index 176126632..79c89d915 100644 --- a/live/src/main/java/com/yunbao/live/dialog/HighNobilityDialog.java +++ b/live/src/main/java/com/yunbao/live/dialog/HighNobilityDialog.java @@ -30,7 +30,7 @@ public class HighNobilityDialog extends AbsDialogFragment { window.setWindowAnimations(R.style.bottomToTopAnim); WindowManager.LayoutParams params = window.getAttributes(); params.width = DpUtil.dp2px(340); - params.height = DpUtil.dp2px(360); + params.height = WindowManager.LayoutParams.WRAP_CONTENT; params.gravity = Gravity.CENTER; window.setAttributes(params); } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveContactDetailsSendGiftDialog.java b/live/src/main/java/com/yunbao/live/dialog/LiveContactDetailsSendGiftDialog.java new file mode 100644 index 000000000..be84c50ae --- /dev/null +++ b/live/src/main/java/com/yunbao/live/dialog/LiveContactDetailsSendGiftDialog.java @@ -0,0 +1,177 @@ +package com.yunbao.live.dialog; + +import static com.yunbao.common.utils.RouteUtil.PATH_COIN; + +import android.app.Dialog; +import android.content.Context; +import android.content.DialogInterface; +import android.text.Html; +import android.text.Spanned; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.alibaba.android.arouter.launcher.ARouter; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.lxj.xpopup.XPopup; +import com.yunbao.common.bean.LiveGiftBean; +import com.yunbao.common.dialog.AbsDialogPopupWindow; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.utils.DialogUitl; +import com.yunbao.common.views.weight.ViewClicksAntiShake; +import com.yunbao.live.R; +import com.yunbao.live.http.LiveHttpUtil; + +import java.util.ArrayList; +import java.util.List; + +public class LiveContactDetailsSendGiftDialog extends AbsDialogPopupWindow { + TextView title; + TextView giftName; + TextView diamond; + ImageView giftIcon; + View send; + + int giftId; + String anchorName; + private String mLiveUid; + private String mStream; + LiveGiftBean bean; + DialogInterface.OnDismissListener onDismissListener; + + public LiveContactDetailsSendGiftDialog(@NonNull Context context) { + super(context); + } + + public LiveContactDetailsSendGiftDialog setGiftId(int giftId) { + this.giftId = giftId; + return this; + } + + public LiveContactDetailsSendGiftDialog setLiveUid(String mLiveUid) { + this.mLiveUid = mLiveUid; + return this; + } + + public LiveContactDetailsSendGiftDialog setStream(String mStream) { + this.mStream = mStream; + return this; + } + + public LiveContactDetailsSendGiftDialog setAnchorName(String anchorName) { + this.anchorName = anchorName; + return this; + } + + public LiveContactDetailsSendGiftDialog setOnDismissListener(DialogInterface.OnDismissListener onDismissListener) { + this.onDismissListener = onDismissListener; + return this; + } + + @Override + public void buildDialog(XPopup.Builder builder) { + + } + + @Override + public int bindLayoutId() { + return R.layout.dialog_live_contact_details_gift; + } + + @Override + protected void onCreate() { + super.onCreate(); + findViewById(R.id.back).setOnClickListener(v -> dismiss()); + send = findViewById(R.id.send); + ViewClicksAntiShake.clicksAntiShake(send, this::send); + + title = findViewById(R.id.title); + giftIcon = findViewById(R.id.gift_icon); + giftName = findViewById(R.id.gift_name); + diamond = findViewById(R.id.diamond); + + initData(); + } + + private void initData() { + LiveHttpUtil.getNewGiftList(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + JSONObject obj = JSON.parseObject(info[0]); + JSONArray array = obj.getJSONArray("listarray"); + List list = new ArrayList<>(); + for (int i = 0; i < array.size(); i++) { + list.addAll(JSONArray.parseArray(array.getJSONObject(i).getJSONArray("giftlist").toJSONString(), LiveGiftBean.class)); + } + for (LiveGiftBean bean : list) { + if (bean.getId() == giftId) { + setData(bean); + break; + } + } + } + } + + @Override + public void onFinish() { + + } + }); + } + @Override + protected void onDismiss() { + super.onDismiss(); + if (onDismissListener != null) { + onDismissListener.onDismiss(null); + } + } + + private void setData(LiveGiftBean bean) { + this.bean = bean; + ImgLoader.display(mContext, bean.getIcon(), giftIcon); + diamond.setText(bean.getPrice()); + giftName.setText(bean.getName()); + Spanned spanned = Html.fromHtml( + "" + mContext.getString(R.string.live_details_sned_gift_text1) + "" + + " (" + bean.getName() + ") " + + "" + mContext.getString(R.string.live_details_sned_gift_text2) + "" + + " (" + anchorName + ")" + + "" + mContext.getString(R.string.live_details_sned_gift_text3) + "" + ); + title.setText(spanned); + } + + private void send() { + LiveHttpUtil.sendGift("0", mLiveUid, mStream, bean.getId(), "1", 1, new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 1001 || code == 1005) { + new DialogUitl.Builder(mContext) + .setView(R.layout.dialog_live_unfollow) + .setConfirmString(mContext.getString(R.string.charge)) + .setContent(mContext.getString(R.string.insufficient_balance)) + .setClickCallback(new DialogUitl.SimpleCallback() { + @Override + public void onConfirmClick(Dialog dialog, String content) { + LiveContactDetailsSendGiftDialog.this.dismiss(); + ARouter.getInstance().build(PATH_COIN).withInt("p", 0).navigation(); + } + }).build().show(); + } else { + dismiss(); + } + } + + @Override + public void onError() { + super.onError(); + } + }); + } +} diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveFansFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveFansFragment.java index 413d80a7e..4a1018d66 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveFansFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveFansFragment.java @@ -34,6 +34,9 @@ public class LiveFansFragment extends AbsDialogFragment { private WebView mWebView; private Activity mContext; + private String anchorName; + private String liveUid; + private String mStream; public LiveFansFragment(Activity mContext) { this.mContext = mContext; @@ -103,6 +106,9 @@ public class LiveFansFragment extends AbsDialogFragment { if (bundle == null) { return; } + anchorName = bundle.getString("anchorName"); + liveUid = bundle.getString("liveUid"); + mStream = bundle.getString("mStream"); Log.e("tag", bundle.getString(Constants.URL)); mWebView.loadUrl(bundle.getString(Constants.URL)); } @@ -126,10 +132,28 @@ public class LiveFansFragment extends AbsDialogFragment { } else if (TextUtils.equals(event.getMethod(), "sendFansCard")) { if (LiveRoomViewHolder.mBtnFollow != null && LiveRoomViewHolder.mBtnFollow.getVisibility() == View.VISIBLE) { LiveRoomViewHolder.follow(); + ToastUtil.show(R.string.live_fans_follow_toast); } //点击 开通粉丝勋章,打开礼物列表送礼物 ((LiveAudienceActivity) mContext).openGiftWindow(event.getLiveId(), "0"); dismiss(); + } else if (TextUtils.equals(event.getMethod(), "androidFansGroupBuy")) { + String id = event.getUserId(); + new LiveFansGroupBuyDialog(mContext) + .setGiftId(id) + .setAnchorName(anchorName) + .setLiveUid(liveUid) + .setSteam(mStream) + .showDialog(); + dismiss(); + } else if (TextUtils.equals(event.getMethod(), "androidFansGroupPack")) { + new LiveFansGroupSendGiftDialog(mContext) + .setLiveUid(liveUid) + .setStream(mStream) + .showDialog(); + dismiss(); + } else if (TextUtils.equals(event.getMethod(), "androidFansGroupInfo")) { + new LiveFansGroupInfoDialog(mContext).showDialog(); } } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveFansGroupBuyDialog.java b/live/src/main/java/com/yunbao/live/dialog/LiveFansGroupBuyDialog.java new file mode 100644 index 000000000..ba6059d5e --- /dev/null +++ b/live/src/main/java/com/yunbao/live/dialog/LiveFansGroupBuyDialog.java @@ -0,0 +1,118 @@ +package com.yunbao.live.dialog; + +import android.content.Context; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.lxj.xpopup.XPopup; +import com.yunbao.common.bean.FansGroupGiftPackInfo; +import com.yunbao.common.bean.HttpCallbackModel; +import com.yunbao.common.dialog.AbsDialogCenterPopupWindow; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.live.R; +import com.yunbao.live.adapter.LiveFansGroupBuyAdapter; + +public class LiveFansGroupBuyDialog extends AbsDialogCenterPopupWindow { + private TextView anchorName; + private TextView buy; + private TextView giftInfo; + private RecyclerView recyclerView; + private LiveFansGroupBuyAdapter adapter; + private String id; + private String name; + private String liveUid; + private String mSteam; + + public LiveFansGroupBuyDialog(@NonNull Context context) { + super(context); + } + + public LiveFansGroupBuyDialog setGiftId(String id) { + this.id = id; + return this; + } + + public LiveFansGroupBuyDialog setAnchorName(String anchorName) { + this.name = anchorName; + return this; + } + + public LiveFansGroupBuyDialog setLiveUid(String liveUid) { + this.liveUid = liveUid; + return this; + } + + public LiveFansGroupBuyDialog setSteam(String mSteam) { + this.mSteam = mSteam; + return this; + } + + @Override + public void buildDialog(XPopup.Builder builder) { + builder.popupWidth(DpUtil.dp2px(370)); + builder.maxWidth(DpUtil.dp2px(370)); + } + + @Override + public int bindLayoutId() { + return R.layout.dialog_fans_group_buy; + } + + @Override + protected void onCreate() { + super.onCreate(); + anchorName = findViewById(R.id.anchorName); + giftInfo = findViewById(R.id.giftInfo); + buy = findViewById(R.id.buy); + recyclerView = findViewById(R.id.giftList); + recyclerView.setLayoutManager(new LinearLayoutManager(mContext,LinearLayoutManager.HORIZONTAL,false){ + @Override + public boolean canScrollHorizontally() { + return false; + } + }); + adapter = new LiveFansGroupBuyAdapter(mContext); + recyclerView.setAdapter(adapter); + anchorName.setText(name); + buy.setOnClickListener(v -> { + LiveNetManager.get(mContext) + .buyFansExclusivePack(liveUid, id,mSteam, new HttpCallback() { + @Override + public void onSuccess(HttpCallbackModel data) { + ToastUtil.show(data.getMsg()); + dismiss(); + } + + @Override + public void onError(String error) { + + } + }); + }); + initData(); + } + + private void initData() { + LiveNetManager.get(mContext) + .getFansExclusivePack(liveUid, id, new HttpCallback() { + @Override + public void onSuccess(FansGroupGiftPackInfo data) { + adapter.setList(data.getData()); + giftInfo.setText(data.getDescription()); + buy.setText(String.format(mContext.getString(R.string.live_fans_group_buy_buy), data.getCoin())); + } + + @Override + public void onError(String error) { + + } + }); + } + +} diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveFansGroupInfoDialog.java b/live/src/main/java/com/yunbao/live/dialog/LiveFansGroupInfoDialog.java new file mode 100644 index 000000000..8822d0fc8 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/dialog/LiveFansGroupInfoDialog.java @@ -0,0 +1,34 @@ +package com.yunbao.live.dialog; + +import android.content.Context; + +import androidx.annotation.NonNull; + +import com.lxj.xpopup.XPopup; +import com.yunbao.common.dialog.AbsDialogCenterPopupWindow; +import com.yunbao.common.utils.DpUtil; +import com.yunbao.live.R; + +public class LiveFansGroupInfoDialog extends AbsDialogCenterPopupWindow { + public LiveFansGroupInfoDialog(@NonNull Context context) { + super(context); + } + + @Override + public void buildDialog(XPopup.Builder builder) { + builder.popupWidth(DpUtil.dp2px(370)); + builder.maxWidth(DpUtil.dp2px(370)); + builder.dismissOnTouchOutside(false); + } + + @Override + public int bindLayoutId() { + return R.layout.dialog_fans_group_info; + } + + @Override + protected void onCreate() { + super.onCreate(); + findViewById(R.id.colse).setOnClickListener(v -> dismiss()); + } +} diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveFansGroupSendGiftDialog.java b/live/src/main/java/com/yunbao/live/dialog/LiveFansGroupSendGiftDialog.java new file mode 100644 index 000000000..c75201359 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/dialog/LiveFansGroupSendGiftDialog.java @@ -0,0 +1,99 @@ +package com.yunbao.live.dialog; + +import android.content.Context; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.lxj.xpopup.XPopup; +import com.yunbao.common.bean.FansGroupGiftPack; +import com.yunbao.common.dialog.AbsDialogCenterPopupWindow; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.live.R; +import com.yunbao.live.adapter.LiveFansGroupSendGiftAdapter; +import com.yunbao.live.http.LiveHttpUtil; + +import java.util.List; + +public class LiveFansGroupSendGiftDialog extends AbsDialogCenterPopupWindow { + private RecyclerView recyclerView; + private LiveFansGroupSendGiftAdapter adapter; + private String liveUid; + private String mStream; + + public LiveFansGroupSendGiftDialog(@NonNull Context context) { + super(context); + } + + public LiveFansGroupSendGiftDialog setLiveUid(String liveUid) { + this.liveUid = liveUid; + return this; + } + + public LiveFansGroupSendGiftDialog setStream(String mStream) { + this.mStream = mStream; + return this; + } + + @Override + public void buildDialog(XPopup.Builder builder) { + builder.popupWidth(DpUtil.dp2px(370)); + builder.maxWidth(DpUtil.dp2px(370)); + } + + @Override + public int bindLayoutId() { + return R.layout.dialog_fans_group_send; + } + + @Override + protected void onCreate() { + super.onCreate(); + recyclerView = findViewById(R.id.giftList); + adapter = new LiveFansGroupSendGiftAdapter(mContext); + adapter.setOnItemClickListener((bean, position) -> { + LiveHttpUtil.sendGift("0", + liveUid, + mStream, + bean.getId(), + "1", + 0, + true, + new com.yunbao.common.http.HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + ToastUtil.show(msg); + System.err.println(">>>>>>>>>>>>>>>>>> code = " + code + "|msg = " + msg + ""); + if (code == 0) { + // dismiss(); + initData(); + } + } + }); + }); + recyclerView.setAdapter(adapter); + initData(); + } + + private void initData() { + LiveNetManager.get(mContext) + .userFansExclusivePackList(liveUid, new HttpCallback>() { + @Override + public void onSuccess(List data) { + adapter.setList(data); + if (data.size() == 0) { + dismiss(); + } + } + + @Override + public void onError(String error) { + + } + }); + } +} diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup.java b/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup.java index 833b30639..cfb401209 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup.java @@ -132,6 +132,7 @@ public class LiveGiftPopup extends AbsDialogFragment { @Override public void onDismiss(DialogInterface dialog) { super.onDismiss(dialog); + EventBus.getDefault().post("checkNewLetter"); Bus.getOff(this); } diff --git a/live/src/main/java/com/yunbao/live/http/LiveHttpUtil.java b/live/src/main/java/com/yunbao/live/http/LiveHttpUtil.java index 12f269782..080068f98 100644 --- a/live/src/main/java/com/yunbao/live/http/LiveHttpUtil.java +++ b/live/src/main/java/com/yunbao/live/http/LiveHttpUtil.java @@ -619,15 +619,17 @@ public class LiveHttpUtil { * 观众给主播送礼物 */ public static void sendGift(String by, String liveUid, String stream, int giftId, String giftCount, HttpCallback callback) { - sendGift(by, liveUid, stream, giftId, giftCount, 0, callback); + sendGift(by, liveUid, stream, giftId, giftCount, 0, false,callback); + } + public static void sendGift(String by, String liveUid, String stream, int giftId, String giftCount, int isContactGift, HttpCallback callback) { + sendGift(by, liveUid, stream, giftId, giftCount, isContactGift, false,callback); } - /** * 观众给主播送礼物 * * @param isContactGift 是否为联系方式礼物 */ - public static void sendGift(String by, String liveUid, String stream, int giftId, String giftCount, int isContactGift, HttpCallback callback) { + public static void sendGift(String by, String liveUid, String stream, int giftId, String giftCount, int isContactGift, boolean isFansGroupGift,HttpCallback callback) { HttpClient.getInstance().get("Live.sendGift", LiveHttpConsts.SEND_GIFT) .params("liveuid", liveUid) .params("stream", stream) @@ -635,6 +637,7 @@ public class LiveHttpUtil { .params("isContactGift", isContactGift) .params("giftcount", giftCount) .params("isprank", by) + .params("fans_exclusive_pack",isFansGroupGift?"1":"0") .params("appVersion", CommonAppConfig.getInstance().getVersion()) .execute(callback); } diff --git a/live/src/main/java/com/yunbao/live/interfaces/IDanmuActionListener.java b/live/src/main/java/com/yunbao/live/interfaces/IDanmuActionListener.java new file mode 100644 index 000000000..a9c314d3a --- /dev/null +++ b/live/src/main/java/com/yunbao/live/interfaces/IDanmuActionListener.java @@ -0,0 +1,9 @@ +package com.yunbao.live.interfaces; + +import com.yunbao.common.views.AbsViewHolder; + +public interface IDanmuActionListener { + void onCanNext(int lineNum); + + void onAnimEnd(AbsViewHolder vh); +} diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveDanmuPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveDanmuPresenter.java index 0e444ea23..8f16c3d30 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveDanmuPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveDanmuPresenter.java @@ -1,10 +1,14 @@ package com.yunbao.live.presenter; import android.content.Context; +import android.util.Log; import android.view.ViewGroup; +import com.yunbao.common.views.AbsViewHolder; import com.yunbao.live.bean.LiveDanMuBean; +import com.yunbao.live.interfaces.IDanmuActionListener; import com.yunbao.live.views.DanmuViewHolder; +import com.yunbao.live.views.FansDanmuViewHolder; import java.util.LinkedList; import java.util.List; @@ -15,13 +19,14 @@ import java.util.concurrent.ConcurrentLinkedQueue; * 弹幕 */ -public class LiveDanmuPresenter implements DanmuViewHolder.ActionListener { +public class LiveDanmuPresenter implements IDanmuActionListener { private Context mContext; private ViewGroup mDanmuContainer; private boolean[] mLines;//弹幕的轨道 private List mList; private ConcurrentLinkedQueue mQueue; + private static final String TAG = "弹幕"; public LiveDanmuPresenter(Context context, ViewGroup danmuContainer) { mContext = context; @@ -56,7 +61,11 @@ public class LiveDanmuPresenter implements DanmuViewHolder.ActionListener { } } if (danmuHolder == null) { - danmuHolder = new DanmuViewHolder(mContext, mDanmuContainer); + if (bean.getFensLevel() >= 16) { + danmuHolder = new FansDanmuViewHolder(mContext, mDanmuContainer); + } else { + danmuHolder = new DanmuViewHolder(mContext, mDanmuContainer); + } danmuHolder.setActionListener(this); mList.add(danmuHolder); } @@ -100,7 +109,7 @@ public class LiveDanmuPresenter implements DanmuViewHolder.ActionListener { } @Override - public void onAnimEnd(DanmuViewHolder vh) { + public void onAnimEnd(AbsViewHolder vh) { if (mQueue.size() == 0) { if (vh != null) { vh.release(); diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java b/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java index 57a56cb9a..635f9e662 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java @@ -215,6 +215,9 @@ public class SocketRyChatUtil { * 发送弹幕消息 */ public static void sendDanmuMessage(String mLiveUid, String danmuToken) { + sendDanmuMessage(mLiveUid,danmuToken,0); + } + public static void sendDanmuMessage(String mLiveUid, String danmuToken,int fansLevel) { UserBean u = CommonAppConfig.getInstance().getUserBean(); if (u == null) { return; @@ -227,6 +230,7 @@ public class SocketRyChatUtil { .param("uname", u.getUserNiceName()) .param("uid", u.getId()) .param("uhead", u.getAvatar()) + .param("fansLevel",fansLevel) .param("ct", danmuToken); msg.create(); String targetId = "g" + mLiveUid; 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 ae0f9eb93..af15fe290 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java @@ -403,6 +403,9 @@ public class SocketRyClient { liveDanMuBean2.setAvatar(map.getString("uhead")); liveDanMuBean2.setUserNiceName(map.getString("uname")); liveDanMuBean2.setContent(map.getString("ct")); + if(map.containsKey("fansLevel")){ + liveDanMuBean2.setFensLevel(map.getInteger("fansLevel")); + } mListener.onSendDanMu(liveDanMuBean2); break; case Constants.SOCKET_LEAVE_ROOM://离开房间 @@ -918,6 +921,8 @@ public class SocketRyClient { chatBean.setMedalNmae(obj.getString("medal_name")); chatBean.setUserNiceName(obj.getString("user_nicename"));//名字 FansMedalBean fansMedalBean = CommonAppConfig.getInstance().getAnchorFansMedal(obj.getIntValue("medal_level")); + u.setFansLevel(obj.getIntValue("medal_level")); + u.setFansEnterRoomUrl(obj.getString("medal_backgroup_thumb")); if (fansMedalBean != null) chatBean.setMedalLevelImageUrl(fansMedalBean.getThumb()); mListener.onEnterRoom(new LiveEnterRoomBean(u, chatBean)); diff --git a/live/src/main/java/com/yunbao/live/views/DanmuViewHolder.java b/live/src/main/java/com/yunbao/live/views/DanmuViewHolder.java index b76b16a71..c4606d746 100644 --- a/live/src/main/java/com/yunbao/live/views/DanmuViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/DanmuViewHolder.java @@ -18,6 +18,7 @@ import com.yunbao.common.utils.ScreenDimenUtil; import com.yunbao.common.views.AbsViewHolder; import com.yunbao.live.R; import com.yunbao.live.bean.LiveDanMuBean; +import com.yunbao.live.interfaces.IDanmuActionListener; /** * Created by cxf on 2017/8/25. @@ -40,7 +41,7 @@ public class DanmuViewHolder extends AbsViewHolder { private Animator.AnimatorListener mAnimatorListener; private boolean mCanNext;//是否可以有下一个 private boolean mIdle;//是否空闲 - private ActionListener mActionListener; + private IDanmuActionListener mActionListener; private int mLineNum; public DanmuViewHolder(Context context, ViewGroup parentView) { @@ -115,7 +116,7 @@ public class DanmuViewHolder extends AbsViewHolder { mIdle = idle; } - public void setActionListener(ActionListener actionListener) { + public void setActionListener(IDanmuActionListener actionListener) { mActionListener = actionListener; } @@ -127,9 +128,4 @@ public class DanmuViewHolder extends AbsViewHolder { mActionListener = null; } - public interface ActionListener { - void onCanNext(int lineNum); - - void onAnimEnd(DanmuViewHolder vh); - } } diff --git a/live/src/main/java/com/yunbao/live/views/FansDanmuViewHolder.java b/live/src/main/java/com/yunbao/live/views/FansDanmuViewHolder.java new file mode 100644 index 000000000..9b786b1c3 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/views/FansDanmuViewHolder.java @@ -0,0 +1,131 @@ +package com.yunbao.live.views; + +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.animation.ValueAnimator; +import android.content.Context; +import android.graphics.Color; +import android.view.ViewGroup; +import android.view.animation.LinearInterpolator; +import android.widget.ImageView; +import android.widget.TextView; + +import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.bean.LevelBean; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.ScreenDimenUtil; +import com.yunbao.live.R; +import com.yunbao.live.bean.LiveDanMuBean; +import com.yunbao.live.interfaces.IDanmuActionListener; + +/** + * Created by cxf on 2017/8/25. + * 弹幕 + */ + +public class FansDanmuViewHolder extends DanmuViewHolder { + + private static final float SPEED = 0.2f;//弹幕的速度,这个值越小,弹幕走的越慢 + private static final int MARGIN_TOP = DpUtil.dp2px(150); + private static final int SPACE = DpUtil.dp2px(50); + private static final int DP_15 = DpUtil.dp2px(15); + private ImageView mAvatar; + private TextView mName; + private TextView mContent; + private int mScreenWidth;//屏幕宽度 + private int mWidth;//控件的宽度 + private ValueAnimator mAnimator; + private ValueAnimator.AnimatorUpdateListener mUpdateListener; + private Animator.AnimatorListener mAnimatorListener; + private boolean mCanNext;//是否可以有下一个 + private boolean mIdle;//是否空闲 + private IDanmuActionListener mActionListener; + private int mLineNum; + + public FansDanmuViewHolder(Context context, ViewGroup parentView) { + super(context, parentView); + } + + + @Override + protected int getLayoutId() { + return R.layout.view_gift_danmu_fans; + } + + @Override + public void init() { + mAvatar = (ImageView) findViewById(R.id.avatar); + mName = (TextView) findViewById(R.id.name); + mContent = (TextView) findViewById(R.id.content); + mScreenWidth = ScreenDimenUtil.getInstance().getScreenWdith(); + mUpdateListener = new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animation) { + float v = (float) animation.getAnimatedValue(); + mContentView.setX(v); + if (!mCanNext && v <= mScreenWidth - mWidth - DP_15) { + mCanNext = true; + if (mActionListener != null) { + mActionListener.onCanNext(mLineNum); + } + } + } + + }; + mAnimatorListener = new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + removeFromParent(); + mIdle = true; + if (mActionListener != null) { + mActionListener.onAnimEnd(FansDanmuViewHolder.this); + } + } + }; + } + + public void show(LiveDanMuBean bean, int lineNum) { + mLineNum = lineNum; + ImgLoader.display(mContext,bean.getAvatar(), mAvatar); + mName.setText(bean.getUserNiceName()+":"); + LevelBean levelBean = CommonAppConfig.getInstance().getLevel(bean.getLevel()); + if (levelBean != null) { + mName.setTextColor(Color.parseColor(levelBean.getColor())); + } + mContent.setText(bean.getContent()); + mCanNext = false; + mContentView.measure(0, 0); + mWidth = mContentView.getMeasuredWidth(); + mContentView.setX(mScreenWidth); + mContentView.setY(MARGIN_TOP + lineNum * SPACE); + addToParent(); + mAnimator = ValueAnimator.ofFloat(mScreenWidth, -mWidth); + mAnimator.addUpdateListener(mUpdateListener); + mAnimator.setInterpolator(new LinearInterpolator()); + mAnimator.setDuration((int) ((mScreenWidth + mWidth) / SPEED)); + mAnimator.addListener(mAnimatorListener); + mAnimator.start(); + } + + public boolean isIdle() { + return mIdle; + } + + public void setIdle(boolean idle) { + mIdle = idle; + } + + public void setActionListener(IDanmuActionListener actionListener) { + mActionListener = actionListener; + } + + public void release() { + if (mAnimator != null) { + mAnimator.cancel(); + } + removeFromParent(); + mActionListener = null; + } + +} 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 3e994c0bc..ddbc18bbd 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -13,6 +13,7 @@ import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.SystemClock; +import android.text.Html; import android.text.TextUtils; import android.util.Log; import android.view.Gravity; @@ -148,10 +149,12 @@ import com.yunbao.live.custom.LiveLightView; import com.yunbao.live.custom.RightGradual; import com.yunbao.live.custom.TopGradual; import com.yunbao.live.dialog.GiftWallDialog; +import com.yunbao.live.dialog.LiveContactDetailsSendGiftDialog; import com.yunbao.live.dialog.LiveFaceUnityDialogFragment; import com.yunbao.live.dialog.LiveFansMedalDialogFragment; import com.yunbao.live.dialog.LiveGameDialogFragment; import com.yunbao.live.dialog.LiveHDDialogFragment; +import com.yunbao.live.dialog.LiveUserAnchorMailBoxWebInfoPopDialog; import com.yunbao.live.dialog.LiveUserDialogFragment; import com.yunbao.live.dialog.LiveWishListDialogFragment4Audience; import com.yunbao.live.dialog.ReceiveRendPacketPopup; @@ -323,6 +326,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis private LinearLayout lt_trickery; private TextView tv_trickery_time; private FrameLayout enterRoomLeave, enterRoomBg; + private ConstraintLayout fans_enter_room_leave; private RecyclerView fastMsgRecyclerView; private LiveRoomFastMessageRecyclerViewAdapter fastMessageRecyclerViewAdapter; @@ -449,6 +453,8 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } } } + }else if("checkNewLetter".equals(str)){ + checkNewLetter(); } } @@ -891,6 +897,12 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } } }); + mAnchorSay.setOnLongClickListener(v -> { + + return false; + }); + + btnEvent = findViewById(R.id.btn_event); fullScreen = (FullServiceNotificationView) findViewById(R.id.full_screen); noble = (NobleNoticeView) findViewById(R.id.noble); @@ -899,6 +911,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis btn_event2 = (LinearLayout) findViewById(R.id.btn_event2); btn_event4 = (LinearLayout) findViewById(R.id.btn_event4); enterRoomLeave = (FrameLayout) findViewById(R.id.enter_room_leave); + fans_enter_room_leave = (ConstraintLayout) findViewById(R.id.fans_enter_room_leave); enterRoomBg = (FrameLayout) findViewById(R.id.enter_room_bg); enterRoomLeave2 = (LinearLayout) findViewById(R.id.enter_room_leave2); mBanner1 = (Banner) findViewById(R.id.banner1); @@ -1648,6 +1661,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis updataCleanMic(); // initStarChallengeStatus(); enterRoomLeave.setVisibility(View.GONE); + fans_enter_room_leave.setVisibility(View.GONE); topBanner1.setVisibility(View.GONE); topBanner2.setVisibility(View.GONE); topBanner1.update(mTopBannerList); @@ -4893,6 +4907,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis mChatRecyclerView.setLayoutParams(params1); enterRoomLeave.setLayoutParams(enterRoomParams); + fans_enter_room_leave.setLayoutParams(enterRoomParams); } @@ -4905,6 +4920,10 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis userName.setText(String.format(mContext.getString(R.string.come_hint), model.getUserNiceName())); ImgLoader.display(mContext, model.getAvatar(), imageAvatar); int level = model.getLevel(); + if (!StringUtil.isEmpty(model.getFansEnterRoomUrl())) { + showFansGroupEnterRoom(model); + return; + } if (level < 50) { enterRoomLeave.setBackgroundResource(R.drawable.background_30); enterRoomLeave2.setBackgroundResource(R.drawable.bg_30_leave); @@ -4963,6 +4982,72 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } + private void showFansGroupEnterRoom(LiveUserGiftBean model) { + + fans_enter_room_leave.post(() -> { + TextView userName = fans_enter_room_leave.findViewById(R.id.user_name); + ImageView bg = fans_enter_room_leave.findViewById(R.id.bg); + + userName.setText(Html.fromHtml(String.format("@%s %s", + model.getUserNiceName(), + mContext.getString(R.string.live_fans_group_enter_room) + ))); + ImgLoader.display(mContext, model.getFansEnterRoomUrl(), bg); + fans_enter_room_leave.setVisibility(View.VISIBLE); + TranslateAnimation animationTranslate = new TranslateAnimation(DeviceUtils.getScreenWidth((Activity) mContext), 0, 0, 0); + AnimationSet animationSet1 = new AnimationSet(true); + animationSet1.addAnimation(animationTranslate); + animationSet1.setFillAfter(true); + animationSet1.setDuration(500); + animationSet1.setAnimationListener(new Animation.AnimationListener() { + @Override + public void onAnimationStart(Animation animation) { + + } + + @Override + public void onAnimationEnd(Animation animation) { + } + + @Override + public void onAnimationRepeat(Animation animation) { + + } + }); + fans_enter_room_leave.startAnimation(animationSet1); + }); + + } + + /** + * 隐藏粉丝团入场提示 + */ + public void hideFansGroupEnter() { + if (fans_enter_room_leave.getVisibility() == View.GONE) return; + TranslateAnimation animationTranslate = new TranslateAnimation(0, -(fans_enter_room_leave.getMeasuredWidth() + DpUtil.dp2px(6)), 0, 0); + AnimationSet animationSet1 = new AnimationSet(true); + animationSet1.addAnimation(animationTranslate); + animationSet1.setFillAfter(true); + animationSet1.setDuration(100); + animationSet1.setAnimationListener(new Animation.AnimationListener() { + @Override + public void onAnimationStart(Animation animation) { + + } + + @Override + public void onAnimationEnd(Animation animation) { + fans_enter_room_leave.setVisibility(View.GONE); + } + + @Override + public void onAnimationRepeat(Animation animation) { + + } + }); + fans_enter_room_leave.startAnimation(animationSet1); + } + /** * 隐藏高等级入场提示 */ @@ -5138,13 +5223,25 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis @Override public void onSuccess(LiveAnchorCallMeModel data) { + if (data.getIsGet() == 1) { + new LiveUserAnchorMailBoxWebInfoPopDialog(mContext, mAnchorName, data.getLink()) + .setOnDismissListener(dialog -> { + checkNewLetter(); + loading.dismiss(); + }) + .showDialog(); + return; + } + new LiveContactDetailsSendGiftDialog(mContext) + .setGiftId(data.getGiftId()) + .setAnchorName(mAnchorName) + .setStream(mStream) + .setLiveUid(mLiveUid) + .setOnDismissListener(dialog1 -> { + checkNewLetter(); + }) + .showDialog(); loading.dismiss(); - Bus.get().post(new LiveAudienceEvent() - .setType(LiveAudienceEvent.LiveAudienceType.GIFT_POPUP) - .setmLiveUid(mLiveUid) - .setmStream(mStream) - .setmWishGiftId(data.getGiftId() + "") - .setIsContactGift(true)); } @Override @@ -5206,15 +5303,25 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis @Override public void onSuccess(LiveAnchorCallMeModel data) { + if (data.getIsGet() == 1) { + new LiveUserAnchorMailBoxWebInfoPopDialog(mContext, mAnchorName, data.getLink()) + .setOnDismissListener(dialog -> { + checkNewLetter(); + loading.dismiss(); + }) + .showDialog(); + return; + } + new LiveContactDetailsSendGiftDialog(mContext) + .setGiftId(data.getGiftId()) + .setAnchorName(mAnchorName) + .setStream(mStream) + .setLiveUid(mLiveUid) + .setOnDismissListener(dialog1 -> { + checkNewLetter(); + }) + .showDialog(); loading.dismiss(); - - Bus.get().post(new LiveAudienceEvent() - .setType(LiveAudienceEvent.LiveAudienceType.GIFT_POPUP) - .setmLiveUid(mLiveUid) - .setmStream(mStream) - .setmWishGiftId(data.getGiftId() + "") - .setIsContactGift(true)); - } @Override @@ -5299,6 +5406,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis return; } } + ((LiveAudienceActivity) mContext).showMsgRed(-1); } @@ -5319,4 +5427,12 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis mLiveGiftAnimPresenter.showSendGiftAnimAllServer2(receiveGiftBean); mLiveGiftAnimPresenter.setLiveUidStream(mLiveUid, mStream); } + + public void sendWelcomeFans() { + LiveChatBean chatBean = new LiveChatBean(); + chatBean.setContent("123123test1243"); + chatBean.setType(LiveChatBean.SYSTEM3_COLOR); + chatBean.setBubble("https://downs.yaoulive.com/20230322/g2_.9.png"); + insertChat(chatBean, 1); + } } 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 844afeb1f..5a61f6020 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -1098,6 +1098,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe public void run() { if (mLiveRoomViewHolder != null) { mLiveRoomViewHolder.hideHighGrade(); + mLiveRoomViewHolder.hideFansGroupEnter(); } enterRoomLeaveHandler.post(enterRoomLeaveRunnable); } @@ -1122,7 +1123,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe LiveChatBean liveChatBean = bean.getLiveChatBean(); LiveUserGiftBean liveUserGiftBean = bean.getUserBean(); int level = liveUserGiftBean.getLevel(); - if (level >= 30) { + if (level >= 30 || liveUserGiftBean.getFansLevel() >= 10) { //高等级飘屏 liveUserGiftBean.setUserNiceName(liveChatBean.getUserNiceName()); enterRoomModel.add(liveUserGiftBean); diff --git a/live/src/main/res/drawable/background_d6e8fe.xml b/live/src/main/res/drawable/background_d6e8fe.xml new file mode 100644 index 000000000..fb55461a0 --- /dev/null +++ b/live/src/main/res/drawable/background_d6e8fe.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_fans_group_buy_dialog_item.xml b/live/src/main/res/drawable/bg_fans_group_buy_dialog_item.xml new file mode 100644 index 000000000..837b1f741 --- /dev/null +++ b/live/src/main/res/drawable/bg_fans_group_buy_dialog_item.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_item_live_send_details_gift.xml b/live/src/main/res/drawable/bg_item_live_send_details_gift.xml new file mode 100644 index 000000000..04103a50b --- /dev/null +++ b/live/src/main/res/drawable/bg_item_live_send_details_gift.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_item_live_send_details_gift_unselect.xml b/live/src/main/res/drawable/bg_item_live_send_details_gift_unselect.xml new file mode 100644 index 000000000..813f394d2 --- /dev/null +++ b/live/src/main/res/drawable/bg_item_live_send_details_gift_unselect.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/dialog_fans_group_buy.xml b/live/src/main/res/layout/dialog_fans_group_buy.xml new file mode 100644 index 000000000..88dde5508 --- /dev/null +++ b/live/src/main/res/layout/dialog_fans_group_buy.xml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/dialog_fans_group_info.xml b/live/src/main/res/layout/dialog_fans_group_info.xml new file mode 100644 index 000000000..33cfbeaf2 --- /dev/null +++ b/live/src/main/res/layout/dialog_fans_group_info.xml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/dialog_fans_group_send.xml b/live/src/main/res/layout/dialog_fans_group_send.xml new file mode 100644 index 000000000..091c138fa --- /dev/null +++ b/live/src/main/res/layout/dialog_fans_group_send.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/dialog_live_contact_details_gift.xml b/live/src/main/res/layout/dialog_live_contact_details_gift.xml new file mode 100644 index 000000000..99c21fb7c --- /dev/null +++ b/live/src/main/res/layout/dialog_live_contact_details_gift.xml @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/item_fans_group_buy_list.xml b/live/src/main/res/layout/item_fans_group_buy_list.xml new file mode 100644 index 000000000..0630e6c01 --- /dev/null +++ b/live/src/main/res/layout/item_fans_group_buy_list.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/item_fans_group_package_list.xml b/live/src/main/res/layout/item_fans_group_package_list.xml new file mode 100644 index 000000000..2a3c16b2f --- /dev/null +++ b/live/src/main/res/layout/item_fans_group_package_list.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/view_fans_group_enter_room_leave.xml b/live/src/main/res/layout/view_fans_group_enter_room_leave.xml new file mode 100644 index 000000000..f63163ed1 --- /dev/null +++ b/live/src/main/res/layout/view_fans_group_enter_room_leave.xml @@ -0,0 +1,37 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/view_funs_live_anchor_start_notify.xml b/live/src/main/res/layout/view_funs_live_anchor_start_notify.xml new file mode 100644 index 000000000..43c6443be --- /dev/null +++ b/live/src/main/res/layout/view_funs_live_anchor_start_notify.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/view_gift_danmu_fans.xml b/live/src/main/res/layout/view_gift_danmu_fans.xml new file mode 100644 index 000000000..8b276529b --- /dev/null +++ b/live/src/main/res/layout/view_gift_danmu_fans.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/view_hight_nobility.xml b/live/src/main/res/layout/view_hight_nobility.xml index 0a8148235..5c7195d59 100644 --- a/live/src/main/res/layout/view_hight_nobility.xml +++ b/live/src/main/res/layout/view_hight_nobility.xml @@ -1,7 +1,7 @@ @@ -37,6 +37,7 @@ android:layout_height="wrap_content" android:layout_marginStart="16dp" android:layout_marginTop="22dp" + android:layout_marginBottom="15dp" android:layout_marginEnd="16dp" android:gravity="center_horizontal"> @@ -60,9 +61,9 @@ android:layout_marginStart="20dp" android:background="@drawable/bg_btn_common" android:enabled="true" - android:paddingStart="48dp" + android:paddingStart="30dp" android:paddingTop="15dp" - android:paddingEnd="48dp" + android:paddingEnd="30dp" android:paddingBottom="15dp" android:text="@string/go_nobility" android:textColor="@color/white" diff --git a/live/src/main/res/layout/view_live_room.xml b/live/src/main/res/layout/view_live_room.xml index cf6398703..4208d812d 100644 --- a/live/src/main/res/layout/view_live_room.xml +++ b/live/src/main/res/layout/view_live_room.xml @@ -223,6 +223,15 @@ android:layout_marginStart="3dp" android:layout_marginBottom="-350dp" android:visibility="gone" /> + Minute Please select You have been banned + Confirm + Give + obtain the + \'s letter and contact information + Select Avatar + Confirm + 1 The fan exclusive gift pack is an exclusive benefit for fan group users, which can quickly increase their companionship with the host after purchase + 2 Limited edition anchor gift (to protect you and love you dearly) is included in the Cherish Gift Bag and Zhenai Gift Bag. After purchase, it is placed in the fan gift backpack + 3 The exclusive gift package is bound to the anchor in a one-on-one relationship, and purchasing gift resources in the exclusive gift package can only be given to the anchor + 4 The gift resources in the gift package are valid for 30 days and can be given normally during the validity period; Gift resources become invalid and cannot be given after expiration + 1 Purchase can only be made once a month, and the gift package will be distributed in real-time after purchase + 2. The final interpretation rights of this gift package belong to PD Live + Introduction + Rules + Join the fan group and unlock exclusive gifts + Gift + Currently Available To Send + The Perfect GiftPack + Purchase a %s Diamond Specific Gift And Receive ALimited Resource + %s Diamond + Welcome fan group to enter the room + Fan group level Of Lv%s Can send this gift \ No newline at end of file diff --git a/live/src/main/res/values/strings.xml b/live/src/main/res/values/strings.xml index 9e1539431..ae12ea481 100644 --- a/live/src/main/res/values/strings.xml +++ b/live/src/main/res/values/strings.xml @@ -91,4 +91,26 @@ 分鐘 請選擇禁言時間 您已被禁言 + 確認獲取 + 贈送 + 會獲取到 + 的信件與聯繫方式 + 選擇頭像 + 確認使用 + 1. 粉絲專屬禮包為粉絲團用戶專屬權益,購買後可 快速提昇與該主播的陪伴值 + 2. 珍愛禮包、臻愛禮包中包入限量主播禮物(守護 你,摯愛你),開啟后立即發放到包裹中 + 3. 專屬禮包與主播為 1 對 1 綁定關係,購買專屬 禮包中禮物資源只可送給該主播 + 4. 禮包中禮物資源有效期 30 天,有效期內均可正 常贈送;過期後禮物資源失效不可贈送 + 1. 當月只可購買一次,購買后禮包实时發放 + 2. 该禮包最終解釋權歸 PD Live 所有 + 禮包介紹 + 購買規則 + 加入粉絲團,解鎖專屬禮物 + 赠送 + 當前可送出 + 的臻愛禮包 + 購買可獲得%s鑽特定禮物,同時可獲得限定資源 + %s鑽購買 + 粉絲團成員歡迎進房 + 粉絲團等級達到 Lv%s 可送出該禮物 diff --git a/main/src/main/AndroidManifest.xml b/main/src/main/AndroidManifest.xml index fef1e28bc..40f7204ba 100644 --- a/main/src/main/AndroidManifest.xml +++ b/main/src/main/AndroidManifest.xml @@ -156,6 +156,8 @@ + \ No newline at end of file diff --git a/main/src/main/java/com/yunbao/main/activity/EditProfileActivity.java b/main/src/main/java/com/yunbao/main/activity/EditProfileActivity.java index 61df9bfd0..cad0cae1b 100644 --- a/main/src/main/java/com/yunbao/main/activity/EditProfileActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/EditProfileActivity.java @@ -36,6 +36,7 @@ import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.interfaces.ActivityResultCallback; import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.interfaces.ImageResultCallback; +import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.CityUtil; import com.yunbao.common.utils.DialogUitl; @@ -414,13 +415,19 @@ public class EditProfileActivity extends AbsActivity { private void editAvatar() { DialogUitl.showStringArrayDialog(mContext, new Integer[]{ - R.string.camera, R.string.alumb}, new DialogUitl.StringArrayDialogCallback() { + R.string.camera, R.string.alumb, R.string.me_edit_avatar_system}, new DialogUitl.StringArrayDialogCallback() { @Override public void onItemClick(String text, int tag) { + if (Integer.parseInt(IMLoginManager.get(mContext).getUserInfo().getLevel()) < 5 && tag != R.string.me_edit_avatar_system) { + ToastUtil.show(R.string.me_edit_avatar_system_tip); + return; + } if (tag == R.string.camera) { mImageUtil.getImageByCamera(); - } else { + } else if (tag == R.string.alumb) { mImageUtil.getImageByAlumb(); + } else { + RouteUtil.forwardUserAvatarSelect(); } } }); 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 cce8ea893..b143dd679 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -58,6 +58,7 @@ import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.activity.WebViewActivity; import com.yunbao.common.adapter.ViewPagerAdapter; import com.yunbao.common.bean.AnchorRecommendModel; +import com.yunbao.common.bean.AnchorStartLiveBean; import com.yunbao.common.bean.ChatRemarksBean; import com.yunbao.common.bean.ConfigBean; import com.yunbao.common.bean.IMLoginModel; @@ -107,6 +108,7 @@ import com.yunbao.live.utils.LiveStorge; import com.yunbao.live.views.ChatListViewHolder; import com.yunbao.main.R; import com.yunbao.main.adapter.FullAdToBannerTransition; +import com.yunbao.main.dialog.AnchorStartLiveNotifyDialog; import com.yunbao.main.dialog.MainStartDialogFragment; import com.yunbao.main.dialog.ReturnUserDialog; import com.yunbao.main.dialog.SigninDialog; @@ -191,6 +193,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene private boolean isfloatBannernet = true, isFirst = true; private View floatRedPacket; + private List startListNotifyList = new ArrayList<>(); @Override @@ -1016,6 +1019,18 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene } } + @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); + } + } + @Override public void onBackPressed() { if (isTabClose && isWebClose) { @@ -1036,6 +1051,20 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene } } + 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(); + } + } + private void loadPageData(int position, boolean needlLoadData) { if (mViewHolders == null) { diff --git a/main/src/main/java/com/yunbao/main/activity/SettingActivity.java b/main/src/main/java/com/yunbao/main/activity/SettingActivity.java index 547a8334b..d55dcefda 100644 --- a/main/src/main/java/com/yunbao/main/activity/SettingActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/SettingActivity.java @@ -66,6 +66,7 @@ public class SettingActivity extends AbsActivity implements OnItemClickListener< private Handler mHandler; private SettingAdapter mAdapter; private ImageView studioGiftEffects, studioRideEffects, upSlideSettings, appWindow, systemWindow; + private ImageView liveNotifySettings; private boolean giftEffect, mountEffect, slide, isFloat; private TextView systemHit, reward; @@ -81,6 +82,7 @@ public class SettingActivity extends AbsActivity implements OnItemClickListener< studioGiftEffects = findViewById(R.id.studio_gift_effects); studioRideEffects = findViewById(R.id.studio_ride_effects); upSlideSettings = findViewById(R.id.up_slide_settings); + liveNotifySettings = findViewById(R.id.live_notify_settings); appWindow = findViewById(R.id.app_window); reward = findViewById(R.id.reward); systemHit = findViewById(R.id.system_hit); @@ -237,6 +239,15 @@ public class SettingActivity extends AbsActivity implements OnItemClickListener< }); } ); + ViewClicksAntiShake.clicksAntiShake(liveNotifySettings, () -> { + boolean isTrue = IMLoginManager.get(mContext).isLiveNotifySettings(); + if (isTrue) { + ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_off, liveNotifySettings); + } else { + ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_on, liveNotifySettings); + } + IMLoginManager.get(mContext).setLiveNotifySettings(!isTrue); + }); SpannableStringBuilder builder = new SpannableStringBuilder(getString(com.yunbao.common.R.string.system_window_hint)); String goTo = getString(com.yunbao.common.R.string.to_open_the); int star = builder.length(); @@ -274,6 +285,11 @@ public class SettingActivity extends AbsActivity implements OnItemClickListener< } else { ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_on, studioRideEffects); } + if(IMLoginManager.get(mContext).isLiveNotifySettings()){ + ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_on, liveNotifySettings); + }else{ + ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_off, liveNotifySettings); + } } diff --git a/main/src/main/java/com/yunbao/main/activity/UserAvatarSelectActivity.java b/main/src/main/java/com/yunbao/main/activity/UserAvatarSelectActivity.java new file mode 100644 index 000000000..af6ba92a1 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/activity/UserAvatarSelectActivity.java @@ -0,0 +1,100 @@ +package com.yunbao.main.activity; + +import android.view.View; +import android.widget.TextView; + +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.alibaba.android.arouter.facade.annotation.Route; +import com.yunbao.common.activity.AbsActivity; +import com.yunbao.common.bean.UserAvatarSelectBean; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.manager.IMLoginManager; +import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.main.R; +import com.yunbao.main.adapter.UserAvatarSelectAdapter; +import com.yunbao.main.event.EditProfileEvent; + +import java.util.ArrayList; +import java.util.List; + +@Route(path = RouteUtil.PATH_SELECT_AVATAR) +public class UserAvatarSelectActivity extends AbsActivity { + RecyclerView recyclerView; + UserAvatarSelectAdapter adapter; + TextView titleView; + View submit; + + @Override + protected int getLayoutId() { + return R.layout.activity_user_select_avatar; + } + + @Override + protected void main() { + super.main(); + titleView = findViewById(R.id.titleView); + submit = findViewById(R.id.send); + titleView.setText(R.string.me_edit_avatar_title); + recyclerView = findViewById(R.id.recyclerView); + adapter = new UserAvatarSelectAdapter(mContext); + recyclerView.setLayoutManager(new GridLayoutManager(mContext, 3)); + recyclerView.setAdapter(adapter); + initData(); + + submit.setOnClickListener(v -> { + int id = adapter.getSelect(); + if (id > -1) { + adapter.setDef(id); + LiveNetManager.get(mContext) + .setSystemUserAvatar(id, new HttpCallback() { + @Override + public void onSuccess(String data) { + ToastUtil.show(data); + IMLoginManager.get(mContext).upDataUserInfo(); + Bus.get().post(new EditProfileEvent()); + submit.setBackgroundResource(R.drawable.bg_item_live_send_details_gift_unselect); + submit.setEnabled(false); + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); + } + }); + adapter.setOnClickListener(new OnItemClickListener() { + @Override + public void onItemClick(Integer bean, int position) { + if (bean == position) { + submit.setBackgroundResource(R.drawable.bg_item_live_send_details_gift_unselect); + submit.setEnabled(false); + } else { + submit.setBackgroundResource(R.drawable.bg_item_live_send_details_gift); + submit.setEnabled(true); + } + } + }); + } + + private void initData() { + LiveNetManager.get(mContext) + .getSystemUserAvatar(new HttpCallback>() { + @Override + public void onSuccess(List data) { + adapter.setList(data); + } + + @Override + public void onError(String error) { + adapter.setList(new ArrayList<>()); + } + }); + } +} diff --git a/main/src/main/java/com/yunbao/main/adapter/UserAvatarSelectAdapter.java b/main/src/main/java/com/yunbao/main/adapter/UserAvatarSelectAdapter.java new file mode 100644 index 000000000..6e79dc956 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/adapter/UserAvatarSelectAdapter.java @@ -0,0 +1,105 @@ +package com.yunbao.main.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.bean.UserAvatarSelectBean; +import com.yunbao.common.custom.RatioRoundImageView; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.main.R; + +import java.util.ArrayList; +import java.util.List; + +public class UserAvatarSelectAdapter extends RecyclerView.Adapter { + private Context mContext; + private List list = new ArrayList<>(); + private OnItemClickListener onClickListener; + private int select = -1; + private int defId = -1; + + public void setList(List list) { + this.list = list; + notifyDataSetChanged(); + } + + public int getSelect() { + if (select == -1 && getItemCount() > 0) { + return list.get(0).getId(); + } + return select; + } + + public void setOnClickListener(OnItemClickListener onClickListener) { + this.onClickListener = onClickListener; + } + + public int getDefId() { + return defId; + } + + public UserAvatarSelectAdapter(Context mContext) { + this.mContext = mContext; + } + + @NonNull + @Override + public AvatarSelectViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new AvatarSelectViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_user_avatar_select, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull AvatarSelectViewHolder holder, int position) { + holder.setData(list.get(position), position); + } + + @Override + public int getItemCount() { + return list.size(); + } + + public void setDef(int id) { + this.defId = id; + } + + public class AvatarSelectViewHolder extends RecyclerView.ViewHolder { + private View hide; + private View show; + private RatioRoundImageView avatar; + + public AvatarSelectViewHolder(@NonNull View itemView) { + super(itemView); + hide = itemView.findViewById(R.id.hideCover); + show = itemView.findViewById(R.id.showCover); + avatar = itemView.findViewById(R.id.avatar); + itemView.setOnClickListener(v -> { + select = (int) v.getTag(); + notifyDataSetChanged(); + onClickListener.onItemClick(select, defId); + }); + } + + public void setData(UserAvatarSelectBean bean, int position) { + ImgLoader.display(itemView.getContext(), bean.getPath(), avatar); + if (select == -1 && bean.getChecked() == 1) { + select = bean.getId(); + defId = bean.getId(); + } + if (select == bean.getId()) { + show.setVisibility(View.VISIBLE); + hide.setVisibility(View.GONE); + } else { + show.setVisibility(View.INVISIBLE); + hide.setVisibility(View.VISIBLE); + } + itemView.setTag(bean.getId()); + } + } + +} diff --git a/main/src/main/java/com/yunbao/main/dialog/AnchorStartLiveNotifyDialog.java b/main/src/main/java/com/yunbao/main/dialog/AnchorStartLiveNotifyDialog.java new file mode 100644 index 000000000..51eafe958 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/dialog/AnchorStartLiveNotifyDialog.java @@ -0,0 +1,107 @@ +package com.yunbao.main.dialog; + +import android.content.Context; +import android.content.DialogInterface; +import android.os.Handler; +import android.os.Looper; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.alibaba.fastjson.JSON; +import com.lxj.xpopup.XPopup; +import com.lxj.xpopup.enums.PopupAnimation; +import com.yunbao.common.bean.AnchorStartLiveBean; +import com.yunbao.common.bean.LiveBean; +import com.yunbao.common.custom.RatioRoundImageView; +import com.yunbao.common.dialog.AbsDialogPositionPopupWindow; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.RouteUtil; +import com.yunbao.live.http.LiveHttpUtil; +import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; +import com.yunbao.main.R; + +public class AnchorStartLiveNotifyDialog extends AbsDialogPositionPopupWindow { + private AnchorStartLiveBean liveBean; + private DialogInterface.OnDismissListener onDismissListener; + + private TextView anchorName; + private RatioRoundImageView avatar; + + + public AnchorStartLiveNotifyDialog(@NonNull Context context) { + super(context); + } + + public AnchorStartLiveNotifyDialog(@NonNull Context context, AnchorStartLiveBean bean) { + super(context); + this.liveBean = bean; + } + + public AnchorStartLiveNotifyDialog setOnDismissListener(DialogInterface.OnDismissListener onDismissListener) { + this.onDismissListener = onDismissListener; + return this; + } + + @Override + public void buildDialog(XPopup.Builder builder) { + builder.positionByWindowCenter(true); + builder.moveUpToKeyboard(false); + builder.dismissOnTouchOutside(false); + builder.dismissOnBackPressed(false); + builder.isTouchThrough(true); + builder.isClickThrough(true); + builder.isCenterHorizontal(true); + builder.hasShadowBg(false); + builder.animationDuration(500); + builder.popupAnimation(PopupAnimation.ScaleAlphaFromCenter); + builder.offsetY(DpUtil.dp2px(60)); + } + + @Override + public int bindLayoutId() { + return R.layout.view_funs_live_anchor_start_notify; + } + + @Override + protected void onCreate() { + super.onCreate(); + findViewById(R.id.liveGo).setOnClickListener(v -> { + LiveHttpUtil.getLiveInfo(liveBean.getRoomId(), new HttpCallback() { + + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class); + new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() { + @Override + public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) { + RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk)); + } + + @Override + public void onCheckError(String contextError) { + + } + }); + } + } + }); + }); + avatar = findViewById(R.id.avatar); + anchorName = findViewById(R.id.anchorName); + ImgLoader.display(mContext, liveBean.getAvatar(), avatar); + anchorName.setText(liveBean.getAnchorName()); + + + new Handler(Looper.getMainLooper()).postDelayed(() -> { + dismiss(); + if (onDismissListener != null) { + onDismissListener.onDismiss(null); + } + }, 5000); + } + +} diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java index f04befa48..551d97f44 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java @@ -1,15 +1,12 @@ package com.yunbao.main.views; import android.content.Context; -import android.content.Intent; -import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.ImageView; import com.yunbao.common.glide.ImgLoader; import com.yunbao.main.R; -import com.yunbao.main.activity.RedPacketListActivity; /** * Created by cxf on 2018/9/22. @@ -42,7 +39,6 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder { ImgLoader.display(mContext, "https://downs.yaoulive.com/gif_trophy.gif", img_trophy); - } public void setCurPosition(int position){ mViewPager.setCurrentItem(position); diff --git a/main/src/main/res/drawable/bg_user_avatar_select_selected.xml b/main/src/main/res/drawable/bg_user_avatar_select_selected.xml new file mode 100644 index 000000000..0a8069452 --- /dev/null +++ b/main/src/main/res/drawable/bg_user_avatar_select_selected.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/main/src/main/res/drawable/bg_user_avatar_select_unselected.xml b/main/src/main/res/drawable/bg_user_avatar_select_unselected.xml new file mode 100644 index 000000000..5f2e8b64c --- /dev/null +++ b/main/src/main/res/drawable/bg_user_avatar_select_unselected.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/main/src/main/res/layout/activity_red_packet.xml b/main/src/main/res/layout/activity_red_packet.xml index b2430f744..572e95850 100644 --- a/main/src/main/res/layout/activity_red_packet.xml +++ b/main/src/main/res/layout/activity_red_packet.xml @@ -13,7 +13,7 @@ app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toBottomOf="@+id/anchorName" /> \ No newline at end of file diff --git a/main/src/main/res/layout/activity_setting.xml b/main/src/main/res/layout/activity_setting.xml index 4017b0080..9f1d42f2c 100644 --- a/main/src/main/res/layout/activity_setting.xml +++ b/main/src/main/res/layout/activity_setting.xml @@ -260,7 +260,14 @@ android:paddingTop="13.67dp" android:paddingBottom="11dp"> - + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/main/src/main/res/layout/item_user_avatar_select.xml b/main/src/main/res/layout/item_user_avatar_select.xml new file mode 100644 index 000000000..2f82ca3c7 --- /dev/null +++ b/main/src/main/res/layout/item_user_avatar_select.xml @@ -0,0 +1,54 @@ + + + + + + + + + + \ No newline at end of file diff --git a/main/src/main/res/layout/view_float_red_packet.xml b/main/src/main/res/layout/view_float_red_packet.xml index a9dc3e883..3d1bd0efc 100644 --- a/main/src/main/res/layout/view_float_red_packet.xml +++ b/main/src/main/res/layout/view_float_red_packet.xml @@ -42,7 +42,7 @@