Merge branch 'yinyou_v3.6.4' into yinyou_develop

# Conflicts:
#	app/src/main/AndroidManifest.xml
#	app/src/main/java/com/yizhuan/erban/avroom/adapter/BaseMicroViewAdapter.java
#	app/src/main/java/com/yizhuan/erban/avroom/anotherroompk/RoomPKBoardView.kt
#	app/src/main/res/layout/layout_room_pk_board_view.xml
#	core/src/main/java/com/yizhuan/xchat_android_core/manager/AvRoomDataManager.java
#	core/src/main/java/com/yizhuan/xchat_android_core/room/bean/RoomInfo.java
This commit is contained in:
huangjian
2021-12-13 19:07:29 +08:00
58 changed files with 6868 additions and 978 deletions

View File

@@ -48,6 +48,7 @@ public class TimeUtils {
public static final String DATE_FORMAT = "yyyy-MM-dd";
public static final String TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
public static final long MILLIS_OF_SEC = 1000;
public static String getCurrentDateStr() {
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.getDefault());
@@ -157,8 +158,6 @@ public class TimeUtils {
return c.getTimeInMillis();
}
public static final long MILLIS_OF_SEC = 1000;
/**
* Get current time in secs.
*
@@ -427,6 +426,308 @@ public class TimeUtils {
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 long toMillis(long years) {
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() {
// SimpleDateFormat hh = new SimpleDateFormat("HH", Locale.CHINA);