修复:修改主播播放时长位置

This commit is contained in:
18401019693 2022-12-14 16:31:43 +08:00
parent a5516ebfb3
commit 606fc64262
4 changed files with 82 additions and 20 deletions

View File

@ -670,6 +670,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
L.e("createRoom----播放地址--->" + playUrl);
mLiveBean.setPull(playUrl);
mTxAppId = obj.getString("tx_appid");
//移除开播前的设置控件添加直播间控件
if (mLiveReadyViewHolder != null) {
mLiveReadyViewHolder.removeFromParent();
@ -701,6 +702,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
mLiveAnchorViewHolder = new LiveRyAnchorViewHolder(mContext, mContainer);
mLiveAnchorViewHolder.setLiveBean(mLiveBean);
mLiveAnchorViewHolder.addToParent();
mLiveAnchorViewHolder.startAnchorLiveTime();
}
mLiveBottomViewHolder = mLiveAnchorViewHolder;
mSocketRyClient = new SocketRyClient(mLiveUid, this);

View File

@ -208,8 +208,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
private GifImageView mGifImageView;
public static SVGAImageView mSVGAImageView;
private ViewGroup mLiveGiftPrizePoolContainer;
private TextView mLiveTimeTextView;//主播的直播时长
private long mAnchorLiveTime;//主播直播时间
private View mBtnPrizePool;//奖池按钮
private TextView mPrizePoolLevel;//奖池等级
private int forAct;
@ -939,9 +938,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
mBtnRedPack.setOnClickListener(this);
if (mContext instanceof LiveAudienceActivity) {
mRoot.setOnClickListener(this);
} else {
mLiveTimeTextView = (TextView) findViewById(R.id.live_time);
mLiveTimeTextView.setVisibility(View.VISIBLE);
}
mLightAnimPresenter = new LiveLightAnimPresenter(mContext, mParentView);
mLiveEnterRoomAnimPresenter = new LiveEnterRoomAnimPresenter(mContext, mContentView, mScreenWdith);
@ -2916,16 +2912,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}
}
/**
* 主播显示直播时间
*/
private void showAnchorLiveTime() {
if (mLiveTimeTextView != null) {
mAnchorLiveTime += 1000;
mLiveTimeTextView.setText(StringUtil.getDurationText(mAnchorLiveTime));
startAnchorLiveTime();
}
}
public void startAnchorLiveTime() {
if (mLiveRoomHandler != null) {
@ -3226,9 +3213,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
case WHAT_TIME_CHARGE:
mLiveRoomViewHolder.requestTimeCharge();
break;
case WHAT_ANCHOR_LIVE_TIME:
mLiveRoomViewHolder.showAnchorLiveTime();
break;
case WHAT_ANCHOR_PAUSE:
mLiveRoomViewHolder.anchorEndLive();
break;

View File

@ -4,13 +4,15 @@ import static com.yunbao.live.activity.LiveActivity.mLiveUid;
import static com.yunbao.live.activity.LiveRyAnchorActivity.PKing;
import static com.yunbao.live.activity.LiveRyAnchorActivity.pk_nub;
import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.START_MESSAGE;
import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.WISH_LIST;
import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.WISH_LIST_UPDATE;
import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.leaveDRRoom;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
@ -37,6 +39,7 @@ 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.StringUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveRyAnchorActivity;
@ -77,10 +80,13 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
private LiveBean mLiveBean;
private List<BannerBean> mBannerList = new ArrayList<>();
private String activityUrl;
private TextView mLiveTimeTextView;//主播的直播时长
private long mAnchorLiveTime;//主播直播时间
private LiveRoomHandler mLiveRoomHandler;
public LiveRyAnchorViewHolder(Context context, ViewGroup parentView) {
super(context, parentView);
}
@Override
@ -163,6 +169,9 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
}
});
findViewById(R.id.btn_link_mic).setOnClickListener(this);
mLiveTimeTextView = (TextView) findViewById(R.id.live_time);
mLiveTimeTextView.setVisibility(View.VISIBLE);
mLiveRoomHandler = new LiveRoomHandler();
}
@Override
@ -568,4 +577,50 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
initWishList();
setLiveUid(mLiveBean.getUid());
}
/**
* 主播显示直播时间
*/
private void showAnchorLiveTime() {
if (mLiveTimeTextView != null) {
mAnchorLiveTime += 1000;
mLiveTimeTextView.setText(StringUtil.getDurationText(mAnchorLiveTime));
startAnchorLiveTime();
}
}
public void startAnchorLiveTime() {
if (mLiveRoomHandler != null) {
mLiveRoomHandler.sendEmptyMessageAtTime(WHAT_ANCHOR_LIVE_TIME, getNextTime(1000));
}
}
private final int WHAT_ANCHOR_LIVE_TIME = 3;//直播间主播计时
private class LiveRoomHandler extends Handler {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case WHAT_ANCHOR_LIVE_TIME:
showAnchorLiveTime();
break;
}
}
public void release() {
removeCallbacksAndMessages(null);
}
}
private long getNextTime(int time) {
long now = SystemClock.uptimeMillis();
if (time < 1000) {
return now + time;
}
return now + time + -now % 1000;
}
}

View File

@ -133,6 +133,7 @@ PK"
android:layout_height="45dp"
android:layout_gravity="bottom">
<ImageView
android:id="@+id/btn_close"
android:layout_width="1dp"
@ -231,5 +232,25 @@ PK"
android:translationY="-4dp"
android:visibility="invisible" />
<com.yunbao.common.custom.DrawableTextView
android:id="@+id/live_time"
android:layout_width="wrap_content"
android:layout_height="34dp"
android:layout_centerVertical="true"
android:layout_marginStart="42dp"
android:layout_marginEnd="10dp"
android:layout_toEndOf="@id/et_input"
android:background="@drawable/bg_live_push_time"
android:drawablePadding="5dp"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="00:00"
android:textColor="@color/white"
android:textSize="10sp"
android:visibility="invisible"
app:dt_left_drawable="@drawable/bg_push_time_point"
app:dt_left_height="4dp"
app:dt_left_width="4dp" />
</RelativeLayout>
</LinearLayout>