public class POBUtils
extends java.lang.Object
| Constructor and Description |
|---|
POBUtils() |
| Modifier and Type | Method and Description |
|---|---|
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 int |
convertPixelToDp(int value)
Method is used to convert Pixel into DP
|
static long |
convertToMilliSeconds(java.lang.String time)
Utility method to convert time string to milli seconds
|
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 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 long |
getEpochTimeInSec()
Returns the epoch time
|
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 POBAdSize |
getOWAdSize(java.lang.String size)
Method for returning the POBAdSize based on provided ad size string.
|
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 |
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 |
isTablet(android.content.Context context)
Method to check whether the device is Phone or Tablet.
|
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 java.lang.String |
md5(java.lang.String string)
Method is used generate MD5 String
|
static boolean |
openExternalBrowser(android.content.Context context,
java.lang.String url)
Opens url in external app of browser
|
static java.lang.String |
readFile(java.lang.String path)
Utility method to read file content from given path
|
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 WebWiew.
|
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.
|
static java.lang.String |
sha1(java.lang.String string)
Method is used to generate SHA1 string
|
static void |
writeFile(java.lang.String content,
java.lang.String fileName)
Utility method to write string content to file
|
public static java.lang.String sha1(java.lang.String string)
string - on which SHA1 to be performpublic static java.lang.String md5(java.lang.String string)
string - on which MD5 algorithm to be perform@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 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 void writeFile(java.lang.String content,
java.lang.String fileName)
content - content to writefileName - name of file@Nullable public static java.lang.String readFile(java.lang.String path)
path - absolute path of filepublic static int getTimeOffsetInMinutes()
public static long convertToMilliSeconds(@NonNull
java.lang.String time)
time - time can be in format HH:MM:SS.mmm, HH:MM:SS, MM:SS, SS etcpublic 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 context@NonNull public static POBAdSize getOWAdSize(@NonNull java.lang.String size)
size - Size in the format of widthxheight For example: 320x50public static void logBidWinningStatus(boolean hasWon,
@Nullable
java.lang.String partnerName)
hasWon - Winning statuspartnerName - Name of the winning partnerpublic static long getEpochTimeInSec()
@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