add:新增小时榜功能

fix:调整外部类调用热度textView问题
This commit is contained in:
zlzw 2022-08-30 11:32:56 +08:00
parent c864608780
commit 31b7667a3d
11 changed files with 213 additions and 31 deletions

View File

@ -163,6 +163,8 @@ public class Constants {
public static final String SOCKET_LUCK_WIN = "luckWin";//幸运礼物中奖 public static final String SOCKET_LUCK_WIN = "luckWin";//幸运礼物中奖
public static final String SOCKET_PRIZE_POOL_WIN = "jackpotWin";//奖池中奖 public static final String SOCKET_PRIZE_POOL_WIN = "jackpotWin";//奖池中奖
public static final String SOCKET_PRIZE_POOL_UP = "jackpotUp";//奖池升级 public static final String SOCKET_PRIZE_POOL_UP = "jackpotUp";//奖池升级
public static final String SOCKET_HOUR = "SendHourChart";//小时榜更新
//游戏socket //游戏socket
public static final String SOCKET_GAME_ZJH = "startGame";//炸金花 public static final String SOCKET_GAME_ZJH = "startGame";//炸金花
public static final String SOCKET_GAME_HD = "startLodumaniGame";//海盗船长 public static final String SOCKET_GAME_HD = "startLodumaniGame";//海盗船长

View File

@ -0,0 +1,70 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
/**
* 小时榜实体类
*/
public class HourRank extends BaseModel{
@SerializedName("liveuid")
String liveuid;
@SerializedName("hourchart_h5_url")
String url;
@SerializedName("rank")
long rank;
@SerializedName("starlightVal")
long starlightVal;
@SerializedName("isshow")
int isshow;
public String getLiveuid() {
return liveuid;
}
public void setLiveuid(String liveuid) {
this.liveuid = liveuid;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public long getRank() {
return rank;
}
public void setRank(long rank) {
this.rank = rank;
}
public long getStarlightVal() {
return starlightVal;
}
public void setStarlightVal(long starlightVal) {
this.starlightVal = starlightVal;
}
public int getIsshow() {
return isshow;
}
public void setIsshow(int isshow) {
this.isshow = isshow;
}
@Override
public String toString() {
return "HourRank{" +
"liveuid='" + liveuid + '\'' +
", url='" + url + '\'' +
", rank=" + rank +
", starlightVal=" + starlightVal +
", isshow=" + isshow +
'}';
}
}

View File

@ -5,6 +5,7 @@ import com.yunbao.common.bean.AnchorRecommendModel;
import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.BaseModel;
import com.yunbao.common.bean.ContributeModel; import com.yunbao.common.bean.ContributeModel;
import com.yunbao.common.bean.FaceBookUpModel; import com.yunbao.common.bean.FaceBookUpModel;
import com.yunbao.common.bean.HourRank;
import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.LiveInfoModel; import com.yunbao.common.bean.LiveInfoModel;
import com.yunbao.common.bean.MsgSwitchDetailModel; import com.yunbao.common.bean.MsgSwitchDetailModel;
@ -205,4 +206,10 @@ public interface PDLiveApi {
@GET("/api/public/?service=Tx.setBeginShowMsgSwitch") @GET("/api/public/?service=Tx.setBeginShowMsgSwitch")
Observable<ResponseModel<List<BaseModel>>> setBeginShowMsgSwitch(@Query("status") String status,@Query("isAll") String isAll,@Query("liveuid") String liveuid); Observable<ResponseModel<List<BaseModel>>> setBeginShowMsgSwitch(@Query("status") String status,@Query("isAll") String isAll,@Query("liveuid") String liveuid);
/**
* 小时榜接口
* @param liveuid 直播间id
*/
@GET("/api/public/?service=Live.getHourChartRank")
Observable<ResponseModel<List<HourRank>>> getHourChartRank(@Query("liveuid")String liveuid);
} }

View File

@ -276,9 +276,10 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
mLiveLinkMicPresenter.onAudienceLeaveRoom(bean); mLiveLinkMicPresenter.onAudienceLeaveRoom(bean);
} }
try { try {
if (mLiveRoomViewHolder.room_hot != null) { if (mLiveRoomViewHolder!=null) {
if (!"".equals(bean.getHot_num()) && !"0".equals(bean.getHot_num())) { if (!"".equals(bean.getHot_num()) && !"0".equals(bean.getHot_num())) {
mLiveRoomViewHolder.room_hot.setText(formatBigNum.formatBigNum(bean.getHot_num())); // mLiveRoomViewHolder.room_hot.setText(formatBigNum.formatBigNum(bean.getHot_num()));
mLiveRoomViewHolder.setHotData(formatBigNum.formatBigNum(bean.getHot_num()));
} }
} }
} catch (Exception e) { } catch (Exception e) {
@ -501,6 +502,13 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
} }
} }
@Override
public void onHourRank(LiveChatBean bean,JSONObject ranks) {
if(mLiveRoomViewHolder!=null){
mLiveRoomViewHolder.setHourRankData(ranks.getInteger(mLiveUid));
}
}
/** /**
* 观众与主播连麦 主播收到观众的连麦申请 * 观众与主播连麦 主播收到观众的连麦申请
*/ */

View File

@ -42,6 +42,7 @@ import java.util.List;
*/ */
public class LiveChatAdapter extends RecyclerView.Adapter { public class LiveChatAdapter extends RecyclerView.Adapter {
public final static int MSG_HOUR_RANK_CHANGE=-100;//收到小时榜推送发送一条弹幕
private Context mContext; private Context mContext;
private List<LiveChatBean> mList; private List<LiveChatBean> mList;
@ -319,7 +320,11 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
mTextView.setText(R.string.automatic_chat); mTextView.setText(R.string.automatic_chat);
bean.setHeart(position); bean.setHeart(position);
} }
} else { }else if(bean.getType()==MSG_HOUR_RANK_CHANGE){
mBg.setBackgroundResource(R.drawable.bg_chat_automatic_item);
mTextView.setText(bean.getContent());
bean.setHeart(position);
}else {
if (bean.getBubble() != null && !bean.getBubble().equals("")) { if (bean.getBubble() != null && !bean.getBubble().equals("")) {
//加载.9图聊天气泡 //加载.9图聊天气泡
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getBubble(), 1); LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getBubble(), 1);

View File

@ -20,6 +20,7 @@ import android.webkit.JavascriptInterface;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebViewClient; import android.webkit.WebViewClient;
import android.widget.LinearLayout;
import com.adjust.sdk.Adjust; import com.adjust.sdk.Adjust;
import com.adjust.sdk.AdjustEvent; import com.adjust.sdk.AdjustEvent;
@ -145,6 +146,10 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
}else { }else {
findViewById(R.id.title_laout).setVisibility(View.VISIBLE); findViewById(R.id.title_laout).setVisibility(View.VISIBLE);
} }
if(bundle.getInt("height",-1)!=-1) {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, bundle.getInt("height",-1));
mWebView.setLayoutParams(params);
}
mWebView.loadUrl(bundle.getString("url")); mWebView.loadUrl(bundle.getString("url"));
mWebView.setWebViewClient(new WebViewClient() { mWebView.setWebViewClient(new WebViewClient() {
@Override @Override

View File

@ -324,4 +324,10 @@ public interface SocketMessageListener {
* 整蛊消息 * 整蛊消息
*/ */
void prankTurntable(String msgtype, int time, JSONObject jsonObject); void prankTurntable(String msgtype, int time, JSONObject jsonObject);
/**
* 小时榜更新
*
*/
void onHourRank(LiveChatBean bean,JSONObject ranks);
} }

View File

@ -25,6 +25,7 @@ import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R; import com.yunbao.live.R;
import com.yunbao.live.activity.LiveAudienceActivity; import com.yunbao.live.activity.LiveAudienceActivity;
import com.yunbao.live.activity.LiveRyAnchorActivity; import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.adapter.LiveChatAdapter;
import com.yunbao.live.bean.LiveBuyGuardMsgBean; import com.yunbao.live.bean.LiveBuyGuardMsgBean;
import com.yunbao.live.bean.LiveChatBean; import com.yunbao.live.bean.LiveChatBean;
import com.yunbao.live.bean.LiveDanMuBean; import com.yunbao.live.bean.LiveDanMuBean;
@ -368,6 +369,13 @@ public class SocketRyClient {
case Constants.SOCKET_PRIZE_POOL_UP://奖池升级 case Constants.SOCKET_PRIZE_POOL_UP://奖池升级
mListener.onPrizePoolUp(map.getString("uplevel")); mListener.onPrizePoolUp(map.getString("uplevel"));
break; break;
case Constants.SOCKET_HOUR://小时榜
liveChatBean=new LiveChatBean();
liveChatBean.setId("-1");
liveChatBean.setType(LiveChatAdapter.MSG_HOUR_RANK_CHANGE);
liveChatBean.setContent(map.getJSONObject("ct").getString("text"));
mListener.onHourRank(liveChatBean, map.getJSONObject("ct").getJSONObject("new_rank"));
break;
//游戏socket //游戏socket
case Constants.SOCKET_GAME_ZJH://游戏 智勇三张 case Constants.SOCKET_GAME_ZJH://游戏 智勇三张
if (CommonAppConfig.GAME_ENABLE) { if (CommonAppConfig.GAME_ENABLE) {

View File

@ -24,7 +24,6 @@ import android.widget.TextView;
import android.widget.ViewFlipper; import android.widget.ViewFlipper;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -51,9 +50,11 @@ import com.opensource.svgaplayer.SVGAVideoEntity;
import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants; import com.yunbao.common.Constants;
import com.yunbao.common.bean.BannerBean; import com.yunbao.common.bean.BannerBean;
import com.yunbao.common.bean.HourRank;
import com.yunbao.common.bean.LevelBean; import com.yunbao.common.bean.LevelBean;
import com.yunbao.common.bean.UserBean; import com.yunbao.common.bean.UserBean;
import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.API;
import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.CommonHttpConsts;
import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
@ -112,8 +113,9 @@ import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
import static com.yunbao.common.CommonAppContext.logger; import static com.yunbao.common.CommonAppContext.logger;
@ -254,6 +256,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
private LiveUserGiftBean nowGuardUser; private LiveUserGiftBean nowGuardUser;
private ViewFlipper wishListFlipper; private ViewFlipper wishListFlipper;
private List<WishlistItemModel> wishlist = new ArrayList<>(); private List<WishlistItemModel> wishlist = new ArrayList<>();
private TextView mHourRank, mHotText;
public LiveRoomViewHolder(boolean isRys, int forActivity, Context context, ViewGroup parentView, GifImageView gifImageView, SVGAImageView svgaImageView, ViewGroup liveGiftPrizePoolContainer, WindowManager windowManager) { public LiveRoomViewHolder(boolean isRys, int forActivity, Context context, ViewGroup parentView, GifImageView gifImageView, SVGAImageView svgaImageView, ViewGroup liveGiftPrizePoolContainer, WindowManager windowManager) {
super(context, parentView); super(context, parentView);
@ -1065,31 +1068,88 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}); });
} }
/** /**
* 初始化小时榜 * 初始化小时榜
* 等待接口
* TextView得独立出来用来替换数字
*/ */
protected void initHourRankList(){ protected void initHourRankList(){
((Activity)mContext).runOnUiThread(()->{
ViewFlipper flipper= (ViewFlipper) findViewById(R.id.hour_rank_list); ViewFlipper flipper= (ViewFlipper) findViewById(R.id.hour_rank_list);
for (int i = 0; i < 2; i++) {
LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(DpUtil.dp2px(44),DpUtil.dp2px(16)); LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(DpUtil.dp2px(44),DpUtil.dp2px(16));
View wish = LayoutInflater.from(mContext).inflate(R.layout.view_wish_list, null); API.get().pdLiveApi(mContext).getHourChartRank(mLiveUid)
ImageView wishPic = wish.findViewById(R.id.wish_pic); .subscribeOn(Schedulers.io())
TextView wishIndex = wish.findViewById(R.id.wish_index); .observeOn(AndroidSchedulers.mainThread())
if(i==0) { .subscribe(listResponseModel -> {
wishPic.setImageResource(R.drawable.live_tags_hot); List<HourRank> info = listResponseModel.getData().getInfo();
}else{ if(!info.isEmpty()){
wishPic.setImageResource(R.drawable.live_tags_hour_list); View hotView=LayoutInflater.from(mContext).inflate(R.layout.view_wish_list,null);
View hourView=LayoutInflater.from(mContext).inflate(R.layout.view_wish_list,null);
ImageView hotPic = hotView.findViewById(R.id.wish_pic);
ImageView hourPic = hourView.findViewById(R.id.wish_pic);
mHotText =hotView.findViewById(R.id.wish_index);
mHourRank=hourView.findViewById(R.id.wish_index);
hotPic.setImageResource(R.drawable.live_tags_hot);
hourPic.setImageResource(R.drawable.live_tags_hour_list);
hotPic.setLayoutParams(params);
hourPic.setLayoutParams(params);
flipper.addView(hotView);
flipper.addView(hourView);
flipper.setOnClickListener(view -> {
Bundle bundle=new Bundle();
String path=info.get(0).getUrl();
if(!path.startsWith("/")){
path="/"+path;
} }
wishPic.setLayoutParams(params); String url=CommonAppConfig.HOST+path;
wishIndex.setText(new Random().nextInt(5000)+""); url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token="
flipper.addView(wish); + CommonAppConfig.getInstance().getToken() + "&liveuid=" + mLiveUid;
}
flipper.startFlipping(); bundle.putString("url", url);
// bundle.putInt("height", DpUtil.dp2px(500));
bundle.putInt("show_type", 0);
LiveHDDialogFragment liveHDDialogFragment = new LiveHDDialogFragment();
liveHDDialogFragment.setArguments(bundle);
liveHDDialogFragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
}); });
flipper.startFlipping();
}
}, Throwable::printStackTrace)
.isDisposed();
} }
/**
* 星光值转带k的字符
* @param val
* @retur 字符串
*/
private String starlightValToString(long val){
if(val>1000) {
double tmp =(double)val / 1000;
return tmp + "k";
}else{
return val+"";
}
}
/**
* 设置小时榜
* @param rank 小时榜
*/
public void setHourRankData(int rank){
if(mHourRank!=null) {
mHourRank.setText(formatBigNum.formatBigNum(rank + ""));
}
}
/**
* 设置热度值
* @param hot 热度值
*/
public void setHotData(String hot){
if(mHotText!=null) {
mHotText.setText(hot);
}
}
/** /**
* 更新心愿单进度 * 更新心愿单进度
* *
@ -1819,6 +1879,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
mLiveEnterRoomAnimPresenter.enterRoom(bean); mLiveEnterRoomAnimPresenter.enterRoom(bean);
} }
room_hot.setText(formatBigNum.formatBigNum(bean.getLiveChatBean().getHot_num())); room_hot.setText(formatBigNum.formatBigNum(bean.getLiveChatBean().getHot_num()));
setHotData(formatBigNum.formatBigNum(bean.getLiveChatBean().getHot_num()));
LiveUserGiftBean chatBean = bean.getUserBean(); LiveUserGiftBean chatBean = bean.getUserBean();
if (chatBean != null && nowGuardUser != null) { if (chatBean != null && nowGuardUser != null) {
LiveUserGiftBean tmp = null; LiveUserGiftBean tmp = null;
@ -1917,6 +1978,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
public void showGiftMessage(LiveReceiveGiftBean bean) { public void showGiftMessage(LiveReceiveGiftBean bean) {
mVotes.setText(bean.getVotes()); mVotes.setText(bean.getVotes());
room_hot.setText(formatBigNum.formatBigNum(bean.getHot_num())); room_hot.setText(formatBigNum.formatBigNum(bean.getHot_num()));
setHotData(formatBigNum.formatBigNum(bean.getLiveChatBean().getHot_num()));
mTvMedalRank.setText(bean.getMedalRankNum()); mTvMedalRank.setText(bean.getMedalRankNum());
if (mLiveGiftAnimPresenter == null) { if (mLiveGiftAnimPresenter == null) {
mLiveGiftAnimPresenter = new LiveGiftAnimPresenter(mContext, mContentView, mGifImageView, mSVGAImageView, mLiveGiftPrizePoolContainer, windowManager); mLiveGiftAnimPresenter = new LiveGiftAnimPresenter(mContext, mContentView, mGifImageView, mSVGAImageView, mLiveGiftPrizePoolContainer, windowManager);
@ -1930,6 +1992,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
public void showGiftMessage(LiveReceiveGiftBean bean, boolean isAncher) { public void showGiftMessage(LiveReceiveGiftBean bean, boolean isAncher) {
mVotes.setText(bean.getVotes()); mVotes.setText(bean.getVotes());
room_hot.setText(formatBigNum.formatBigNum(bean.getHot_num())); room_hot.setText(formatBigNum.formatBigNum(bean.getHot_num()));
setHotData(formatBigNum.formatBigNum(bean.getLiveChatBean().getHot_num()));
mTvMedalRank.setText(bean.getMedalRankNum()); mTvMedalRank.setText(bean.getMedalRankNum());
//开通粉丝勋章成功弹窗 //开通粉丝勋章成功弹窗
if (!isAncher && bean.getMedalFirstGet() != null && bean.getMedalFirstGet().equals("1") if (!isAncher && bean.getMedalFirstGet() != null && bean.getMedalFirstGet().equals("1")

View File

@ -578,9 +578,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
try { try {
if (mLiveRoomViewHolder != null) { if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.onExitRoom(bean); mLiveRoomViewHolder.onExitRoom(bean);
if (mLiveRoomViewHolder.room_hot != null) { if (mLiveRoomViewHolder != null) {
if (!"".equals(bean.getHot_num()) && !"0".equals(bean.getHot_num())) { if (!"".equals(bean.getHot_num()) && !"0".equals(bean.getHot_num())) {
mLiveRoomViewHolder.room_hot.setText(formatBigNum.formatBigNum(bean.getHot_num())); mLiveRoomViewHolder.setHotData(formatBigNum.formatBigNum(bean.getHot_num()));
} }
} }
} }
@ -916,6 +916,13 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
} }
} }
@Override
public void onHourRank(LiveChatBean bean, JSONObject ranks) {
if(mLiveRoomViewHolder!=null){
mLiveRoomViewHolder.setHourRankData(ranks.getInteger(liveID));
}
}
private PagerAdapter pagerAdapter = new PagerAdapter() { private PagerAdapter pagerAdapter = new PagerAdapter() {
@Override @Override
public int getCount() { public int getCount() {

View File

@ -15,13 +15,14 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="2dp" android:layout_marginStart="2dp"
android:scrollHorizontally="true" android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true" android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever" android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true" android:singleLine="true"
android:text="0"
android:textColor="#FFFFFFFF" android:textColor="#FFFFFFFF"
android:focusable="true"
android:ellipsize="marquee"
android:textSize="10sp" /> android:textSize="10sp" />
</LinearLayout> </LinearLayout>