Skip to content

Instantly share code, notes, and snippets.

View alistairsykes's full-sized avatar

Alistair Sykes alistairsykes

View GitHub Profile
/**
* MIT License
*
* Copyright (c) 2020 Brightec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
/**
* MIT License
*
* Copyright (c) 2020 Brightec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.com.intellij.lang.ASTNode
import org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.TreeUtil
import org.jetbrains.kotlin.psi.KtClass
internal object Utils {
internal fun getOuterClass(node: ASTNode?): KtClass? {
return TreeUtil.findParent(node, KtNodeTypes.CLASS)?.psi as? KtClass
}
import com.pinterest.ktlint.core.Rule
import org.jetbrains.kotlin.KtNodeTypes.BLOCK
import org.jetbrains.kotlin.KtNodeTypes.CALL_EXPRESSION
import org.jetbrains.kotlin.KtNodeTypes.DOT_QUALIFIED_EXPRESSION
import org.jetbrains.kotlin.KtNodeTypes.FUNCTION_LITERAL
import org.jetbrains.kotlin.KtNodeTypes.LAMBDA_ARGUMENT
import org.jetbrains.kotlin.KtNodeTypes.LAMBDA_EXPRESSION
import org.jetbrains.kotlin.KtNodeTypes.PROPERTY_DELEGATE
import org.jetbrains.kotlin.KtNodeTypes.REFERENCE_EXPRESSION
import org.jetbrains.kotlin.KtNodeTypes.VALUE_PARAMETER_LIST
import com.pinterest.ktlint.core.Rule
import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.KtNodeTypes.CALL_EXPRESSION
import org.jetbrains.kotlin.com.intellij.lang.ASTNode
import org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.CompositeElement
import org.jetbrains.kotlin.com.intellij.psi.tree.TokenSet
import package.Utils
class NamedParametersRule(private val shouldError: Boolean = false) : Rule(RULE_ID) {
configurations {
// ...
xmlchecker
}
dependencies {
// ...
xmlchecker fileTree(dir: "$project.rootDir/.../xmlchecker/libs", include: ['*.jar'])
}
def camerax_version = "1.0.0-alpha01"
implementation "androidx.camera:camera-core:${camerax_version}"
implementation "androidx.camera:camera-camera2:${camerax_version}"
internal fun Activity.navigateUp() {
val successful = findNavController(R.id.id_to_host_fragment).popBackStack()
if (!successful) {
finish()
}
}
internal fun Fragment.navigateUp() {
requireActivity().navigateUp()
}
object Utils {
fun multipleBy2(x: Int) = x * 2
}
class UtilsTest {
@Test
fun x1__multiplyBy2__2() {
// GIVEN
import android.app.Application
import android.arch.lifecycle.LiveData
import android.content.Context
import android.net.ConnectivityManager
import android.net.Network
import android.net.NetworkInfo
import android.net.NetworkRequest
import android.os.Build
import android.support.annotation.RequiresPermission
import android.support.annotation.VisibleForTesting