public final class Util
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEVICE
Like
Build.DEVICE, but in a place where it can be conveniently overridden for local
testing. |
static java.lang.String |
DEVICE_DEBUG_INFO
A concise description of the device that it can be useful to log for debugging purposes.
|
static java.lang.String |
MANUFACTURER
Like
Build.MANUFACTURER, but in a place where it can be conveniently overridden for
local testing. |
static java.lang.String |
MODEL
Like
Build.MODEL, but in a place where it can be conveniently overridden for local
testing. |
static int |
SDK_INT
Like
Build.VERSION.SDK_INT, but in a place where it can be conveniently
overridden for local testing. |
| Modifier and Type | Method and Description |
|---|---|
static long |
addWithOverflowDefault(long x,
long y,
long overflowResult)
Returns the sum of two arguments, or a third argument if the result overflows.
|
static boolean |
areEqual(java.lang.Object o1,
java.lang.Object o2)
Tests two objects for
Object.equals(Object) equality, handling the case where one or
both may be null. |
static <T> int |
binarySearchCeil(java.util.List<? extends java.lang.Comparable<? super T>> list,
T value,
boolean inclusive,
boolean stayInBounds)
Returns the index of the smallest element in
list that is greater than (or optionally
equal to) a specified value. |
static int |
binarySearchCeil(long[] array,
long value,
boolean inclusive,
boolean stayInBounds)
Returns the index of the smallest element in
array that is greater than (or optionally
equal to) a specified value. |
static int |
binarySearchFloor(int[] array,
int value,
boolean inclusive,
boolean stayInBounds)
Returns the index of the largest element in
array that is less than (or optionally
equal to) a specified value. |
static <T> int |
binarySearchFloor(java.util.List<? extends java.lang.Comparable<? super T>> list,
T value,
boolean inclusive,
boolean stayInBounds)
Returns the index of the largest element in
list that is less than (or optionally equal
to) a specified value. |
static int |
binarySearchFloor(long[] array,
long value,
boolean inclusive,
boolean stayInBounds)
Returns the index of the largest element in
array that is less than (or optionally
equal to) a specified value. |
static int |
ceilDivide(int numerator,
int denominator)
Divides a
numerator by a denominator, returning the ceiled result. |
static long |
ceilDivide(long numerator,
long denominator)
Divides a
numerator by a denominator, returning the ceiled result. |
static void |
closeQuietly(java.io.Closeable closeable)
Closes a
Closeable, suppressing any IOException that may occur. |
static void |
closeQuietly(DataSource dataSource)
Closes a
DataSource, suppressing any IOException that may occur. |
static int |
compareLong(long left,
long right)
Compares two long values and returns the same value as
Long.compare(long, long). |
static float |
constrainValue(float value,
float min,
float max)
Constrains a value to the specified bounds.
|
static int |
constrainValue(int value,
int min,
int max)
Constrains a value to the specified bounds.
|
static long |
constrainValue(long value,
long min,
long max)
Constrains a value to the specified bounds.
|
static boolean |
contains(java.lang.Object[] items,
java.lang.Object item)
Tests whether an
items array contains an object equal to item, according to
Object.equals(Object). |
static int |
crc(byte[] bytes,
int start,
int end,
int initialValue)
Returns the result of updating a CRC with the specified bytes in a "most significant bit first"
order.
|
static java.io.File |
createTempDirectory(android.content.Context context,
java.lang.String prefix)
Creates an empty directory in the directory returned by
Context.getCacheDir(). |
static java.io.File |
createTempFile(android.content.Context context,
java.lang.String prefix)
Creates a new empty file in the directory returned by
Context.getCacheDir(). |
static java.lang.String |
escapeFileName(java.lang.String fileName)
Escapes a string so that it's safe for use as a file or directory name on at least FAT32
filesystems.
|
static java.lang.String |
formatInvariant(java.lang.String format,
java.lang.Object... args)
Formats a string using
Locale.US. |
static java.lang.String |
fromUtf8Bytes(byte[] bytes)
Returns a new
String constructed by decoding UTF-8 encoded bytes. |
static java.lang.String |
fromUtf8Bytes(byte[] bytes,
int offset,
int length)
Returns a new
String constructed by decoding UTF-8 encoded bytes in a subarray. |
static int |
getAudioContentTypeForStreamType(int streamType)
Returns the
C.AudioContentType corresponding to the specified C.StreamType. |
static int |
getAudioUsageForStreamType(int streamType)
Returns the
C.AudioUsage corresponding to the specified C.StreamType. |
static byte[] |
getBytesFromHexString(java.lang.String hexString)
Returns a byte array containing values parsed from the hex string provided.
|
static java.lang.String |
getCodecsOfType(java.lang.String codecs,
int trackType)
Returns a copy of
codecs without the codecs whose track type doesn't match
trackType. |
static java.lang.String |
getCommaDelimitedSimpleClassNames(java.lang.Object[] objects)
Returns a string with comma delimited simple names of each object's class.
|
static int |
getDefaultBufferSize(int trackType)
|
static java.util.UUID |
getDrmUuid(java.lang.String drmScheme)
Derives a DRM
UUID from drmScheme. |
static int |
getIntegerCodeForString(java.lang.String string)
Returns the integer equal to the big-endian concatenation of the characters in
string
as bytes. |
static long |
getMediaDurationForPlayoutDuration(long playoutDuration,
float speed)
Returns the duration of media that will elapse in
playoutDuration. |
static int |
getPcmEncoding(int bitDepth)
Converts a sample bit depth to a corresponding PCM encoding constant.
|
static int |
getPcmFrameSize(int pcmEncoding,
int channelCount)
Returns the frame size for audio with
channelCount channels in the specified encoding. |
static android.graphics.Point |
getPhysicalDisplaySize(android.content.Context context)
Gets the physical size of the default display, in pixels.
|
static android.graphics.Point |
getPhysicalDisplaySize(android.content.Context context,
android.view.Display display)
Gets the physical size of the specified display, in pixels.
|
static long |
getPlayoutDurationForMediaDuration(long mediaDuration,
float speed)
Returns the playout duration of
mediaDuration of media. |
static int |
getStreamTypeForAudioUsage(int usage)
Returns the
C.StreamType corresponding to the specified C.AudioUsage. |
static java.lang.String |
getStringForTime(java.lang.StringBuilder builder,
java.util.Formatter formatter,
long timeMs)
Returns the specified millisecond time formatted as a string.
|
static java.lang.String |
getUserAgent(android.content.Context context,
java.lang.String applicationName)
Returns a user agent string based on the given application name and the library version.
|
static byte[] |
getUtf8Bytes(java.lang.String value)
Returns a new byte array containing the code points of a
String encoded using UTF-8. |
static int |
inferContentType(java.lang.String fileName)
Makes a best guess to infer the type from a file name.
|
static int |
inferContentType(android.net.Uri uri)
Makes a best guess to infer the type from a
Uri. |
static int |
inferContentType(android.net.Uri uri,
java.lang.String overrideExtension)
Makes a best guess to infer the type from a
Uri. |
static boolean |
isEncodingHighResolutionIntegerPcm(int encoding)
Returns whether
encoding is high resolution (> 16-bit) integer PCM. |
static boolean |
isEncodingPcm(int encoding)
Returns whether
encoding is one of the PCM encodings. |
static boolean |
isLinebreak(int c)
Returns whether the given character is a carriage return ('\r') or a line feed ('\n').
|
static boolean |
isLocalFileUri(android.net.Uri uri)
Returns true if the URI is a path to a local file or a reference to a local file.
|
static boolean |
maybeRequestReadExternalStoragePermission(android.app.Activity activity,
android.net.Uri... uris)
Checks whether it's necessary to request the
Manifest.permission.READ_EXTERNAL_STORAGE
permission read the specified Uris, requesting the permission if necessary. |
static java.util.concurrent.ExecutorService |
newSingleThreadExecutor(java.lang.String threadName)
Instantiates a new single threaded executor whose thread has the specified name.
|
static java.lang.String |
normalizeLanguageCode(java.lang.String language)
Returns a normalized RFC 639-2/T code for
language. |
static <T> T[] |
nullSafeArrayCopy(T[] input,
int length)
Copies and optionally truncates an array.
|
static long |
parseXsDateTime(java.lang.String value)
Parses an xs:dateTime attribute value, returning the parsed timestamp in milliseconds since
the epoch.
|
static long |
parseXsDuration(java.lang.String value)
Parses an xs:duration attribute value, returning the parsed duration in milliseconds.
|
static boolean |
readBoolean(android.os.Parcel parcel)
Reads an integer from a
Parcel and interprets it as a boolean, with 0 mapping to false
and all other values mapping to true. |
static void |
recursiveDelete(java.io.File fileOrDirectory)
Recursively deletes a directory and its content.
|
static <T> void |
removeRange(java.util.List<T> list,
int fromIndex,
int toIndex)
Removes an indexed range from a List.
|
static long |
resolveSeekPositionUs(long positionUs,
SeekParameters seekParameters,
long firstSyncUs,
long secondSyncUs)
Resolves a seek given the requested seek position, a
SeekParameters and two candidate
sync points. |
static long |
scaleLargeTimestamp(long timestamp,
long multiplier,
long divisor)
Scales a large timestamp.
|
static long[] |
scaleLargeTimestamps(java.util.List<java.lang.Long> timestamps,
long multiplier,
long divisor)
Applies
scaleLargeTimestamp(long, long, long) to a list of unscaled timestamps. |
static void |
scaleLargeTimestampsInPlace(long[] timestamps,
long multiplier,
long divisor)
Applies
scaleLargeTimestamp(long, long, long) to an array of unscaled timestamps. |
static void |
sneakyThrow(java.lang.Throwable t)
A hacky method that always throws
t even if t is a checked exception,
and is not declared to be thrown. |
static java.lang.String[] |
split(java.lang.String value,
java.lang.String regex)
Splits a string using
value.split(regex, -1). |
static java.lang.String[] |
splitAtFirst(java.lang.String value,
java.lang.String regex)
Splits the string at the first occurrence of the delimiter
regex. |
static android.content.ComponentName |
startForegroundService(android.content.Context context,
android.content.Intent intent)
Calls
Context.startForegroundService(Intent) if SDK_INT is 26 or higher, or
Context.startService(Intent) otherwise. |
static long |
subtractWithOverflowDefault(long x,
long y,
long overflowResult)
Returns the difference between two arguments, or a third argument if the result overflows.
|
static int[] |
toArray(java.util.List<java.lang.Integer> list)
Converts a list of integers to a primitive array.
|
static byte[] |
toByteArray(java.io.InputStream inputStream)
Converts the entirety of an
InputStream to a byte array. |
static java.lang.String |
toLowerInvariant(java.lang.String text)
Converts text to lower case using
Locale.US. |
static java.lang.String |
toUpperInvariant(java.lang.String text)
Converts text to upper case using
Locale.US. |
static java.lang.String |
unescapeFileName(java.lang.String fileName)
Unescapes an escaped file or directory name back to its original value.
|
static void |
writeBoolean(android.os.Parcel parcel,
boolean value)
Writes a boolean to a
Parcel. |
public static final int SDK_INT
Build.VERSION.SDK_INT, but in a place where it can be conveniently
overridden for local testing.public static final java.lang.String DEVICE
Build.DEVICE, but in a place where it can be conveniently overridden for local
testing.public static final java.lang.String MANUFACTURER
Build.MANUFACTURER, but in a place where it can be conveniently overridden for
local testing.public static final java.lang.String MODEL
Build.MODEL, but in a place where it can be conveniently overridden for local
testing.public static final java.lang.String DEVICE_DEBUG_INFO
public static byte[] toByteArray(java.io.InputStream inputStream)
throws java.io.IOException
InputStream to a byte array.inputStream - the InputStream to be read. The input stream is not closed by this
method.java.io.IOException - if an error occurs reading from the stream.public static android.content.ComponentName startForegroundService(android.content.Context context,
android.content.Intent intent)
Context.startForegroundService(Intent) if SDK_INT is 26 or higher, or
Context.startService(Intent) otherwise.context - The context to call.intent - The intent to pass to the called method.public static boolean maybeRequestReadExternalStoragePermission(android.app.Activity activity,
android.net.Uri... uris)
Manifest.permission.READ_EXTERNAL_STORAGE
permission read the specified Uris, requesting the permission if necessary.activity - The host activity for checking and requesting the permission.uris - Uris that may require Manifest.permission.READ_EXTERNAL_STORAGE to read.public static boolean isLocalFileUri(android.net.Uri uri)
uri - The uri to test.public static boolean areEqual(@Nullable
java.lang.Object o1,
@Nullable
java.lang.Object o2)
Object.equals(Object) equality, handling the case where one or
both may be null.o1 - The first object.o2 - The second object.o1 == null ? o2 == null : o1.equals(o2).public static boolean contains(java.lang.Object[] items,
java.lang.Object item)
items array contains an object equal to item, according to
Object.equals(Object).
If item is null then true is returned if and only if items contains null.
items - The array of items to search.item - The item to search for.public static <T> void removeRange(java.util.List<T> list,
int fromIndex,
int toIndex)
list - The List to remove the range from.fromIndex - The first index to be removed (inclusive).toIndex - The last index to be removed (exclusive).public static <T> T[] nullSafeArrayCopy(T[] input,
int length)
Arrays.copyOf(Object[], int) by ensuring the new length does not exceed the current length.input - The input array.length - The output array length. Must be less or equal to the length of the input array.public static java.util.concurrent.ExecutorService newSingleThreadExecutor(java.lang.String threadName)
threadName - The name of the thread.public static void closeQuietly(DataSource dataSource)
DataSource, suppressing any IOException that may occur.dataSource - The DataSource to close.public static void closeQuietly(java.io.Closeable closeable)
Closeable, suppressing any IOException that may occur. Both OutputStream and InputStream are Closeable.closeable - The Closeable to close.public static boolean readBoolean(android.os.Parcel parcel)
Parcel and interprets it as a boolean, with 0 mapping to false
and all other values mapping to true.parcel - The Parcel to read from.public static void writeBoolean(android.os.Parcel parcel,
boolean value)
Parcel. The boolean is written as an integer with value 1 (true)
or 0 (false).parcel - The Parcel to write to.value - The value to write.@Nullable
public static java.lang.String normalizeLanguageCode(@Nullable
java.lang.String language)
language.language - A case-insensitive ISO 639 alpha-2 or alpha-3 language code.language.toLowerCase() if the language could not be normalized.public static java.lang.String fromUtf8Bytes(byte[] bytes)
String constructed by decoding UTF-8 encoded bytes.bytes - The UTF-8 encoded bytes to decode.public static java.lang.String fromUtf8Bytes(byte[] bytes,
int offset,
int length)
String constructed by decoding UTF-8 encoded bytes in a subarray.bytes - The UTF-8 encoded bytes to decode.offset - The index of the first byte to decode.length - The number of bytes to decode.public static byte[] getUtf8Bytes(java.lang.String value)
String encoded using UTF-8.value - The String whose bytes should be obtained.public static java.lang.String[] split(java.lang.String value,
java.lang.String regex)
value.split(regex, -1). Note: this is is similar to String.split(String) but empty matches at the end of the string will not be omitted from the
returned array.value - The string to split.regex - A delimiting regular expression.public static java.lang.String[] splitAtFirst(java.lang.String value,
java.lang.String regex)
regex. If the delimiter does
not match, returns an array with one element which is the input string. If the delimiter does
match, returns an array with the portion of the string before the delimiter and the rest of the
string.value - The string.regex - A delimiting regular expression.public static boolean isLinebreak(int c)
c - The character.public static java.lang.String toLowerInvariant(java.lang.String text)
Locale.US.text - The text to convert.text is null.public static java.lang.String toUpperInvariant(java.lang.String text)
Locale.US.text - The text to convert.text is null.public static java.lang.String formatInvariant(java.lang.String format,
java.lang.Object... args)
Locale.US.String.format(String, Object...)public static int ceilDivide(int numerator,
int denominator)
numerator by a denominator, returning the ceiled result.numerator - The numerator to divide.denominator - The denominator to divide by.public static long ceilDivide(long numerator,
long denominator)
numerator by a denominator, returning the ceiled result.numerator - The numerator to divide.denominator - The denominator to divide by.public static int constrainValue(int value,
int min,
int max)
value - The value to constrain.min - The lower bound.max - The upper bound.Math.max(min, Math.min(value, max)).public static long constrainValue(long value,
long min,
long max)
value - The value to constrain.min - The lower bound.max - The upper bound.Math.max(min, Math.min(value, max)).public static float constrainValue(float value,
float min,
float max)
value - The value to constrain.min - The lower bound.max - The upper bound.Math.max(min, Math.min(value, max)).public static long addWithOverflowDefault(long x,
long y,
long overflowResult)
x - The first value.y - The second value.overflowResult - The return value if x + y overflows.x + y, or overflowResult if the result overflows.public static long subtractWithOverflowDefault(long x,
long y,
long overflowResult)
x - The first value.y - The second value.overflowResult - The return value if x - y overflows.x - y, or overflowResult if the result overflows.public static int binarySearchFloor(int[] array,
int value,
boolean inclusive,
boolean stayInBounds)
array that is less than (or optionally
equal to) a specified value.
The search is performed using a binary search algorithm, so the array must be sorted. If the
array contains multiple elements equal to value and inclusive is true, the
index of the first one will be returned.
array - The array to search.value - The value being searched for.inclusive - If the value is present in the array, whether to return the corresponding
index. If false then the returned index corresponds to the largest element strictly less
than the value.stayInBounds - If true, then 0 will be returned in the case that the value is smaller than
the smallest element in the array. If false then -1 will be returned.array that is less than (or optionally
equal to) value.public static int binarySearchFloor(long[] array,
long value,
boolean inclusive,
boolean stayInBounds)
array that is less than (or optionally
equal to) a specified value.
The search is performed using a binary search algorithm, so the array must be sorted. If the
array contains multiple elements equal to value and inclusive is true, the
index of the first one will be returned.
array - The array to search.value - The value being searched for.inclusive - If the value is present in the array, whether to return the corresponding
index. If false then the returned index corresponds to the largest element strictly less
than the value.stayInBounds - If true, then 0 will be returned in the case that the value is smaller than
the smallest element in the array. If false then -1 will be returned.array that is less than (or optionally
equal to) value.public static <T> int binarySearchFloor(java.util.List<? extends java.lang.Comparable<? super T>> list,
T value,
boolean inclusive,
boolean stayInBounds)
list that is less than (or optionally equal
to) a specified value.
The search is performed using a binary search algorithm, so the list must be sorted. If the
list contains multiple elements equal to value and inclusive is true, the
index of the first one will be returned.
T - The type of values being searched.list - The list to search.value - The value being searched for.inclusive - If the value is present in the list, whether to return the corresponding
index. If false then the returned index corresponds to the largest element strictly less
than the value.stayInBounds - If true, then 0 will be returned in the case that the value is smaller than
the smallest element in the list. If false then -1 will be returned.list that is less than (or optionally equal
to) value.public static int binarySearchCeil(long[] array,
long value,
boolean inclusive,
boolean stayInBounds)
array that is greater than (or optionally
equal to) a specified value.
The search is performed using a binary search algorithm, so the array must be sorted. If the
array contains multiple elements equal to value and inclusive is true, the
index of the last one will be returned.
array - The array to search.value - The value being searched for.inclusive - If the value is present in the array, whether to return the corresponding
index. If false then the returned index corresponds to the smallest element strictly
greater than the value.stayInBounds - If true, then (a.length - 1) will be returned in the case that the
value is greater than the largest element in the array. If false then a.length will
be returned.array that is greater than (or optionally
equal to) value.public static <T> int binarySearchCeil(java.util.List<? extends java.lang.Comparable<? super T>> list,
T value,
boolean inclusive,
boolean stayInBounds)
list that is greater than (or optionally
equal to) a specified value.
The search is performed using a binary search algorithm, so the list must be sorted. If the
list contains multiple elements equal to value and inclusive is true, the
index of the last one will be returned.
T - The type of values being searched.list - The list to search.value - The value being searched for.inclusive - If the value is present in the list, whether to return the corresponding
index. If false then the returned index corresponds to the smallest element strictly
greater than the value.stayInBounds - If true, then (list.size() - 1) will be returned in the case that
the value is greater than the largest element in the list. If false then
list.size() will be returned.list that is greater than (or optionally
equal to) value.public static int compareLong(long left,
long right)
Long.compare(long, long).left - The left operand.right - The right operand.public static long parseXsDuration(java.lang.String value)
value - The attribute value to decode.public static long parseXsDateTime(java.lang.String value)
throws ParserException
value - The attribute value to decode.ParserException - if an error occurs parsing the dateTime attribute value.public static long scaleLargeTimestamp(long timestamp,
long multiplier,
long divisor)
Logically, scaling consists of a multiplication followed by a division. The actual operations performed are designed to minimize the probability of overflow.
timestamp - The timestamp to scale.multiplier - The multiplier.divisor - The divisor.public static long[] scaleLargeTimestamps(java.util.List<java.lang.Long> timestamps,
long multiplier,
long divisor)
scaleLargeTimestamp(long, long, long) to a list of unscaled timestamps.timestamps - The timestamps to scale.multiplier - The multiplier.divisor - The divisor.public static void scaleLargeTimestampsInPlace(long[] timestamps,
long multiplier,
long divisor)
scaleLargeTimestamp(long, long, long) to an array of unscaled timestamps.timestamps - The timestamps to scale.multiplier - The multiplier.divisor - The divisor.public static long getMediaDurationForPlayoutDuration(long playoutDuration,
float speed)
playoutDuration.playoutDuration - The duration to scale.speed - The playback speed.playoutDuration.public static long getPlayoutDurationForMediaDuration(long mediaDuration,
float speed)
mediaDuration of media.mediaDuration - The duration to scale.mediaDuration.public static long resolveSeekPositionUs(long positionUs,
SeekParameters seekParameters,
long firstSyncUs,
long secondSyncUs)
SeekParameters and two candidate
sync points.positionUs - The requested seek position, in microseocnds.seekParameters - The SeekParameters.firstSyncUs - The first candidate seek point, in micrseconds.secondSyncUs - The second candidate seek point, in microseconds. May equal firstSyncUs if there's only one candidate.public static int[] toArray(java.util.List<java.lang.Integer> list)
list - A list of integers.public static int getIntegerCodeForString(java.lang.String string)
string
as bytes. The string must be no more than four characters long.string - A string no more than four characters long.public static byte[] getBytesFromHexString(java.lang.String hexString)
hexString - The hex string to convert to bytes.public static java.lang.String getCommaDelimitedSimpleClassNames(java.lang.Object[] objects)
objects - The objects whose simple class names should be comma delimited and returned.public static java.lang.String getUserAgent(android.content.Context context,
java.lang.String applicationName)
context - A valid context of the calling application.applicationName - String that will be prefix'ed to the generated user agent.public static java.lang.String getCodecsOfType(java.lang.String codecs,
int trackType)
codecs without the codecs whose track type doesn't match
trackType.codecs - A codec sequence string, as defined in RFC 6381.trackType - One of C.TRACK_TYPE_*.codecs without the codecs whose track type doesn't match
trackType.public static int getPcmEncoding(int bitDepth)
bitDepth - The bit depth. Supported values are 8, 16, 24 and 32.C.ENCODING_PCM_8BIT,
C.ENCODING_PCM_16BIT, C.ENCODING_PCM_24BIT and
C.ENCODING_PCM_32BIT. If the bit depth is unsupported then
C.ENCODING_INVALID is returned.public static boolean isEncodingPcm(int encoding)
encoding is one of the PCM encodings.encoding - The encoding of the audio data.public static boolean isEncodingHighResolutionIntegerPcm(int encoding)
encoding is high resolution (> 16-bit) integer PCM.encoding - The encoding of the audio data.public static int getPcmFrameSize(int pcmEncoding,
int channelCount)
channelCount channels in the specified encoding.pcmEncoding - The encoding of the audio data.channelCount - The channel count.public static int getAudioUsageForStreamType(int streamType)
C.AudioUsage corresponding to the specified C.StreamType.public static int getAudioContentTypeForStreamType(int streamType)
C.AudioContentType corresponding to the specified C.StreamType.public static int getStreamTypeForAudioUsage(int usage)
C.StreamType corresponding to the specified C.AudioUsage.public static java.util.UUID getDrmUuid(java.lang.String drmScheme)
UUID from drmScheme.drmScheme - A UUID string, or "widevine", "playready" or "clearkey".UUID, or null if one could not be derived.public static int inferContentType(android.net.Uri uri,
java.lang.String overrideExtension)
Uri.uri - The Uri.overrideExtension - If not null, used to infer the type.public static int inferContentType(android.net.Uri uri)
Uri.uri - The Uri.public static int inferContentType(java.lang.String fileName)
fileName - Name of the file. It can include the path of the file.public static java.lang.String getStringForTime(java.lang.StringBuilder builder,
java.util.Formatter formatter,
long timeMs)
builder - The builder that formatter will write to.formatter - The formatter.timeMs - The time to format as a string, in milliseconds.public static int getDefaultBufferSize(int trackType)
trackType - The track type.public static java.lang.String escapeFileName(java.lang.String fileName)
For simplicity, this only handles common characters known to be illegal on FAT32:
<, >, :, ", /, \, |, ?, and *. % is also escaped since it is used as the escape
character. Escaping is performed in a consistent way so that no collisions occur and
unescapeFileName(String) can be used to retrieve the original file name.
fileName - File name to be escaped.public static java.lang.String unescapeFileName(java.lang.String fileName)
See escapeFileName(String) for more information.
fileName - File name to be unescaped.public static void sneakyThrow(java.lang.Throwable t)
t even if t is a checked exception,
and is not declared to be thrown.public static void recursiveDelete(java.io.File fileOrDirectory)
public static java.io.File createTempDirectory(android.content.Context context,
java.lang.String prefix)
throws java.io.IOException
Context.getCacheDir().java.io.IOExceptionpublic static java.io.File createTempFile(android.content.Context context,
java.lang.String prefix)
throws java.io.IOException
Context.getCacheDir().java.io.IOExceptionpublic static int crc(byte[] bytes,
int start,
int end,
int initialValue)
bytes - Array containing the bytes to update the crc value with.start - The index to the first byte in the byte range to update the crc with.end - The index after the last byte in the byte range to update the crc with.initialValue - The initial value for the crc calculation.public static android.graphics.Point getPhysicalDisplaySize(android.content.Context context)
context - Any context.public static android.graphics.Point getPhysicalDisplaySize(android.content.Context context,
android.view.Display display)
context - Any context.display - The display whose size is to be returned.