Skip to content

Instantly share code, notes, and snippets.

View hitesh-dhamshaniya's full-sized avatar
🎯
Focusing

Hitesh Dhamshaniya hitesh-dhamshaniya

🎯
Focusing
View GitHub Profile
@hitesh-dhamshaniya
hitesh-dhamshaniya / Application.java
Created September 4, 2019 09:15
Handle System Font Size. Regardless of system font size apply application font size
/*That's how we do it. In Application class override onConfigurationChanged() like this. If you want different behavior for different activities - override onConfigurationChanged() in Activity.
Don't forget to add manifest tag android:configChanges="fontScale" since you are hadnling this configuration change yourself.*/
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// In some cases modifying newConfig leads to unexpected behavior,
// so it's better to edit new instance.
@hitesh-dhamshaniya
hitesh-dhamshaniya / ValidationManager.kt
Last active September 3, 2019 12:47
Kotlin Validation manager class, it will help to easy check validation
package com.devdigital.eztp.utils.validator
import com.devdigital.eztp.extensions.getTrimString
import com.google.android.material.textfield.TextInputLayout
import kotlinx.android.synthetic.main.component_edittext.view.*
import java.util.regex.Pattern
/**
* @author Hitesh
* @version 1.0
@hitesh-dhamshaniya
hitesh-dhamshaniya / ValidationManager.kt
Created August 29, 2019 13:17
Kotlin Validation manager class, it will help to easy check validation
package com.devdigital.eztp.utils.validator
import com.devdigital.eztp.extensions.getTrimString
import com.google.android.material.textfield.TextInputLayout
import kotlinx.android.synthetic.main.component_edittext.view.*
import java.util.regex.Pattern
/**
* @author Hitesh
* @version 1.0
@hitesh-dhamshaniya
hitesh-dhamshaniya / IntentHelper.kt
Created August 23, 2019 10:07
Basic Method require frequently for common functionality.
/**
* @author Hitesh
* @version 1.0
* @since 23-08-2019
*/
class IntentHelper() {
fun launchCall(mActivity: Activity, phoneNumber: String) {
val intent = Intent(Intent.ACTION_DIAL, Uri.parse("tel:$phoneNumber"))
mActivity.startActivity(intent)
}
@hitesh-dhamshaniya
hitesh-dhamshaniya / activity_main.xml
Created August 19, 2019 13:35
While use fab button in android application and find difficulties to set tint color of fab button, use below code to set desire color. I have spend many hours to resolve the issue.
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_gravity="bottom|end"
app:fabSize="normal"
app:tint="@color/colorAccent"
app:srcCompat="@drawable/ic_google"/>
@hitesh-dhamshaniya
hitesh-dhamshaniya / WhatAppLikeWebSiteURLPreviewUsingLib.kt
Last active August 7, 2019 12:40
WhatApp Like WebSite URL Preview Using Lib
richLinkViewTel.setLink("https://www.youtube.com/channel/UC5DlHdPZqA1IzqqSqBXvo0g", object : ViewListener {
override fun onSuccess(status: Boolean) {
}
override fun onError(e: Exception) {
}
})
@hitesh-dhamshaniya
hitesh-dhamshaniya / deeplinking
Created July 9, 2019 11:52
Deep Linking in Android Manifest file
<activity
android:name=".ui.screen.main_screen.MainActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.Light.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
@hitesh-dhamshaniya
hitesh-dhamshaniya / CalendarUtils.kt
Last active June 13, 2019 07:08
Class is used for date related operation, i.e change date format, convert date string object to date object, check past and future date and many more functions are there.
object CalendarUtils {
val yyyyFormat: String = "yyyy"
val MMMMdFormat: String = "MMMM d"
val MMMdFormat: String = "MMM d"
val DMMMFormat: String = "d MMM"
val MMMdyyyyFormat: String = "MMM d, yyyy"
val MMMMdyyyyFormat: String = "MMMM d, yyyy"
val mddyyyyFormat: String = "M/dd/yyyy"
val yyyyMMddFormat: String = "yyyy-MM-dd"
val HHmmssFormat: String = "hh:mm:ss a"
@hitesh-dhamshaniya
hitesh-dhamshaniya / app build.gradle
Created June 5, 2019 04:49
Common Gradle we need to every project in Android. Script added to make meaning full name of apk file.
apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
@hitesh-dhamshaniya
hitesh-dhamshaniya / String.xml
Created January 28, 2019 12:12
How to add DOCTYPE In Android String.xml for use multiple same string without repeating its value
<!DOCTYPE resources [<!ENTITY appName "Food App">
<!ENTITY addFood "Add Food">]>
<resources>
<string name="app_name">&appName;</string>
<string name="action_add_food">&addFood;</string>
<string name="title_add_food">&addFood;</string>
</resources>