pk 倒计时去掉小时

This commit is contained in:
ningwenqiang 2024-09-23 14:51:58 +08:00
parent 50bdc01ea9
commit fd8e805f78
2 changed files with 31 additions and 4 deletions

View File

@ -120,6 +120,33 @@ public class StringUtil {
return sStringBuilder.toString();
}
/**
* 把一个long类型的总毫秒数转成时长
*/
public static String getDurationText2(long mms) {
int minutes = (int) ((mms % (1000 * 60 * 60)) / (1000 * 60));
int seconds = (int) ((mms % (1000 * 60)) / 1000);
sStringBuilder.delete(0, sStringBuilder.length());
if (minutes > 0) {
if (minutes < 10) {
sStringBuilder.append("0");
}
sStringBuilder.append(String.valueOf(minutes));
sStringBuilder.append(":");
} else {
sStringBuilder.append("00:");
}
if (seconds > 0) {
if (seconds < 10) {
sStringBuilder.append("0");
}
sStringBuilder.append(String.valueOf(seconds));
} else {
sStringBuilder.append("00");
}
return sStringBuilder.toString();
}
/**
* 设置视频输出路径

View File

@ -331,7 +331,7 @@ public class LiveSwLinkMicPkPresenter extends AbsLinkMicPkPresenter implements V
}
if (mLiveLinkMicPkViewHolder != null) {
String s = mIsPkEnd ? mPkTimeString2 : mPkTimeString1;
String s1 = StringUtil.getDurationText(mPkTimeCount * 1000);
String s1 = StringUtil.getDurationText2(mPkTimeCount * 1000);
Log.i("tag23333", mPkTimeCount + "mPkTimeCount" + s1 + "is" + is);
if (i == 1 && s1.equals("00:01")) {
s1 = "00:00";
@ -1729,11 +1729,11 @@ public class LiveSwLinkMicPkPresenter extends AbsLinkMicPkPresenter implements V
layoutParams.topMargin = DpUtil.dp2px(165);
livePushSwViewHolder.timeTitle.setLayoutParams(layoutParams);
livePushSwViewHolder.timeTitle.setVisibility(View.VISIBLE);
String pkTime = StringUtil.getDurationText(time * 1000);
String pkTime = StringUtil.getDurationText2(time * 1000);
livePushSwViewHolder.textTime.setText(String.format(mContext.getString(R.string.pk_time), pkTime));
mPkTimeCount = time;
if (time > 0) {
String s1 = StringUtil.getDurationText(mPkTimeCount * 1000);
String s1 = StringUtil.getDurationText2(mPkTimeCount * 1000);
livePushSwViewHolder.textTime.setText(String.format(mContext.getString(R.string.pk_time), s1));
mHandler.sendEmptyMessage(WHAT_PK_TIME2);
}
@ -1989,7 +1989,7 @@ public class LiveSwLinkMicPkPresenter extends AbsLinkMicPkPresenter implements V
mPkTimeCount--;
if (mPkTimeCount > 0) {//
if (mHandler != null) {
String s1 = StringUtil.getDurationText(mPkTimeCount * 1000);
String s1 = StringUtil.getDurationText2(mPkTimeCount * 1000);
livePushSwViewHolder.textTime.setText(String.format(mContext.getString(R.string.pk_time), s1));
mHandler.sendEmptyMessageAtTime(WHAT_PK_TIME2, getNextSecondTime());
}