Skip to content

Instantly share code, notes, and snippets.

View hasankucuk's full-sized avatar

Hasan Küçük hasankucuk

View GitHub Profile
@AndroidEntryPoint
class MainActivity : AppCompatActivity() { @Inject lateinit var analytics: AnalyticsAdapter
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
}
class AnalyticsAdapter @Inject constructor() { ... }
@HiltAndroidApp
class MyApplication : Application() { ... }
@hasankucuk
hasankucuk / gist:93bc5734a83447139d9da0e343b9c56a
Created August 6, 2020 19:21 — forked from smyykb/gist:c342f332d3c1017373189de7659caba6
Change Author template in Android Studio
You can overwrite the ${USER} variable in the template file with the
#set( $VARIABLE = "value")
function. Go to Settings -> File and Code Templates -> Includes -> File Header prepend the #set() function call, for example:
#set( $USER = "Your name" )
/**
* Created by ${USER} on ${DATE}.
*/
@hasankucuk
hasankucuk / material_design_colors.xml
Created June 23, 2020 19:56
material_design_colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Red -->
<color name="material_red_50">#FFEBEE</color>
<color name="material_red_100">#FFCDD2</color>
<color name="material_red_200">#EF9A9A</color>
<color name="material_red_300">#E57373</color>
<color name="material_red_400">#EF5350</color>
<color name="material_red_500">#F44336</color>
<color name="material_red_600">#E53935</color>
fun myDelegate(): ReadWriteProperty<Nothing?, Int> =
object : ReadWriteProperty<Nothing?, Int> {
...
}
val foo: Int by myDelegate()
var bar: Int by myDelegate()
val max = maxOf(1, 2, 3, 4)
println(max)
println(Double.NaN) // NaN
println(Double.NEGATIVE_INFINITY) // -Infinity
println(Double.POSITIVE_INFINITY > Double.MAX_VALUE ) // true
println(Double.SIZE_BITS) // 64
val s: String? = null
println(s.toBoolean()) // false
val numbers = mutableListOf(0, 1, 2, 3, 4, 5)
val runningReduceSum = numbers.runningReduce() { sum, item -> sum + item} // [0, 1, 3, 6, 10, 15]
val runningFoldSum = numbers.runningFold(10) { sum, item -> sum + item} // [10, 10, 11, 13, 16, 20, 25]