直播计时功能添加
This commit is contained in:
parent
8d823f7a07
commit
7cb7258210
@ -30,6 +30,7 @@
|
||||
app:cardElevation="0dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/live_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
|
@ -674,6 +674,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
bundle.putBoolean(Constants.HAS_GAME, hasGame);
|
||||
bundle.putInt("leave", leave);
|
||||
bundle.putBoolean("isPk", isDRPK == 1 || PKing || mLivePushViewHolder.isPking());
|
||||
bundle.putLong("liveTime", mLiveAnchorViewHolder.getmAnchorLiveTime());
|
||||
bundle.putBoolean(Constants.OPEN_FLASH, mLivePushViewHolder != null && mLivePushViewHolder.isFlashOpen());
|
||||
fragment.setArguments(bundle);
|
||||
fragment.setFunctionClickListener(this);
|
||||
|
@ -13,6 +13,9 @@ import static com.yunbao.common.Constants.LIVE_FUNC_ZSLK;
|
||||
import static com.yunbao.common.Constants.LIVE_ROBOT;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
@ -23,6 +26,7 @@ import android.widget.TextView;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.dialog.AbsDialogFragment;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.views.LiveAnchorMessageCustomPopup;
|
||||
import com.yunbao.live.R;
|
||||
@ -40,7 +44,7 @@ public class LiveNewFunctionDialogFragment extends AbsDialogFragment implements
|
||||
private LiveFunctionClickListener mFunctionClickListener;
|
||||
private int leave = 0;
|
||||
private boolean isPk;
|
||||
|
||||
private TextView mLiveTimeTextView;//主播的直播时长
|
||||
|
||||
// boolean isRy = false;
|
||||
@Override
|
||||
@ -81,6 +85,7 @@ public class LiveNewFunctionDialogFragment extends AbsDialogFragment implements
|
||||
leave = bundle.getInt("leave", 0);
|
||||
isPk = bundle.getBoolean("isPk", false);
|
||||
// isRy = bundle.getBoolean("isRy", false);
|
||||
mAnchorLiveTime = bundle.getLong("liveTime");
|
||||
}
|
||||
mWishView = findViewById(R.id.live_tool_wish);
|
||||
mPrankView = findViewById(R.id.live_tool_prank);
|
||||
@ -92,7 +97,7 @@ public class LiveNewFunctionDialogFragment extends AbsDialogFragment implements
|
||||
mMultiPkView = findViewById(R.id.live_tool_multi_pk);
|
||||
mMicView = findViewById(R.id.live_tool_mic);
|
||||
mRandomPk = findViewById(R.id.live_tool_random_pk);
|
||||
|
||||
mLiveTimeTextView = (TextView) findViewById(R.id.live_time);
|
||||
mWishView.setOnClickListener(this);
|
||||
mPrankView.setOnClickListener(this);
|
||||
mWksView.setOnClickListener(this);
|
||||
@ -114,7 +119,9 @@ public class LiveNewFunctionDialogFragment extends AbsDialogFragment implements
|
||||
((ImageView) mLeaveView.findViewById(R.id.live_tool_leave_img)).setImageResource(R.mipmap.icon_leave_p);
|
||||
((TextView) mLeaveView.findViewById(R.id.live_tool_leave_text)).setText(R.string.live_zslk1);
|
||||
}
|
||||
|
||||
mLiveRoomHandler = new LiveRoomHandler();
|
||||
mLiveTimeTextView.setText(StringUtil.getDurationText(mAnchorLiveTime));
|
||||
startAnchorLiveTime();
|
||||
}
|
||||
|
||||
public void setFunctionClickListener(LiveFunctionClickListener functionClickListener) {
|
||||
@ -169,4 +176,52 @@ public class LiveNewFunctionDialogFragment extends AbsDialogFragment implements
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
private final int WHAT_ANCHOR_LIVE_TIME = 3;//直播间主播计时
|
||||
private LiveRoomHandler mLiveRoomHandler;
|
||||
private long mAnchorLiveTime;//主播直播时间
|
||||
|
||||
/**
|
||||
* 主播显示直播时间
|
||||
*/
|
||||
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 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;
|
||||
}
|
||||
}
|
||||
|
@ -87,6 +87,9 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
|
||||
super(context, parentView);
|
||||
|
||||
}
|
||||
public long getmAnchorLiveTime() {
|
||||
return mAnchorLiveTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
|
Loading…
Reference in New Issue
Block a user