implementation "androidx.exifinterface:exifinterface:1.0.0"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MainActivity : ActivityCompat { | |
| private lateinit var bordersListener: ViewTreeObserver.OnGlobalLayoutListener | |
| private var statusBarHeight = 0 | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| val decorView = window.decorView | |
| bordersListener = ViewTreeObserver.OnGlobalLayoutListener { | |
| val r = Rect() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import kotlin.math.absoluteValue | |
| import kotlin.math.roundToInt | |
| private const val NORTH = "N" | |
| private const val SOUTH = "S" | |
| private const val EAST = "E" | |
| private const val WEST = "W" | |
| fun convertDecimalToDegrees(lat: Double, lng: Double): String = "${convertLat(lat)} ${convertLng(lng)}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import android.annotation.SuppressLint | |
| import android.graphics.Rect | |
| import android.os.Build | |
| import android.view.View | |
| import android.view.ViewTreeObserver | |
| import androidx.core.view.updatePaddingRelative | |
| class UnderKeyboardViewElevator(private val decorView: View, private val contentView: View) { | |
| private var initialPaddingBottom: Int = contentView.paddingBottom |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import kotlin.math.* | |
| const val EARTH_RADIUS_METERS = 6378137 | |
| data class Coordinate( | |
| val latitude: Double, | |
| val longitude: Double | |
| ) { | |
| /** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.math.BigDecimal | |
| import java.math.RoundingMode | |
| val BigDecimal.fractionLength: Int | |
| get() = | |
| stripTrailingZeros().toPlainString().substringAfterLast(".", "").length | |
| infix fun BigDecimal.isValueEquals(another: BigDecimal?): Boolean { | |
| if (another == null) return false | |
| return compareTo(another) == 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import android.text.InputFilter | |
| import android.text.Spanned | |
| abstract class SuggestedInputFilter : InputFilter { | |
| override fun filter(source: CharSequence, start: Int, end: Int, dest: Spanned, dstart: Int, dend: Int): CharSequence? { | |
| val suggestedResult = dest.replaceRange(dstart, dend, source) | |
| val cancelResult = dest.slice(dstart until dend) | |
| return if (accept(suggestedResult)) null else cancelResult | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun Context.vectorToBitmap(@DrawableRes id: Int): Bitmap { | |
| val drawable = ContextCompat.getDrawable(this, id)!! | |
| val bitmap = Bitmap.createBitmap(drawable.intrinsicWidth, drawable.intrinsicHeight, Bitmap.Config.ARGB_8888) | |
| val canvas = Canvas(bitmap) | |
| drawable.setBounds(0, 0, canvas.width, canvas.height) | |
| drawable.draw(canvas) | |
| return bitmap | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.text.SimpleDateFormat | |
| import java.util.* | |
| fun toDate(text: String): Date { | |
| val dateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ") | |
| val modifiedText = text.substring(0..25) + "GMT" + text.substring(26) | |
| return dateFormat.parse(modifiedText) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.net.InetSocketAddress | |
| import java.net.Socket | |
| class SocketConnectionChecker( | |
| private val timeout: Int = 1000, | |
| private val hostname: String = "8.8.8.8", | |
| private val port: Port = Port.DNS | |
| ) { | |
| fun isConnected(): Boolean = |
NewerOlder