yh端多人Pk合流完成,Pk结束完成
This commit is contained in:
parent
5e9f23286e
commit
e380c8dcbc
@ -10,9 +10,9 @@ ext {
|
|||||||
manifestPlaceholders = [
|
manifestPlaceholders = [
|
||||||
//正式
|
//正式
|
||||||
|
|
||||||
// serverHost : "https://napi.yaoulive.com",
|
serverHost : "https://napi.yaoulive.com",
|
||||||
//測試
|
//測試
|
||||||
serverHost : "https://ceshi.yaoulive.com",
|
// serverHost : "https://ceshi.yaoulive.com",
|
||||||
|
|
||||||
//腾讯地图
|
//腾讯地图
|
||||||
txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB",
|
txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB",
|
||||||
|
@ -1230,6 +1230,17 @@ public class LiveAudienceActivity extends LiveActivity {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LEAVE_PK_SCORE:
|
||||||
|
if (manager != null) {
|
||||||
|
manager.upDataPkScore(event.getPkScores(), event.getTime());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PK_TIME_COUNT:
|
||||||
|
if (manager != null) {
|
||||||
|
manager.endDRGif();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import static com.lzy.okgo.utils.HttpUtils.runOnUiThread;
|
|||||||
import static cn.rongcloud.rtc.core.RendererCommon.ScalingType.SCALE_ASPECT_FILL;
|
import static cn.rongcloud.rtc.core.RendererCommon.ScalingType.SCALE_ASPECT_FILL;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
@ -13,18 +12,23 @@ import android.media.AudioManager;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewParent;
|
import android.view.ViewParent;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.lzf.easyfloat.EasyFloat;
|
import com.lzf.easyfloat.EasyFloat;
|
||||||
import com.lzy.okserver.OkDownload;
|
import com.lzy.okserver.OkDownload;
|
||||||
import com.lzy.okserver.download.DownloadTask;
|
import com.lzy.okserver.download.DownloadTask;
|
||||||
@ -33,21 +37,24 @@ import com.tencent.live2.V2TXLivePlayer;
|
|||||||
import com.tencent.live2.V2TXLivePlayerObserver;
|
import com.tencent.live2.V2TXLivePlayerObserver;
|
||||||
import com.tencent.live2.impl.V2TXLivePlayerImpl;
|
import com.tencent.live2.impl.V2TXLivePlayerImpl;
|
||||||
import com.tencent.rtmp.ui.TXCloudVideoView;
|
import com.tencent.rtmp.ui.TXCloudVideoView;
|
||||||
import com.yunbao.common.Constants;
|
|
||||||
import com.yunbao.common.bean.CrashSaveBean;
|
import com.yunbao.common.bean.CrashSaveBean;
|
||||||
|
import com.yunbao.common.glide.ImgLoader;
|
||||||
import com.yunbao.common.http.HttpCallback;
|
import com.yunbao.common.http.HttpCallback;
|
||||||
import com.yunbao.common.http.HttpClient;
|
import com.yunbao.common.http.HttpClient;
|
||||||
|
import com.yunbao.common.utils.Bus;
|
||||||
import com.yunbao.common.utils.DeviceUtils;
|
import com.yunbao.common.utils.DeviceUtils;
|
||||||
import com.yunbao.common.utils.DialogUitl;
|
import com.yunbao.common.utils.DialogUitl;
|
||||||
import com.yunbao.common.utils.DpUtil;
|
import com.yunbao.common.utils.DpUtil;
|
||||||
import com.yunbao.common.utils.L;
|
import com.yunbao.common.utils.L;
|
||||||
import com.yunbao.common.utils.MicStatusManager;
|
import com.yunbao.common.utils.MicStatusManager;
|
||||||
import com.yunbao.common.utils.ScreenDimenUtil;
|
import com.yunbao.common.utils.ScreenDimenUtil;
|
||||||
|
import com.yunbao.common.utils.StringUtil;
|
||||||
import com.yunbao.common.utils.ToastUtil;
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
import com.yunbao.common.utils.WordUtil;
|
import com.yunbao.common.utils.WordUtil;
|
||||||
import com.yunbao.live.R;
|
import com.yunbao.live.R;
|
||||||
import com.yunbao.live.activity.LiveActivity;
|
import com.yunbao.live.activity.LiveActivity;
|
||||||
import com.yunbao.live.activity.LiveAudienceActivity;
|
import com.yunbao.live.activity.LiveAudienceActivity;
|
||||||
|
import com.yunbao.live.event.LiveAudienceEvent;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
@ -149,6 +156,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
|||||||
mLoading = findViewById(R.id.loading);
|
mLoading = findViewById(R.id.loading);
|
||||||
mLoading2 = findViewById(R.id.loading2);
|
mLoading2 = findViewById(R.id.loading2);
|
||||||
mCover = (ImageView) findViewById(R.id.cover);
|
mCover = (ImageView) findViewById(R.id.cover);
|
||||||
|
|
||||||
ScreenDimenUtil util = ScreenDimenUtil.getInstance();
|
ScreenDimenUtil util = ScreenDimenUtil.getInstance();
|
||||||
int mScreenWdith = util.getScreenWdith();
|
int mScreenWdith = util.getScreenWdith();
|
||||||
vHeight = mScreenWdith * 720 / 960;
|
vHeight = mScreenWdith * 720 / 960;
|
||||||
@ -1022,4 +1030,131 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int mPkTimeCount = 0;
|
||||||
|
private Handler countdownHandler = new Handler();
|
||||||
|
private View detailsView = null;
|
||||||
|
private FrameLayout timeTitle;
|
||||||
|
private TextView textTime;
|
||||||
|
private TextView textPkName1, textPkName2, textPkName3, textPkName4;
|
||||||
|
private TextView textGrade1, textGrade2, textGrade3, textGrade4;
|
||||||
|
private ImageView imageGrade1, imageGrade2, imageGrade3, imageGrade4;
|
||||||
|
private LinearLayout linearGrade1, linearGrade2, linearGrade3, linearGrade4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PK倒计时
|
||||||
|
*/
|
||||||
|
public void upDataPkScore(JSONArray pkScores, int time) {
|
||||||
|
|
||||||
|
if (detailsView == null) {
|
||||||
|
detailsView = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
|
||||||
|
timeTitle = detailsView.findViewById(R.id.time_title);
|
||||||
|
textTime = detailsView.findViewById(R.id.text_time);
|
||||||
|
linearGrade1 = detailsView.findViewById(R.id.lin_pk1);
|
||||||
|
linearGrade2 = detailsView.findViewById(R.id.lin_pk2);
|
||||||
|
linearGrade3 = detailsView.findViewById(R.id.lin_pk3);
|
||||||
|
linearGrade4 = detailsView.findViewById(R.id.lin_pk4);
|
||||||
|
textPkName1 = detailsView.findViewById(R.id.text_pk_name1);
|
||||||
|
textPkName2 = detailsView.findViewById(R.id.text_pk_name2);
|
||||||
|
textPkName3 = detailsView.findViewById(R.id.text_pk_name3);
|
||||||
|
textPkName4 = detailsView.findViewById(R.id.text_pk_name4);
|
||||||
|
textGrade1 = detailsView.findViewById(R.id.text_grade1);
|
||||||
|
textGrade2 = detailsView.findViewById(R.id.text_grade2);
|
||||||
|
textGrade3 = detailsView.findViewById(R.id.text_grade3);
|
||||||
|
textGrade4 = detailsView.findViewById(R.id.text_grade4);
|
||||||
|
imageGrade1 = detailsView.findViewById(R.id.image_grade1);
|
||||||
|
imageGrade2 = detailsView.findViewById(R.id.image_grade2);
|
||||||
|
imageGrade3 = detailsView.findViewById(R.id.image_grade3);
|
||||||
|
imageGrade4 = detailsView.findViewById(R.id.image_grade4);
|
||||||
|
linearGrade1.setVisibility(View.GONE);
|
||||||
|
linearGrade2.setVisibility(View.GONE);
|
||||||
|
linearGrade3.setVisibility(View.GONE);
|
||||||
|
linearGrade4.setVisibility(View.GONE);
|
||||||
|
mVideoView.addView(detailsView);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < pkScores.size(); i++) {
|
||||||
|
JSONObject score = pkScores.getJSONObject(i);
|
||||||
|
String userNiceName = score.getString("user_nicename");
|
||||||
|
long userScore = score.getLong("score");
|
||||||
|
int resScore = R.mipmap.icon_livepk_no1;
|
||||||
|
if (userScore == 0 && !score.containsKey("paiming")) {
|
||||||
|
resScore = R.mipmap.icon_livepk_no1;
|
||||||
|
} else {
|
||||||
|
if (score.containsKey("paiming")) {
|
||||||
|
int ranking = score.getIntValue("paiming");
|
||||||
|
switch (ranking) {
|
||||||
|
case 1:
|
||||||
|
resScore = R.mipmap.icon_livepk_no1;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
resScore = R.mipmap.icon_livepk_no2;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
resScore = R.mipmap.icon_livepk_no3;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
resScore = R.mipmap.icon_livepk_no4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i == 0) {
|
||||||
|
linearGrade1.setVisibility(View.VISIBLE);
|
||||||
|
textPkName1.setText(userNiceName);
|
||||||
|
ImgLoader.display(mContext, resScore, imageGrade1);
|
||||||
|
textGrade1.setText(String.valueOf(userScore));
|
||||||
|
} else if (i == 1) {
|
||||||
|
linearGrade2.setVisibility(View.VISIBLE);
|
||||||
|
textPkName2.setText(userNiceName);
|
||||||
|
ImgLoader.display(mContext, resScore, imageGrade2);
|
||||||
|
textGrade2.setText(String.valueOf(userScore));
|
||||||
|
} else if (i == 2) {
|
||||||
|
linearGrade4.setVisibility(View.VISIBLE);
|
||||||
|
textPkName4.setText(userNiceName);
|
||||||
|
ImgLoader.display(mContext, resScore, imageGrade4);
|
||||||
|
textGrade4.setText(String.valueOf(userScore));
|
||||||
|
} else if (i == 3) {
|
||||||
|
linearGrade3.setVisibility(View.VISIBLE);
|
||||||
|
textPkName3.setText(userNiceName);
|
||||||
|
ImgLoader.display(mContext, resScore, imageGrade3);
|
||||||
|
textGrade3.setText(String.valueOf(userScore));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (time > 0) {
|
||||||
|
mPkTimeCount = time;
|
||||||
|
timeTitle.setVisibility(View.VISIBLE);
|
||||||
|
countdownHandler.postAtTime(countdownRunnable, getNextSecondTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Runnable countdownRunnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
mPkTimeCount--;
|
||||||
|
if (mPkTimeCount > 0) {//
|
||||||
|
String s1 = StringUtil.getDurationText(mPkTimeCount * 1000);
|
||||||
|
textTime.setText(String.format(mContext.getString(R.string.pk_time), s1));
|
||||||
|
countdownHandler.postAtTime(countdownRunnable, getNextSecondTime());
|
||||||
|
} else {
|
||||||
|
timeTitle.setVisibility(View.GONE);
|
||||||
|
countdownHandler.removeCallbacks(countdownRunnable);
|
||||||
|
Bus.get().post(new LiveAudienceEvent()
|
||||||
|
.setType(LiveAudienceEvent.LiveAudienceType.PK_TIME_COUNT));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取下一秒钟的时间
|
||||||
|
*/
|
||||||
|
private long getNextSecondTime() {
|
||||||
|
long now = SystemClock.uptimeMillis();
|
||||||
|
return now + (1000 - now % 1000);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,15 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.drawerlayout.widget.DrawerLayout;
|
import androidx.drawerlayout.widget.DrawerLayout;
|
||||||
import androidx.viewpager.widget.PagerAdapter;
|
import androidx.viewpager.widget.PagerAdapter;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.blankj.utilcode.util.GsonUtils;
|
import com.blankj.utilcode.util.GsonUtils;
|
||||||
import com.lzf.easyfloat.EasyFloat;
|
import com.lzf.easyfloat.EasyFloat;
|
||||||
@ -523,8 +526,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
|||||||
mLiveRoomViewHolder.initPkRank(null);
|
mLiveRoomViewHolder.initPkRank(null);
|
||||||
}
|
}
|
||||||
mLivePlayViewHolder.setViewUP(4);
|
mLivePlayViewHolder.setViewUP(4);
|
||||||
|
upDataPkScore(pkInfo.getJSONArray("userlist"),pkInfo.getIntValue("drpk_time"));
|
||||||
mLiveRoomViewHolder.UpPkBar(pkInfo.getJSONArray("userlist"), mLiveBean.getUid(), pkInfo.getIntValue("drpk_time"));
|
|
||||||
}
|
}
|
||||||
//守护相关
|
//守护相关
|
||||||
mLiveGuardInfo = new LiveGuardInfo();
|
mLiveGuardInfo = new LiveGuardInfo();
|
||||||
@ -1735,4 +1737,22 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
|||||||
mViewPager.setCanScroll(enableScroll);
|
mViewPager.setCanScroll(enableScroll);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户端多人Pk
|
||||||
|
*
|
||||||
|
* @param pkScores
|
||||||
|
* @param time
|
||||||
|
*/
|
||||||
|
public void upDataPkScore(JSONArray pkScores, int time) {
|
||||||
|
if (mLivePlayViewHolder != null) {
|
||||||
|
mLivePlayViewHolder.upDataPkScore(pkScores, time);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endDRGif() {
|
||||||
|
if (mLiveRoomViewHolder != null) {
|
||||||
|
mLiveRoomViewHolder.endDRGif();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -231,4 +231,22 @@
|
|||||||
android:textSize="6.67sp" />
|
android:textSize="6.67sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
<!--PK时间-->
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/time_title"
|
||||||
|
android:layout_width="60dp"
|
||||||
|
android:layout_height="16.67dp"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:background="@mipmap/live_pk_time_bg"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text_time"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/pk_time"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="8sp" />
|
||||||
|
</FrameLayout>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
Loading…
Reference in New Issue
Block a user