Skip to content

Instantly share code, notes, and snippets.


Kaustubh Patange KaustubhPatange

View GitHub Profile
KaustubhPatange / ActivityResultExtensions.kt
Created February 23, 2022 11:11
Some extension methods to use ActivityResult API in a callback way.
View ActivityResultExtensions.kt
package com.kpstv.xclipper.extensions
import android.content.Intent
import androidx.activity.ComponentActivity
import androidx.activity.result.ActivityResult
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContract
import androidx.activity.result.contract.ActivityResultContracts
import java.util.*
KaustubhPatange / library.kt
Last active December 26, 2020 14:35
Mapping a data class to another data class typically found in the apps which follows clean architecture (domain, etc.)
View library.kt
* If there is two same classes like below one maybe domain & other may be entity
* Following method might help to map such instance to other classes.
* This is done completely through reflection by matching parameters name.
* [convertType] This can be used to transform intermediate values if their types are different in other.
inline fun <reified F : Any, reified T : Any> mapToClass(from: F, convertType: (String, Any?) -> Any? = { _,v -> v }): T {
val args = HashMap<KParameter, Any?>()
KaustubhPatange / publish.gradle
Last active February 5, 2021 05:04
A Gradle script to automatically publish Android library to maven or sonatype provided your central sync is enabled.
View publish.gradle
* Copyright 2020 Kaustubh Patange
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software
KaustubhPatange / clean-proj.ps1
Created April 3, 2020 09:55
An utility to clean temp files in project.
View clean-proj.ps1
# Created by Kaustubh Patange
# Date Modified: 3rd April 2020
# @Platform: Windows (only) - A Powershell script
# @Summary: We often get into some space issues during coding, especially when you are
# doing Android development (native) in Android Studio which exceptionally
# creates larger gradle downloads and stuff. This is applicable also for
# flutter, Xamarin or even a standard .Net project, etc.