본문 바로가기

#kotlin

[Kotlin] kotlin 프로젝트 생성 시, 참조할 만한 소스 Kotlin으로써 새로운 프로젝트를 시작하고자 할 때,참조할만한 괜찮은 소스가 있어서 공유 하고자 합니다. https://github.com/Plastix/Kotlin-Android-Boilerplate 소스 형태는 아래와 같다고 쓰여 있네요.LibrariesDagger 2 -> 의존 관계 주입(Dependency Injection) 라이브러리RxJava 2 and RxAndroid -> 요새 화두가 되고 있는 Reactive 라이브러리Retrofit 2 -> 네트워크 통신 라이브러리Picasso -> 이미지 로드 라이브러리 (전 Glide로 교체할 예정)Google Support Libraries -> 구글에서 지원해주는 라이브러리Testing LibrariesJUnitMockitoRequirement.. 더보기
[Kotlin] let을 이용한 Null 체크 val result: Boolean if (user != null) { result = write(user) } else { result = false }이런 케이스에서는 Kotlin에서는 다음과 같이 쓰는 것이 가능합니다.val result: Boolean = user?.let { write(it) } ?: false참고 : https://gist.github.com/Hazealign/1bbc586ded1649a8f08f#약간-특이한-부분 하지만, 위 소스에서 false가 아닌 {} 같이 구문을 이용하고자 한다면 어떻게 하면 될까요?? fun letTest(a: String?) { a?.let { Log.d("Test","letTest :: 1 : "+it) }.let { Log.d("Test","le.. 더보기
[Android][Kotlin] public static final -> const val Java에서 public static final 을 kotlin 에서는 const val로 사용하면 똑같이 사용 할 수 있습니다. Contants.javapackage com.test.kotlin; public class Contants { public static final int CONTANTS_INT_ID_1 = 100; public static final int CONTANTS_INT_ID_2 = 101; public static final int CONTANTS_INT_ID_3 = 102; public static final int CONTANTS_INT_ID_4 = 103; } Contants.kt@file:JvmName("Contants") package com.namuon.ringq.dat.. 더보기