diff --git a/common/src/main/java/com/yunbao/common/bean/NewPeopleInfo.java b/common/src/main/java/com/yunbao/common/bean/NewPeopleInfo.java new file mode 100644 index 000000000..e5a548232 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/NewPeopleInfo.java @@ -0,0 +1,62 @@ +package com.yunbao.common.bean; + +import androidx.annotation.NonNull; + +import com.google.gson.annotations.SerializedName; + +/** + * 直播间新人特惠入口信息 + */ +public class NewPeopleInfo extends BaseModel{ + @SerializedName("charge_hidden") + private int chargeHidden; + @SerializedName("one_coin_show") + private int oneCoinShow; + @SerializedName("is_show") + private int isShow;//是否展示入口 + @SerializedName("link") + private String link;//入口地址 + + public boolean getChargeHidden() { + return chargeHidden==1; + } + + public void setChargeHidden(int chargeHidden) { + this.chargeHidden = chargeHidden; + } + + public boolean getOneCoinShow() { + return oneCoinShow==1; + } + + public void setOneCoinShow(int oneCoinShow) { + this.oneCoinShow = oneCoinShow; + } + + public boolean getIsShow() { + return isShow==1; + } + + public void setIsShow(int isShow) { + this.isShow = isShow; + } + + public String getLink() { + return link; + } + + public void setLink(String link) { + this.link = link; + } + + @NonNull + @Override + public String toString() { + return "NewPeopleInfo{" + + "chargeHidden=" + chargeHidden + + ", oneCoinShow=" + oneCoinShow + + ", isShow=" + isShow + + ", link='" + link + '\'' + + '}'; + } +} 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 ce10c9128..97998d2db 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -7,6 +7,7 @@ import com.yunbao.common.bean.ContributeModel; import com.yunbao.common.bean.FaceBookUpModel; import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.LiveInfoModel; +import com.yunbao.common.bean.NewPeopleInfo; import com.yunbao.common.bean.NobleTrumpetModel; import com.yunbao.common.bean.SearchModel; import com.yunbao.common.bean.SetAttentsModel; @@ -162,4 +163,11 @@ public interface PDLiveApi { */ @GET("/api/public/?service=Contribute.index") Observable> getRanksList(@Query("uid")String uid); + + /** + * 直播间新人特惠信息 + * @return 新人特惠数据 + */ + @GET("/api/public/?service=Live.newUserPreferential") + Observable> getNewPeopleInfo(); } diff --git a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java index d35ce79da..4ea8cb93e 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java @@ -33,9 +33,10 @@ import com.opensource.svgaplayer.SVGAVideoEntity; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.bean.MsgModel; -import com.yunbao.live.event.LiveAudienceEvent; +import com.yunbao.common.bean.NewPeopleInfo; import com.yunbao.common.event.MessageIMEvent; import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.http.API; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; import com.yunbao.common.manager.imrongcloud.MessageIMManager; @@ -50,6 +51,7 @@ import com.yunbao.live.bean.LiveChatBean; import com.yunbao.live.dialog.LiveHDDialogFragment; import com.yunbao.live.dialog.LiveMicUserDialogFragment; import com.yunbao.live.dialog.LivePromotionDialogFragment; +import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.http.LiveHttpUtil; import org.greenrobot.eventbus.EventBus; @@ -58,6 +60,9 @@ import org.greenrobot.eventbus.ThreadMode; import java.util.Locale; +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.schedulers.Schedulers; + /** * Created by cxf on 2018/10/9. * 观众直播间逻辑 @@ -78,6 +83,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { private int icon = 0; private String nobleName, nobleTtext; private ImageView giftImage, liveNewPeople; + private String newPeopleUrl=null; public LiveAudienceViewHolder(Context context, ViewGroup parentView) { super(context, parentView); @@ -356,7 +362,20 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { LiveRoomViewHolder.insertChat(lvBean2, 1); } }, 10000);//3秒后执行Runnable中的run方法 - + getNewPeopleInfo(); + } + public void getNewPeopleInfo(){ + API.get().pdLiveApi(mContext) + .getNewPeopleInfo() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(stringResponseModel -> { + NewPeopleInfo peopleInfo = stringResponseModel.getData().getInfo(); + if(peopleInfo.getIsShow()){ + liveNewPeople.setVisibility(View.VISIBLE); + newPeopleUrl=peopleInfo.getLink(); + } + }).isDisposed(); } @Override @@ -387,7 +406,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { showTrickeryDialog(); }else if (i==R.id.live_new_people){ Bundle bundle=new Bundle(); - String url= CommonAppConfig.HOST+"/h5/activity/1diamondLottery/index.html?g=Appapi&m=Turntable&a=tricky"; + String url= newPeopleUrl+"?g=Appapi&m=Turntable&a=tricky"; url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid; bundle.putString("url", url); diff --git a/live/src/main/res/layout/view_live_audience.xml b/live/src/main/res/layout/view_live_audience.xml index deeef0d45..8a0bbe024 100644 --- a/live/src/main/res/layout/view_live_audience.xml +++ b/live/src/main/res/layout/view_live_audience.xml @@ -1,6 +1,7 @@ @@ -460,6 +461,7 @@ android:layout_marginEnd="16dp" android:layout_toStartOf="@id/gift_image" android:padding="4dp" + android:visibility="gone" android:src="@mipmap/live_icon_newpeople_en" />