Skip to content

Instantly share code, notes, and snippets.

View mksantoki's full-sized avatar
🏠
Working from home

Maulik Santoki (MK) mksantoki

🏠
Working from home
  • India
View GitHub Profile
@mksantoki
mksantoki / DateFormatExtensions.kt
Created September 16, 2020 17:07
This extension is used to format dates. Android date format extension kotlin
import java.text.SimpleDateFormat
import java.util.*
fun getDefaultDateTime(date: String): String {
val formatter = SimpleDateFormat("dd-MM-yyyy hh:mm aa")
return formatter.format(date.toDate())
}
fun getDefaultDateTime1(date: String): String {
val formatter = SimpleDateFormat("dd-MM-yyyy HH:MM")
@mksantoki
mksantoki / IntentExtensions.kt
Created September 16, 2020 17:12
This extensions is used to perform intent operations
fun onDocument(): Intent {
val mimeTypes = arrayOf(
"application/pdf",
"image/*"
)
val intent = Intent(Intent.ACTION_GET_CONTENT)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.addCategory(Intent.CATEGORY_OPENABLE)
intent.type = if (mimeTypes.size == 1) mimeTypes[0] else "*/*"
if (mimeTypes.isNotEmpty()) {
@mksantoki
mksantoki / ValidationExtension.kt
Created September 16, 2020 17:17
Kotlin validation extensions to validate email,phone number and many others
import android.text.TextUtils
import android.widget.EditText
import androidx.appcompat.widget.AppCompatEditText
fun String.isEmpty(): Boolean {
return (TextUtils.isEmpty(this)
|| this.equals("", ignoreCase = true)
|| this.equals("{}", ignoreCase = true)
|| this.equals("null", ignoreCase = true)
|| this.equals("undefined", ignoreCase = true))
@mksantoki
mksantoki / MapExtensions.kt
Created October 14, 2020 09:47
how to draw an arc line on google map?
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.Polyline
import com.google.android.gms.maps.model.PolylineOptions
import com.google.maps.android.SphericalUtil
val optionsForeground: PolylineOptions? = null
fun showCurvedPolyline(
googleMap: GoogleMap,