public class Utils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
Utils.emails |
Modifier and Type | Field and Description |
---|---|
static java.lang.String[] |
ZERO_LENGTH_STRING_ARRAY
Utility empty array which avoids having to instanciate empty arrays across the app, whenever
an empty array is needed.
|
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
canCall(android.content.Context context)
Function to check if device is capable to make call or not
|
static java.lang.String |
ConvertStreamToString(java.io.InputStream is) |
static android.graphics.Bitmap |
drawableToBitmap(android.content.Context context,
int drawableId,
int color) |
static java.lang.CharSequence |
FormatPwd(java.lang.CharSequence pwd)
Takes as an input a string and converts it into a list of n "*".
|
static int |
GetBestDealBtnResourceId(int n)
Get the background that should be applied to the buton on the nth best deal in a list
|
static int |
GetBestDealResourceId(int n)
Get the background that should be applied to the nth best deal in a list
|
static char |
GetRandomChar() |
static java.lang.String |
GetRandomNumericString(int length) |
static long |
GetUniqueId()
Gets a unique number, that can be used to define a transaction id or something similar when
communicating with some other services
|
static java.lang.String |
GetUniqueStringId()
Gets a unique string, that can be used to define a transaction id or something similar when
communicating with some other services
|
static int |
GetVersionCode(android.content.Context c) |
static boolean |
HasBannedError(org.json.JSONObject obj)
Check if the current JSON object contains the account blocked in error message (code login-001)
|
static boolean |
HasLoggedOutError(org.json.JSONObject obj)
Check if the current JSON object contains the not logged in error message (code auth-001)
|
static boolean |
HasPasswordChangedError(org.json.JSONObject obj)
Check if the current JSON object contains the account password changed in error message (code login-005)
|
static boolean |
IsEmailValid(java.lang.String email)
Deprecated.
|
static boolean |
IsPasswordInvalid(java.lang.CharSequence password)
Returns true if a password is considered as invalid
|
static long |
java2PhpDate(long date)
Converts a java timestamp into a php timestamp
|
static long |
php2JavaDate(long date)
Converts a php timestamp into a java timestamp
|
static void |
SendEmail(android.content.Context context,
java.lang.String emailId) |
static void |
SendEmail(android.content.Context context,
java.lang.String emailId,
java.lang.String subject) |
static java.lang.String |
Sha256(java.lang.String base)
Get the "sha-256" hash of a string
|
static java.util.List<java.lang.String> |
SplitSqlScript(java.lang.String script,
char delim)
Converts an sql script string into a list of sub queries
|
public static final java.lang.String[] ZERO_LENGTH_STRING_ARRAY
public static long php2JavaDate(long date)
date
- php timestamppublic static long java2PhpDate(long date)
date
- java timestamppublic static boolean HasLoggedOutError(org.json.JSONObject obj)
obj
- jsonObject received from the serverpublic static boolean HasBannedError(org.json.JSONObject obj)
obj
- jsonObject received from the serverpublic static boolean HasPasswordChangedError(org.json.JSONObject obj)
obj
- jsonObject received from the server@Deprecated public static boolean IsEmailValid(java.lang.String email)
email
- string to checkpublic static boolean IsPasswordInvalid(java.lang.CharSequence password)
password
- string to be tested@DrawableRes public static int GetBestDealResourceId(int n)
n
- position of the best deal in the list@DrawableRes public static int GetBestDealBtnResourceId(int n)
n
- position of the best deal in the listGetBestDealResourceId(int)
public static long GetUniqueId()
public static java.lang.String GetUniqueStringId()
public static java.lang.String GetRandomNumericString(int length)
length
- length of the stringpublic static java.lang.String Sha256(java.lang.String base)
base
- string to be hashedpublic static java.lang.String ConvertStreamToString(java.io.InputStream is)
public static java.util.List<java.lang.String> SplitSqlScript(java.lang.String script, char delim)
script
- sql scriptdelim
- delimeter to be usedpublic static char GetRandomChar()
public static boolean canCall(android.content.Context context)
context
- Contextpublic static java.lang.CharSequence FormatPwd(java.lang.CharSequence pwd)
pwd
- reference stringpublic static int GetVersionCode(android.content.Context c)
c
- Contextpublic static void SendEmail(@NonNull android.content.Context context, @NonNull java.lang.String emailId, java.lang.String subject)
public static void SendEmail(@NonNull android.content.Context context, @NonNull java.lang.String emailId)
public static android.graphics.Bitmap drawableToBitmap(android.content.Context context, int drawableId, int color)