From d912ad6119a512bec270bd70ada6374e428230f1 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Sat, 5 Aug 2023 16:52:48 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E7=B2=89=E4=B8=9D=E5=9B=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- .../yunbao/common/bean/FansGroupGiftPack.java | 81 ++++++++++ .../common/bean/FansGroupGiftPackInfo.java | 150 ++++++++++++++++++ .../dialog/AbsDialogCenterPopupWindow.java | 39 +++++ .../com/yunbao/common/http/PDLiveApi.java | 31 +++- .../common/http/live/LiveNetManager.java | 73 ++++++++- .../yunbao/live/activity/LiveActivity.java | 5 +- .../live/activity/LiveAudienceActivity.java | 3 + .../live/adapter/LiveFansGroupBuyAdapter.java | 39 ++++- .../adapter/LiveFansGroupSendGiftAdapter.java | 42 ++++- .../yunbao/live/dialog/LiveFansFragment.java | 20 ++- .../live/dialog/LiveFansGroupBuyDialog.java | 73 ++++++++- .../live/dialog/LiveFansGroupInfoDialog.java | 9 +- .../dialog/LiveFansGroupSendGiftDialog.java | 67 +++++++- .../com/yunbao/live/dialog/LiveGiftPopup.java | 1 + .../com/yunbao/live/http/LiveHttpUtil.java | 9 +- .../yunbao/live/views/LiveRoomViewHolder.java | 32 ++-- .../main/res/layout/dialog_fans_group_buy.xml | 4 +- .../res/layout/item_fans_group_buy_list.xml | 24 +-- live/src/main/res/values-en/strings.xml | 2 +- 20 files changed, 644 insertions(+), 62 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/bean/FansGroupGiftPack.java create mode 100644 common/src/main/java/com/yunbao/common/bean/FansGroupGiftPackInfo.java create mode 100644 common/src/main/java/com/yunbao/common/dialog/AbsDialogCenterPopupWindow.java 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/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/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/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index 3b54e4dcd..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; @@ -844,6 +846,7 @@ public interface PDLiveApi { /** * 设置系统默认头像 + * * @param id 头像id */ @GET("/api/public/?service=Userhome.setAvatar") @@ -913,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 26ce37819..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; @@ -64,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 +1803,7 @@ public class LiveNetManager { } }).isDisposed(); } + public void getSystemUserAvatar(HttpCallback> callback) { API.get().pdLiveApi(mContext) .getSystemUserAvatar() @@ -1825,6 +1827,7 @@ public class LiveNetManager { } }).isDisposed(); } + public void setSystemUserAvatar(int id, HttpCallback callback) { API.get().pdLiveApi(mContext) .setSystemUserAvatar(id) @@ -2025,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()) @@ -2047,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/live/src/main/java/com/yunbao/live/activity/LiveActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java index e94e1cb0e..dd8c9d1a0 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java @@ -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 50586d85c..1f3a666d9 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/LiveFansGroupBuyAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveFansGroupBuyAdapter.java index ca4af865f..7b09e750e 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveFansGroupBuyAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveFansGroupBuyAdapter.java @@ -10,6 +10,8 @@ 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; @@ -17,14 +19,16 @@ import java.util.List; public class LiveFansGroupBuyAdapter extends RecyclerView.Adapter { Context mContext; - List list=new ArrayList<>(); + List list = new ArrayList<>(); public LiveFansGroupBuyAdapter(Context mContext) { this.mContext = mContext; } - public void setList(List list) { + public void setList(List list) { + this.list.clear(); this.list = list; + notifyDataSetChanged(); } @NonNull @@ -35,7 +39,7 @@ public class LiveFansGroupBuyAdapter extends RecyclerView.Adapter 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 index e88ddb3cf..2ec7d9ac5 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveFansGroupSendGiftAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveFansGroupSendGiftAdapter.java @@ -10,21 +10,34 @@ 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<>(); + List list = new ArrayList<>(); + private OnItemClickListener onItemClickListener; + public LiveFansGroupSendGiftAdapter(Context mContext) { this.mContext = mContext; } - public void setList(List list) { + public void setList(List list) { + this.list.clear(); this.list = list; + notifyDataSetChanged(); + } + + public void setOnItemClickListener(OnItemClickListener onItemClickListener) { + this.onItemClickListener = onItemClickListener; } @NonNull @@ -35,7 +48,7 @@ public class LiveFansGroupSendGiftAdapter extends RecyclerView.Adapter 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/dialog/LiveFansFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveFansFragment.java index 87a1abc04..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)); } @@ -133,9 +139,19 @@ public class LiveFansFragment extends AbsDialogFragment { dismiss(); } else if (TextUtils.equals(event.getMethod(), "androidFansGroupBuy")) { String id = event.getUserId(); - new LiveFansGroupBuyDialog(mContext).setGiftId(id).showDialog(); + new LiveFansGroupBuyDialog(mContext) + .setGiftId(id) + .setAnchorName(anchorName) + .setLiveUid(liveUid) + .setSteam(mStream) + .showDialog(); + dismiss(); } else if (TextUtils.equals(event.getMethod(), "androidFansGroupPack")) { - new LiveFansGroupSendGiftDialog(mContext).showDialog(); + 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 index 930c059f1..ba6059d5e 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveFansGroupBuyDialog.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveFansGroupBuyDialog.java @@ -4,32 +4,59 @@ 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.dialog.AbsDialogPopupWindow; +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 AbsDialogPopupWindow { +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; + 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 @@ -41,15 +68,51 @@ public class LiveFansGroupBuyDialog extends AbsDialogPopupWindow { 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 index b2a4c22db..8822d0fc8 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveFansGroupInfoDialog.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveFansGroupInfoDialog.java @@ -5,17 +5,20 @@ import android.content.Context; import androidx.annotation.NonNull; import com.lxj.xpopup.XPopup; -import com.yunbao.common.dialog.AbsDialogPopupWindow; +import com.yunbao.common.dialog.AbsDialogCenterPopupWindow; +import com.yunbao.common.utils.DpUtil; import com.yunbao.live.R; -public class LiveFansGroupInfoDialog extends AbsDialogPopupWindow { +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 diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveFansGroupSendGiftDialog.java b/live/src/main/java/com/yunbao/live/dialog/LiveFansGroupSendGiftDialog.java index 6350cdd5d..c75201359 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveFansGroupSendGiftDialog.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveFansGroupSendGiftDialog.java @@ -6,21 +6,43 @@ import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.lxj.xpopup.XPopup; -import com.yunbao.common.dialog.AbsDialogPopupWindow; +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; -public class LiveFansGroupSendGiftDialog extends AbsDialogPopupWindow { +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 @@ -33,6 +55,45 @@ public class LiveFansGroupSendGiftDialog extends AbsDialogPopupWindow { 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 e502936b3..33ec4798f 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/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index 18de1d9fc..ae2733813 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -453,6 +453,8 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } } } + }else if("checkNewLetter".equals(str)){ + checkNewLetter(); } } @@ -5226,12 +5228,15 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis .showDialog(); return; } - Bus.get().post(new LiveAudienceEvent() - .setType(LiveAudienceEvent.LiveAudienceType.GIFT_POPUP) - .setmLiveUid(mLiveUid) - .setmStream(mStream) - .setmWishGiftId(data.getGiftId() + "") - .setIsContactGift(true)); + new LiveContactDetailsSendGiftDialog(mContext) + .setGiftId(data.getGiftId()) + .setAnchorName(mAnchorName) + .setStream(mStream) + .setLiveUid(mLiveUid) + .setOnDismissListener(dialog1 -> { + checkNewLetter(); + }) + .showDialog(); loading.dismiss(); } @@ -5303,12 +5308,15 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis .showDialog(); return; } - Bus.get().post(new LiveAudienceEvent() - .setType(LiveAudienceEvent.LiveAudienceType.GIFT_POPUP) - .setmLiveUid(mLiveUid) - .setmStream(mStream) - .setmWishGiftId(data.getGiftId() + "") - .setIsContactGift(true)); + new LiveContactDetailsSendGiftDialog(mContext) + .setGiftId(data.getGiftId()) + .setAnchorName(mAnchorName) + .setStream(mStream) + .setLiveUid(mLiveUid) + .setOnDismissListener(dialog1 -> { + checkNewLetter(); + }) + .showDialog(); loading.dismiss(); } diff --git a/live/src/main/res/layout/dialog_fans_group_buy.xml b/live/src/main/res/layout/dialog_fans_group_buy.xml index 7ff9b8f82..88dde5508 100644 --- a/live/src/main/res/layout/dialog_fans_group_buy.xml +++ b/live/src/main/res/layout/dialog_fans_group_buy.xml @@ -60,7 +60,7 @@ + android:background="@mipmap/icon_fans_group_buy_dialog_item"> + app:layout_constraintTop_toTopOf="parent" + tools:text="1天" + tools:visibility="visible" /> + app:layout_constraintStart_toStartOf="parent" + tools:text="5200" /> Currently Available To Send The Perfect GiftPack Purchase a %s Diamond Specific Gift And Receive ALimited Resource - Diamond Purchase + %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