Skip to content

Instantly share code, notes, and snippets.

Avatar

Mark Allison StylingAndroid

View GitHub Profile
View FunctionReferences6.kt
fun main() {
val classThree = ClassThree()
val color3 = classThree.obtainColor(context, R.color.my_color, ContextCompat::getColor)
}
class ClassThree {
fun obtainColor(context: Context, colorRes: Int, colorLookup: (Context, Int) -> Int) = colorLookup(context, colorRes)
}
View FunctionReferences5.kt
classTwo.obtainColor(R.color.my_color) {
Color.RED
}
View FunctionReferences4.kt
fun main() {
val classOne = ClassOne()
val color1 = classOne.obtainColor(context, R.color.my_color)
val classTwo = ClassTwo()
classTwo.obtainColor(R.color.my_color, context.resources::getColor)
}
View FunctionReferences3.kt
fun main() {
val classOne = ClassOne()
val classTwo = ClassTwo()
classTwo.myFunc(true, classOne::doSomething)
}
class ClassOne {
private val output = "Hello, world!!!"
View FunctionReferences2.kt
fun main() {
myFunc(true, ::doSomething)
}
fun doSomething() {
println("Hello, world!!!")
}
fun myFunc(someCondition: Boolean, funcRef: () -> Unit) {
if (someCondition) {
View FunctionReferences1.kt
fun main() {
myFunc(false) {
println("Hello, world!!!")
}
}
fun myFunc(someCondition: Boolean, funcRef: () -> Unit) {
if (someCondition) {
funcRef()
}
View keybase.md

Keybase proof

I hereby claim:

  • I am StylingAndroid on github.
  • I am stylingandroid (https://keybase.io/stylingandroid) on keybase.
  • I have a public key whose fingerprint is B3F2 DD7F E0BC 2542 F33F D7A5 07DC C222 845A 5B74

To claim this, I am signing this object:

View gist:976f3ad3796584bd64e9
import com.google.gson.annotations.SerializedName;
public class GsonClass {
private static final String EMPTY = "";
@SerializedName("mandatory")
private String mandatory;
@SerializedName("optional")
private String optional;