This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val value: T | |
when(value) { | |
is String -> ... | |
is Int -> ... | |
else -> ... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum class HttpStatusCode(val value: Int) { | |
Default(0), | |
Continue(100), | |
SwitchingProtocols(101), | |
Processing(102), | |
Ok(200), | |
Created(201), | |
Accepted(202), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Not object class. AndroidManifest.xml error happen. | |
class MainApplication : Application() { | |
init { | |
instance = this | |
} | |
companion object { | |
private var instance: MainApplication? = null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// recommend class.java.simpleName is not wrapped | |
private val LogTag = MainActivity::class.java.simpleName | |
// deprecate class.simpleName is wrapped. | |
private val LogTag = MainActivity::class.simpleName |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
※It might not work... | |
※I tried Parceler and PaperParcel, But I don't use Parcelable Library by Kotlin. | |
1. Remove apply plugin: 'com.neenbedankt.android-apt' | |
2. Change dependencies kapt to apt | |
dependencies { | |
… | |
kapt 'com.github.grandstaish.paperparcel:compiler:1.0.0' | |
↓ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Quit Android Studio | |
Android Studio → Tools → Kotlin → Configure Kotlin in Project | |
Clean build | |
😰 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class KotlinCustomView | |
@JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : View(context, attrs, defStyleAttr) | |
class KotlinCustomView: View { | |
// Basic constructors | |
constructor(context: Context) : super(context) | |
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) | |
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) |
NewerOlder