java.lang.Object
org.prebid.mobile.rendering.utils.helpers.Utils

public final class Utils extends Object
  • Field Details

    • DENSITY

      public static float DENSITY
  • Constructor Details

    • Utils

      public Utils()
  • Method Details

    • isMraidActionUrl

      public static boolean isMraidActionUrl(String url)
    • isVideoContent

      public static boolean isVideoContent(String type)
    • generateSHA1

      public static byte[] generateSHA1(byte[] bytes)
      This function generates a SHA1 byte[] from another byte[].
      Parameters:
      bytes -
      Returns:
    • generateUUIDTimeBased

      public static String generateUUIDTimeBased()
      Generate time-based UUID
      Returns:
      RFC 4122 high-quality random number
    • generateSHA1

      public static String generateSHA1(String exp)
      Generate SHA1 for string expression
      Parameters:
      exp - is string expression
      Returns:
      SHA1 code
    • byteArrayToHexString

      public static String byteArrayToHexString(byte[] byteArray)
      This function encodes byte[] into a hex
      Parameters:
      byteArray -
      Returns:
    • md5

      public static String md5(String s)
      Md5.
      Parameters:
      s - the string for which MD5 hash will be generated
      Returns:
      the MD5 hash
    • loadStringFromFile

      public static String loadStringFromFile(android.content.res.Resources res, int file)
      Load JavaScript file from resources.
      Parameters:
      res - the resource path
      file - the resource file name
      Returns:
      the JavaScript file content
    • atLeastKitKat

      public static boolean atLeastKitKat()
      Check that Android SDK version at least Kit Kat
      Returns:
      true if at least Kit Kat
    • atLeastQ

      public static boolean atLeastQ()
    • atLeastICS

      public static boolean atLeastICS()
      Check that Android SDK version at least Ice Cream Sandwich.
      Returns:
      true if at least Ice Cream Sandwich
    • isExternalStorageAvailable

      public static boolean isExternalStorageAvailable()
      Check the state that device external storage is available.
      Returns:
      true if available and writeable
    • isScreenVisible

      public static boolean isScreenVisible(int visibility)
    • hasScreenVisibilityChanged

      public static boolean hasScreenVisibilityChanged(int oldVisibility, int newVisibility)
    • isBlank

      public static boolean isBlank(CharSequence cs)

      Checks if a CharSequence is whitespace, empty ("") or null.

       StringUtils.isBlank(null)      = true
       StringUtils.isBlank("")        = true
       StringUtils.isBlank(" ")       = true
       StringUtils.isBlank("bob")     = false
       StringUtils.isBlank("  bob  ") = false
       
      Parameters:
      cs - the CharSequence to check, may be null
      Returns:
      true if the CharSequence is null, empty or whitespace
    • isNotBlank

      public static boolean isNotBlank(CharSequence cs)

      Checks if a CharSequence is not empty (""), not null and not whitespace only.

       StringUtils.isNotBlank(null)      = false
       StringUtils.isNotBlank("")        = false
       StringUtils.isNotBlank(" ")       = false
       StringUtils.isNotBlank("bob")     = true
       StringUtils.isNotBlank("  bob  ") = true
       
      Parameters:
      cs - the CharSequence to check, may be null
      Returns:
      true if the CharSequence is not empty and not null and not whitespace
    • subJsonArray

      public static org.json.JSONArray subJsonArray(org.json.JSONArray array, int start, int length)
      Get subsection of JSONArray, starting from 'start' and has length 'length'
    • parseUrl

      public static BaseNetworkTask.GetUrlParams parseUrl(String url)
    • getScreenWidth

      public static int getScreenWidth(android.view.WindowManager windowManager)
    • getScreenHeight

      public static int getScreenHeight(android.view.WindowManager windowManager)
    • getQueryMap

      public static Map<String,String> getQueryMap(String query)
    • createSkipView

      public static android.view.View createSkipView(android.content.Context context, InterstitialDisplayPropertiesInternal properties)
    • createCloseView

      public static android.view.View createCloseView(android.content.Context context)
    • createCloseView

      public static android.view.View createCloseView(android.content.Context context, InterstitialDisplayPropertiesInternal properties)
    • createSoundView

      public static android.view.View createSoundView(android.content.Context context)
    • convertPxToDp

      public static int convertPxToDp(int px, android.content.Context context)
    • convertDpToPx

      public static int convertDpToPx(int dp, android.content.Context context)
    • createWatchAgainView

      public static android.view.View createWatchAgainView(android.content.Context context)
    • isPermissionGranted

      public static boolean isPermissionGranted(android.content.Context context, String permission)
      Checks if the permission was granted
      Parameters:
      context - - Activity context
      permission - - permission to check
      Returns:
    • getMsFrom

      public static long getMsFrom(String durationInString)
      Parameters:
      durationInString - String time in hh:mm:ss format
      Returns:
      time converted to milliseconds, -1 if failed to convert
    • getMsFromSeconds

      public static long getMsFromSeconds(long seconds)
      Parameters:
      seconds -
      Returns:
      milliseconds value
    • isVast

      public static boolean isVast(String data)
      Parameters:
      data - which is used to create VAST with the help of AdResponseParserVast
      Returns:
      true if VAST creation was successful, false otherwise
    • getFileExtension

      public static String getFileExtension(String url)
    • clampAutoRefresh

      public static int clampAutoRefresh(int refreshDelay)
    • clampInMillis

      public static int clampInMillis(int value, int lowerBound, int upperBound)
    • generateRandomInt

      public static int generateRandomInt()
    • toJson

      public static <E, U> org.json.JSONObject toJson(Map<E,? extends Collection<U>> map)
    • addValue

      public static <E, U> void addValue(Map<E,Set<U>> map, E key, U value)
    • addValue

      public static void addValue(org.json.JSONObject target, String key, Object jsonObject)