Class SystemUtils

  • All Implemented Interfaces:

    
    public class SystemUtils
    
                        

    Created by weiqinxiao on 15/10/14.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
      public static Context applicationContext
    • Constructor Summary

      Constructors 
      Constructor Description
      SystemUtils()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static Context getApplicationContext()
      static void setApplicationContext(Context context)
      static String getCurrentProcessName(Context context)
      static boolean isMainProcess(Context context) Indicates whether the current process is the main process.
      static Intent registerReceiverCompat(Context context, BroadcastReceiver receiver, IntentFilter filter) Unify broadcast registration encapsulation for centralized handling of permissions, compliance, and other issues.
      static boolean isValidAppKey(String appKey) Current policy for server appKey: Only lowercase letters or numbers are allowed.
      static String listToString(List<String> list) Converts a Listto a String, with each String separated by a comma.
      static String listCmpDataToString(List<CmpData> list) Converts Listto String.
      static String mapToString(Map map) Converts a Map to a string.
      static boolean isParameterValid(ConversationType conversationType, String targetId, String channelId)
      static boolean isConversationTypeValid(ConversationType conversationType)
      static boolean isTargetIdValid(String targetId)
      static boolean isChannelIdValid(String channelId)
      static boolean nonSupportSuperGroup(ConversationType conversationType)
      static boolean judgeUIDInvalid(String messageUId, OperationCallback callback)
      static boolean judgeListInvalid(List<String> keyArray, OperationCallback callback)
      static boolean judgeMapInvalid(Map<String, String> expansion, OperationCallback callback)
      static <T extends Enum<T>> Array<int> enumArrayToOrdinalArray(Array<T> enumArray) Converts an array of enums to an array of their ordinal values
      static <T> List<)>T> )>deduplicate(List<)>T> list, Deduplicate<T> deduplicate) Deduplicates a List.
      static <T> List<T> deduplicate(List<T> list)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SystemUtils

        SystemUtils()
    • Method Detail

      • getCurrentProcessName

         static String getCurrentProcessName(Context context)
        Parameters:
        context - The context
        Returns:

        The current process name

      • isMainProcess

         static boolean isMainProcess(Context context)

        Indicates whether the current process is the main process.

        Parameters:
        context - The context.
        Returns:

        Indicates whether the current process is the main process. Returns `true` if it is the main process; otherwise, returns `false`.

      • registerReceiverCompat

         static Intent registerReceiverCompat(Context context, BroadcastReceiver receiver, IntentFilter filter)

        Unify broadcast registration encapsulation for centralized handling of permissions, compliance, and other issues.

      • isValidAppKey

         static boolean isValidAppKey(String appKey)

        Current policy for server appKey: Only lowercase letters or numbers are allowed. For future extensibility, the client-side logic includes uppercase letters. Validates if the string contains only a-z, A-Z, 0-9 and has a length less than or equal to 20.

        Parameters:
        appKey - The string to be validated
        Returns:

        true if the string meets the criteria

      • listToString

         static String listToString(List<String> list)

        Converts a Listto a String, with each String separated by a comma.

        Parameters:
        list - The Listto be converted
        Returns:

        The converted String

      • listCmpDataToString

         static String listCmpDataToString(List<CmpData> list)

        Converts Listto String. Each CmpData is separated by a comma (,), and the addr, protocol, and weight fields of CmpData are separated by a semicolon (;).

        Parameters:
        list - The Listto be converted
        Returns:

        The converted String

      • mapToString

         static String mapToString(Map map)

        Converts a Map to a string. Each entry is separated by ';', and key and value are separated by ':'.

        Parameters:
        map - The map to be converted.
        Returns:

        The converted string.

      • isParameterValid

         static boolean isParameterValid(ConversationType conversationType, String targetId, String channelId)
      • 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)

        Converts an array of enums to an array of their ordinal values

        Parameters:
        enumArray - The array of enums
        Returns:

        The converted array of integers

      • deduplicate

         static <T> List<)>T> )>deduplicate(List<)>T> list, Deduplicate<T> deduplicate)

        Deduplicates a List.

        If a key is duplicated, the existing element will be overwritten by the subsequent element. Time complexity is 2N.

        Parameters:
        list - The List before deduplication
        deduplicate - The deduplication interface, where the upper layer determines the key for deduplication
        Returns:

        The deduplicated List