Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Kaustubh Patange KaustubhPatange

🎯
Focusing
View GitHub Profile
@KaustubhPatange
KaustubhPatange / ActivityResultExtensions.kt
Created Feb 23, 2022
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 androidx.fragment.app.Fragment
import java.util.*
@KaustubhPatange
KaustubhPatange / library.kt
Last active Dec 26, 2020
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
KaustubhPatange / publish.gradle
Last active Feb 5, 2021
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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@KaustubhPatange
KaustubhPatange / clean-proj.ps1
Created Apr 3, 2020
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.
#