add:新增小时榜功能
fix:调整外部类调用热度textView问题
This commit is contained in:
parent
c864608780
commit
31b7667a3d
@ -163,6 +163,8 @@ public class Constants {
|
||||
public static final String SOCKET_LUCK_WIN = "luckWin";//幸运礼物中奖
|
||||
public static final String SOCKET_PRIZE_POOL_WIN = "jackpotWin";//奖池中奖
|
||||
public static final String SOCKET_PRIZE_POOL_UP = "jackpotUp";//奖池升级
|
||||
public static final String SOCKET_HOUR = "SendHourChart";//小时榜更新
|
||||
|
||||
//游戏socket
|
||||
public static final String SOCKET_GAME_ZJH = "startGame";//炸金花
|
||||
public static final String SOCKET_GAME_HD = "startLodumaniGame";//海盗船长
|
||||
|
70
common/src/main/java/com/yunbao/common/bean/HourRank.java
Normal file
70
common/src/main/java/com/yunbao/common/bean/HourRank.java
Normal 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 +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import com.yunbao.common.bean.AnchorRecommendModel;
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
import com.yunbao.common.bean.ContributeModel;
|
||||
import com.yunbao.common.bean.FaceBookUpModel;
|
||||
import com.yunbao.common.bean.HourRank;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.bean.LiveInfoModel;
|
||||
import com.yunbao.common.bean.MsgSwitchDetailModel;
|
||||
@ -205,4 +206,10 @@ public interface PDLiveApi {
|
||||
@GET("/api/public/?service=Tx.setBeginShowMsgSwitch")
|
||||
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);
|
||||
}
|
||||
|
@ -276,9 +276,10 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
|
||||
mLiveLinkMicPresenter.onAudienceLeaveRoom(bean);
|
||||
}
|
||||
try {
|
||||
if (mLiveRoomViewHolder.room_hot != null) {
|
||||
if (mLiveRoomViewHolder!=null) {
|
||||
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) {
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 观众与主播连麦 主播收到观众的连麦申请
|
||||
*/
|
||||
|
@ -42,6 +42,7 @@ import java.util.List;
|
||||
*/
|
||||
|
||||
public class LiveChatAdapter extends RecyclerView.Adapter {
|
||||
public final static int MSG_HOUR_RANK_CHANGE=-100;//收到小时榜推送,发送一条弹幕
|
||||
|
||||
private Context mContext;
|
||||
private List<LiveChatBean> mList;
|
||||
@ -319,7 +320,11 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
|
||||
mTextView.setText(R.string.automatic_chat);
|
||||
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("")) {
|
||||
//加载.9图聊天气泡
|
||||
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
|
||||
|
@ -20,6 +20,7 @@ import android.webkit.JavascriptInterface;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.adjust.sdk.Adjust;
|
||||
import com.adjust.sdk.AdjustEvent;
|
||||
@ -145,6 +146,10 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
|
||||
}else {
|
||||
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.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
|
@ -324,4 +324,10 @@ public interface SocketMessageListener {
|
||||
* 整蛊消息
|
||||
*/
|
||||
void prankTurntable(String msgtype, int time, JSONObject jsonObject);
|
||||
|
||||
/**
|
||||
* 小时榜更新
|
||||
*
|
||||
*/
|
||||
void onHourRank(LiveChatBean bean,JSONObject ranks);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.activity.LiveAudienceActivity;
|
||||
import com.yunbao.live.activity.LiveRyAnchorActivity;
|
||||
import com.yunbao.live.adapter.LiveChatAdapter;
|
||||
import com.yunbao.live.bean.LiveBuyGuardMsgBean;
|
||||
import com.yunbao.live.bean.LiveChatBean;
|
||||
import com.yunbao.live.bean.LiveDanMuBean;
|
||||
@ -368,6 +369,13 @@ public class SocketRyClient {
|
||||
case Constants.SOCKET_PRIZE_POOL_UP://奖池升级
|
||||
mListener.onPrizePoolUp(map.getString("uplevel"));
|
||||
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
|
||||
case Constants.SOCKET_GAME_ZJH://游戏 智勇三张
|
||||
if (CommonAppConfig.GAME_ENABLE) {
|
||||
|
@ -24,7 +24,6 @@ import android.widget.TextView;
|
||||
import android.widget.ViewFlipper;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
@ -51,9 +50,11 @@ import com.opensource.svgaplayer.SVGAVideoEntity;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.BannerBean;
|
||||
import com.yunbao.common.bean.HourRank;
|
||||
import com.yunbao.common.bean.LevelBean;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.API;
|
||||
import com.yunbao.common.http.CommonHttpConsts;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
@ -112,8 +113,9 @@ import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
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 static com.yunbao.common.CommonAppContext.logger;
|
||||
@ -254,6 +256,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
|
||||
private LiveUserGiftBean nowGuardUser;
|
||||
private ViewFlipper wishListFlipper;
|
||||
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) {
|
||||
super(context, parentView);
|
||||
@ -1065,31 +1068,88 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 初始化小时榜。
|
||||
* 等待接口
|
||||
* TextView得独立出来用来替换数字
|
||||
* 初始化小时榜
|
||||
*/
|
||||
protected void initHourRankList(){
|
||||
((Activity)mContext).runOnUiThread(()->{
|
||||
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));
|
||||
View wish = LayoutInflater.from(mContext).inflate(R.layout.view_wish_list, null);
|
||||
ImageView wishPic = wish.findViewById(R.id.wish_pic);
|
||||
TextView wishIndex = wish.findViewById(R.id.wish_index);
|
||||
if(i==0) {
|
||||
wishPic.setImageResource(R.drawable.live_tags_hot);
|
||||
}else{
|
||||
wishPic.setImageResource(R.drawable.live_tags_hour_list);
|
||||
}
|
||||
wishPic.setLayoutParams(params);
|
||||
wishIndex.setText(new Random().nextInt(5000)+"");
|
||||
flipper.addView(wish);
|
||||
}
|
||||
flipper.startFlipping();
|
||||
});
|
||||
ViewFlipper flipper= (ViewFlipper) findViewById(R.id.hour_rank_list);
|
||||
LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(DpUtil.dp2px(44),DpUtil.dp2px(16));
|
||||
API.get().pdLiveApi(mContext).getHourChartRank(mLiveUid)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(listResponseModel -> {
|
||||
List<HourRank> info = listResponseModel.getData().getInfo();
|
||||
if(!info.isEmpty()){
|
||||
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;
|
||||
}
|
||||
String url=CommonAppConfig.HOST+path;
|
||||
url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token="
|
||||
+ CommonAppConfig.getInstance().getToken() + "&liveuid=" + mLiveUid;
|
||||
|
||||
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);
|
||||
}
|
||||
room_hot.setText(formatBigNum.formatBigNum(bean.getLiveChatBean().getHot_num()));
|
||||
setHotData(formatBigNum.formatBigNum(bean.getLiveChatBean().getHot_num()));
|
||||
LiveUserGiftBean chatBean = bean.getUserBean();
|
||||
if (chatBean != null && nowGuardUser != null) {
|
||||
LiveUserGiftBean tmp = null;
|
||||
@ -1917,6 +1978,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
|
||||
public void showGiftMessage(LiveReceiveGiftBean bean) {
|
||||
mVotes.setText(bean.getVotes());
|
||||
room_hot.setText(formatBigNum.formatBigNum(bean.getHot_num()));
|
||||
setHotData(formatBigNum.formatBigNum(bean.getLiveChatBean().getHot_num()));
|
||||
mTvMedalRank.setText(bean.getMedalRankNum());
|
||||
if (mLiveGiftAnimPresenter == null) {
|
||||
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) {
|
||||
mVotes.setText(bean.getVotes());
|
||||
room_hot.setText(formatBigNum.formatBigNum(bean.getHot_num()));
|
||||
setHotData(formatBigNum.formatBigNum(bean.getLiveChatBean().getHot_num()));
|
||||
mTvMedalRank.setText(bean.getMedalRankNum());
|
||||
//开通粉丝勋章成功弹窗
|
||||
if (!isAncher && bean.getMedalFirstGet() != null && bean.getMedalFirstGet().equals("1")
|
||||
|
@ -578,9 +578,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
try {
|
||||
if (mLiveRoomViewHolder != null) {
|
||||
mLiveRoomViewHolder.onExitRoom(bean);
|
||||
if (mLiveRoomViewHolder.room_hot != null) {
|
||||
if (mLiveRoomViewHolder != null) {
|
||||
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() {
|
||||
@Override
|
||||
public int getCount() {
|
||||
|
@ -15,13 +15,14 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="2dp"
|
||||
android:scrollHorizontally="true"
|
||||
android:ellipsize="marquee"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:scrollHorizontally="true"
|
||||
android:singleLine="true"
|
||||
android:text="0"
|
||||
android:textColor="#FFFFFFFF"
|
||||
android:focusable="true"
|
||||
android:ellipsize="marquee"
|
||||
android:textSize="10sp" />
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user