守護等級的檢查接口,領取接口。相關頁面的請求添加。h5方法新鄭

This commit is contained in:
18401019693 2024-03-18 14:52:24 +08:00
parent ddc9bc344e
commit 53f389ddc8
10 changed files with 347 additions and 46 deletions

View File

@ -0,0 +1,48 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class CheckUpgradesModel extends BaseModel {
/**
* {
* "level": 33, // 等级
* "rewards": [ // 奖励信息
* {
* "id": 1,
* "reward_name": "星之守護等級牌", // 奖励名称
* "image_path": "https://ceshi.yaoulive.com/data/upload/20240304/tequan_1.png" // 图片链接
* },
* {
* "id": 2,
* "reward_name": "人氣票",
* "image_path": "https://ceshi.yaoulive.com/data/upload/20240304/tequan_1.png"
* }
* ]
* }
* }
*/
@SerializedName("level")
private String level;
@SerializedName("rewards")
private List<RewardsModel> rewards;
public String getLevel() {
return level;
}
public CheckUpgradesModel setLevel(String level) {
this.level = level;
return this;
}
public List<RewardsModel> getRewards() {
return rewards;
}
public CheckUpgradesModel setRewards(List<RewardsModel> rewards) {
this.rewards = rewards;
return this;
}
}

View File

@ -0,0 +1,39 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
public class RewardsModel extends BaseModel {
@SerializedName("id")
private int id;
@SerializedName("reward_name")
private String rewardName;
@SerializedName("image_path")
private String imagePath;
public int getId() {
return id;
}
public RewardsModel setId(int id) {
this.id = id;
return this;
}
public String getRewardName() {
return rewardName;
}
public RewardsModel setRewardName(String rewardName) {
this.rewardName = rewardName;
return this;
}
public String getImagePath() {
return imagePath;
}
public RewardsModel setImagePath(String imagePath) {
this.imagePath = imagePath;
return this;
}
}

View File

@ -0,0 +1,136 @@
package com.yunbao.common.dialog;
import android.content.Context;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentActivity;
import com.lxj.xpopup.core.CenterPopupView;
import com.yunbao.common.R;
import com.yunbao.common.bean.CheckUpgradesModel;
import com.yunbao.common.bean.RewardsModel;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
public class GuardUpgradePopup extends CenterPopupView {
FragmentActivity activity;
String mLiveUid;
CheckUpgradesModel mUpgradesModel;
TextView leave_hint;
LinearLayout rewards_line1, rewards_line2, rewards_line3;
ImageView rewards_img1, rewards_img2, rewards_img3;
TextView rewards_text1, rewards_text2, rewards_text3;
public GuardUpgradePopup(@NonNull Context context, String liveUid, CheckUpgradesModel upgradesModel) {
super(context);
activity = (FragmentActivity) context;
mLiveUid = liveUid;
mUpgradesModel = upgradesModel;
}
@Override
protected int getImplLayoutId() {
return R.layout.guard_upgrade_popup;
}
// 执行初始化操作比如findView设置点击或者任何你弹窗内的业务逻辑
@Override
protected void onCreate() {
super.onCreate();
leave_hint = findViewById(R.id.leave_hint);
rewards_line1 = findViewById(R.id.rewards_line1);
rewards_line2 = findViewById(R.id.rewards_line2);
rewards_line3 = findViewById(R.id.rewards_line3);
rewards_img1 = findViewById(R.id.rewards_img1);
rewards_img2 = findViewById(R.id.rewards_img2);
rewards_img3 = findViewById(R.id.rewards_img3);
rewards_text1 = findViewById(R.id.rewards_text1);
rewards_text2 = findViewById(R.id.rewards_text2);
rewards_text3 = findViewById(R.id.rewards_text3);
StringBuffer hintStringBuffer = new StringBuffer();
if (WordUtil.isNewZh()) {
hintStringBuffer.append("您的守護等級已達到")
.append(mUpgradesModel.getLevel())
.append("級 可以領取以下獎勵");
} else {
hintStringBuffer.append("Your guardian level has reached level ")
.append(mUpgradesModel.getLevel())
;
}
leave_hint.setText(hintStringBuffer.toString());
if (mUpgradesModel.getRewards().size() > 0) {
if (mUpgradesModel.getRewards().size() == 1) {
rewards_line1.setVisibility(GONE);
rewards_line2.setVisibility(VISIBLE);
rewards_line3.setVisibility(GONE);
RewardsModel rewardsModel = mUpgradesModel.getRewards().get(0);
ImgLoader.display(getContext(), rewardsModel.getImagePath(), rewards_img2);
rewards_text2.setText(rewardsModel.getRewardName());
} else if (mUpgradesModel.getRewards().size() == 2) {
rewards_line1.setVisibility(VISIBLE);
rewards_line2.setVisibility(GONE);
rewards_line3.setVisibility(VISIBLE);
RewardsModel rewardsModel1 = mUpgradesModel.getRewards().get(0);
RewardsModel rewardsModel3 = mUpgradesModel.getRewards().get(1);
ImgLoader.display(getContext(), rewardsModel1.getImagePath(), rewards_img1);
rewards_text1.setText(rewardsModel1.getRewardName());
ImgLoader.display(getContext(), rewardsModel3.getImagePath(), rewards_img3);
rewards_text3.setText(rewardsModel3.getRewardName());
} else if (mUpgradesModel.getRewards().size() == 3) {
rewards_line1.setVisibility(VISIBLE);
rewards_line2.setVisibility(VISIBLE);
rewards_line3.setVisibility(VISIBLE);
RewardsModel rewardsModel1 = mUpgradesModel.getRewards().get(0);
RewardsModel rewardsModel2 = mUpgradesModel.getRewards().get(1);
RewardsModel rewardsModel3 = mUpgradesModel.getRewards().get(3);
ImgLoader.display(getContext(), rewardsModel1.getImagePath(), rewards_img1);
rewards_text1.setText(rewardsModel1.getRewardName());
ImgLoader.display(getContext(), rewardsModel2.getImagePath(), rewards_img2);
rewards_text2.setText(rewardsModel2.getRewardName());
ImgLoader.display(getContext(), rewardsModel3.getImagePath(), rewards_img3);
rewards_text3.setText(rewardsModel3.getRewardName());
} else {
rewards_line1.setVisibility(GONE);
rewards_line2.setVisibility(GONE);
rewards_line3.setVisibility(GONE);
}
} else {
rewards_line1.setVisibility(GONE);
rewards_line2.setVisibility(GONE);
rewards_line3.setVisibility(GONE);
}
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.confirm), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
LiveNetManager.get(getContext())
.getRewards(new HttpCallback<CheckUpgradesModel>() {
@Override
public void onSuccess(CheckUpgradesModel data) {
dismiss();
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
}
});
}
}

View File

@ -11,6 +11,7 @@ import com.yunbao.common.bean.BattlePassUserInfoBean;
import com.yunbao.common.bean.BlindBoxInfoModel;
import com.yunbao.common.bean.CheckLiveModel;
import com.yunbao.common.bean.CheckRemainingBalance;
import com.yunbao.common.bean.CheckUpgradesModel;
import com.yunbao.common.bean.ContributeModel;
import com.yunbao.common.bean.CoolConfig;
import com.yunbao.common.bean.CreateSudRoomModel;
@ -1186,4 +1187,8 @@ public interface PDLiveApi {
Observable<ResponseModel<String>> participateMoneyLong(@Query("liveuid") String liveUid, @Query("send_money_long_key") String sendMoneyLongKey);
@GET("/api/public/?service=Guard.endSendMoneyLong")
Observable<ResponseModel<SendMoneyLongModel>> endSendMoneyLong(@Query("liveuid") String liveUid, @Query("send_money_long_key") String sendMoneyLongKey);
@GET("/api/public/?service=Guard.checkUpgrades")
Observable<ResponseModel<CheckUpgradesModel>> checkUpgrades(@Query("liveuid") String liveUid);
@GET("/api/public/?service=Guard.getRewards")
Observable<ResponseModel<CheckUpgradesModel>> getRewards(@Query("type") String type);
}

View File

@ -14,6 +14,7 @@ import com.yunbao.common.bean.BattlePassUserInfoBean;
import com.yunbao.common.bean.BlindBoxInfoModel;
import com.yunbao.common.bean.CheckLiveModel;
import com.yunbao.common.bean.CheckRemainingBalance;
import com.yunbao.common.bean.CheckUpgradesModel;
import com.yunbao.common.bean.CoolConfig;
import com.yunbao.common.bean.CreateSudRoomModel;
import com.yunbao.common.bean.CustomSidebarInfoModel;
@ -3006,7 +3007,29 @@ public class LiveNetManager {
}).isDisposed();
}
public void sendMoneyLongList(String liveUid,HttpCallback<List<sendMoneyLongListModel>> callback) {
API.get().pdLiveApi(mContext)
.sendMoneyLongList(liveUid)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<List<sendMoneyLongListModel>>>() {
@Override
public void accept(ResponseModel<List<sendMoneyLongListModel>> stringResponseModel) throws Exception {
if (callback != null) {
callback.onSuccess(stringResponseModel.getData().getInfo());
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
throwable.printStackTrace();
if (callback != null) {
callback.onError(mContext.getString(R.string.net_error));
}
}
}).isDisposed();
}
public void sendMoneyLong(String liveUid, String goldNum, HttpCallback<String> callback) {
API.get().pdLiveApi(mContext)
.sendMoneyLong(liveUid, goldNum)
@ -3055,6 +3078,7 @@ public class LiveNetManager {
}
public void endSendMoneyLong(String liveUid, String sendMoneyLongKey, HttpCallback<SendMoneyLongModel> callback) {
API.get().pdLiveApi(mContext)
.endSendMoneyLong(liveUid, sendMoneyLongKey)
@ -3079,14 +3103,38 @@ public class LiveNetManager {
}
public void sendMoneyLongList(String liveUid, HttpCallback<List<sendMoneyLongListModel>> callback) {
public void checkUpgrades( String liveUid,HttpCallback<CheckUpgradesModel> callback) {
API.get().pdLiveApi(mContext)
.sendMoneyLongList(liveUid)
.checkUpgrades(liveUid)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<List<sendMoneyLongListModel>>>() {
.subscribe(new Consumer<ResponseModel<CheckUpgradesModel>>() {
@Override
public void accept(ResponseModel<List<sendMoneyLongListModel>> listResponseModel) throws Exception {
public void accept(ResponseModel<CheckUpgradesModel> listResponseModel) throws Exception {
if (callback != null) {
callback.onSuccess(listResponseModel.getData().getInfo());
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
throwable.printStackTrace();
if (callback != null) {
callback.onError(mContext.getString(R.string.net_error));
}
}
}).isDisposed();
}
public void getRewards(HttpCallback<CheckUpgradesModel> callback) {
API.get().pdLiveApi(mContext)
.getRewards("2")
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<CheckUpgradesModel>>() {
@Override
public void accept(ResponseModel<CheckUpgradesModel> listResponseModel) throws Exception {
if (callback != null) {
callback.onSuccess(listResponseModel.getData().getInfo());
}

View File

@ -8,6 +8,7 @@ import android.app.Activity;
import android.app.Dialog;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
@ -17,14 +18,19 @@ import android.webkit.WebView;
import com.alibaba.android.arouter.launcher.ARouter;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.lxj.xpopup.XPopup;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.CheckUpgradesModel;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.bean.ReportCommunityBean;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.bean.VideoBean;
import com.yunbao.common.bean.VideoListBean;
import com.yunbao.common.dialog.GuardUpgradePopup;
import com.yunbao.common.event.JavascriptInterfaceEvent;
import com.yunbao.common.event.LiveRoomChangeEvent;
import com.yunbao.common.event.QuickGiftingEvent;
@ -688,4 +694,16 @@ public class JavascriptInterfaceUtils {
public void androidtoCommunityVideo() {
RouteUtil.forwardCommunityActivity();
}
@JavascriptInterface
public void getRewards(String checkUpgradesJson){
try {
CheckUpgradesModel upgradesModel = new Gson().fromJson(checkUpgradesJson,CheckUpgradesModel.class);
if (!TextUtils.isEmpty(upgradesModel.getLevel()))
new XPopup.Builder(mWebView.getContext())
.asCustom(new GuardUpgradePopup(mWebView.getContext(), "", upgradesModel))
.show();
} catch (JsonSyntaxException e) {
throw new RuntimeException(e);
}
}
}

View File

@ -23,6 +23,7 @@
app:gradient_stroke_strokeWidth="5dp" />
<TextView
android:id="@+id/leave_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
@ -46,6 +47,7 @@
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/rewards_line1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="13dp"
@ -53,12 +55,14 @@
android:orientation="vertical">
<ImageView
android:id="@+id/rewards_img1"
android:layout_width="80dp"
android:layout_height="80dp"
android:scaleType="fitXY"
android:src="@mipmap/tequan_1" />
<TextView
android:id="@+id/rewards_text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
@ -69,6 +73,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/rewards_line2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
@ -78,12 +83,14 @@
android:orientation="vertical">
<ImageView
android:id="@+id/rewards_img2"
android:layout_width="80dp"
android:layout_height="80dp"
android:scaleType="fitXY"
android:src="@mipmap/tequan_1" />
<TextView
android:id="@+id/rewards_text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
@ -94,6 +101,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/rewards_line3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="13dp"
@ -101,12 +109,14 @@
android:orientation="vertical">
<ImageView
android:id="@+id/rewards_img3"
android:layout_width="80dp"
android:layout_height="80dp"
android:scaleType="fitXY"
android:src="@mipmap/tequan_1" />
<TextView
android:id="@+id/rewards_text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
@ -139,7 +149,7 @@
android:layout_height="36dp"
android:layout_gravity="end"
android:background="@drawable/button_guard_upgrade"
android:text="@string/confirm"
android:text="@string/to_receive"
android:textColor="#893D0D"
android:textSize="14sp" />
</FrameLayout>

View File

@ -1,38 +0,0 @@
package com.yunbao.live.dialog;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentActivity;
import com.lxj.xpopup.core.CenterPopupView;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
import com.yunbao.live.R;
public class GuardUpgradePopup extends CenterPopupView {
FragmentActivity activity;
String mLiveUid;
public GuardUpgradePopup(@NonNull Context context, String liveUid) {
super(context);
activity = (FragmentActivity) context;
mLiveUid = liveUid;
}
@Override
protected int getImplLayoutId() {
return R.layout.guard_upgrade_popup;
}
// 执行初始化操作比如findView设置点击或者任何你弹窗内的业务逻辑
@Override
protected void onCreate() {
super.onCreate();
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.confirm), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
dismiss();
}
});
}
}

View File

@ -28,11 +28,13 @@ import com.makeramen.roundedimageview.RoundedImageView;
import com.stx.xhb.androidx.XBanner;
import com.umeng.analytics.MobclickAgent;
import com.yunbao.common.adapter.LiveBuyGuardPrivilegeAdapter;
import com.yunbao.common.bean.CheckUpgradesModel;
import com.yunbao.common.bean.GuardDataTipModel;
import com.yunbao.common.bean.GuardGetGuardOpenInfoModel;
import com.yunbao.common.bean.GuardPriceModel;
import com.yunbao.common.dialog.AbsDialogPopupWindow;
import com.yunbao.common.dialog.GuardBuyTipsDialog;
import com.yunbao.common.dialog.GuardUpgradePopup;
import com.yunbao.common.dialog.LiveBuyGuardSelectPopup;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.base.HttpCallback;
@ -126,15 +128,15 @@ public class LiveBuyGuardDialog extends AbsDialogPopupWindow {
if (guardDataTipModel.getGuardType() == 1) {
guardBannerModel.setGradientColors(gradientColorsStart)
.setGuardOpen(R.mipmap.icon_bg_star_guard_open)
.setGuardImage(WordUtil.isNewZh()?R.mipmap.bg_star_guard:R.mipmap.bg_star_guard_en);
.setGuardImage(WordUtil.isNewZh() ? R.mipmap.bg_star_guard : R.mipmap.bg_star_guard_en);
} else if (guardDataTipModel.getGuardType() == 2) {
guardBannerModel.setGuardOpen(R.mipmap.icon_bg_king_guard_open)
.setGradientColors(gradientColorsKing)
.setGuardImage(WordUtil.isNewZh()?R.mipmap.bg_king_guard:R.mipmap.bg_king_guard_en);
.setGuardImage(WordUtil.isNewZh() ? R.mipmap.bg_king_guard : R.mipmap.bg_king_guard_en);
} else {
guardBannerModel.setGuardOpen(R.mipmap.icon_god_guard_open)
.setGradientColors(gradientColorsGod)
.setGuardImage(WordUtil.isNewZh()?R.mipmap.bg_god_guard:R.mipmap.bg_god_guard_en);
.setGuardImage(WordUtil.isNewZh() ? R.mipmap.bg_god_guard : R.mipmap.bg_god_guard_en);
}
buyGuardBannerModels.add(guardBannerModel);
}
@ -342,6 +344,21 @@ public class LiveBuyGuardDialog extends AbsDialogPopupWindow {
// .show();
}
});
LiveNetManager.get(getContext())
.checkUpgrades(mLiveUid, new com.yunbao.common.http.base.HttpCallback<CheckUpgradesModel>() {
@Override
public void onSuccess(CheckUpgradesModel data) {
if (!TextUtils.isEmpty(data.getLevel()))
new XPopup.Builder(mContext)
.asCustom(new GuardUpgradePopup(mContext, mLiveUid, data))
.show();
}
@Override
public void onError(String error) {
}
});
}

View File

@ -1,6 +1,7 @@
package com.yunbao.live.dialog;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
@ -16,9 +17,11 @@ import com.makeramen.roundedimageview.RoundedImageView;
import com.opensource.svgaplayer.SVGAImageView;
import com.umeng.analytics.MobclickAgent;
import com.yunbao.common.adapter.RefreshAdapter;
import com.yunbao.common.bean.CheckUpgradesModel;
import com.yunbao.common.bean.GuardGetGuardUserInfoModel;
import com.yunbao.common.custom.CommonRefreshView;
import com.yunbao.common.dialog.AbsDialogPopupWindow;
import com.yunbao.common.dialog.GuardUpgradePopup;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.LiveHttpUtil;
@ -186,6 +189,21 @@ public class LiveGuardDialog extends AbsDialogPopupWindow {
btnGuardOpen.setText(WordUtil.isNewZh() ? "開通守護" : "Open Guard");
}
});
LiveNetManager.get(getContext())
.checkUpgrades(mLiveUid, new com.yunbao.common.http.base.HttpCallback<CheckUpgradesModel>() {
@Override
public void onSuccess(CheckUpgradesModel data) {
if (!TextUtils.isEmpty(data.getLevel()))
new XPopup.Builder(mContext)
.asCustom(new GuardUpgradePopup(mContext, mLiveUid, data))
.show();
}
@Override
public void onError(String error) {
}
});
}
private void setAdapterData() {