小礼物逻辑第er次上传

This commit is contained in:
18401019693 2023-11-25 13:54:31 +08:00
parent 7b1f3ddd79
commit 089b1881f1
11 changed files with 304 additions and 60 deletions

View File

@ -39,6 +39,28 @@ public class EnterRoomNewModel extends BaseModel {
private String sudGameRoomName;
@SerializedName("sud_gameDate")
private SudGameDateModel sudGameDateModel;
@SerializedName("quick_gift_remaining_quantity")
private int quickGiftRemainingQuantity;//剩余的小PD礼物数量
@SerializedName("if_viewing_duration_complete")
private int ifViewingDurationComplete;//通过观看时间获取小PD礼物的次数
public int getQuickGiftRemainingQuantity() {
return quickGiftRemainingQuantity;
}
public EnterRoomNewModel setQuickGiftRemainingQuantity(int quickGiftRemainingQuantity) {
this.quickGiftRemainingQuantity = quickGiftRemainingQuantity;
return this;
}
public int getIfViewingDurationComplete() {
return ifViewingDurationComplete;
}
public EnterRoomNewModel setIfViewingDurationComplete(int ifViewingDurationComplete) {
this.ifViewingDurationComplete = ifViewingDurationComplete;
return this;
}
public SudGameDateModel getSudGameDateModel() {
return sudGameDateModel;

View File

@ -0,0 +1,28 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
public class QuickGiftSendGiftModel extends BaseModel {
@SerializedName("quick_gift_remaining_quantity")
private int quickGiftRemainingQuantity;//剩余的小PD礼物数量
@SerializedName("if_viewing_duration_complete")
private int ifViewingDurationComplete;//通过观看时间获取小PD礼物的次数
public int getQuickGiftRemainingQuantity() {
return quickGiftRemainingQuantity;
}
public QuickGiftSendGiftModel setQuickGiftRemainingQuantity(int quickGiftRemainingQuantity) {
this.quickGiftRemainingQuantity = quickGiftRemainingQuantity;
return this;
}
public int getIfViewingDurationComplete() {
return ifViewingDurationComplete;
}
public QuickGiftSendGiftModel setIfViewingDurationComplete(int ifViewingDurationComplete) {
this.ifViewingDurationComplete = ifViewingDurationComplete;
return this;
}
}

View File

@ -5,6 +5,16 @@ import com.yunbao.common.bean.BaseModel;
public class QuickGiftingEvent extends BaseModel {
private int index;
private String svgaName;
private boolean show =false;
public boolean isShow() {
return show;
}
public QuickGiftingEvent setShow(boolean show) {
this.show = show;
return this;
}
public int getIndex() {
return index;

View File

@ -46,6 +46,7 @@ import com.yunbao.common.bean.OpenAdModel;
import com.yunbao.common.bean.PkRankBean;
import com.yunbao.common.bean.PrankGiftBean;
import com.yunbao.common.bean.PrankHttpTurntableBean;
import com.yunbao.common.bean.QuickGiftSendGiftModel;
import com.yunbao.common.bean.RandomPkUserBean;
import com.yunbao.common.bean.RankPkInfoBean;
import com.yunbao.common.bean.RedPacketDetailsBean;
@ -1061,9 +1062,23 @@ public interface PDLiveApi {
@GET("/api/public/?service=Sudgameserver.deductMoney")
Observable<ResponseModel<Object>> deductMoney(
@Query("room_id") String roomId
);
@GET("/api/public/?service=Sudgameserver.checkCurrency")
Observable<ResponseModel<CheckCurrencyModel>> checkCurrency(
);
@GET("/api/public/?service=Quickgift.sendGift")
Observable<ResponseModel<QuickGiftSendGiftModel>> quickGiftSendGift(
@Query("quick_gift_number") String quickGiftNumber,
@Query("liveuid") String liveUid,
@Query("stream") String stream
);
@GET("/api/public/?service=Quickgift.viewingDurationGetGift")
Observable<ResponseModel<QuickGiftSendGiftModel>> viewingDurationGetGift(
@Query("liveuid") String liveUid
);
}

View File

@ -44,6 +44,7 @@ import com.yunbao.common.bean.OpenAdModel;
import com.yunbao.common.bean.PkRankBean;
import com.yunbao.common.bean.PrankGiftBean;
import com.yunbao.common.bean.PrankHttpTurntableBean;
import com.yunbao.common.bean.QuickGiftSendGiftModel;
import com.yunbao.common.bean.RandomPkUserBean;
import com.yunbao.common.bean.RankPkInfoBean;
import com.yunbao.common.bean.RedPacketDetailsBean;
@ -2317,21 +2318,21 @@ public class LiveNetManager {
}
public void deductMoney(String roomId) {
API.get().pdLiveApi(mContext)
.deductMoney(roomId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<Object>>() {
@Override
public void accept(ResponseModel<Object> objectResponseModel) throws Exception {
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
}
}).isDisposed();
// API.get().pdLiveApi(mContext)
// .deductMoney(roomId)
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new Consumer<ResponseModel<Object>>() {
// @Override
// public void accept(ResponseModel<Object> objectResponseModel) throws Exception {
//
// }
// }, new Consumer<Throwable>() {
// @Override
// public void accept(Throwable throwable) throws Exception {
//
// }
// }).isDisposed();
}
public void checkCurrency(HttpCallback<CheckCurrencyModel> callback) {
@ -2384,6 +2385,50 @@ public class LiveNetManager {
}).isDisposed();
}
public void viewingDurationGetGift(String liveUid, HttpCallback<QuickGiftSendGiftModel> callback) {
API.get().pdLiveApi(mContext)
.viewingDurationGetGift(liveUid)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<QuickGiftSendGiftModel>>() {
@Override
public void accept(ResponseModel<QuickGiftSendGiftModel> quickGiftSendGiftModelResponseModel) throws Exception {
if (callback != null) {
callback.onSuccess(quickGiftSendGiftModelResponseModel.getData().getInfo());
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (callback != null) {
callback.onError(mContext.getString(R.string.net_error));
}
}
}).isDisposed();
}
public void quickGiftSendGift(String quickGiftNumber, String liveUid, String stream, HttpCallback<QuickGiftSendGiftModel> callback) {
API.get().pdLiveApi(mContext)
.quickGiftSendGift(quickGiftNumber, liveUid, stream)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<QuickGiftSendGiftModel>>() {
@Override
public void accept(ResponseModel<QuickGiftSendGiftModel> quickGiftSendGiftModelResponseModel) throws Exception {
if (callback != null) {
callback.onSuccess(quickGiftSendGiftModelResponseModel.getData().getInfo());
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (callback != null) {
callback.onError(mContext.getString(R.string.net_error));
}
}
}).isDisposed();
}
public void getRoomList(String sudGameId, String threshold, String roomHolderType, String liveUid, String currencyType, int page, HttpCallback<List<SudRoomListModel>> callback) {
API.get().pdLiveApi(mContext)
.getRoomList(sudGameId, threshold, roomHolderType, liveUid, currencyType, page)

View File

@ -14,7 +14,7 @@ public class CircleProgress2 extends View {
private RectF mRectF;
private int mCurrent = 1, mMax = 100;
//圆弧也可以说是圆环的宽度
private float mArcWidth =8;
private float mArcWidth =9;
//控件的宽度
private float mWidth;
@ -56,14 +56,14 @@ public class CircleProgress2 extends View {
mPaint.setStyle(Paint.Style.STROKE);
//设置圆弧的宽度圆环的宽度
mPaint.setStrokeWidth(mArcWidth);
mPaint.setColor(Color.parseColor("#FEC51B"));
mPaint.setColor(Color.parseColor("#46433F"));
//大圆的半径
float bigCircleRadius = mWidth / 2;
//小圆的半径
float smallCircleRadius = bigCircleRadius - mArcWidth;
//绘制小圆
canvas.drawCircle(bigCircleRadius, bigCircleRadius, smallCircleRadius, mPaint);
mPaint.setColor(Color.parseColor("#46433F"));
mPaint.setColor(Color.parseColor("#FEC51B"));
mRectF.set(mArcWidth, mArcWidth, mWidth - mArcWidth, mWidth - mArcWidth);
//绘制圆弧
canvas.drawArc(mRectF, -90, mCurrent * 360 / mMax, false, mPaint);

View File

@ -1766,7 +1766,7 @@ public class LiveAudienceActivity extends LiveActivity {
}
}
@Subscribe(threadMode = ThreadMode .MAIN)
@Subscribe(threadMode = ThreadMode.MAIN)
public void onSlideEvent(SlideEvent event) {
verticalViewPager.setEnableScroll(event.isSlide());
}
@ -1775,9 +1775,14 @@ public class LiveAudienceActivity extends LiveActivity {
public void onQuickGiftingEvent(QuickGiftingEvent event) {
if (manager != null) {
if (event.isShow()) {
manager.onQuickGifting2(true);
} else {
manager.onQuickGifting(event.getIndex(), event.getSvgaName());
}
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onNewRoleCustomDrawerPopupEvent(NewRoleCustomDrawerPopupEvent event) {

View File

@ -29,6 +29,7 @@ import com.umeng.analytics.MobclickAgent;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.NewPeopleInfo;
import com.yunbao.common.bean.QuickGiftSendGiftModel;
import com.yunbao.common.dialog.LiveNewRolePopup;
import com.yunbao.common.event.MessageIMEvent;
import com.yunbao.common.event.QuickGiftingEvent;
@ -36,12 +37,14 @@ 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.http.live.LiveNetManager;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.ProcessResultUtil;
import com.yunbao.common.utils.SpUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.views.weight.CircleProgress2;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
@ -80,7 +83,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
private View v_msg_redpoint, stationHornBanner;
private Activity context;
private ViewFlipper viewFlipper;
private TextView goToRomm;
private TextView goToRomm, quick_gift_remaining_quantity, time_text;
private int icon = 0;
private String nobleName, nobleTtext;
private ImageView giftImage, liveNewPeople;
@ -91,6 +94,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
private ImageView mPlay;//
private ImageView mCheat;//整蛊
private ImageView pd_pao, combo;
private CircleProgress2 circleProgress;
public LiveAudienceViewHolder(Context context, ViewGroup parentView) {
super(context, parentView);
@ -116,6 +120,8 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
findViewById(R.id.btn_zg).setOnClickListener(this);
voiceButton = (LinearLayout) findViewById(R.id.voice_button);
giftImage = (ImageView) findViewById(R.id.gift_image);
quick_gift_remaining_quantity = (TextView) findViewById(R.id.quick_gift_remaining_quantity);
time_text = (TextView) findViewById(R.id.time_text);
liveNewPeople = (ImageView) findViewById(R.id.live_new_people);
viewFlipper = (ViewFlipper) findViewById(R.id.viewflipper_banner);
@ -126,6 +132,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
mNewPeopleRedDot = findViewById(R.id.live_new_people_red_dot);
pd_pao = (ImageView) findViewById(R.id.pd_pao);
combo = (ImageView) findViewById(R.id.combo);
circleProgress = (CircleProgress2) findViewById(R.id.circleProgress);
combo.setVisibility(View.GONE);
liveNewPeople.setOnClickListener(this);
mRole.setOnClickListener(this);
@ -270,10 +277,12 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
return true;
});
mProcessResultUtil = new ProcessResultUtil((FragmentActivity) mContext);
quick_gift_remaining_quantity.setVisibility(View.GONE);
time_text.setVisibility(View.GONE);
pd_pao.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mQuickGiftRemainingQuantity > 0) {
quickGiftingIndex = 1;
combo.setVisibility(View.VISIBLE);
removeRunnable = true;
@ -282,40 +291,107 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
int randomNumber = random.nextInt(shortSvgas.size());
String randomName = shortSvgas.get(randomNumber);
Bus.get().post(new QuickGiftingEvent().setIndex(quickGiftingIndex).setSvgaName(randomName));
mQuickGiftRemainingQuantity = mQuickGiftRemainingQuantity - 1;
quick_gift_remaining_quantity.setText(String.valueOf(mQuickGiftRemainingQuantity));
}
}
});
combo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mQuickGiftRemainingQuantity > 0) {
quickGiftingIndex = quickGiftingIndex + 1;
removeRunnable = true;
lianSongHandler.postDelayed(lianSongRunnable, 1000);
Random random = new Random();
if (quickGiftingIndex<11){
if (quickGiftingIndex < 11) {
int randomNumber = random.nextInt(shortSvgas.size());
String randomName = shortSvgas.get(randomNumber);
Bus.get().post(new QuickGiftingEvent().setIndex(quickGiftingIndex).setSvgaName(randomName));
}else {
} else {
int randomNumber = random.nextInt(highSvgas.size());
String randomName = highSvgas.get(randomNumber);
if (quickGiftingIndex>=88){
if (quickGiftingIndex >= 88) {
Bus.get().post(new QuickGiftingEvent().setIndex(quickGiftingIndex).setSvgaName("littlepanda_craft.svga"));
}else {
} else {
Bus.get().post(new QuickGiftingEvent().setIndex(quickGiftingIndex).setSvgaName(randomName));
}
}
mQuickGiftRemainingQuantity = mQuickGiftRemainingQuantity - 1;
quick_gift_remaining_quantity.setText(String.valueOf(mQuickGiftRemainingQuantity));
}
}
});
}
private int mQuickGiftRemainingQuantity = 0, mIfViewingDurationComplete;
public void upDataQuickGift(int quickGiftRemainingQuantity, int ifViewingDurationComplete) {
mQuickGiftRemainingQuantity = quickGiftRemainingQuantity;
mIfViewingDurationComplete = ifViewingDurationComplete;
quickGiftContDown = 120;
circleProgress.setMax(120);
circleProgress.setCurrent(quickGiftContDown);
if (quickGiftRemainingQuantity > 0) {
quick_gift_remaining_quantity.setVisibility(View.VISIBLE);
quick_gift_remaining_quantity.setText(String.valueOf(quickGiftRemainingQuantity));
} else {
quick_gift_remaining_quantity.setVisibility(View.GONE);
}
if (quickGiftRemainingQuantity >= 10 && ifViewingDurationComplete > 0) {
quickGiftHandler.postDelayed(quickGiftRunnable, 1000);
}
}
private int quickGiftContDown = 120;
private Handler quickGiftHandler = new Handler();
private Runnable quickGiftRunnable = new Runnable() {
@Override
public void run() {
if (mQuickGiftRemainingQuantity == 0) {
time_text.setVisibility(View.VISIBLE);
quick_gift_remaining_quantity.setVisibility(View.GONE);
} else {
time_text.setVisibility(View.GONE);
}
if (quickGiftContDown > 0) {
quickGiftContDown = quickGiftContDown - 1;
if (time_text.getVisibility() == View.VISIBLE) {
time_text.setText(String.valueOf(quickGiftContDown) + "s");
}
circleProgress.setCurrent(quickGiftContDown);
quickGiftHandler.postDelayed(quickGiftRunnable, 1000);
} else {
quickGiftHandler.removeCallbacks(quickGiftRunnable);
LiveNetManager.get(mContext).viewingDurationGetGift(mLiveUid, new com.yunbao.common.http.base.HttpCallback<QuickGiftSendGiftModel>() {
@Override
public void onSuccess(QuickGiftSendGiftModel data) {
if (data.getQuickGiftRemainingQuantity() >= 10 && data.getIfViewingDurationComplete() > 0) {
upDataQuickGift(data.getQuickGiftRemainingQuantity(), data.getIfViewingDurationComplete());
}
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
}
}
};
public void resetView() {
pd_pao.setVisibility(View.VISIBLE);
combo.setVisibility(View.GONE);
lianSongHandler.removeCallbacks(lianSongRunnable);
lianSongHandler.removeCallbacks(lianSongRunnable);
}
private boolean removeRunnable = false;
private int mLianCountDownCount;//连送倒计时的数字
private Handler lianSongHandler = new Handler();
@ -334,6 +410,21 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
pd_pao.setVisibility(View.VISIBLE);
combo.setVisibility(View.GONE);
lianSongHandler.removeCallbacks(lianSongRunnable);
Bus.get().post(new QuickGiftingEvent().setShow(true));
LiveNetManager.get(mContext).quickGiftSendGift(String.valueOf(quickGiftingIndex), mLiveUid, mStream, new com.yunbao.common.http.base.HttpCallback<QuickGiftSendGiftModel>() {
@Override
public void onSuccess(QuickGiftSendGiftModel data) {
upDataQuickGift(data.getQuickGiftRemainingQuantity(), data.getIfViewingDurationComplete());
if (mQuickGiftRemainingQuantity >= 10 && mIfViewingDurationComplete > 0) {
quickGiftHandler.postDelayed(quickGiftRunnable, 1000);
}
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
} else {
lianSongHandler.postDelayed(lianSongRunnable, 1000);
}

View File

@ -708,12 +708,18 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
HashMap<String, SVGAImageView> svgaImageViewHashMap = new HashMap<>();
public void onQuickGifting2(boolean show) {
if (show) {
combo_layout.setVisibility(View.GONE);
}
}
public void onQuickGifting(int index, String svgaName) {
pa_pao_layout.setVisibility(View.VISIBLE);
combo_layout.setVisibility(View.VISIBLE);
combo_number.setText(String.valueOf(index));
SVGAImageView svgaImageView = new SVGAImageView(mContext);
String tag = svgaName+System.currentTimeMillis();
String tag = svgaName + System.currentTimeMillis();
svgaImageViewHashMap.put(tag, svgaImageView);
Bus.get().post(new SlideEvent().setSlide(!(svgaImageViewHashMap.size() > 0)));
@ -739,7 +745,7 @@ String tag = svgaName+System.currentTimeMillis();
Log.e("QuickGiftingEvent", "pa_pao_layout:getChildCount:" + pa_pao_layout.getChildCount());
if (pa_pao_layout.getChildCount() == 0) {
pa_pao_layout.setVisibility(View.GONE);
combo_layout.setVisibility(View.GONE);
Bus.get().post(new SlideEvent().setSlide(true));
}
}

View File

@ -56,7 +56,6 @@ import com.yunbao.common.event.LiveFloatEvent;
import com.yunbao.common.event.LiveGiftDialogEvent;
import com.yunbao.common.event.LiveRoomChangeEvent;
import com.yunbao.common.event.LiveSudGamePopupShowOrHideEvent;
import com.yunbao.common.event.QuickGiftingEvent;
import com.yunbao.common.event.SendBlindGiftEvent;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.CommonHttpConsts;
@ -224,9 +223,15 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
}
public void onQuickGifting(int index,String svgaName) {
public void onQuickGifting(int index, String svgaName) {
if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.onQuickGifting(index,svgaName);
mLiveRoomViewHolder.onQuickGifting(index, svgaName);
}
}
public void onQuickGifting2(boolean show) {
if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.onQuickGifting2(show);
}
}
@ -734,6 +739,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.setSudName(WordUtil.isNewZh() ? data.getSudGameDateModel().getSudGameName() : data.getSudGameDateModel().getSud_game_name_en(), data.getSudGameDateModel());
}
}
mLiveAudienceViewHolder.upDataQuickGift(data.getQuickGiftRemainingQuantity(), data.getIfViewingDurationComplete());
}

View File

@ -392,34 +392,50 @@
<com.yunbao.common.views.weight.CircleProgress2
android:id="@+id/circleProgress"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
<ImageView
android:id="@+id/pd_pao"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_width="27dp"
android:layout_height="27dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@mipmap/icon_pd_pao" />
<TextView
android:layout_width="30dp"
android:layout_height="30dp"
android:id="@+id/time_text"
android:layout_width="27dp"
android:layout_height="27dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@drawable/backgroud_panda_time"
android:gravity="center"
android:text="120S"
android:textColor="@color/white"
android:textSize="12sp"
android:textSize="10sp"
android:visibility="gone" />
<TextView
android:id="@+id/quick_gift_remaining_quantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="-2dp"
android:text="99"
android:textColor="#FFB403"
android:textSize="10sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/combo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@mipmap/icon_combo" />
android:src="@mipmap/icon_combo"
android:visibility="gone" />
</RelativeLayout>
<!--礼物-->