Package io.rong.common
Class SystemUtils
-
- All Implemented Interfaces:
public class SystemUtilsCreated by weiqinxiao on 15/10/14.
-
-
Field Summary
Fields Modifier and Type Field Description public static ContextapplicationContext
-
Constructor Summary
Constructors Constructor Description SystemUtils()
-
Method Summary
Modifier and Type Method Description static ContextgetApplicationContext()static voidsetApplicationContext(Context context)static StringgetCurrentProcessName(Context context)static booleanisMainProcess(Context context)当前进程是否为主进程。 static IntentregisterReceiverCompat(Context context, BroadcastReceiver receiver, IntentFilter filter)统一封装广播注册,方便统一处理权限、合规等问题。 static booleanisValidAppKey(String appKey)服务端 appKey 目前的策略:只包含小写字母或数字。 客户端为了便于以后的扩展,增加大写字母的逻辑。 校验字符串是否只包含 a-z、A-Z、0-9. static StringlistToString(List<String> list)将 List转换成 String。 每个 String 之间用 , 分隔 static StringlistCmpDataToString(List<CmpData> list)将 List转换成 String。 每个 CmpData 之间用 , 分隔, CmpData 的 addr、protocol、weight 之间用 ; 分隔 static StringmapToString(Map map)Map 转 string。 每个 entry 之间用 ; 分隔, key 和 value 之间用:分隔 static booleanisParameterValid(ConversationType conversationType, String targetId, String channelId)static booleanisConversationTypeValid(ConversationType conversationType)static booleanisTargetIdValid(String targetId)static booleanisChannelIdValid(String channelId)static booleannonSupportSuperGroup(ConversationType conversationType)static booleanjudgeUIDInvalid(String messageUId, OperationCallback callback)static booleanjudgeListInvalid(List<String> keyArray, OperationCallback callback)static booleanjudgeMapInvalid(Map<String, String> expansion, OperationCallback callback)static <T extends Enum<T>> Array<int>enumArrayToOrdinalArray(Array<T> enumArray)枚举数组转换为其ordinal值数组 static <T> List<)>T>)>deduplicate(List<)>T> list, Deduplicate<T> deduplicate)对List去重。 假如key重复,则已插入的元素会被后面的元素所覆盖。复杂度2N。 static <T> List<T>deduplicate(List<T> list)简化重载方法,按泛型T的toString去做key -
-
Method Detail
-
getApplicationContext
static Context getApplicationContext()
-
setApplicationContext
static void setApplicationContext(Context context)
-
getCurrentProcessName
static String getCurrentProcessName(Context context)
- Parameters:
context- 上下文- Returns:
当前进程名
-
isMainProcess
static boolean isMainProcess(Context context)
当前进程是否为主进程。
- Parameters:
context- 上下文- Returns:
当前进程是否为主进程。true 是主进程; false 不是主进程。
-
registerReceiverCompat
static Intent registerReceiverCompat(Context context, BroadcastReceiver receiver, IntentFilter filter)
统一封装广播注册,方便统一处理权限、合规等问题。
-
isValidAppKey
static boolean isValidAppKey(String appKey)
服务端 appKey 目前的策略:只包含小写字母或数字。 客户端为了便于以后的扩展,增加大写字母的逻辑。 校验字符串是否只包含 a-z、A-Z、0-9. 长度小于等于 20.
- Parameters:
appKey- 待校验字符串- Returns:
true 符合条件
-
listToString
static String listToString(List<String> list)
将 List转换成 String。 每个 String 之间用 , 分隔
- Parameters:
list- 待转换的 List- Returns:
转换后的 String
-
listCmpDataToString
static String listCmpDataToString(List<CmpData> list)
将 List转换成 String。 每个 CmpData 之间用 , 分隔, CmpData 的 addr、protocol、weight 之间用 ; 分隔
- Parameters:
list- 待转换的 List- Returns:
转换后的 String
-
mapToString
static String mapToString(Map map)
Map 转 string。 每个 entry 之间用 ; 分隔, key 和 value 之间用:分隔
- Parameters:
map- 待转换的 map- Returns:
转换完的字符串。
-
isParameterValid
static boolean isParameterValid(ConversationType conversationType, String targetId, String channelId)
-
isConversationTypeValid
static boolean isConversationTypeValid(ConversationType conversationType)
-
isTargetIdValid
static boolean isTargetIdValid(String targetId)
-
isChannelIdValid
static boolean isChannelIdValid(String channelId)
-
nonSupportSuperGroup
static boolean nonSupportSuperGroup(ConversationType conversationType)
-
judgeUIDInvalid
static boolean judgeUIDInvalid(String messageUId, OperationCallback callback)
-
judgeListInvalid
static boolean judgeListInvalid(List<String> keyArray, OperationCallback callback)
-
judgeMapInvalid
static boolean judgeMapInvalid(Map<String, String> expansion, OperationCallback callback)
-
enumArrayToOrdinalArray
static <T extends Enum<T>> Array<int> enumArrayToOrdinalArray(Array<T> enumArray)
枚举数组转换为其ordinal值数组
- Parameters:
enumArray- 枚举数组- Returns:
转换后的int数组
-
deduplicate
static <T> List<)>T> )>deduplicate(List<)>T> list, Deduplicate<T> deduplicate)
对List去重。
假如key重复,则已插入的元素会被后面的元素所覆盖。复杂度2N。
- Parameters:
list- 去重前Listdeduplicate- 去重接口,上层实现来决定去重的key是什么- Returns:
去重后List
-
deduplicate
static <T> List<T> deduplicate(List<T> list)
简化重载方法,按泛型T的toString去做key
-
-
-
-