public class LiCoreSDKUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
addLSIRequestHeaders(android.content.Context context,
Request.Builder builder) |
static void |
checkArgument(boolean expression,
java.lang.String errorTemplate,
java.lang.Object... params) |
static <T extends java.util.Collection<?>> |
checkCollectionNotEmpty(T collection,
java.lang.String errorMessage)
Ensures that a collection is not null or empty.
|
static java.lang.String |
checkNotEmpty(java.lang.String str,
java.lang.Object errorMessage)
Ensures that a string is not null or empty.
|
static <ArgT> void |
checkNotNull(ArgT... argValue)
Check that the specified argument value is not
null . |
static <ArgT> ArgT |
checkNotNull(ArgT argValue)
Check that the specified argument value is not
null . |
static <ArgT> ArgT |
checkNotNull(ArgT argValue,
java.lang.String errorMessage)
Check that the specified argument value is not
null . |
static java.lang.String |
checkNullOrNotEmpty(java.lang.String str,
java.lang.Object errorMessage)
Ensures that the string is either null, or a non-empty string.
|
static void |
closeQuietly(java.io.InputStream in)
Close an input stream quietly, i.e.
|
static java.lang.Long |
getLongIfDefined(org.json.JSONObject json,
java.lang.String field) |
static byte[] |
getRandomBytes(java.util.Random rand,
int bits)
Create a random byte array using a random number generator supplied by the caller.
|
static java.lang.String |
getRandomHexString() |
static java.lang.String |
getRawString(android.content.Context context,
int rawResId)
Computes default json as string from raw folder.
|
static java.lang.String |
getString(org.json.JSONObject json,
java.lang.String field) |
static java.lang.String |
getStringIfDefined(org.json.JSONObject json,
java.lang.String field) |
static int |
getThemePrimaryColor(android.content.Context context) |
static java.lang.Long |
getTime(java.lang.Long time) |
static java.util.Map<LiBrowse,java.util.List<LiBaseModel>> |
getTransformedResponse(java.util.List<LiBaseModel> response)
this method creates a Tree like structure depicting parent child relation for the Category and SubCategory in
a community.
|
static android.net.Uri |
getUriIfDefined(org.json.JSONObject json,
java.lang.String field) |
static java.lang.String |
iterableToString(java.lang.Iterable<java.lang.String> strings) |
static void |
put(org.json.JSONObject json,
java.lang.String field,
int value) |
static void |
put(org.json.JSONObject json,
java.lang.String field,
org.json.JSONArray value) |
static void |
put(org.json.JSONObject json,
java.lang.String field,
org.json.JSONObject value)
Checks if json, field and value are non null and inserts into JSONObject.
|
static void |
put(org.json.JSONObject json,
java.lang.String field,
java.lang.String value) |
static void |
putIfNotNull(org.json.JSONObject json,
java.lang.String field,
java.lang.Long value) |
static void |
putIfNotNull(org.json.JSONObject json,
java.lang.String field,
java.lang.String value)
Checks if json and field are non null and inserts into JSONObject.
|
static void |
putIfNotNull(org.json.JSONObject json,
java.lang.String field,
android.net.Uri value) |
static java.lang.String |
readInputStream(java.io.InputStream in)
Read a string from an input stream.
|
static void |
sendLoginBroadcast(android.content.Context context,
boolean isLoginSuccessful,
int responseCode) |
static java.util.Set<java.lang.String> |
stringToSet(java.lang.String spaceDelimitedStr)
Converts the consolidated, space-delimited scope string to a set.
|
static java.lang.String |
toHexString(byte[] bytes)
Convert a byte[] array to hex string format.
|
public static java.lang.String getRandomHexString()
public static byte[] getRandomBytes(java.util.Random rand, int bits)
SecureRandom
as the
random number generator implementation.rand
- the random number generator to use. Cannot be null
.bits
- minimum number of bytes in returned array, actual output may be longer due to rounding.java.lang.IllegalArgumentException
- if bits < 1 or bits > 65536 (byte array of length 8192).public static java.lang.String toHexString(byte[] bytes)
bytes
- byte[] buffer to convert to string formatpublic static <ArgT> ArgT checkNotNull(ArgT argValue)
null
.
If it is null
, throw a IllegalArgumentException
argValue
- the argument value to check.java.lang.IllegalArgumentException
- if the argument value is null
.public static <ArgT> void checkNotNull(ArgT... argValue)
null
.
If it is null
, throw a IllegalArgumentException
argValue
- the argument value to check.java.lang.IllegalArgumentException
- if the argument value is null
.public static <ArgT> ArgT checkNotNull(ArgT argValue, java.lang.String errorMessage)
null
.
If it is null
, throw a IllegalArgumentException
argValue
- the argument value to check.java.lang.IllegalArgumentException
- if the argument value is null
.public static <T extends java.util.Collection<?>> T checkCollectionNotEmpty(T collection, java.lang.String errorMessage)
public static java.lang.String checkNullOrNotEmpty(java.lang.String str, java.lang.Object errorMessage)
public static java.lang.String checkNotEmpty(java.lang.String str, java.lang.Object errorMessage)
public static void checkArgument(boolean expression, java.lang.String errorTemplate, java.lang.Object... params)
public static java.lang.String readInputStream(java.io.InputStream in) throws java.io.IOException
java.io.IOException
public static void closeQuietly(java.io.InputStream in)
public static int getThemePrimaryColor(android.content.Context context)
public static java.util.Set<java.lang.String> stringToSet(java.lang.String spaceDelimitedStr)
null
, then null
will be returned.public static void putIfNotNull(org.json.JSONObject json, java.lang.String field, java.lang.String value)
json
- field
- value
- public static void putIfNotNull(org.json.JSONObject json, java.lang.String field, java.lang.Long value)
public static void putIfNotNull(org.json.JSONObject json, java.lang.String field, android.net.Uri value)
public static java.lang.String getStringIfDefined(org.json.JSONObject json, java.lang.String field) throws org.json.JSONException
org.json.JSONException
public static java.lang.Long getLongIfDefined(org.json.JSONObject json, java.lang.String field) throws org.json.JSONException
org.json.JSONException
public static java.lang.String iterableToString(java.lang.Iterable<java.lang.String> strings)
public static void put(org.json.JSONObject json, java.lang.String field, org.json.JSONObject value)
json
- field
- value
- public static void put(org.json.JSONObject json, java.lang.String field, int value)
public static void put(org.json.JSONObject json, java.lang.String field, java.lang.String value)
public static void put(org.json.JSONObject json, java.lang.String field, org.json.JSONArray value)
public static java.lang.String getString(org.json.JSONObject json, java.lang.String field) throws org.json.JSONException
org.json.JSONException
public static android.net.Uri getUriIfDefined(org.json.JSONObject json, java.lang.String field) throws org.json.JSONException
org.json.JSONException
public static java.util.Map<LiBrowse,java.util.List<LiBaseModel>> getTransformedResponse(java.util.List<LiBaseModel> response)
response
- public static java.lang.String getRawString(android.content.Context context, int rawResId)
context
- rawResId
- public static java.lang.Long getTime(java.lang.Long time)
public static void sendLoginBroadcast(android.content.Context context, boolean isLoginSuccessful, int responseCode)
public static void addLSIRequestHeaders(android.content.Context context, Request.Builder builder)