com.ooyala.android.Utils Class Reference

Static Public Member Functions

static ExecutorService sharedExecutorService ()
 
static String device ()
 
static URL makeURL (String host, String uri, Map< String, String > params)
 
static URL makeURL (String host, String uri, String params)
 
static< T extends Comparable<? super T > List< T > asSortedList (Collection< T > c)
 
static String getParamsString (Map< String, String > params, String separator, boolean urlEncode)
 
static< T > Set< T > getSubset (Map< String, T > objects, int firstIndex, int count)
 
static String join (Collection<? extends Object > list, String separator)
 
static boolean isNullOrEmpty (String string)
 
static Object getJSONValueOrElse (JSONObject json, String key, Object orElse)
 
static JSONObject objectFromJSON (String json)
 
static void overwriteJSONObject (JSONObject src, JSONObject dst) throws JSONException
 
static String encryptString (String rawString)
 
static String blockingGetEmbedTokenForEmbedCodes (EmbedTokenGenerator generator, List< String > embedCodes)
 Block the current thread while getting the Ooyala Player Token. More...
 
static String getUrlContent (URL url, int connectionTimeoutInMillisecond, int readTimeoutInMillisecond)
 Get string from http get method. More...
 
static String postUrl (URL url, String body, int connectionTimeoutInMillisecond, int readTimeoutInMillisecond)
 calling http post method More...
 
static byte [] bytesFromPostUrl (String urlString, byte[] body, Map< String, String > requestProperties, int connectionTimeoutInMillisecond, int readTimeoutInMillisecond)
 calling http post method and returns the response byte array More...
 
static String mapToJsonString (Map< String, String > map)
 convert a map to a json string More...
 
static void pingUrl (URL url)
 Simply send an HTTP get via shared thread pool, usually used to send tracking feedbacks. More...
 
static void openUrlInBrowser (Context context, String url)
 open a url in device browser More...
 
static void bytesToFile (File file, byte[] bytes) throws IOException
 
static byte [] bytesFromFile (File file)
 
static boolean objectToFile (File file, Serializable object) throws IOException
 
static HashMap< String, String > mapFromFile (File file)
 
static int generateViewId ()
 
static boolean isInternetAvailable (Context context)
 Check if internet is available. More...
 
static boolean isInternetConnected (Context context, int[] desiredNetworkTypes)
 Check if internet is available for specifics network types. More...
 
static boolean hasInternetCapabilities (Context context, int[] desiredNetworkTransports)
 Check if internet is available for specifics network transports. More...
 
static String updateProtocolToHttps (String url)
 Return an updated URL string, with https as a protocol. More...
 

Member Function Documentation

static <T extends Comparable<? super T> List<T> com.ooyala.android.Utils.asSortedList ( Collection< T >  c)
static
static String com.ooyala.android.Utils.blockingGetEmbedTokenForEmbedCodes ( EmbedTokenGenerator  generator,
List< String >  embedCodes 
)
static

Block the current thread while getting the Ooyala Player Token.

Parameters
generatoran implemented EmbedTokenGenerator to generate an embed code, can be null
embedCodesthe List of embed codes which need a generated embed token
Returns
a string of the Ooyala Player Token, or null if there is no generator or an error
static byte [] com.ooyala.android.Utils.bytesFromFile ( File  file)
static
static byte [] com.ooyala.android.Utils.bytesFromPostUrl ( String  urlString,
byte []  body,
Map< String, String >  requestProperties,
int  connectionTimeoutInMillisecond,
int  readTimeoutInMillisecond 
)
static

calling http post method and returns the response byte array

Parameters
urlStringthe url
bodythe post body
requestPropertiesthe properties for http connections
connectionTimeoutInMillisecondconnectionTimeOut
readTimeoutInMillisecondreadTimeout
Returns
the response message
static void com.ooyala.android.Utils.bytesToFile ( File  file,
byte []  bytes 
) throws IOException
static
static String com.ooyala.android.Utils.device ( )
static
static String com.ooyala.android.Utils.encryptString ( String  rawString)
static
static int com.ooyala.android.Utils.generateViewId ( )
static
static Object com.ooyala.android.Utils.getJSONValueOrElse ( JSONObject  json,
String  key,
Object  orElse 
)
static
static String com.ooyala.android.Utils.getParamsString ( Map< String, String >  params,
String  separator,
boolean  urlEncode 
)
static
static <T> Set<T> com.ooyala.android.Utils.getSubset ( Map< String, T >  objects,
int  firstIndex,
int  count 
)
static
static String com.ooyala.android.Utils.getUrlContent ( URL  url,
int  connectionTimeoutInMillisecond,
int  readTimeoutInMillisecond 
)
static

Get string from http get method.

Parameters
urlthe url
connectionTimeoutInMillisecondconnectionTimeOut
readTimeoutInMillisecondreadTimeout
Returns
a string of http response
static boolean com.ooyala.android.Utils.hasInternetCapabilities ( Context  context,
int []  desiredNetworkTransports 
)
static

Check if internet is available for specifics network transports.

Parameters
contextandroid context
desiredNetworkTransportsDesired network transports, check NetworkCapabilities for valid network transports.
Returns
true if network connectivity exists and it's the desired transports
static boolean com.ooyala.android.Utils.isInternetAvailable ( Context  context)
static

Check if internet is available.

Parameters
contextandroid context
Returns
true if network connectivity exists
static boolean com.ooyala.android.Utils.isInternetConnected ( Context  context,
int []  desiredNetworkTypes 
)
static

Check if internet is available for specifics network types.

Parameters
contextandroid context
desiredNetworkTypesDesired network types, check ConnectivityManager for valid network types.
Returns
true if network connectivity exists and it's the desired type
static boolean com.ooyala.android.Utils.isNullOrEmpty ( String  string)
static
static String com.ooyala.android.Utils.join ( Collection<? extends Object >  list,
String  separator 
)
static
static URL com.ooyala.android.Utils.makeURL ( String  host,
String  uri,
Map< String, String >  params 
)
static
static URL com.ooyala.android.Utils.makeURL ( String  host,
String  uri,
String  params 
)
static
static HashMap<String, String> com.ooyala.android.Utils.mapFromFile ( File  file)
static
static String com.ooyala.android.Utils.mapToJsonString ( Map< String, String >  map)
static

convert a map to a json string

Parameters
mapthe map to be converted
Returns
the converted string, null if error occurs
static JSONObject com.ooyala.android.Utils.objectFromJSON ( String  json)
static
static boolean com.ooyala.android.Utils.objectToFile ( File  file,
Serializable  object 
) throws IOException
static
static void com.ooyala.android.Utils.openUrlInBrowser ( Context  context,
String  url 
)
static

open a url in device browser

Parameters
contexta context
urlthe url string to open
static void com.ooyala.android.Utils.overwriteJSONObject ( JSONObject  src,
JSONObject  dst 
) throws JSONException
static
static void com.ooyala.android.Utils.pingUrl ( URL  url)
static

Simply send an HTTP get via shared thread pool, usually used to send tracking feedbacks.

Parameters
urlthe url to ping
static String com.ooyala.android.Utils.postUrl ( URL  url,
String  body,
int  connectionTimeoutInMillisecond,
int  readTimeoutInMillisecond 
)
static

calling http post method

Parameters
urlthe url
bodythe post body
connectionTimeoutInMillisecondconnectionTimeOut
readTimeoutInMillisecondreadTimeout
Returns
the response message
static ExecutorService com.ooyala.android.Utils.sharedExecutorService ( )
static
static String com.ooyala.android.Utils.updateProtocolToHttps ( String  url)
static

Return an updated URL string, with https as a protocol.

Parameters
urlthe string to be updated
Returns
an updated URL string, with https as a protocol