Class Utils
java.lang.Object
org.prebid.mobile.rendering.utils.helpers.Utils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <E,U> void static voidstatic booleanCheck that Android SDK version at least Ice Cream Sandwich.static booleanCheck that Android SDK version at least Kit Katstatic booleanatLeastQ()static StringbyteArrayToHexString(byte[] byteArray) This function encodes byte[] into a hexstatic intclampAutoRefresh(int refreshDelay) static intclampInMillis(int value, int lowerBound, int upperBound) static intconvertDpToPx(int dp, android.content.Context context) static intconvertPxToDp(int px, android.content.Context context) static android.view.ViewcreateCloseView(android.content.Context context) static android.view.ViewcreateCloseView(android.content.Context context, InterstitialDisplayPropertiesInternal properties) static android.view.ViewcreateSkipView(android.content.Context context, InterstitialDisplayPropertiesInternal properties) static android.view.ViewcreateSoundView(android.content.Context context) static android.view.ViewcreateWatchAgainView(android.content.Context context) static intstatic byte[]generateSHA1(byte[] bytes) This function generates a SHA1 byte[] from another byte[].static StringgenerateSHA1(String exp) Generate SHA1 for string expressionstatic StringGenerate time-based UUIDstatic StringgetFileExtension(String url) static longstatic longgetMsFromSeconds(long seconds) getQueryMap(String query) static intgetScreenHeight(android.view.WindowManager windowManager) static intgetScreenWidth(android.view.WindowManager windowManager) static booleanhasScreenVisibilityChanged(int oldVisibility, int newVisibility) static booleanisBlank(CharSequence cs) Checks if a CharSequence is whitespace, empty ("") or null.static booleanCheck the state that device external storage is available.static booleanisMraidActionUrl(String url) static booleanChecks if a CharSequence is not empty (""), not null and not whitespace only.static booleanisPermissionGranted(android.content.Context context, String permission) Checks if the permission was grantedstatic booleanisScreenVisible(int visibility) static booleanstatic booleanisVideoContent(String type) static StringloadStringFromFile(android.content.res.Resources res, int file) Load JavaScript file from resources.static StringMd5.static BaseNetworkTask.GetUrlParamsstatic org.json.JSONArraysubJsonArray(org.json.JSONArray array, int start, int length) Get subsection of JSONArray, starting from 'start' and has length 'length'static <E,U> org.json.JSONObject toJson(Map<E, ? extends Collection<U>> map)
-
Field Details
-
DENSITY
public static float DENSITY
-
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
isMraidActionUrl
-
isVideoContent
-
generateSHA1
public static byte[] generateSHA1(byte[] bytes) This function generates a SHA1 byte[] from another byte[].- Parameters:
bytes-- Returns:
-
generateUUIDTimeBased
Generate time-based UUID- Returns:
- RFC 4122 high-quality random number
-
generateSHA1
Generate SHA1 for string expression- Parameters:
exp- is string expression- Returns:
- SHA1 code
-
byteArrayToHexString
This function encodes byte[] into a hex- Parameters:
byteArray-- Returns:
-
md5
Md5.- Parameters:
s- the string for which MD5 hash will be generated- Returns:
- the MD5 hash
-
loadStringFromFile
Load JavaScript file from resources.- Parameters:
res- the resource pathfile- 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
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:
trueif the CharSequence is null, empty or whitespace
-
isNotBlank
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:
trueif 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
-
getScreenWidth
public static int getScreenWidth(android.view.WindowManager windowManager) -
getScreenHeight
public static int getScreenHeight(android.view.WindowManager windowManager) -
getQueryMap
-
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
Checks if the permission was granted- Parameters:
context- - Activity contextpermission- - permission to check- Returns:
-
getMsFrom
- 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
- Parameters:
data- which is used to createVASTwith the help ofAdResponseParserVast- Returns:
- true if
VASTcreation was successful, false otherwise
-
getFileExtension
-
clampAutoRefresh
public static int clampAutoRefresh(int refreshDelay) -
clampInMillis
public static int clampInMillis(int value, int lowerBound, int upperBound) -
generateRandomInt
public static int generateRandomInt() -
toJson
-
addValue
-
addValue
-