星级挑战

This commit is contained in:
18401019693 2022-10-10 17:22:04 +08:00
parent d1e40abe2e
commit ce7433226d
15 changed files with 542 additions and 18 deletions

View File

@ -7,11 +7,33 @@ import com.alibaba.fastjson.annotation.JSONField;
*/
public class BannerBean {
//是否是星标
private boolean isStart = false;
private String mImageUrl;
private String mLink;
private String show_type;
private String mIntoUrl;
private StarChallengeStatusModel model;
public boolean isStart() {
return isStart;
}
public BannerBean setStart(boolean start) {
isStart = start;
return this;
}
public StarChallengeStatusModel getModel() {
return model;
}
public BannerBean setModel(StarChallengeStatusModel model) {
this.model = model;
return this;
}
public String getShow_type() {
return show_type;
}

View File

@ -0,0 +1,112 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
public class StarChallengeStatusModel extends BaseModel {
//当前星级
@SerializedName("taskNum")
private String taskNum;
//当前总星值
@SerializedName("currentStarVal")
private String currentStarVal;
//目标总星值
@SerializedName("targetStarVal")
private String targetStarVal;
//当前助力数
@SerializedName("currentAssistNum")
private String currentAssistNum;
//目标助力数
@SerializedName("targetAssistNum")
private String targetAssistNum;
//总星值图标
@SerializedName("starSrc")
private String starSrc;
//助力图标
@SerializedName("assistSrc")
private String assistSrc;
@SerializedName("taskName1")
private String taskName1;
@SerializedName("taskName2")
private String taskName2;
public String getTaskName1() {
return taskName1;
}
public StarChallengeStatusModel setTaskName1(String taskName1) {
this.taskName1 = taskName1;
return this;
}
public String getTaskName2() {
return taskName2;
}
public StarChallengeStatusModel setTaskName2(String taskName2) {
this.taskName2 = taskName2;
return this;
}
public String getTaskNum() {
return taskNum;
}
public BaseModel setTaskNum(String taskNum) {
this.taskNum = taskNum;
return this;
}
public String getCurrentStarVal() {
return currentStarVal;
}
public BaseModel setCurrentStarVal(String currentStarVal) {
this.currentStarVal = currentStarVal;
return this;
}
public String getTargetStarVal() {
return targetStarVal;
}
public BaseModel setTargetStarVal(String targetStarVal) {
this.targetStarVal = targetStarVal;
return this;
}
public String getCurrentAssistNum() {
return currentAssistNum;
}
public BaseModel setCurrentAssistNum(String currentAssistNum) {
this.currentAssistNum = currentAssistNum;
return this;
}
public String getTargetAssistNum() {
return targetAssistNum;
}
public BaseModel setTargetAssistNum(String targetAssistNum) {
this.targetAssistNum = targetAssistNum;
return this;
}
public String getStarSrc() {
return starSrc;
}
public BaseModel setStarSrc(String starSrc) {
this.starSrc = starSrc;
return this;
}
public String getAssistSrc() {
return assistSrc;
}
public BaseModel setAssistSrc(String assistSrc) {
this.assistSrc = assistSrc;
return this;
}
}

View File

@ -15,6 +15,7 @@ import com.yunbao.common.bean.NobleTrumpetModel;
import com.yunbao.common.bean.SearchModel;
import com.yunbao.common.bean.SetAttentsModel;
import com.yunbao.common.bean.SlideInBannerModel;
import com.yunbao.common.bean.StarChallengeStatusModel;
import com.yunbao.common.bean.VipModel;
import java.util.List;
@ -232,4 +233,12 @@ public interface PDLiveApi {
*/
@GET("/api/public/?service=Noble.getNobleRankHideUserList")
Observable<ResponseModel<NobleRankHideUserListModel>> getNobleRankHideUserList();
/**
*获取当前星级
* @param liveUid
* @return
*/
@GET("/api/public/?service=StarChallenge.getStarChallengeStatus")
Observable<ResponseModel<StarChallengeStatusModel>> getStarChallengeStatus(@Query("liveUid") String liveUid);
}

View File

@ -10,8 +10,10 @@ import com.yunbao.common.bean.LiveInfoModel;
import com.yunbao.common.bean.NobleRankHideUserListModel;
import com.yunbao.common.bean.NobleTrumpetModel;
import com.yunbao.common.bean.SetAttentsModel;
import com.yunbao.common.bean.StarChallengeStatusModel;
import com.yunbao.common.bean.VipModel;
import com.yunbao.common.http.API;
import com.yunbao.common.http.ResponseModel;
import com.yunbao.common.http.base.HttpCallback;
import java.util.List;
@ -213,4 +215,22 @@ public class LiveNetManager {
callback.onError(throwable.getMessage());
}).isDisposed();
}
/**
* 获取当前星级
*/
public void getStarChallengeStatus(String liveUid, HttpCallback<StarChallengeStatusModel> callback) {
API.get().pdLiveApi(mContext)
.getStarChallengeStatus(liveUid)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(starChallengeStatusModelResponseModel -> {
if (callback != null) {
callback.onSuccess(starChallengeStatusModelResponseModel.getData().getInfo());
}
}, throwable -> {
if (callback != null)
callback.onError(throwable.getMessage());
}).isDisposed();
}
}

View File

@ -0,0 +1,136 @@
package com.yunbao.common.views.weight;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;
/**
* 横向进度条星级
*/
public class ProgressView extends View {
/**
* 进度条最大值
*/
private float maxCount;
/**
* 进度条当前值
*/
private float currentCount;
/**
* 画笔
*/
private Paint mPaint;
private int mWidth, mHeight;
public ProgressView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public ProgressView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ProgressView(Context context) {
super(context);
}
/***
* 设置最大的进度值
*/
public void setMaxCount(float maxCount) {
this.maxCount = maxCount;
}
/**
* 得到最大进度值
*/
public double getMaxCount() {
return maxCount;
}
/***
* 设置当前的进度值
* @param currentCount
*/
public void setCurrentCount(float currentCount) {
this.currentCount = currentCount > maxCount ? maxCount : currentCount;
/**
* invalidate()是用来刷新View的必须是在UI线程中进行工作比如在修改某个view的显示时
* 调用invalidate()才能看到重新绘制的界面invalidate()的调用是把之前的旧的view从主UI
* 线程队列中pop掉
*/
invalidate();
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
mPaint = new Paint();
//设置抗锯齿效果
mPaint.setAntiAlias(true);
int round = mHeight;
/**
* RectF绘制矩形四个参数分别是left,top,right,bottom
* 类型是单精度浮点数
*/
RectF rf = new RectF(0, 0, mWidth, mHeight);
/*绘制圆角矩形,背景色为画笔颜色*/
/*设置progress内部是灰色*/
mPaint.setColor(Color.parseColor("#F6CCDA"));
RectF rectBlackBg = new RectF(2, 2, mWidth - 2, mHeight - 2);
canvas.drawRoundRect(rectBlackBg, round, round, mPaint);
//设置进度条进度及颜色
float section = currentCount / maxCount;
RectF rectProgressBg = new RectF(3, 3, (mWidth - 3) * section, mHeight - 3);
if (section != 0.0f) {
mPaint.setColor(Color.parseColor("#F85F73"));
} else {
mPaint.setColor(Color.TRANSPARENT);
}
canvas.drawRoundRect(rectProgressBg, round, round, mPaint);
}
//dip * scale + 0.5f * (dip >= 0 ? 1 : -1)
private int dipToPx(int dip) {
float scale = getContext().getResources().getDisplayMetrics().density;
return (int) (dip * scale + 0.5f * (dip >= 0 ? 1 : -1));//加0.5是为了四舍五入
}
/**
* 指定自定义控件在屏幕上的大小,onMeasure方法的两个参数是由上一层控件
* <p>
* 传入的大小而且是模式和尺寸混合在一起的数值需要MeasureSpec.getMode(widthMeasureSpec)
* <p>
* 得到模式MeasureSpec.getSize(widthMeasureSpec)得到尺寸
*/
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec);
int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec);
int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec);
int heightSpecSize = MeasureSpec.getSize(heightMeasureSpec);
//MeasureSpec.EXACTLY精确尺寸
if (widthSpecMode == MeasureSpec.EXACTLY || widthSpecMode == MeasureSpec.AT_MOST) {
mWidth = widthSpecSize;
} else {
mWidth = 0;
}
//MeasureSpec.AT_MOST最大尺寸只要不超过父控件允许的最大尺寸即可MeasureSpec.UNSPECIFIED未指定尺寸
if (heightSpecMode == MeasureSpec.AT_MOST || heightSpecMode == MeasureSpec.UNSPECIFIED) {
mHeight = dipToPx(20);
} else {
mHeight = heightSpecSize;
}
//设置控件实际大小
setMeasuredDimension(mWidth, mHeight);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

View File

@ -921,6 +921,8 @@
<string name="online_audience">在線觀眾</string>
<string name="audience">觀眾</string>
<string name="cannot_yourself">無法@自己</string>
<string name="total_star_value">總星值</string>
<string name="number_of_people_assisted">助力人數</string>
</resources>

View File

@ -173,7 +173,7 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
itemView.setTag(bean);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.setMargins(0, 0, DpUtil.dp2px(80), 12);
params.setMargins(0, 0, DpUtil.dp2px(95), 12);
mBg.setLayoutParams(params);
if (bean.getType() == 6) {//大作战活动
view_action_game.setVisibility(View.VISIBLE);

View File

@ -1,28 +1,72 @@
package com.yunbao.live.views;
import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.ms.banner.holder.BannerViewHolder;
import com.yunbao.common.bean.BannerBean;
import com.yunbao.common.views.weight.ProgressView;
import com.yunbao.live.R;
public class CustomViewHolder implements BannerViewHolder<BannerBean> {
@Override
public View createView(Context context, int position, BannerBean data) {
// 返回mImageView页面布局
ImageView imageView = new ImageView(context);
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT
);
imageView.setLayoutParams(params);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
Glide.with(context).load(data.getImageUrl()).into(imageView);
LayoutInflater inflater = LayoutInflater.from(context);
return imageView;
View contextView = inflater.inflate(R.layout.view_start_level, null);
FrameLayout startContext = contextView.findViewById(R.id.start_context);
ImageView bannerBack = contextView.findViewById(R.id.banner_back);
ImageView iconStart = contextView.findViewById(R.id.icon_start);
ImageView iconStartNumber = contextView.findViewById(R.id.icon_start_number);
ProgressView totalStarProgress = contextView.findViewById(R.id.total_star_progress);
ProgressView assistProgress = contextView.findViewById(R.id.assist_progress);
TextView currentStart = contextView.findViewById(R.id.current_start);
TextView targetStart = contextView.findViewById(R.id.target_start);
TextView totalStarValue = contextView.findViewById(R.id.total_star_value);
TextView numberOfPeopleAssisted = contextView.findViewById(R.id.number_of_people_assisted);
TextView targetAssist = contextView.findViewById(R.id.target_assist_num);
TextView currentAssist = contextView.findViewById(R.id.current_assist_num);
if (data.isStart()) {
startContext.setVisibility(View.VISIBLE);
Glide.with(context).load(R.mipmap.start_level).into(bannerBack);
Glide.with(context)
.load(data.getModel().getStarSrc())
.error(R.mipmap.icon_start)
.into(iconStart);
Glide.with(context)
.load(data.getModel().getAssistSrc())
.error(R.mipmap.icon_start_number)
.into(iconStartNumber);
int targetStarVal = TextUtils.isEmpty(data.getModel().getTargetStarVal()) ? 100 : Integer.parseInt(data.getModel().getTargetStarVal());
int currentStarVal = TextUtils.isEmpty(data.getModel().getCurrentStarVal()) ? 0 : Integer.parseInt(data.getModel().getCurrentStarVal());
int targetAssistNum = TextUtils.isEmpty(data.getModel().getTargetAssistNum()) ? 0 : Integer.parseInt(data.getModel().getTargetAssistNum());
int currentAssistNum = TextUtils.isEmpty(data.getModel().getCurrentAssistNum()) ? 0 : Integer.parseInt(data.getModel().getCurrentAssistNum());
totalStarProgress.setMaxCount(targetStarVal);
assistProgress.setMaxCount(targetAssistNum);
totalStarProgress.setCurrentCount(currentStarVal);
assistProgress.setCurrentCount(currentAssistNum);
currentStart.setText(String.valueOf(currentStarVal));
targetStart.setText("/" + targetStarVal);
totalStarValue.setText(TextUtils.isEmpty(data.getModel().getTaskName1()) ? context.getString(R.string.total_star_value) : data.getModel().getTaskName1());
numberOfPeopleAssisted.setText(TextUtils.isEmpty(data.getModel().getTaskName2()) ? context.getString(R.string.total_star_value) : data.getModel().getTaskName2());
targetAssist.setText("/" + targetAssistNum);
currentAssist.setText(String.valueOf(currentAssistNum));
} else {
String imagerUrl = data.getImageUrl().replace("qny", "downs");
Glide.with(context).load(imagerUrl).into(bannerBack);
startContext.setVisibility(View.GONE);
}
return contextView;
}
}

View File

@ -65,6 +65,7 @@ import com.yunbao.common.bean.HourRank;
import com.yunbao.common.bean.LevelBean;
import com.yunbao.common.bean.LiveGiftBean;
import com.yunbao.common.bean.MsgModel;
import com.yunbao.common.bean.StarChallengeStatusModel;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.API;
@ -1024,6 +1025,17 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
reloadIM();
}
public void showStart(StarChallengeStatusModel data) {
if (mBannerList2 == null) {
mBannerList2 = new ArrayList<>();
}
BannerBean bannerBean = new BannerBean();
bannerBean.setStart(true);
bannerBean.setModel(data);
mBannerList2.add(bannerBean);
showBanner2();
}
public void hideFloatMsg() {
msgLayout.setVisibility(View.GONE);
}

View File

@ -37,6 +37,7 @@ import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.MsgModel;
import com.yunbao.common.bean.StarChallengeStatusModel;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.custom.MyViewPager;
import com.yunbao.common.event.FollowEvent;
@ -45,6 +46,7 @@ import com.yunbao.common.http.CommonHttpConsts;
import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DialogUitl;
@ -284,7 +286,23 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.initHourRankList();
}
});
/**
* 获取当前直播间星级
*/
LiveNetManager.get(mContext)
.getStarChallengeStatus(mLiveBean.getUid(), new com.yunbao.common.http.base.HttpCallback<StarChallengeStatusModel>() {
@Override
public void onSuccess(StarChallengeStatusModel data) {
if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.showStart(data);
}
}
@Override
public void onError(String error) {
}
});
}
@Override
@ -1534,6 +1552,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.showNewMessage();
}
}
public void showAtMessage() {
if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.showAtMessage();

View File

@ -91,8 +91,8 @@
<LinearLayout
android:id="@+id/btn_event2"
android:layout_width="58dp"
android:layout_height="80dp"
android:layout_width="70dp"
android:layout_height="93dp"
android:layout_gravity="right"
android:layout_marginRight="15dp"
android:layout_marginBottom="5dp"
@ -102,8 +102,8 @@
<com.ms.banner.Banner
android:id="@+id/banner2"
android:layout_width="58dp"
android:layout_height="80dp"
android:layout_width="70dp"
android:layout_height="93dp"
android:layout_marginBottom="5dp"
app:delay_time="5000"
app:indicator_height="8dp"
@ -2010,8 +2010,8 @@
android:layout_width="106.67dp"
android:layout_height="27.33dp"
android:layout_above="@id/new_message"
android:layout_marginStart="10dp"
android:layout_alignParentBottom="true"
android:layout_marginStart="10dp"
android:layout_marginBottom="35dp"
android:visibility="gone" />

View File

@ -0,0 +1,148 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="70dp"
android:layout_height="93dp">
<ImageView
android:id="@+id/banner_back"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@mipmap/start_level" />
<FrameLayout
android:id="@+id/start_context"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="18.33dp"
android:text="星级挑战"
android:textColor="#C53F4E"
android:textSize="6sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginTop="33dp"
android:layout_marginEnd="5.67dp"
android:gravity="center_vertical">
<ImageView
android:id="@+id/icon_start"
android:layout_width="13.33dp"
android:layout_height="13.33dp"
android:src="@mipmap/icon_start" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="3.33dp"
android:orientation="vertical">
<TextView
android:id="@+id/total_star_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/total_star_value"
android:textColor="#C53F4E"
android:textSize="5.33sp" />
<com.yunbao.common.views.weight.ProgressView
android:id="@+id/total_star_progress"
android:layout_width="match_parent"
android:layout_height="4.33dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="1.67dp">
<TextView
android:id="@+id/current_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textColor="#FE762A"
android:textSize="5.33dp" />
<TextView
android:id="@+id/target_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/100"
android:textColor="#7A0002"
android:textSize="5.33dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginTop="58dp"
android:layout_marginEnd="5.67dp"
android:gravity="center_vertical">
<ImageView
android:id="@+id/icon_start_number"
android:layout_width="13.33dp"
android:layout_height="13.33dp"
android:src="@mipmap/icon_start_number" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="3.33dp"
android:orientation="vertical">
<TextView
android:id="@+id/number_of_people_assisted"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/number_of_people_assisted"
android:textColor="#C53F4E"
android:textSize="5.33sp" />
<com.yunbao.common.views.weight.ProgressView
android:id="@+id/assist_progress"
android:layout_width="match_parent"
android:layout_height="4.33dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="1.67dp">
<TextView
android:id="@+id/current_assist_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textColor="#FE762A"
android:textSize="5.33dp" />
<TextView
android:id="@+id/target_assist_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/100"
android:textColor="#7A0002"
android:textSize="5.33dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>
</RelativeLayout>