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
| import io.ktor.client.HttpClient | |
| import io.ktor.client.call.call | |
| import io.ktor.client.engine.okhttp.OkHttp | |
| import io.ktor.client.request.forms.MultiPartFormDataContent | |
| import io.ktor.client.request.forms.formData | |
| import io.ktor.client.request.url | |
| import io.ktor.http.Headers | |
| import io.ktor.http.HttpHeaders | |
| import io.ktor.http.HttpMethod | |
| import kotlinx.coroutines.GlobalScope |
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.webkit.MimeTypeMap | |
| import java.net.URLConnection | |
| fun getFileInfo(bytes: ByteArray): Pair<String?, String?> { | |
| val mime = URLConnection.guessContentTypeFromStream(bytes.inputStream()) | |
| val extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(mime) | |
| return mime to extension | |
| } |
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.content.Context | |
| import android.graphics.Bitmap | |
| import android.renderscript.Allocation | |
| import android.renderscript.Element | |
| import android.renderscript.RenderScript | |
| import android.renderscript.ScriptIntrinsicBlur | |
| import com.bumptech.glide.load.Key | |
| import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool | |
| import com.bumptech.glide.load.resource.bitmap.BitmapTransformation | |
| import java.security.MessageDigest |
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 = |
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
| 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 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
| 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 kotlin.math.* | |
| const val EARTH_RADIUS_METERS = 6378137 | |
| data class Coordinate( | |
| val latitude: Double, | |
| val longitude: Double | |
| ) { | |
| /** |
OlderNewer