Skip to content

Instantly share code, notes, and snippets.

View avirias's full-sized avatar
🎯
Focusing

Avinash Kumar avirias

🎯
Focusing
View GitHub Profile
@avirias
avirias / band.json
Created May 21, 2021 17:57
Metal Archive Schema
{
"name" : "Arch Enemy",
"country_of_origin": "Sweden",
"location": "Halmstad, Halland",
"status": "Active",
"formed_in": 1995,
"logo_url": "https://www.metal-archives.com/images/1/0/10_logo.jpg?5127",
"image_url": "https://www.metal-archives.com/images/1/0/10_photo.jpeg?3322",
"years_active": "1995-present",
"genre": ["Melodic Death Metal"],
suspend fun thumbnailExtract(videoFile: File): Bitmap {
return suspendCancellableCoroutine<Bitmap> {
try {
val retriever = MediaMetadataRetriever().apply {
setDataSource(videoFile.absolutePath)
}
val width =
retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH)
@avirias
avirias / Resolver.kt
Created February 21, 2022 10:36
Query content with ease
suspend fun <T> Context.getContent(
uri: Uri,
projection: Array<String>? = null,
selection: String? = null,
selectionArgs: Array<String>? = null,
sortOrder: String? = null,
builder: Cursor.() -> T
): List<T> = suspendCancellableCoroutine { cont ->
val cancellationSignal = CancellationSignal()
try {
@avirias
avirias / DownloadWorker.kt
Created February 22, 2022 17:15
Download anything with work manager
class DownloadWorker(
private val context: Context,
params: WorkerParameters
) : CoroutineWorker(context, params) {
private val urlString: String? = inputData.getString("urlFile")
private val fileName: String? = inputData.getString("fileName")
override suspend fun doWork(): Result {
urlString ?: return Result.failure()