星级挑战
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
BIN
common/src/main/res/mipmap-xxhdpi/icon_start.png
Normal file
BIN
common/src/main/res/mipmap-xxhdpi/icon_start.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.5 KiB |
BIN
common/src/main/res/mipmap-xxhdpi/icon_start_number.png
Normal file
BIN
common/src/main/res/mipmap-xxhdpi/icon_start_number.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
BIN
common/src/main/res/mipmap-xxhdpi/start_level.png
Normal file
BIN
common/src/main/res/mipmap-xxhdpi/start_level.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user