Skip to content

Instantly share code, notes, and snippets.

View vlad-kasatkin's full-sized avatar

Vladimir Kasatkin vlad-kasatkin

  • Toronto
View GitHub Profile
@vlad-kasatkin
vlad-kasatkin / SuspendProxy.kt
Last active February 4, 2020 20:48
Proxy for suspend calls that checks if generic is one of the arguments
fun createProxy(forTarget: KClass<*>, delegate: SomeType<*>): SomeType<SomeGeneric> {
return Proxy.newProxyInstance(
delegate.javaClass.classLoader,
Array(1) { SomeType::class.java }) { proxy, method, args ->
val hasFailedTypeCheck = args.filterIsInstance<SomeGeneric>().any { !it::class.isSubclassOf(forTarget) }
if (hasFailedTypeCheck) {
throw IllegalStateException()
}
method.kotlinFunction!!.call(delegate, *args)
} as SomeType<SomeGeneric>
@vlad-kasatkin
vlad-kasatkin / ActivityActions.kt
Created August 27, 2019 16:02
Espresso Activity Actions (rewrite with new espresso APIs)
object ActivityActions {
fun backgroundActivity(activity: Activity) {
val intent = Intent().apply {
action = Intent.ACTION_MAIN
addCategory(Intent.CATEGORY_HOME)
}
launchActivityWithIntent(activity, intent)
}
@vlad-kasatkin
vlad-kasatkin / ActivityActions.kt
Created August 27, 2019 16:02
Espresso Activity Actions (rewrite with new espresso APIs)
object ActivityActions {
fun backgroundActivity(activity: Activity) {
val intent = Intent().apply {
action = Intent.ACTION_MAIN
addCategory(Intent.CATEGORY_HOME)
}
launchActivityWithIntent(activity, intent)
}

Angular architecture guide:

Purpose of this guide

This guide should be a living document describing the core principles of writing a modern, scalable angular application that is aligned with best practices in the angular style guide and the angular community.

Main theme

The constant theme of this guide is the clear and explicit separation of boundaries of the application.
These boundaries can take the variety of forms, some of them will be discussed in the next sections.

Modules

@vlad-kasatkin
vlad-kasatkin / Circles
Last active October 29, 2018 01:06
Power levels(https://imgur.com/a/XmB2pD6) custom view. Not polished, does not provide customisation. Just a good starting point
import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.graphics.RectF
import android.util.AttributeSet
import android.view.View
class Circles : View {
@vlad-kasatkin
vlad-kasatkin / build.gradle
Created June 15, 2015 14:51
jacoco task for espresso coverage
apply plugin: 'jacoco'
jacoco {
version "0.7.1.201405082137"
}
task jacocoTestReportAndroidTest(type: JacocoReport, dependsOn: "connectedAndroidTest") {
def coverageSourceDirs = [
'src/main/java'
]
group = "Reporting"
@vlad-kasatkin
vlad-kasatkin / withAdaptedData.java
Created June 11, 2015 20:46
Matcher to assert that item is not in the adapter
public static Matcher<View> withAdaptedData(final Matcher<Object> dataMatcher) {
return new TypeSafeMatcher<View>() {
@Override
public void describeTo(Description description) {
description.appendText("with class name: ");
dataMatcher.describeTo(description);
}
@Override