public final class Utility extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Utility.DialogFeatureConfig |
static class |
Utility.FetchedAppSettings |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_STREAM_BUFFER_SIZE |
Constructor and Description |
---|
Utility() |
Modifier and Type | Method and Description |
---|---|
static <T> boolean |
areObjectsEqual(T a,
T b) |
static <T> ArrayList<T> |
arrayList(T... ts) |
static <T> List<T> |
asListNoNulls(T... array) |
static Uri |
buildUri(String authority,
String path,
Bundle parameters) |
static void |
clearCaches(Context context) |
static void |
clearFacebookCookies(Context context) |
static void |
closeQuietly(Closeable closeable) |
static String |
coerceValueIfNullOrEmpty(String s,
String valueIfNullOrEmpty)
Use this when you want to normalize empty and null strings
This way, Utility.areObjectsEqual can used for comparison, where a null string is to be treated the same as
an empty string.
|
static void |
deleteDirectory(File directoryOrFile) |
static void |
disconnectQuietly(URLConnection connection) |
static String |
getActivityName(Context context)
Returns the name of the current activity if the context is an activity, otherwise return "unknown"
|
static Utility.DialogFeatureConfig |
getDialogFeatureConfig(String applicationId,
String actionName,
String featureName) |
static String |
getMetadataApplicationId(Context context) |
static Method |
getMethodQuietly(Class<?> clazz,
String methodName,
Class<?>... parameterTypes) |
static Method |
getMethodQuietly(String className,
String methodName,
Class<?>... parameterTypes) |
static Object |
getStringPropertyAsJSON(JSONObject jsonObject,
String key,
String nonJSONPropertyKey) |
static int[] |
intersectRanges(int[] range1,
int[] range2)
Each array represents a set of closed or open Range, like so:
[0,10,50,60] - Ranges are {0-9}, {50-59}
[20] - Ranges are {20-}
[30,40,100] - Ranges are {30-39}, {100-}
All Ranges in the array have a closed lower bound.
|
static Object |
invokeMethodQuietly(Object receiver,
Method method,
Object... args) |
static <T> boolean |
isNullOrEmpty(Collection<T> c) |
static boolean |
isNullOrEmpty(String s) |
static <T> boolean |
isSubset(Collection<T> subset,
Collection<T> superset) |
static void |
loadAppSettingsAsync(Context context,
String applicationId) |
static void |
logd(String tag,
Exception e) |
static void |
logd(String tag,
String msg) |
static void |
logd(String tag,
String msg,
Throwable t) |
static Bundle |
parseUrlQueryString(String queryString) |
static void |
putObjectInBundle(Bundle bundle,
String key,
Object value) |
static Utility.FetchedAppSettings |
queryAppSettings(String applicationId,
boolean forceRequery) |
static String |
readStreamToString(InputStream inputStream) |
static boolean |
safeGetBooleanFromResponse(GraphObject response,
String propertyName) |
static String |
safeGetStringFromResponse(GraphObject response,
String propertyName) |
static void |
setAppEventAttributionParameters(GraphObject params,
AttributionIdentifiers attributionIdentifiers,
String anonymousAppDeviceGUID,
boolean limitEventUsage) |
static void |
setAppEventExtendedDeviceInfoParameters(GraphObject params,
Context appContext) |
static boolean |
stringsEqualOrEmpty(String a,
String b) |
static JSONArray |
tryGetJSONArrayFromResponse(GraphObject response,
String propertyKey) |
static JSONObject |
tryGetJSONObjectFromResponse(GraphObject response,
String propertyKey) |
static <T> Collection<T> |
unmodifiableCollection(T... ts) |
public static final int DEFAULT_STREAM_BUFFER_SIZE
public static int[] intersectRanges(int[] range1, int[] range2)
range1
- range2
- public static <T> boolean isSubset(Collection<T> subset, Collection<T> superset)
public static <T> boolean isNullOrEmpty(Collection<T> c)
public static boolean isNullOrEmpty(String s)
public static String coerceValueIfNullOrEmpty(String s, String valueIfNullOrEmpty)
s
- valueIfNullOrEmpty
- public static <T> Collection<T> unmodifiableCollection(T... ts)
public static <T> ArrayList<T> arrayList(T... ts)
public static void closeQuietly(Closeable closeable)
public static void disconnectQuietly(URLConnection connection)
public static Object getStringPropertyAsJSON(JSONObject jsonObject, String key, String nonJSONPropertyKey) throws JSONException
JSONException
public static String readStreamToString(InputStream inputStream) throws IOException
IOException
public static void clearFacebookCookies(Context context)
public static <T> boolean areObjectsEqual(T a, T b)
public static Utility.FetchedAppSettings queryAppSettings(String applicationId, boolean forceRequery)
public static Utility.DialogFeatureConfig getDialogFeatureConfig(String applicationId, String actionName, String featureName)
public static boolean safeGetBooleanFromResponse(GraphObject response, String propertyName)
public static String safeGetStringFromResponse(GraphObject response, String propertyName)
public static JSONObject tryGetJSONObjectFromResponse(GraphObject response, String propertyKey)
public static JSONArray tryGetJSONArrayFromResponse(GraphObject response, String propertyKey)
public static void clearCaches(Context context)
public static void deleteDirectory(File directoryOrFile)
public static <T> List<T> asListNoNulls(T... array)
public static void setAppEventAttributionParameters(GraphObject params, AttributionIdentifiers attributionIdentifiers, String anonymousAppDeviceGUID, boolean limitEventUsage)
public static void setAppEventExtendedDeviceInfoParameters(GraphObject params, Context appContext)
public static Method getMethodQuietly(Class<?> clazz, String methodName, Class<?>... parameterTypes)
public static Method getMethodQuietly(String className, String methodName, Class<?>... parameterTypes)
public static Object invokeMethodQuietly(Object receiver, Method method, Object... args)