-
public final class Utils
-
-
Field Summary
Fields Modifier and Type Field Description public static floatDENSITY
-
Method Summary
Modifier and Type Method Description static booleanisMraidActionUrl(String url)static booleanisVideoContent(String type)static Array<byte>generateSHA1(Array<byte> bytes)This function generates a SHA1 byte[] from another byte[]. static StringgenerateUUIDTimeBased()Generate time-based UUID static StringgenerateSHA1(String exp)Generate SHA1 for string expression static StringbyteArrayToHexString(Array<byte> byteArray)This function encodes byte[] into a hex static Stringmd5(String s)Md5. static StringloadStringFromFile(Resources res, int file)Load JavaScript file from resources. static booleanatLeastKitKat()Check that Android SDK version at least Kit Kat static booleanatLeastQ()static booleanatLeastICS()Check that Android SDK version at least Ice Cream Sandwich. static booleanisExternalStorageAvailable()Check the state that device external storage is available. static booleanisScreenVisible(int visibility)static booleanhasScreenVisibilityChanged(int oldVisibility, int newVisibility)static booleanisBlank(CharSequence cs)Checks if a CharSequence is whitespace, empty ("") or null. static booleanisNotBlank(CharSequence cs)Checks if a CharSequence is not empty (""), not null and not whitespace only. static JSONArraysubJsonArray(JSONArray array, int start, int length)Get subsection of JSONArray, starting from 'start' and has length 'length' static BaseNetworkTask.GetUrlParamsparseUrl(String url)static intgetScreenWidth(WindowManager windowManager)static intgetScreenHeight(WindowManager windowManager)static Map<String, String>getQueryMap(String query)static ViewcreateSkipView(Context context, @Nullable() InterstitialDisplayPropertiesInternal properties)static ViewcreateCloseView(Context context)static ViewcreateCloseView(Context context, @Nullable() InterstitialDisplayPropertiesInternal properties)static ViewcreateSoundView(Context context)static intconvertPxToDp(int px, Context context)static intconvertDpToPx(int dp, Context context)static ViewcreateWatchAgainView(Context context)static booleanisPermissionGranted(Context context, String permission)Checks if the permission was granted static longgetMsFrom(String durationInString)static longgetMsFromSeconds(long seconds)static booleanisVast(String data)static StringgetFileExtension(String url)static intclamp(int value, int lowerBound, int upperBound)static intgenerateRandomInt()static <E, U> JSONObjecttoJson(Map<E, out Collection<U>> map)static <E, U> voidaddValue(Map<E, Set<U>> map, E key, U value)static voidaddValue(JSONObject target, String key, Object jsonObject)-
-
Method Detail
-
isMraidActionUrl
static boolean isMraidActionUrl(String url)
-
isVideoContent
static boolean isVideoContent(String type)
-
generateSHA1
static Array<byte> generateSHA1(Array<byte> bytes)
This function generates a SHA1 byte[] from another byte[].
-
generateUUIDTimeBased
static String generateUUIDTimeBased()
Generate time-based UUID
-
generateSHA1
static String generateSHA1(String exp)
Generate SHA1 for string expression
- Parameters:
exp- is string expression
-
byteArrayToHexString
static String byteArrayToHexString(Array<byte> byteArray)
This function encodes byte[] into a hex
-
md5
static String md5(String s)
Md5.
- Parameters:
s- the string for which MD5 hash will be generated
-
loadStringFromFile
static String loadStringFromFile(Resources res, int file)
Load JavaScript file from resources.
- Parameters:
res- the resource pathfile- the resource file name
-
atLeastKitKat
static boolean atLeastKitKat()
Check that Android SDK version at least Kit Kat
-
atLeastQ
static boolean atLeastQ()
-
atLeastICS
static boolean atLeastICS()
Check that Android SDK version at least Ice Cream Sandwich.
-
isExternalStorageAvailable
static boolean isExternalStorageAvailable()
Check the state that device external storage is available.
-
isScreenVisible
static boolean isScreenVisible(int visibility)
-
hasScreenVisibilityChanged
static boolean hasScreenVisibilityChanged(int oldVisibility, int newVisibility)
-
isBlank
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
-
isNotBlank
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
-
subJsonArray
static JSONArray subJsonArray(JSONArray array, int start, int length)
Get subsection of JSONArray, starting from 'start' and has length 'length'
-
parseUrl
static BaseNetworkTask.GetUrlParams parseUrl(String url)
-
getScreenWidth
static int getScreenWidth(WindowManager windowManager)
-
getScreenHeight
static int getScreenHeight(WindowManager windowManager)
-
getQueryMap
static Map<String, String> getQueryMap(String query)
-
createSkipView
static View createSkipView(Context context, @Nullable() InterstitialDisplayPropertiesInternal properties)
-
createCloseView
static View createCloseView(Context context)
-
createCloseView
static View createCloseView(Context context, @Nullable() InterstitialDisplayPropertiesInternal properties)
-
createSoundView
static View createSoundView(Context context)
-
convertPxToDp
static int convertPxToDp(int px, Context context)
-
convertDpToPx
static int convertDpToPx(int dp, Context context)
-
createWatchAgainView
static View createWatchAgainView(Context context)
-
isPermissionGranted
static boolean isPermissionGranted(Context context, String permission)
Checks if the permission was granted
- Parameters:
context- - Activity contextpermission- - permission to check
-
getMsFrom
static long getMsFrom(String durationInString)
- Parameters:
durationInString- String time in hh:mm:ss format
-
getMsFromSeconds
static long getMsFromSeconds(long seconds)
-
isVast
static boolean isVast(String data)
- Parameters:
data- which is used to create VAST with the help of AdResponseParserVast
-
getFileExtension
@NonNull() static String getFileExtension(String url)
-
clamp
static int clamp(int value, int lowerBound, int upperBound)
-
generateRandomInt
static int generateRandomInt()
-
toJson
static <E, U> JSONObject toJson(Map<E, out Collection<U>> map)
-
addValue
static void addValue(JSONObject target, String key, Object jsonObject)
-
-
-
-