AndroidEasyUtils
AndroidEasyUtils is a simple android library that contains some utils method which is much more needed when working in any android project. Categories are - Validators, Dialog, Progress Dialog, Connectivity, Date Time, Bitmaps, HashMap and Others.
Usage
Step 1. Add the JitPack repository & dependencies to your build file
- Add below code in your project level
build.gradle
file, At the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- Add the dependency to your app level
build.gradle
file.
dependencies {
implementation 'com.github.Piashsarker:AndroidEasyUtils:1.0.0'
}
Usages Methods
VALIDATORS
-
Utils.isValidURL(String url)
- returntrue
if url is valid otherwisefalse
. -
Utils.isValidEmail(String email)
- returntrue
if email is valid otherwisefalse
. -
Utils.isValidIP(String ipAddress)
- returntrue
if ip is valid otherwisefalse
.
DIALOGS
-
Utils.showExitDialog(Context context , String title, String message)
- Show a exits dialog with title and message also with Exit & Cancel button. By clicking Exit button user will prompt out from app. -
Utils.showExitDialog(Context context, String title ,String message ,String exitButtonText, String noButtonText)
- Same as exit dialog with exitButtonText & noButtonText. -
Utils.showDialog(Context context,String title, String message)
- Show dialog with with title & message. -
Utils.showMessageDialog(Context context ,String title,String message, int dialogLogo)
- Show dialog with with title & message & logo. -
Utils.showGPSEnableDialog(Context context)
- Show GPS Enable dialog with default message and GPS enable button. -
Utils.showGPSEnableDialog(Context context, String messge , String positiveButtonText, String negativeButtonText)
- Show GPS Enable dialog with message, positiveButtonText , negativeButtonText.
PROGRESS DIALOG
-
Utils.showProgressDialog(Context context)
- Show progress dialog with default title & message. -
Utils.showProgressDialog(Context context, String title , String message)
- Show progress dialog with title & message. -
Utils.hideProgressDialog()
- Don't forget to hide the progress dialog.
CONNECTIVITY
-
Utils.isNetworkAvailable(Context context)
- returntrue
if network/internet is enable otherwisefalse
. Require permission<uses-permission android:name="android.permission.INTERNET" />
&<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
in your manifest file. -
Utils.isGPSEnable(Context context)
- returntrue
if gps is enable otherwisefalse
. -
Utils.getWifiIpAddress(Context context)
- return ip address. -
Utils.getDeviceIMEI(Context context)
= return device IMEI. Require runtime permission<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
DATE TIME
See Supported Date Time Formats - https://developer.android.com/reference/java/text/SimpleDateFormat
-
Utils.getCurrentDateTime()
- Return current date time. Default format - dd-MMM-yyyy hh:mm:ss -
Utils.getCurrentTime()
- Return currrent time. Default format - hh:mm -
Utils.getCurrentTime(String format)
- Return current time with format. -
Utils.getCurrentDateTime(String format )
- Return current date time with format. -
Utils.getCurrentTimeInMillis()
- Return current time in milliseconds. -
Utils.getLocalTimeFromUTCTime(String utcTime)
- Return local time from UTC Time. -
Utils.getLocalDateFromUTCTime(String utcTime)
- Return local date from UTC Time. -
Utils.getLocalFromUTC(String utcTime)
- Return local date time from UTC
BITMAP
-
Utils.getBitmapFromFile("/path/to/storage")
- ReturnBitmap
object from a file. -
Utils.getBitmapFromURI(Uri uri, Context context)
- ReturnBitmap
object fromUri
. -
Utils.getByteFromBitmap(Bitmap bitmap)
- Returnbyte[]
array from a Bitmap. -
Utils.getBitmapFromByte(byte[] bytes)
- ReturnBitmap
from a byte[].
LOG & TOAST
-
Utils.log(String TAG, String message)
- Print a log in debug console. -
Utils.shortToast(Context context, String message)
- Show short toast. -
Utils.longToast(Context context, String message)
- Show long toast.
HASHMAP & ARRAYLIST
-
Utils.removeFromArrayListByName(ArrayList<String> list, String name)
- Delete a specifiy string value from Arraylist. -
Utils.getValuesFromHashMap(HashMap<String, String> map)
- Return aArrayList
ofHashMap
values. -
Utils.getKeyFromValue(HashMap<String,String> map ,String value)
- Return key of that value ofHashMap
.
Amount Format
-
Utils.getFormatFromDecimalValue(Double amount)
- Return String of Amount with Format . Example Utils.getFormatFromDecimalValue(33333.05) will return 33,333.05. -
Utils.getFormatFromIntegerValue(int amount )
- Return String of Amount with Format . Example Utils.getFormatFromIntegerlValue(33333) will return 33,333.
OTHERS
Utils.isObjectNull(Object object)
- Returntrue
if a object isnull
otherwisefalse
;
Supports
For any kinds of support mail sarkerpt@gmail.com Follow me on Twitter - https://twitter.com/PiashSarker
MIT License
Copyright (c) 2018 Piash Sarker