Skip to content

Instantly share code, notes, and snippets.

View tmaxxdd's full-sized avatar
💻
In my mind, 🍺 in my heart

Tomasz Kądziołka tmaxxdd

💻
In my mind, 🍺 in my heart
View GitHub Profile
@tmaxxdd
tmaxxdd / CollapsingTitleLayout.java
Last active August 29, 2015 14:25 — forked from chrisbanes/CollapsingTitleLayout.java
CollapsingTitleLayout
/*
* Copyright 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@tmaxxdd
tmaxxdd / generating_array_before.kt
Last active May 17, 2018 08:14
Code before using Array() in Kotlin.
...
val items: ArrayList<Topic> = ArrayList()
for (i in 1..20) items.add(Topic("Some topic", "Some description"))
return items
@tmaxxdd
tmaxxdd / generating_array_after.kt
Last active May 17, 2018 09:15
Code after using Array() in kotlin
...
return Array(20, { Topic("Some topic", "Some description")} )
@tmaxxdd
tmaxxdd / generating_array_before.java
Last active May 17, 2018 08:56
Generating sample data array with java
...
Topic[] items = new Topic[20];
for (int i = 0; i < items.length; i++){
items[i] = new Topic("Some topic", "Some description");
}
return items;
@tmaxxdd
tmaxxdd / kotlin_array_example.kt
Created May 17, 2018 09:10
Sample about Array() constructor
// Tworzy Array<String> z wartosciami ["0", "1", "4", "9", "16"]
val asc = Array(5, { i -> (i * i).toString() })
class MainActivity : AppCompatActivity() {
...
private lateinit var recyclerView: RecyclerView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
recyclerView = findViewById<RecyclerView>(R.id.main_rv).apply {
setHasFixedSize(true)
class Example {
private lateinit var text: String
fun initialize() {
text = "Nadaje wiadomosc"
}
fun readText(): String {
if (::text.isInitialized) {
return text
class GetTopics {
// getter method
operator fun getValue(thisRef: Any?, property: KProperty<*>): Array<Topic> {
//Here we can change implementation
return Array(20, { Topic("Some topic", "Some description")} )
}
}
class MainActivity : AppCompatActivity() {
val topics: Array<Topic> by GetTopics()//delegated properties