Collection of basic needed functions required for android app development
-
disableTouch(Window window)
Use this function to disable touch on any activity in android.
Pass "Window" object of the activity -
enableTouch(Window window)
Use this function to enable touch once you have disabled using above function
Pass "Window" object of the activity -
isValidEmail(String email)
Pass your email string to function
Function returns true/false -
md5(final String s)
Pass string to be converted to md5 hash
Function returns md5 hash -
viewVisible(View... views)
Pass mutliple views seperated by comma to function (Eg: viewVisible(textView, button, editText);
Return void, change visibility of all views to VISIBILE -
viewHidden(View... views)
Pass mutliple views seperated by comma to function (Eg: viewHidden(textView, button, editText);
Return void, change visibility of all views to GONE -
viewInvisible(View... views)
Pass mutliple views seperated by comma to function (Eg: viewInvisible(textView, button, editText);
Return void, change visibility of all views to INVISIBILE -
generateMacId(Context context)
Pass activity context to function
Return macId of device -
createHorizontalRecyclerView(Context context, RecyclerView... recyclerViews)
Pass activity context and recyclerViews seperated by comma
Return void, changes all recyclerView layout to Horizontal -
startProgressDialog(ProgressDialog dialog, int resourceId)
Pass ProgressDialog and resourceId (Drawable) to use as progressDialog layout
Return void, starts showing progress dialog with transaparent background and custom view -
stopProgressDialog(dialog)
Pass dialog to function
Return void, stops the dialog
Note: Pass only dialog which is already running -
formatDateTime(String date, String fromFormat, Strint toFormat)
Pass your DATE in string format, Current format of DATE String (Eg: dd-MMM-yyyy HH:MM), Required Format of Date string (Eg: dd MM yyyy)
Return date string in required format
Note: Can be used for TIME also -
convertFiletoBitmap(File file)
Pass ImageFile to function
Return Bitmap
Note: Default dimension is 200x200 you can change it as per your needed -
setupTabTitleFont(final Context mContext, final TabLayout tabLayout)
Pass Activity Context and TabLayout (TabLayout should contain tabs)
Return void
You will get TextView from Tab for custom styling of textView
Note: All styling needs to be done in this function itself -
rotateImageView(ImageView iv, float degree)
Pass ImageView and Rotation degress
Return void, rotate ImageView to required degrees -
setCustomRatingBarColor(Context mContext, RatingBar rbRating, int colorId)
Pass Context, RatingBar, ColorID (R.color.colorName)
Return void
Changes RatingBar color to color
Note: Does not work for all AndroidOS version. Works for 5.0+, not tested with below 5.0 -
generateFacebookLoginKey(Context mContext)
Pass Context
Return void
Logs FaceBook hashKey in console -
encodeToBase64(Bitmap image)
Pass Bitmap
Return base64 string -
decodeBase64(String base64)
Pass base64 string
Return bitmap -
isAppInstalled(String packageName, Context context)
Pass App Package Name and Context
Returns boolean true/false -
convertFiletoBitmap(File file); Pass image file Returns centre crop square bitmap image
Stay Tuned for more functions
SharedPreferences Handler
Use SharedPrefs file for SharedPrefs storing and fetching
- Store and fetch String, Integer, Boolean, Float value to and from SharedPreferences
- Remove Data from SharedPreferences for particular key
- Clear Complete SharedPreferences
Note: Change app_name to your app package name in sharedPrefs file