Skip to content

Instantly share code, notes, and snippets.

Gaurav Vashisth vashisthg

Block or report user

Report or block vashisthg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@vashisthg
vashisthg / TryDebounce.kt
Last active Mar 14, 2019
Trying coroutine. Kind of debounce.
View TryDebounce.kt
import kotlinx.coroutines.*
/*
* Trying learning couroutine. Investigating for getting debounce effect.
* Some inspiration from https://medium.com/@pro100svitlo/edittext-debounce-with-kotlin-coroutines-fd134d54f4e9
*/
fun main() {
val list = listOf(1, 2, 3, 4, 5)
var time = java.util.Calendar.getInstance().timeInMillis
for (i in list) {
@vashisthg
vashisthg / script.sh
Last active Nov 21, 2018 — forked from dlew/script.sh
Simple AndroidX Migration Script
View script.sh
#!/usr/bin/env bash
# I've found that the "Migrate to AndroidX" converter in Android Studio doesn't work very
# well, so I wrote my own script to do the simple job of converting package names.
#
# You can download a CSV of package names here: https://developer.android.com/topic/libraries/support-library/downloads/androidx-class-mapping.csv
#
# It'll run faster on a clean build because then there are fewer files to scan over.
#
# Uses `gsed` because I'm on a Mac. Can easily replace with `sed` if you don't have `gsed`.
@vashisthg
vashisthg / CropView.java
Created Jul 26, 2018
Sample code to see issues with Xfermode on Android P beta
View CropView.java
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
@vashisthg
vashisthg / CropView.java
Created Jul 26, 2018
Issue with Xfermode in Android P beta
View CropView.java
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
View dependencies block
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
implementation(Libraries.Kotlin.stdlib)
implementation(Libraries.Support.appcompatV7)
testImplementation(Libraries.Tests.junit)
androidTestImplementation(Libraries.AndroidTests.testRunner)
androidTestImplementation(Libraries.AndroidTests.espressoCore)
}
View Libraries.kt
object Libraries {
object Kotlin {
val stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${Versions.kotlinVersion}"
}
object Support {
val appcompatV7 = "com.android.support:appcompat-v7:28.0.0-alpha3"
}
object Tests {
View Libraries.kt
object Libraries {
object Kotlin {
val stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${Versions.kotlinVersion}"
}
object Support {
val appcompatV7 = "com.android.support:appcompat-v7:28.0.0-alpha3"
}
object Tests {
View buildtype kotlin dsl
buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android.txt"), file("proguard-rules.pro"))
}
}
View plugin kotlin dsl
plugins {
id("com.android.application")
kotlin("android") // or id("kotlin-android")
id("kotlin-android-extensions")
}
You can’t perform that action at this time.