public class POBUtils
extends java.lang.Object
| Constructor and Description |
|---|
POBUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
buildUriWithQueryParams(android.net.Uri uri,
java.util.Map<java.lang.String,java.lang.String> queryParams)
Util method to build a url with given map of query params
|
static java.lang.String |
buildUrlWithQueryParam(java.lang.String serverUrl,
java.lang.String key,
java.lang.String value)
Util method to add query param to a url
|
static int |
convertDpToPixel(int value)
Method is used to covert DP into pixel
|
static float |
convertDpToPixelWithFloatPrecession(int value)
Method is used to covert DP into pixel with float precession
|
static int |
convertPixelToDp(int value)
Method is used to convert Pixel into DP
|
static java.util.List<java.lang.String> |
convertStringJsonArrayToList(org.json.JSONArray jsonArray)
Converts the JSONArray to List
|
static double |
convertToSeconds(java.lang.String duration,
java.lang.String skipOffset)
Calculates time in seconds whether skip offset is in time format or percentage
|
static java.util.List<java.lang.String> |
filterListOfStrings(java.util.List<java.lang.String> listOfStrings,
java.lang.String filter)
Filters out the strings which contains the filter string in it.
|
static boolean |
getBooleanValue(java.lang.String data) |
static java.lang.Object |
getBuildConfigValue(android.content.Context context,
java.lang.String fieldName)
Gets a field from the project's BuildConfig.
|
static int |
getDeviceOrientation(android.content.Context appContext)
Returns the device current orientation
|
static int |
getIntegerValue(java.lang.String data) |
static POBAdSize |
getInterstitialAdSize(android.content.Context context) |
static POBLocation |
getLocation(POBLocationDetector locationDetector)
Method identifies isLocationDetectionEnabled
if enabled then fetch last known location of the device
if disabled then get location provided by the publisher
|
static java.lang.String |
getMappingKey(int profileId,
java.lang.Integer versionId)
MappingKey is the key used to search the requested profile in the CacheManager.
|
static int |
getRandomNumber(int lowerBound,
int upperBound)
Returns the random number between lowerBound and upperBound
|
static int |
getScreenHeight()
Method to get screen height in DP
|
static int |
getScreenWidth()
Method to get screen width in DP
|
static double |
getSeconds(java.lang.String time)
Utility method to convert time string to seconds
|
static int |
getTimeOffsetInMinutes()
Returns local time as the number +/- of minutes from UTC.
|
static int |
getValidRefreshInterval(int refreshInterval,
int minRefreshInterval)
Validates and returns time interval in seconds to refresh the banner ad.
|
static int |
getViewVisiblePixel(android.view.View view)
To get visible pixel of view.
|
static int[] |
getViewXYPosition(android.view.View view)
Method is used get x, y position of View
|
static float |
getVisiblePercent(android.view.View view)
To get visibility percent of view, if view is null it will always returns 0 as visibility percent
|
static boolean |
hasPermission(android.content.Context appContext,
java.lang.String permission)
Method is used to check app has user permission
|
static boolean |
isJsonArrayNullOrEmpty(org.json.JSONArray jsonArray)
Checks if the json array is null or not empty.
|
static boolean |
isJsonObjectNullOrEmpty(org.json.JSONObject jsonObject)
Checks if the json object is null or not empty.
|
static boolean |
isListNullOrEmpty(java.util.List<?> list)
Function used to check whether the list is null or empty
|
static boolean |
isNull(java.lang.Object[] obj)
Method to check Object array is Null/Empty or one of the object inside the object array is null
|
static boolean |
isNullOrEmpty(java.lang.String str)
Method to check String isNull or isEmpty
|
static boolean |
isStringValueNullOrEmpty(java.lang.String string)
Function return true if the string passed is null or empty or is "null"
|
static boolean |
isTablet(android.content.Context context)
Method to check whether the device is Phone or Tablet.
|
static boolean |
isValidPlayStoreUrl(java.lang.String urlString)
Method to check if url is valid play store url and contains bundle id
|
static boolean |
isViewVisible(android.view.View view,
int visibilityCriteriaInPixel)
To get visibility of view.
|
static void |
logBidWinningStatus(boolean hasWon,
java.lang.String partnerName)
Log the statement based on the winning status
|
static boolean |
openExternalBrowser(android.content.Context context,
java.lang.String url)
Opens url in external app of browser
|
static java.util.Set<java.lang.String> |
parseJsonArrayToSet(org.json.JSONArray jsonArray)
Parse the json array to
|
static java.lang.String |
parseJsTracker(java.util.List<java.lang.String> jsTrackers)
Function takes List of script tags can convert it into a single string which can directly be
embedded in head tag for execution
|
static java.lang.String |
readFromAssets(android.content.Context context,
java.lang.String file)
Utility method to read file from assets
|
static android.content.Context |
resolveWebViewContext(android.content.Context context)
Used to get resolved context for WebView.
|
static void |
runOnBackgroundThread(java.lang.Runnable action)
Runs the specified action on the non main thread.
|
static void |
runOnMainThread(java.lang.Runnable action)
Runs the specified action on the Main/UI thread.
|
@Nullable
public static java.lang.Object getBuildConfigValue(android.content.Context context,
java.lang.String fieldName)
context - Used to find the correct filefieldName - The name of the field-to-accessnull if the field is not found.public static boolean hasPermission(@NonNull
android.content.Context appContext,
@NonNull
java.lang.String permission)
appContext - android app contextpermission - string of app permissionpublic static int getRandomNumber(int lowerBound,
int upperBound)
lowerBound - Minimum value for random numberupperBound - Maximum value for random numberpublic static boolean openExternalBrowser(android.content.Context context,
java.lang.String url)
context - android app contexturl - which is going to be opened in external browser/applicationpublic static boolean isNullOrEmpty(@Nullable
java.lang.String str)
str - which is going to checkedpublic static boolean isNull(@Nullable
java.lang.Object[] obj)
obj - accepts array of object@Nullable public static POBLocation getLocation(@Nullable POBLocationDetector locationDetector)
locationDetector - instance of POBLocationDetectorpublic static int getScreenWidth()
public static int convertPixelToDp(int value)
value - in Pixelpublic static int getScreenHeight()
public static int[] getViewXYPosition(android.view.View view)
view - on which operation to be performedpublic static int convertDpToPixel(int value)
value - of DPpublic static float convertDpToPixelWithFloatPrecession(int value)
value - of DPpublic static POBAdSize getInterstitialAdSize(@NonNull android.content.Context context)
public static int getDeviceOrientation(@NonNull
android.content.Context appContext)
appContext - application contextpublic static boolean isTablet(android.content.Context context)
context - provide screenLayout and screenLayout size mask@Nullable
@WorkerThread
public static java.lang.String readFromAssets(@NonNull
android.content.Context context,
@NonNull
java.lang.String file)
context - instance of Contextfile - name of filepublic static int getTimeOffsetInMinutes()
public static double convertToSeconds(@Nullable
java.lang.String duration,
@Nullable
java.lang.String skipOffset)
duration - should be in format HH:MM:SS.mmm, HH:MM:SS, MM:SS, SS etcskipOffset - should be in format HH:MM:SS.mmm or HH:MM:SS or in percentagepublic static double getSeconds(@Nullable
java.lang.String time)
time - time can be in format HH:MM:SS.mmm, HH:MM:SS, MM:SS, SS etcpublic static int getIntegerValue(@Nullable
java.lang.String data)
public static boolean getBooleanValue(@Nullable
java.lang.String data)
public static float getVisiblePercent(@Nullable
android.view.View view)
view - on which visibility percent is calculatedpublic static boolean isViewVisible(@Nullable
android.view.View view,
int visibilityCriteriaInPixel)
view - on which visibility should be checkedvisibilityCriteriaInPixel - number of pixel needed to meet visibility criteriapublic static int getViewVisiblePixel(@Nullable
android.view.View view)
view - on which visibility should be checkedpublic static void runOnMainThread(java.lang.Runnable action)
action - the action to run on the Main/UI threadpublic static void runOnBackgroundThread(java.lang.Runnable action)
action - the action to run on the Main/UI threadpublic static int getValidRefreshInterval(int refreshInterval,
int minRefreshInterval)
refreshInterval - time interval in seconds@NonNull
public static android.content.Context resolveWebViewContext(@NonNull
android.content.Context context)
Note: Must be used with WebView FIXME: Remove this method onces new appcompat library available with above mentioned fix.
context - the instance of contextpublic static void logBidWinningStatus(boolean hasWon,
@Nullable
java.lang.String partnerName)
hasWon - Winning statuspartnerName - Name of the winning partner@NonNull
public static java.lang.String buildUrlWithQueryParam(@NonNull
java.lang.String serverUrl,
@NonNull
java.lang.String key,
@NonNull
java.lang.String value)
serverUrl - url in which the param needs to be addedkey - key of query paramvalue - value of query param@NonNull
public static java.lang.String buildUriWithQueryParams(@NonNull
android.net.Uri uri,
@NonNull
java.util.Map<java.lang.String,java.lang.String> queryParams)
url - url stringqueryParams - map of query paramspublic static boolean isJsonObjectNullOrEmpty(@Nullable
org.json.JSONObject jsonObject)
jsonObject - JSONObjectpublic static boolean isJsonArrayNullOrEmpty(@Nullable
org.json.JSONArray jsonArray)
jsonArray - JSONArray@Nullable
public static java.util.List<java.lang.String> convertStringJsonArrayToList(@Nullable
org.json.JSONArray jsonArray)
jsonArray - JSONArray@NonNull
public static java.lang.String parseJsTracker(@NonNull
java.util.List<java.lang.String> jsTrackers)
jsTrackers - List of script tags string or the url of .js files.public static boolean isListNullOrEmpty(@Nullable
java.util.List<?> list)
list - List of any data typepublic static boolean isValidPlayStoreUrl(@Nullable
java.lang.String urlString)
urlString - url string@NonNull
public static java.util.List<java.lang.String> filterListOfStrings(@Nullable
java.util.List<java.lang.String> listOfStrings,
@NonNull
java.lang.String filter)
listOfStrings - List of strings to be used to filtering.filter - Filter string used to filter out the string.@NonNull
public static java.util.Set<java.lang.String> parseJsonArrayToSet(@Nullable
org.json.JSONArray jsonArray)
throws org.json.JSONException
jsonArray - the json array of StringSetorg.json.JSONExceptionpublic static boolean isStringValueNullOrEmpty(@Nullable
java.lang.String string)
string - String to perform check onpublic static java.lang.String getMappingKey(int profileId,
@Nullable
java.lang.Integer versionId)
profileId - The profile ID of the userversionId - The version of the profile