public class Helpers extends Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
doesFileExist(android.content.Context c,
String fileName,
long fileSize,
boolean deleteFileOnMismatch)
Helper function to ascertain the existence of a file and return
true/false appropriately
|
static String |
generateSaveFileName(android.content.Context c,
String fileName)
Returns the filename (where the file should be saved) from info about a
download
|
static long |
getAvailableBytes(File root) |
static int |
getDownloaderStringResourceIDFromState(int state)
Converts download states that are returned by the
IDownloaderClient.onDownloadStateChanged(int) callback into usable strings. |
static String |
getDownloadProgressPercent(long overallProgress,
long overallTotal) |
static String |
getDownloadProgressString(long overallProgress,
long overallTotal)
Showing progress in MB here.
|
static String |
getDownloadProgressStringNotification(long overallProgress,
long overallTotal)
Adds a percentile to getDownloadProgressString.
|
static String |
getExpansionAPKFileName(android.content.Context c,
boolean mainFile,
int versionCode)
Returns the file name (without full path) for an Expansion APK file from
the given context.
|
static File |
getFilesystemRoot(String path) |
static String |
getSaveFilePath(android.content.Context c) |
static String |
getSpeedString(float bytesPerMillisecond) |
static String |
getTimeRemaining(long durationInMilliseconds) |
static boolean |
isExternalMediaMounted() |
static boolean |
isFilenameValid(String filename)
Checks whether the filename looks legitimate
|
public static Random sRandom
public static File getFilesystemRoot(String path)
public static boolean isExternalMediaMounted()
public static long getAvailableBytes(File root)
public static boolean isFilenameValid(String filename)
public static String getDownloadProgressString(long overallProgress, long overallTotal)
overallProgress - overallTotal - public static String getDownloadProgressStringNotification(long overallProgress, long overallTotal)
overallProgress - overallTotal - public static String getDownloadProgressPercent(long overallProgress, long overallTotal)
public static String getSpeedString(float bytesPerMillisecond)
public static String getTimeRemaining(long durationInMilliseconds)
public static String getExpansionAPKFileName(android.content.Context c, boolean mainFile, int versionCode)
c - the contextmainFile - true for main file, false for patch fileversionCode - the version of the filepublic static String generateSaveFileName(android.content.Context c, String fileName)
public static String getSaveFilePath(android.content.Context c)
public static boolean doesFileExist(android.content.Context c,
String fileName,
long fileSize,
boolean deleteFileOnMismatch)
c - the app/activity/service contextfileName - the name (sans path) of the file to queryfileSize - the size that the file must matchdeleteFileOnMismatch - if the file sizes do not match, delete the
filepublic static int getDownloaderStringResourceIDFromState(int state)
IDownloaderClient.onDownloadStateChanged(int) callback into usable strings.
This is useful if using the state strings built into the library to display user messages.state - One of the STATE_* constants from IDownloaderClient.Copyright © 2012–2014 simpligility technologies inc.. All rights reserved.