bug fix:1.发起跨房PK自定义时间输入方式优化 2.钻石开箱是否显示处理时间相等的情况 3.去掉重PK方进入房间提示功能 4.PK面板有时候展开失败的问题
This commit is contained in:
@@ -8,6 +8,7 @@ import android.util.AttributeSet
|
|||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.widget.FrameLayout
|
||||||
import android.widget.PopupWindow
|
import android.widget.PopupWindow
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
@@ -54,14 +55,14 @@ class RoomPKBoardView @JvmOverloads constructor(
|
|||||||
if (CommonUtils.isFastDoubleClick(1000)) return@setOnClickListener
|
if (CommonUtils.isFastDoubleClick(1000)) return@setOnClickListener
|
||||||
binding.groupRank.isVisible = !binding.groupRank.isVisible
|
binding.groupRank.isVisible = !binding.groupRank.isVisible
|
||||||
if (binding.groupRank.isVisible) {
|
if (binding.groupRank.isVisible) {
|
||||||
binding.root.setBackgroundResource(R.drawable.bg_room_pk_board)
|
binding.clRoot.setBackgroundResource(R.drawable.bg_room_pk_board)
|
||||||
binding.root.updateLayoutParams<LayoutParams> {
|
binding.clRoot.updateLayoutParams<FrameLayout.LayoutParams> {
|
||||||
width = ScreenUtil.dip2px(339f)
|
width = ScreenUtil.dip2px(339f)
|
||||||
height = ScreenUtil.dip2px(233f)
|
height = ScreenUtil.dip2px(233f)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
binding.root.setBackgroundResource(R.drawable.bg_room_pk_board_small)
|
binding.clRoot.setBackgroundResource(R.drawable.bg_room_pk_board_small)
|
||||||
binding.root.updateLayoutParams<LayoutParams> {
|
binding.clRoot.updateLayoutParams<FrameLayout.LayoutParams> {
|
||||||
width = ScreenUtil.dip2px(339f)
|
width = ScreenUtil.dip2px(339f)
|
||||||
height = ScreenUtil.dip2px(137f)
|
height = ScreenUtil.dip2px(137f)
|
||||||
}
|
}
|
||||||
@@ -84,7 +85,7 @@ class RoomPKBoardView @JvmOverloads constructor(
|
|||||||
|
|
||||||
binding.tvGoAnotherRoom.setOnClickListener {
|
binding.tvGoAnotherRoom.setOnClickListener {
|
||||||
roomPkBean?.let {
|
roomPkBean?.let {
|
||||||
AVRoomActivity.startForFromType(context, it.aUid, AVRoomActivity.FROM_TYPE_ROOM_PK)
|
AVRoomActivity.start(context, it.aUid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,6 +138,8 @@ class RoomPKBoardView @JvmOverloads constructor(
|
|||||||
binding.tvTime.text = roomPkBean?.endTime?.let {
|
binding.tvTime.text = roomPkBean?.endTime?.let {
|
||||||
val remainTime = (it - CurrentTimeUtils.getCurrentTime()).toInt() / 1000
|
val remainTime = (it - CurrentTimeUtils.getCurrentTime()).toInt() / 1000
|
||||||
binding.tvTime.setTextColor(Color.parseColor(if (remainTime <= 30) "#ff87a1" else "#fff600"))
|
binding.tvTime.setTextColor(Color.parseColor(if (remainTime <= 30) "#ff87a1" else "#fff600"))
|
||||||
|
binding.tvTime.isVisible = remainTime > 0
|
||||||
|
binding.tvEndHint.isVisible = remainTime <= 0
|
||||||
TimeUtil.secToTime(remainTime)
|
TimeUtil.secToTime(remainTime)
|
||||||
} ?: "00:00"
|
} ?: "00:00"
|
||||||
}
|
}
|
||||||
|
@@ -58,21 +58,21 @@ class RoomPKCreateActivity : BaseViewBindingActivity<ActivityRoomPkCreateBinding
|
|||||||
}
|
}
|
||||||
|
|
||||||
binding.rbMin10.setOnCheckedChangeListener { _, isChecked ->
|
binding.rbMin10.setOnCheckedChangeListener { _, isChecked ->
|
||||||
if (isChecked){
|
if (isChecked) {
|
||||||
pkTime = 10
|
pkTime = 10
|
||||||
binding.editTime.setText("")
|
binding.editTime.setText("")
|
||||||
checkCommitEnable()
|
checkCommitEnable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
binding.rbMin20.setOnCheckedChangeListener { _, isChecked ->
|
binding.rbMin20.setOnCheckedChangeListener { _, isChecked ->
|
||||||
if (isChecked){
|
if (isChecked) {
|
||||||
pkTime = 20
|
pkTime = 20
|
||||||
binding.editTime.setText("")
|
binding.editTime.setText("")
|
||||||
checkCommitEnable()
|
checkCommitEnable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
binding.rbMin30.setOnCheckedChangeListener { _, isChecked ->
|
binding.rbMin30.setOnCheckedChangeListener { _, isChecked ->
|
||||||
if (isChecked){
|
if (isChecked) {
|
||||||
pkTime = 30
|
pkTime = 30
|
||||||
binding.editTime.setText("")
|
binding.editTime.setText("")
|
||||||
checkCommitEnable()
|
checkCommitEnable()
|
||||||
@@ -84,12 +84,6 @@ class RoomPKCreateActivity : BaseViewBindingActivity<ActivityRoomPkCreateBinding
|
|||||||
override fun afterTextChanged(s: Editable?) {
|
override fun afterTextChanged(s: Editable?) {
|
||||||
s?.toString().ifNotNullOrEmpty {
|
s?.toString().ifNotNullOrEmpty {
|
||||||
pkTime = it.toIntOrDef(0)
|
pkTime = it.toIntOrDef(0)
|
||||||
if (pkTime > 180) {
|
|
||||||
binding.editTime.setText("180")
|
|
||||||
}
|
|
||||||
if (pkTime < 5) {
|
|
||||||
binding.editTime.setText("5")
|
|
||||||
}
|
|
||||||
if (pkTime != 0) {
|
if (pkTime != 0) {
|
||||||
binding.rg.clearCheck()
|
binding.rg.clearCheck()
|
||||||
}
|
}
|
||||||
@@ -99,7 +93,10 @@ class RoomPKCreateActivity : BaseViewBindingActivity<ActivityRoomPkCreateBinding
|
|||||||
})
|
})
|
||||||
|
|
||||||
binding.tvOk.setOnClickListener {
|
binding.tvOk.setOnClickListener {
|
||||||
if (!checkCommitEnable()) return@setOnClickListener
|
if (pkTime < 5 || pkTime > 180) {
|
||||||
|
"PK时长在5-180分钟内,请重新输入!".toast()
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
currSimpleRoomInfo?.let {
|
currSimpleRoomInfo?.let {
|
||||||
RoomPKModel.initiateRoomPK(
|
RoomPKModel.initiateRoomPK(
|
||||||
it.roomUid,
|
it.roomUid,
|
||||||
@@ -114,7 +111,7 @@ class RoomPKCreateActivity : BaseViewBindingActivity<ActivityRoomPkCreateBinding
|
|||||||
"发起邀请成功!".toast()
|
"发起邀请成功!".toast()
|
||||||
finish()
|
finish()
|
||||||
}, { throwable ->
|
}, { throwable ->
|
||||||
dialogManager.showTipsDialog(throwable.message,null)
|
dialogManager.showTipsDialog(throwable.message, null)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -2557,9 +2557,6 @@ public class MessageView extends FrameLayout {
|
|||||||
enterText = " 的邀请,进入了房间";
|
enterText = " 的邀请,进入了房间";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fromType == AVRoomActivity.FROM_TYPE_ROOM_PK) {
|
|
||||||
enterText = " 从PK方进入了房间";
|
|
||||||
}
|
|
||||||
text.append(enterText, new ForegroundColorSpan(whiteColor));
|
text.append(enterText, new ForegroundColorSpan(whiteColor));
|
||||||
|
|
||||||
//如果自己在麦上,增加一个欢迎ta的按钮,并且这条消息不是自己的
|
//如果自己在麦上,增加一个欢迎ta的按钮,并且这条消息不是自己的
|
||||||
|
@@ -186,6 +186,7 @@
|
|||||||
android:background="@drawable/bg_room_pk_common_btn"
|
android:background="@drawable/bg_room_pk_common_btn"
|
||||||
android:hint="自定义(5-180)"
|
android:hint="自定义(5-180)"
|
||||||
android:inputType="number"
|
android:inputType="number"
|
||||||
|
android:maxLength="3"
|
||||||
android:paddingStart="20dp"
|
android:paddingStart="20dp"
|
||||||
android:paddingEnd="50dp"
|
android:paddingEnd="50dp"
|
||||||
android:textColor="@color/text_title_white"
|
android:textColor="@color/text_title_white"
|
||||||
@@ -223,9 +224,9 @@
|
|||||||
android:layout_marginEnd="12dp"
|
android:layout_marginEnd="12dp"
|
||||||
android:background="@drawable/bg_room_pk_common_btn"
|
android:background="@drawable/bg_room_pk_common_btn"
|
||||||
android:hint="选填,10个字以内"
|
android:hint="选填,10个字以内"
|
||||||
|
android:maxLength="10"
|
||||||
android:paddingStart="20dp"
|
android:paddingStart="20dp"
|
||||||
android:paddingEnd="50dp"
|
android:paddingEnd="50dp"
|
||||||
android:maxLength="10"
|
|
||||||
android:textColor="@color/text_title_white"
|
android:textColor="@color/text_title_white"
|
||||||
android:textColorHint="@color/white_transparent_50"
|
android:textColorHint="@color/white_transparent_50"
|
||||||
android:textSize="15sp"
|
android:textSize="15sp"
|
||||||
|
@@ -1,260 +1,283 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="339dp"
|
android:layout_width="339dp"
|
||||||
android:layout_height="233dp"
|
android:layout_height="233dp">
|
||||||
android:background="@drawable/bg_room_pk_board"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
tools:contentDescription="PK记分板">
|
|
||||||
|
|
||||||
<TextView
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/tv_time"
|
android:id="@+id/cl_root"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="339dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="233dp"
|
||||||
android:layout_marginTop="6dp"
|
android:background="@drawable/bg_room_pk_board"
|
||||||
android:includeFontPadding="false"
|
android:orientation="horizontal"
|
||||||
android:text="00:00"
|
tools:contentDescription="PK记分板">
|
||||||
android:textColor="#fffff600"
|
|
||||||
android:textSize="16dp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintHorizontal_bias="0.69"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<View
|
<TextView
|
||||||
android:id="@+id/view_help_anchor"
|
android:id="@+id/tv_time"
|
||||||
android:layout_width="1dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="1dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="72dp"
|
android:layout_marginTop="6dp"
|
||||||
android:layout_marginTop="33dp"
|
android:includeFontPadding="false"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
android:text="00:00"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
android:textColor="#fffff600"
|
||||||
|
android:textSize="16dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.69"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<ImageView
|
<TextView
|
||||||
android:id="@+id/iv_help"
|
android:id="@+id/tv_end_hint"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="6dp"
|
android:layout_marginTop="8dp"
|
||||||
android:src="@drawable/ic_room_pk_board_help"
|
android:includeFontPadding="false"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
android:text="PK结果计算中..."
|
||||||
app:layout_constraintHorizontal_bias="0.45"
|
android:textColor="#fffff600"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
android:textSize="11dp"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
android:visibility="gone"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.72"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<TextView
|
<View
|
||||||
android:id="@+id/tv_room_name_left"
|
android:id="@+id/view_help_anchor"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="1dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="1dp"
|
||||||
android:layout_marginStart="12dp"
|
android:layout_marginStart="72dp"
|
||||||
android:layout_marginTop="40dp"
|
android:layout_marginTop="33dp"
|
||||||
android:textColor="@color/text_title_white"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
android:textSize="14dp"
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
tools:text="厅的名字七个字" />
|
|
||||||
|
|
||||||
<TextView
|
<ImageView
|
||||||
android:id="@+id/tv_room_name_right"
|
android:id="@+id/iv_help"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="40dp"
|
android:layout_marginTop="6dp"
|
||||||
android:layout_marginEnd="12dp"
|
android:src="@drawable/ic_room_pk_board_help"
|
||||||
android:textColor="@color/text_title_white"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:textSize="14dp"
|
app:layout_constraintHorizontal_bias="0.45"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
tools:text="厅的名字七个字" />
|
|
||||||
|
|
||||||
<com.yizhuan.erban.common.widget.CircleImageView
|
<TextView
|
||||||
android:id="@+id/iv_avatar_left"
|
android:id="@+id/tv_room_name_left"
|
||||||
android:layout_width="44dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="44dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="30dp"
|
android:layout_marginStart="12dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="40dp"
|
||||||
android:src="@drawable/default_avatar"
|
android:textColor="@color/text_title_white"
|
||||||
app:cborder_color="#FFFF4D73"
|
android:textSize="14dp"
|
||||||
app:cborder_width="1dp"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tv_room_name_left" />
|
tools:text="厅的名字七个字" />
|
||||||
|
|
||||||
<com.yizhuan.erban.common.widget.CircleImageView
|
<TextView
|
||||||
android:id="@+id/iv_avatar_right"
|
android:id="@+id/tv_room_name_right"
|
||||||
android:layout_width="44dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="44dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="40dp"
|
||||||
android:layout_marginEnd="30dp"
|
android:layout_marginEnd="12dp"
|
||||||
android:src="@drawable/default_avatar"
|
android:textColor="@color/text_title_white"
|
||||||
app:cborder_color="#FF45C0FF"
|
android:textSize="14dp"
|
||||||
app:cborder_width="1dp"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tv_room_name_right" />
|
tools:text="厅的名字七个字" />
|
||||||
|
|
||||||
<TextView
|
<com.yizhuan.erban.common.widget.CircleImageView
|
||||||
android:id="@+id/tv_send_gift"
|
android:id="@+id/iv_avatar_left"
|
||||||
android:layout_width="50dp"
|
android:layout_width="44dp"
|
||||||
android:layout_height="18dp"
|
android:layout_height="44dp"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="30dp"
|
||||||
android:background="@drawable/bg_room_pk_send_gift"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="center"
|
android:src="@drawable/default_avatar"
|
||||||
android:includeFontPadding="false"
|
app:cborder_color="#FFFF4D73"
|
||||||
android:text="助攻"
|
app:cborder_width="1dp"
|
||||||
android:textColor="#ffffffff"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
android:textSize="12dp"
|
app:layout_constraintTop_toBottomOf="@id/tv_room_name_left" />
|
||||||
app:layout_constraintStart_toEndOf="@id/iv_avatar_left"
|
|
||||||
app:layout_constraintTop_toTopOf="@id/iv_avatar_left" />
|
|
||||||
|
|
||||||
<TextView
|
<com.yizhuan.erban.common.widget.CircleImageView
|
||||||
android:id="@+id/tv_go_another_room"
|
android:id="@+id/iv_avatar_right"
|
||||||
android:layout_width="50dp"
|
android:layout_width="44dp"
|
||||||
android:layout_height="18dp"
|
android:layout_height="44dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginTop="10dp"
|
||||||
android:background="@drawable/bg_room_pk_go_another_room"
|
android:layout_marginEnd="30dp"
|
||||||
android:gravity="center"
|
android:src="@drawable/default_avatar"
|
||||||
android:includeFontPadding="false"
|
app:cborder_color="#FF45C0FF"
|
||||||
android:text="去围观"
|
app:cborder_width="1dp"
|
||||||
android:textColor="#ffffffff"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:textSize="12dp"
|
app:layout_constraintTop_toBottomOf="@id/tv_room_name_right" />
|
||||||
app:layout_constraintEnd_toStartOf="@id/iv_avatar_right"
|
|
||||||
app:layout_constraintTop_toTopOf="@id/iv_avatar_right" />
|
|
||||||
|
|
||||||
<ProgressBar
|
<TextView
|
||||||
android:id="@+id/pb_score"
|
android:id="@+id/tv_send_gift"
|
||||||
style="?android:attr/progressBarStyleHorizontal"
|
android:layout_width="50dp"
|
||||||
android:layout_width="0dp"
|
android:layout_height="18dp"
|
||||||
android:layout_height="12dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginStart="8dp"
|
android:background="@drawable/bg_room_pk_send_gift"
|
||||||
android:layout_marginEnd="8dp"
|
android:gravity="center"
|
||||||
android:max="100"
|
android:includeFontPadding="false"
|
||||||
android:progress="50"
|
android:text="助攻"
|
||||||
android:progressDrawable="@drawable/bg_room_pk_board_pb"
|
android:textColor="#ffffffff"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/iv_avatar_left"
|
android:textSize="12dp"
|
||||||
app:layout_constraintEnd_toStartOf="@id/iv_avatar_right"
|
app:layout_constraintStart_toEndOf="@id/iv_avatar_left"
|
||||||
app:layout_constraintStart_toEndOf="@id/iv_avatar_left" />
|
app:layout_constraintTop_toTopOf="@id/iv_avatar_left" />
|
||||||
|
|
||||||
<com.opensource.svgaplayer.SVGAImageView
|
<TextView
|
||||||
android:id="@+id/svga_hot"
|
android:id="@+id/tv_go_another_room"
|
||||||
android:layout_width="18dp"
|
android:layout_width="50dp"
|
||||||
android:layout_height="27dp"
|
android:layout_height="18dp"
|
||||||
app:autoPlay="true"
|
android:layout_marginEnd="8dp"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/pb_score"
|
android:background="@drawable/bg_room_pk_go_another_room"
|
||||||
app:layout_constraintEnd_toStartOf="@id/iv_avatar_right"
|
android:gravity="center"
|
||||||
app:layout_constraintHorizontal_bias="0"
|
android:includeFontPadding="false"
|
||||||
app:layout_constraintStart_toEndOf="@id/iv_avatar_left"
|
android:text="去围观"
|
||||||
app:source="svga/room_pk_pb_indicator.svga" />
|
android:textColor="#ffffffff"
|
||||||
|
android:textSize="12dp"
|
||||||
|
app:layout_constraintEnd_toStartOf="@id/iv_avatar_right"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/iv_avatar_right" />
|
||||||
|
|
||||||
<TextView
|
<ProgressBar
|
||||||
android:id="@+id/tv_score_left"
|
android:id="@+id/pb_score"
|
||||||
android:layout_width="wrap_content"
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_marginStart="5dp"
|
android:layout_height="12dp"
|
||||||
android:fontFamily="sans-serif"
|
android:layout_marginStart="8dp"
|
||||||
android:includeFontPadding="false"
|
android:layout_marginEnd="8dp"
|
||||||
android:textColor="@color/white"
|
android:max="100"
|
||||||
android:textSize="9dp"
|
android:progress="50"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/pb_score"
|
android:progressDrawable="@drawable/bg_room_pk_board_pb"
|
||||||
app:layout_constraintStart_toStartOf="@id/pb_score"
|
app:layout_constraintBottom_toBottomOf="@id/iv_avatar_left"
|
||||||
app:layout_constraintTop_toTopOf="@id/pb_score"
|
app:layout_constraintEnd_toStartOf="@id/iv_avatar_right"
|
||||||
tools:text="123456" />
|
app:layout_constraintStart_toEndOf="@id/iv_avatar_left" />
|
||||||
|
|
||||||
<TextView
|
<com.opensource.svgaplayer.SVGAImageView
|
||||||
android:id="@+id/tv_score_right"
|
android:id="@+id/svga_hot"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="18dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="27dp"
|
||||||
android:layout_marginEnd="5dp"
|
android:layout_marginBottom="18dp"
|
||||||
android:fontFamily="sans-serif"
|
app:autoPlay="true"
|
||||||
android:includeFontPadding="false"
|
app:layout_constraintBottom_toBottomOf="@id/iv_details"
|
||||||
android:textColor="@color/white"
|
app:layout_constraintEnd_toStartOf="@id/iv_avatar_right"
|
||||||
android:textSize="9dp"
|
app:layout_constraintHorizontal_bias="0"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/pb_score"
|
app:layout_constraintStart_toEndOf="@id/iv_avatar_left"
|
||||||
app:layout_constraintEnd_toEndOf="@id/pb_score"
|
app:source="svga/room_pk_pb_indicator.svga" />
|
||||||
app:layout_constraintTop_toTopOf="@id/pb_score"
|
|
||||||
tools:text="123456" />
|
<TextView
|
||||||
|
android:id="@+id/tv_score_left"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:fontFamily="sans-serif"
|
||||||
|
android:includeFontPadding="false"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="9dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/pb_score"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/pb_score"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/pb_score"
|
||||||
|
tools:text="123456" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_score_right"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="5dp"
|
||||||
|
android:fontFamily="sans-serif"
|
||||||
|
android:includeFontPadding="false"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="9dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/pb_score"
|
||||||
|
app:layout_constraintEnd_toEndOf="@id/pb_score"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/pb_score"
|
||||||
|
tools:text="123456" />
|
||||||
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/iv_details"
|
android:id="@+id/iv_details"
|
||||||
android:layout_width="30dp"
|
android:layout_width="30dp"
|
||||||
android:layout_height="20dp"
|
android:layout_height="20dp"
|
||||||
android:scaleType="center"
|
android:scaleType="center"
|
||||||
android:src="@drawable/ic_room_pk_top"
|
android:src="@drawable/ic_room_pk_top"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/pb_score" />
|
app:layout_constraintTop_toBottomOf="@id/pb_score" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_contribute_title"
|
android:id="@+id/tv_contribute_title"
|
||||||
android:layout_width="53dp"
|
android:layout_width="53dp"
|
||||||
android:layout_height="22dp"
|
android:layout_height="22dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:background="@drawable/bg_room_pk_contribute_text"
|
android:background="@drawable/bg_room_pk_contribute_text"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:includeFontPadding="false"
|
android:includeFontPadding="false"
|
||||||
android:text="神豪"
|
android:text="神豪"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:textSize="14dp"
|
android:textSize="14dp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/iv_details" />
|
app:layout_constraintTop_toBottomOf="@id/iv_details" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_charm_title"
|
android:id="@+id/tv_charm_title"
|
||||||
android:layout_width="53dp"
|
android:layout_width="53dp"
|
||||||
android:layout_height="22dp"
|
android:layout_height="22dp"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="24dp"
|
||||||
android:background="@drawable/bg_room_pk_charm_text"
|
android:background="@drawable/bg_room_pk_charm_text"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:includeFontPadding="false"
|
android:includeFontPadding="false"
|
||||||
android:text="魅力"
|
android:text="魅力"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:textSize="14dp"
|
android:textSize="14dp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tv_contribute_title" />
|
app:layout_constraintTop_toBottomOf="@id/tv_contribute_title" />
|
||||||
|
|
||||||
|
|
||||||
<com.yizhuan.erban.avroom.anotherroompk.RoomPKRankListView
|
<com.yizhuan.erban.avroom.anotherroompk.RoomPKRankListView
|
||||||
android:id="@+id/view_rank_list_contribute_left"
|
android:id="@+id/view_rank_list_contribute_left"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/tv_contribute_title"
|
app:layout_constraintBottom_toBottomOf="@id/tv_contribute_title"
|
||||||
app:layout_constraintEnd_toStartOf="@id/tv_contribute_title"
|
app:layout_constraintEnd_toStartOf="@id/tv_contribute_title"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="@id/tv_contribute_title" />
|
app:layout_constraintTop_toTopOf="@id/tv_contribute_title" />
|
||||||
|
|
||||||
<com.yizhuan.erban.avroom.anotherroompk.RoomPKRankListView
|
<com.yizhuan.erban.avroom.anotherroompk.RoomPKRankListView
|
||||||
android:id="@+id/view_rank_list_charm_left"
|
android:id="@+id/view_rank_list_charm_left"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/tv_charm_title"
|
app:layout_constraintBottom_toBottomOf="@id/tv_charm_title"
|
||||||
app:layout_constraintEnd_toStartOf="@id/tv_charm_title"
|
app:layout_constraintEnd_toStartOf="@id/tv_charm_title"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="@id/tv_charm_title" />
|
app:layout_constraintTop_toTopOf="@id/tv_charm_title" />
|
||||||
|
|
||||||
<com.yizhuan.erban.avroom.anotherroompk.RoomPKRankListView
|
<com.yizhuan.erban.avroom.anotherroompk.RoomPKRankListView
|
||||||
android:id="@+id/view_rank_list_contribute_right"
|
android:id="@+id/view_rank_list_contribute_right"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/tv_contribute_title"
|
app:layout_constraintBottom_toBottomOf="@id/tv_contribute_title"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@id/tv_contribute_title"
|
app:layout_constraintStart_toEndOf="@id/tv_contribute_title"
|
||||||
app:layout_constraintTop_toTopOf="@id/tv_contribute_title" />
|
app:layout_constraintTop_toTopOf="@id/tv_contribute_title" />
|
||||||
|
|
||||||
<com.yizhuan.erban.avroom.anotherroompk.RoomPKRankListView
|
<com.yizhuan.erban.avroom.anotherroompk.RoomPKRankListView
|
||||||
android:id="@+id/view_rank_list_charm_right"
|
android:id="@+id/view_rank_list_charm_right"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/tv_charm_title"
|
app:layout_constraintBottom_toBottomOf="@id/tv_charm_title"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@id/tv_charm_title"
|
app:layout_constraintStart_toEndOf="@id/tv_charm_title"
|
||||||
app:layout_constraintTop_toTopOf="@id/tv_charm_title" />
|
app:layout_constraintTop_toTopOf="@id/tv_charm_title" />
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.Group
|
<androidx.constraintlayout.widget.Group
|
||||||
android:id="@+id/group_rank"
|
android:id="@+id/group_rank"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:constraint_referenced_ids="view_rank_list_charm_right,view_rank_list_contribute_right,view_rank_list_charm_left,view_rank_list_contribute_left,tv_charm_title,tv_contribute_title" />
|
app:constraint_referenced_ids="view_rank_list_charm_right,view_rank_list_contribute_right,view_rank_list_charm_left,view_rank_list_contribute_left,tv_charm_title,tv_contribute_title" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
@@ -14,7 +14,6 @@
|
|||||||
android:layout_marginStart="10dp"
|
android:layout_marginStart="10dp"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="24dp"
|
||||||
android:layout_marginEnd="10dp"
|
android:layout_marginEnd="10dp"
|
||||||
android:lineSpacingExtra="3dp"
|
|
||||||
android:text="@string/room_pk_help"
|
android:text="@string/room_pk_help"
|
||||||
android:textColor="@color/text_title_white"
|
android:textColor="@color/text_title_white"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
@@ -48,6 +48,7 @@ public class TimeUtils {
|
|||||||
|
|
||||||
public static final String DATE_FORMAT = "yyyy-MM-dd";
|
public static final String DATE_FORMAT = "yyyy-MM-dd";
|
||||||
public static final String TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
public static final String TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
||||||
|
public static final long MILLIS_OF_SEC = 1000;
|
||||||
|
|
||||||
public static String getCurrentDateStr() {
|
public static String getCurrentDateStr() {
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.getDefault());
|
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.getDefault());
|
||||||
@@ -157,8 +158,6 @@ public class TimeUtils {
|
|||||||
return c.getTimeInMillis();
|
return c.getTimeInMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final long MILLIS_OF_SEC = 1000;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get current time in secs.
|
* Get current time in secs.
|
||||||
*
|
*
|
||||||
@@ -427,6 +426,308 @@ public class TimeUtils {
|
|||||||
return t * scale;
|
return t * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将毫秒转换为年月日时分秒 ,只拿时分秒
|
||||||
|
*
|
||||||
|
* @author GaoHuanjie
|
||||||
|
*/
|
||||||
|
public static String getYearMonthDayHourMinuteSecond(long timeMillis) {
|
||||||
|
int timezone = 8; // 时区
|
||||||
|
long totalSeconds = timeMillis / 1000;
|
||||||
|
totalSeconds += 60 * 60 * timezone;
|
||||||
|
int second = (int) (totalSeconds % 60);// 秒
|
||||||
|
long totalMinutes = totalSeconds / 60;
|
||||||
|
int minute = (int) (totalMinutes % 60);// 分
|
||||||
|
long totalHours = totalMinutes / 60;
|
||||||
|
int hour = (int) (totalHours % 24);// 时
|
||||||
|
int totalDays = (int) (totalHours / 24);
|
||||||
|
int _year = 1970;
|
||||||
|
int year = _year + totalDays / 366;
|
||||||
|
int month = 1;
|
||||||
|
int day = 1;
|
||||||
|
int diffDays;
|
||||||
|
boolean leapYear;
|
||||||
|
while (true) {
|
||||||
|
int diff = (year - _year) * 365;
|
||||||
|
diff += (year - 1) / 4 - (_year - 1) / 4;
|
||||||
|
diff -= ((year - 1) / 100 - (_year - 1) / 100);
|
||||||
|
diff += (year - 1) / 400 - (_year - 1) / 400;
|
||||||
|
diffDays = totalDays - diff;
|
||||||
|
leapYear = (year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0);
|
||||||
|
if (!leapYear && diffDays < 365 || leapYear && diffDays < 366) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
year++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int[] monthDays;
|
||||||
|
if (diffDays >= 59 && leapYear) {
|
||||||
|
monthDays = new int[]{-1, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};
|
||||||
|
} else {
|
||||||
|
monthDays = new int[]{-1, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
|
||||||
|
}
|
||||||
|
for (int i = monthDays.length - 1; i >= 1; i--) {
|
||||||
|
if (diffDays >= monthDays[i]) {
|
||||||
|
month = i;
|
||||||
|
day = diffDays - monthDays[i] + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String hours;
|
||||||
|
String minutes;
|
||||||
|
String seconds;
|
||||||
|
if (hour < 10) {
|
||||||
|
hours = "0" + hour;
|
||||||
|
} else {
|
||||||
|
hours = "" + hour;
|
||||||
|
}
|
||||||
|
if (minute < 10) {
|
||||||
|
minutes = "0" + minute;
|
||||||
|
} else {
|
||||||
|
minutes = "" + minute;
|
||||||
|
}
|
||||||
|
if (second < 10) {
|
||||||
|
seconds = "0" + second;
|
||||||
|
} else {
|
||||||
|
seconds = "" + second;
|
||||||
|
}
|
||||||
|
|
||||||
|
// return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
|
||||||
|
return hours + ":" + minutes + ":" + seconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Date getTimesnight(int i) {
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
cal.set(Calendar.HOUR_OF_DAY, i);
|
||||||
|
cal.set(Calendar.SECOND, 0);
|
||||||
|
cal.set(Calendar.MINUTE, 0);
|
||||||
|
cal.set(Calendar.MILLISECOND, 0);
|
||||||
|
return cal.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*获得指定天数的0点和24点*/
|
||||||
|
public static Date getTimesnights(Date time) {
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
cal.setTime(time);
|
||||||
|
cal.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
cal.set(Calendar.SECOND, 0);
|
||||||
|
cal.set(Calendar.MINUTE, 0);
|
||||||
|
cal.set(Calendar.MILLISECOND, 0);
|
||||||
|
return cal.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将时间戳ms 转成星座
|
||||||
|
* 白羊:0321~0420 天秤:0924~1023
|
||||||
|
* 金牛:0421~0521 天蝎:1024~1122
|
||||||
|
* 双子:0522~0621 射手:1123~1221
|
||||||
|
* 巨蟹:0622~0722 摩羯:1222~0120
|
||||||
|
* 狮子:0723~0823 水瓶:0121~0219
|
||||||
|
* 处女:0824~0923 双鱼:0220~0320
|
||||||
|
*/
|
||||||
|
public static String msToConstellation(long ms) {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTimeInMillis(ms);
|
||||||
|
int month = calendar.get(Calendar.MONTH) + 1;
|
||||||
|
int day = calendar.get(Calendar.DAY_OF_MONTH);
|
||||||
|
Log.e("mouse_debug", month + ", " + day);
|
||||||
|
String xingzuo = "";
|
||||||
|
switch (month) {
|
||||||
|
case 1:
|
||||||
|
xingzuo = day < 21 ? "摩羯座" : "水瓶座";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
xingzuo = day < 20 ? "水瓶座" : "双鱼座";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
xingzuo = day < 21 ? "双鱼座" : "白羊座";
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
xingzuo = day < 21 ? "白羊座" : "金牛座";
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
xingzuo = day < 22 ? "金牛座" : "双子座";
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
xingzuo = day < 22 ? "双子座" : "巨蟹座";
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
xingzuo = day < 23 ? "巨蟹座" : "狮子座";
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
xingzuo = day < 24 ? "狮子座" : "处女座";
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
xingzuo = day < 24 ? "处女座" : "天秤座";
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
xingzuo = day < 24 ? "天秤座" : "天蝎座";
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
xingzuo = day < 23 ? "天蝎座" : "射手座";
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
xingzuo = day < 22 ? "射手座" : "摩羯座";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return xingzuo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是不是 第二天
|
||||||
|
*
|
||||||
|
* @param cacheTime 和 当前时间对比,判断现在是不是第二天了
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isTomorrow(long cacheTime) {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTimeInMillis(System.currentTimeMillis());
|
||||||
|
int currYear = calendar.get(Calendar.YEAR);
|
||||||
|
int currMonth = calendar.get(Calendar.MONTH);
|
||||||
|
int currDayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
|
||||||
|
calendar.setTimeInMillis(cacheTime);
|
||||||
|
int cacheYear = calendar.get(Calendar.YEAR);
|
||||||
|
int cacheMonth = calendar.get(Calendar.MONTH);
|
||||||
|
int cacheDayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
|
||||||
|
if (currYear > cacheYear) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
boolean equalYear = currYear == cacheYear;
|
||||||
|
if (equalYear && currMonth > cacheMonth) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return equalYear && currMonth == cacheMonth && currDayOfMonth > cacheDayOfMonth;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param cacheTime 和 当前时间对比,判断现在是不是当天
|
||||||
|
* @return -
|
||||||
|
*/
|
||||||
|
public static boolean isToday(long cacheTime) {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTimeInMillis(System.currentTimeMillis());
|
||||||
|
int currYear = calendar.get(Calendar.YEAR);
|
||||||
|
int currMonth = calendar.get(Calendar.MONTH);
|
||||||
|
int currDayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
|
||||||
|
calendar.setTimeInMillis(cacheTime);
|
||||||
|
int cacheYear = calendar.get(Calendar.YEAR);
|
||||||
|
int cacheMonth = calendar.get(Calendar.MONTH);
|
||||||
|
int cacheDayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
|
||||||
|
return currYear == cacheYear && currMonth == cacheMonth && currDayOfMonth == cacheDayOfMonth;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param cacheTime 和 当前时间对比,是不是同一年
|
||||||
|
* @return -
|
||||||
|
*/
|
||||||
|
public static boolean isSameYear(long cacheTime) {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTimeInMillis(System.currentTimeMillis());
|
||||||
|
int currYear = calendar.get(Calendar.YEAR);
|
||||||
|
calendar.setTimeInMillis(cacheTime);
|
||||||
|
int cacheYear = calendar.get(Calendar.YEAR);
|
||||||
|
return currYear == cacheYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得系统时间 年、月、日、小时、分钟
|
||||||
|
*
|
||||||
|
* @return HashMap
|
||||||
|
*/
|
||||||
|
public static int getTime24() {
|
||||||
|
SimpleDateFormat hh = new SimpleDateFormat("HH", Locale.CHINA);
|
||||||
|
SimpleDateFormat mm = new SimpleDateFormat("mm", Locale.CHINA);
|
||||||
|
hh.setTimeZone(TimeZone.getTimeZone("GMT+08")); // 获取指定时区的时间
|
||||||
|
mm.setTimeZone(TimeZone.getTimeZone("GMT+08"));
|
||||||
|
Date date = new Date();
|
||||||
|
String hour = hh.format(date);
|
||||||
|
String minute = mm.format(date);
|
||||||
|
return Integer.parseInt(hour + minute);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean getTimeLimit(int start_hour, int end_hour) {
|
||||||
|
if (start_hour == end_hour) return false;
|
||||||
|
SimpleDateFormat hh = new SimpleDateFormat("HH", Locale.CHINA);
|
||||||
|
SimpleDateFormat mm = new SimpleDateFormat("mm", Locale.CHINA);
|
||||||
|
hh.setTimeZone(TimeZone.getTimeZone("GMT+08")); // 获取指定时区的时间
|
||||||
|
mm.setTimeZone(TimeZone.getTimeZone("GMT+08"));
|
||||||
|
Date date = new Date();
|
||||||
|
String hour = hh.format(date);
|
||||||
|
String minute = mm.format(date);
|
||||||
|
Log.i("stf", "--hour:minute-->" + hour + ":" + minute);
|
||||||
|
int currentTime = Integer.parseInt(hour + minute);
|
||||||
|
LogUtil.print("start" + start_hour);
|
||||||
|
LogUtil.print("end" + end_hour);
|
||||||
|
LogUtil.print("minuteOfDay" + currentTime);
|
||||||
|
if (currentTime >= start_hour && currentTime <= end_hour) {
|
||||||
|
LogUtil.print("工作时间内" + hour + ":" + minute);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
if (start_hour > end_hour) {
|
||||||
|
if (currentTime >= start_hour || currentTime <= end_hour) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LogUtil.print("工作时间外" + hour + ":" + minute);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定年月的第一天
|
||||||
|
*
|
||||||
|
* @param ym yyyy-MM
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getFirstDayOfMonth(String ym) {
|
||||||
|
String arr[] = ym.split("-");
|
||||||
|
|
||||||
|
int year = Integer.parseInt(arr[0]);
|
||||||
|
int month = Integer.parseInt(arr[1]);
|
||||||
|
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
//设置年份
|
||||||
|
cal.set(Calendar.YEAR, year);
|
||||||
|
|
||||||
|
//设置月份
|
||||||
|
cal.set(Calendar.MONTH, month - 1);
|
||||||
|
//获取某月最小天数
|
||||||
|
int firstDay = cal.getMinimum(Calendar.DATE);
|
||||||
|
//设置日历中月份的最小天数
|
||||||
|
cal.set(Calendar.DAY_OF_MONTH, firstDay);
|
||||||
|
//格式化日期
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
|
||||||
|
return sdf.format(cal.getTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定年月的最后一天
|
||||||
|
*
|
||||||
|
* @param ym
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getLastDayOfMonth(String ym) {
|
||||||
|
String arr[] = ym.split("-");
|
||||||
|
|
||||||
|
int year = Integer.parseInt(arr[0]);
|
||||||
|
int month = Integer.parseInt(arr[1]);
|
||||||
|
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
//设置年份
|
||||||
|
cal.set(Calendar.YEAR, year);
|
||||||
|
//设置月份
|
||||||
|
cal.set(Calendar.MONTH, month - 1);
|
||||||
|
//获取某月最大天数
|
||||||
|
int lastDay = cal.getActualMaximum(Calendar.DATE);
|
||||||
|
//设置日历中月份的最大天数
|
||||||
|
cal.set(Calendar.DAY_OF_MONTH, lastDay);
|
||||||
|
//格式化日期
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
return sdf.format(cal.getTime());
|
||||||
|
}
|
||||||
|
|
||||||
public static class YEARS {
|
public static class YEARS {
|
||||||
public static long toMillis(long years) {
|
public static long toMillis(long years) {
|
||||||
return checkOverflow(years, DAYS_OF_YEAR * HOURS_OF_DAY * MINUTES_OF_HOUR * SECONDS_OF_MINUTE * MILLIS_OF_SECOND);
|
return checkOverflow(years, DAYS_OF_YEAR * HOURS_OF_DAY * MINUTES_OF_HOUR * SECONDS_OF_MINUTE * MILLIS_OF_SECOND);
|
||||||
@@ -609,311 +910,6 @@ public class TimeUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 将毫秒转换为年月日时分秒 ,只拿时分秒
|
|
||||||
*
|
|
||||||
* @author GaoHuanjie
|
|
||||||
*/
|
|
||||||
public static String getYearMonthDayHourMinuteSecond(long timeMillis) {
|
|
||||||
int timezone = 8; // 时区
|
|
||||||
long totalSeconds = timeMillis / 1000;
|
|
||||||
totalSeconds += 60 * 60 * timezone;
|
|
||||||
int second = (int) (totalSeconds % 60);// 秒
|
|
||||||
long totalMinutes = totalSeconds / 60;
|
|
||||||
int minute = (int) (totalMinutes % 60);// 分
|
|
||||||
long totalHours = totalMinutes / 60;
|
|
||||||
int hour = (int) (totalHours % 24);// 时
|
|
||||||
int totalDays = (int) (totalHours / 24);
|
|
||||||
int _year = 1970;
|
|
||||||
int year = _year + totalDays / 366;
|
|
||||||
int month = 1;
|
|
||||||
int day = 1;
|
|
||||||
int diffDays;
|
|
||||||
boolean leapYear;
|
|
||||||
while (true) {
|
|
||||||
int diff = (year - _year) * 365;
|
|
||||||
diff += (year - 1) / 4 - (_year - 1) / 4;
|
|
||||||
diff -= ((year - 1) / 100 - (_year - 1) / 100);
|
|
||||||
diff += (year - 1) / 400 - (_year - 1) / 400;
|
|
||||||
diffDays = totalDays - diff;
|
|
||||||
leapYear = (year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0);
|
|
||||||
if (!leapYear && diffDays < 365 || leapYear && diffDays < 366) {
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
year++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int[] monthDays;
|
|
||||||
if (diffDays >= 59 && leapYear) {
|
|
||||||
monthDays = new int[]{-1, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};
|
|
||||||
} else {
|
|
||||||
monthDays = new int[]{-1, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
|
|
||||||
}
|
|
||||||
for (int i = monthDays.length - 1; i >= 1; i--) {
|
|
||||||
if (diffDays >= monthDays[i]) {
|
|
||||||
month = i;
|
|
||||||
day = diffDays - monthDays[i] + 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String hours;
|
|
||||||
String minutes;
|
|
||||||
String seconds;
|
|
||||||
if (hour < 10) {
|
|
||||||
hours = "0" + hour;
|
|
||||||
} else {
|
|
||||||
hours = "" + hour;
|
|
||||||
}
|
|
||||||
if (minute < 10) {
|
|
||||||
minutes = "0" + minute;
|
|
||||||
} else {
|
|
||||||
minutes = "" + minute;
|
|
||||||
}
|
|
||||||
if (second < 10) {
|
|
||||||
seconds = "0" + second;
|
|
||||||
} else {
|
|
||||||
seconds = "" + second;
|
|
||||||
}
|
|
||||||
|
|
||||||
// return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
|
|
||||||
return hours + ":" + minutes + ":" + seconds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Date getTimesnight(int i) {
|
|
||||||
Calendar cal = Calendar.getInstance();
|
|
||||||
cal.set(Calendar.HOUR_OF_DAY, i);
|
|
||||||
cal.set(Calendar.SECOND, 0);
|
|
||||||
cal.set(Calendar.MINUTE, 0);
|
|
||||||
cal.set(Calendar.MILLISECOND, 0);
|
|
||||||
return cal.getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*获得指定天数的0点和24点*/
|
|
||||||
public static Date getTimesnights(Date time) {
|
|
||||||
Calendar cal = Calendar.getInstance();
|
|
||||||
cal.setTime(time);
|
|
||||||
cal.set(Calendar.HOUR_OF_DAY, 0);
|
|
||||||
cal.set(Calendar.SECOND, 0);
|
|
||||||
cal.set(Calendar.MINUTE, 0);
|
|
||||||
cal.set(Calendar.MILLISECOND, 0);
|
|
||||||
return cal.getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将时间戳ms 转成星座
|
|
||||||
* 白羊:0321~0420 天秤:0924~1023
|
|
||||||
* 金牛:0421~0521 天蝎:1024~1122
|
|
||||||
* 双子:0522~0621 射手:1123~1221
|
|
||||||
* 巨蟹:0622~0722 摩羯:1222~0120
|
|
||||||
* 狮子:0723~0823 水瓶:0121~0219
|
|
||||||
* 处女:0824~0923 双鱼:0220~0320
|
|
||||||
*/
|
|
||||||
public static String msToConstellation(long ms) {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTimeInMillis(ms);
|
|
||||||
int month = calendar.get(Calendar.MONTH) + 1;
|
|
||||||
int day = calendar.get(Calendar.DAY_OF_MONTH);
|
|
||||||
Log.e("mouse_debug", month + ", " + day);
|
|
||||||
String xingzuo = "";
|
|
||||||
switch (month) {
|
|
||||||
case 1:
|
|
||||||
xingzuo = day < 21 ? "摩羯座" : "水瓶座";
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
xingzuo = day < 20 ? "水瓶座" : "双鱼座";
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
xingzuo = day < 21 ? "双鱼座" : "白羊座";
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
xingzuo = day < 21 ? "白羊座" : "金牛座";
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
xingzuo = day < 22 ? "金牛座" : "双子座";
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
xingzuo = day < 22 ? "双子座" : "巨蟹座";
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
xingzuo = day < 23 ? "巨蟹座" : "狮子座";
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
xingzuo = day < 24 ? "狮子座" : "处女座";
|
|
||||||
break;
|
|
||||||
case 9:
|
|
||||||
xingzuo = day < 24 ? "处女座" : "天秤座";
|
|
||||||
break;
|
|
||||||
case 10:
|
|
||||||
xingzuo = day < 24 ? "天秤座" : "天蝎座";
|
|
||||||
break;
|
|
||||||
case 11:
|
|
||||||
xingzuo = day < 23 ? "天蝎座" : "射手座";
|
|
||||||
break;
|
|
||||||
case 12:
|
|
||||||
xingzuo = day < 22 ? "射手座" : "摩羯座";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return xingzuo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断是不是 第二天
|
|
||||||
*
|
|
||||||
* @param cacheTime 和 当前时间对比,判断现在是不是第二天了
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static boolean isTomorrow(long cacheTime) {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTimeInMillis(System.currentTimeMillis());
|
|
||||||
int currYear = calendar.get(Calendar.YEAR);
|
|
||||||
int currMonth = calendar.get(Calendar.MONTH);
|
|
||||||
int currDayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
|
|
||||||
calendar.setTimeInMillis(cacheTime);
|
|
||||||
int cacheYear = calendar.get(Calendar.YEAR);
|
|
||||||
int cacheMonth = calendar.get(Calendar.MONTH);
|
|
||||||
int cacheDayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
|
|
||||||
if (currYear > cacheYear) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
boolean equalYear = currYear == cacheYear;
|
|
||||||
if (equalYear && currMonth > cacheMonth) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return equalYear && currMonth == cacheMonth && currDayOfMonth > cacheDayOfMonth;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param cacheTime 和 当前时间对比,判断现在是不是当天
|
|
||||||
* @return -
|
|
||||||
*/
|
|
||||||
public static boolean isToday(long cacheTime) {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTimeInMillis(System.currentTimeMillis());
|
|
||||||
int currYear = calendar.get(Calendar.YEAR);
|
|
||||||
int currMonth = calendar.get(Calendar.MONTH);
|
|
||||||
int currDayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
|
|
||||||
calendar.setTimeInMillis(cacheTime);
|
|
||||||
int cacheYear = calendar.get(Calendar.YEAR);
|
|
||||||
int cacheMonth = calendar.get(Calendar.MONTH);
|
|
||||||
int cacheDayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
|
|
||||||
return currYear == cacheYear && currMonth == cacheMonth && currDayOfMonth == cacheDayOfMonth;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param cacheTime 和 当前时间对比,是不是同一年
|
|
||||||
* @return -
|
|
||||||
*/
|
|
||||||
public static boolean isSameYear(long cacheTime) {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTimeInMillis(System.currentTimeMillis());
|
|
||||||
int currYear = calendar.get(Calendar.YEAR);
|
|
||||||
calendar.setTimeInMillis(cacheTime);
|
|
||||||
int cacheYear = calendar.get(Calendar.YEAR);
|
|
||||||
return currYear == cacheYear;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得系统时间 年、月、日、小时、分钟
|
|
||||||
* @return HashMap
|
|
||||||
*/
|
|
||||||
public static int getTime24(){
|
|
||||||
SimpleDateFormat hh = new SimpleDateFormat("HH", Locale.CHINA);
|
|
||||||
SimpleDateFormat mm = new SimpleDateFormat("mm", Locale.CHINA);
|
|
||||||
hh.setTimeZone(TimeZone.getTimeZone("GMT+08")); // 获取指定时区的时间
|
|
||||||
mm.setTimeZone(TimeZone.getTimeZone("GMT+08"));
|
|
||||||
Date date = new Date();
|
|
||||||
String hour = hh.format(date);
|
|
||||||
String minute = mm.format(date);
|
|
||||||
return Integer.parseInt(hour +minute);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean getTimeLimit(int start_hour,int end_hour) {
|
|
||||||
SimpleDateFormat hh = new SimpleDateFormat("HH", Locale.CHINA);
|
|
||||||
SimpleDateFormat mm = new SimpleDateFormat("mm", Locale.CHINA);
|
|
||||||
hh.setTimeZone(TimeZone.getTimeZone("GMT+08")); // 获取指定时区的时间
|
|
||||||
mm.setTimeZone(TimeZone.getTimeZone("GMT+08"));
|
|
||||||
Date date = new Date();
|
|
||||||
String hour = hh.format(date);
|
|
||||||
String minute = mm.format(date);
|
|
||||||
Log.i("stf", "--hour:minute-->" + hour + ":" + minute);
|
|
||||||
int currentTime = Integer.parseInt(hour +minute);
|
|
||||||
LogUtil.print("start" +start_hour);
|
|
||||||
LogUtil.print("end" +end_hour);
|
|
||||||
LogUtil.print("minuteOfDay" +currentTime);
|
|
||||||
if (currentTime >= start_hour && currentTime <= end_hour) {
|
|
||||||
LogUtil.print("工作时间内" + hour + ":" + minute);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
if (start_hour > end_hour){
|
|
||||||
if (currentTime >= start_hour || currentTime <= end_hour){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LogUtil.print( "工作时间外" + hour + ":" + minute);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取指定年月的第一天
|
|
||||||
* @param ym yyyy-MM
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String getFirstDayOfMonth(String ym) {
|
|
||||||
String arr[] = ym.split("-");
|
|
||||||
|
|
||||||
int year = Integer.parseInt(arr[0]);
|
|
||||||
int month = Integer.parseInt(arr[1]);
|
|
||||||
|
|
||||||
Calendar cal = Calendar.getInstance();
|
|
||||||
//设置年份
|
|
||||||
cal.set(Calendar.YEAR, year);
|
|
||||||
|
|
||||||
//设置月份
|
|
||||||
cal.set(Calendar.MONTH, month - 1);
|
|
||||||
//获取某月最小天数
|
|
||||||
int firstDay = cal.getMinimum(Calendar.DATE);
|
|
||||||
//设置日历中月份的最小天数
|
|
||||||
cal.set(Calendar.DAY_OF_MONTH, firstDay);
|
|
||||||
//格式化日期
|
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
||||||
|
|
||||||
return sdf.format(cal.getTime());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取指定年月的最后一天
|
|
||||||
* @param ym
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String getLastDayOfMonth(String ym) {
|
|
||||||
String arr[] = ym.split("-");
|
|
||||||
|
|
||||||
int year = Integer.parseInt(arr[0]);
|
|
||||||
int month = Integer.parseInt(arr[1]);
|
|
||||||
|
|
||||||
Calendar cal = Calendar.getInstance();
|
|
||||||
//设置年份
|
|
||||||
cal.set(Calendar.YEAR, year);
|
|
||||||
//设置月份
|
|
||||||
cal.set(Calendar.MONTH, month - 1);
|
|
||||||
//获取某月最大天数
|
|
||||||
int lastDay = cal.getActualMaximum(Calendar.DATE);
|
|
||||||
//设置日历中月份的最大天数
|
|
||||||
cal.set(Calendar.DAY_OF_MONTH, lastDay);
|
|
||||||
//格式化日期
|
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
||||||
return sdf.format(cal.getTime());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// public static boolean getTimeLimit() {
|
// public static boolean getTimeLimit() {
|
||||||
// SimpleDateFormat hh = new SimpleDateFormat("HH", Locale.CHINA);
|
// SimpleDateFormat hh = new SimpleDateFormat("HH", Locale.CHINA);
|
||||||
|
Reference in New Issue
Block a user