Kotlin(4)
-
안드로이드 Hilt 무작정 써보기
이전 포스팅에서는 Dagger2를 무작정 따라 써 보는 방법에 대해 알려드렸습니다. 이번엔 엄청난 Hilt(이하 힐트)를 무작정 따라 써 볼 수 있게 해드리겠습니다. 이 예제 역시 간단하게 파일 목록 조회와, 해당 파일명의 랜덤 아이디를 부여하는걸로 작성되었습니다. 우선 gradle 설정이 필요합니다. [프로젝트 단위] classpath 'com.google.dagger:hilt-android-gradle-plugin:2.28-alpha' [앱 단위] apply plugin: 'kotlin-kapt' apply plugin: 'dagger.hilt.android.plugin' ... dependencies { ... implementation 'com.google.dagger:hilt-android:2...
2020.10.19 -
안드로이드 Dagger2 무작정 써보기
우선 이 포스트는 Dagger2 무작정 써보기이기 때문에 Dagger에 대한 기초 지식을 알고 있다는 가정 하에 시작합니다. 이 예제는 간단하게 파일 목록 조회와, 해당 파일명의 랜덤 아이디를 부여하는걸로 작성되었습니다. 제일 먼저 Dagger2(이하 대거)를 쓰기 위해선 gradle 설정이 필요합니다. apply plugin: 'kotlin-kapt' ... dependencies { ... implementation 'com.google.dagger:dagger:2.28' kapt 'com.google.dagger:dagger-compiler:2.28' ... } 일단 이렇게 대거를 쓰기 위한 gradle 설정은 끝났습니다. 이제 모델을 만들어야 합니다. data class FileDataModel ..
2020.10.19 -
content uri으로 부터 content path 가져오기
@Suppress("DEPRECATION") fun convertUriToPath(context: Context, contentUri: Uri?): String? { val projection = arrayOf(MediaStore.Images.Media.DATA) return context.contentResolver.query(contentUri!!, projection, null, null, null) ?.use { cursor -> val columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA) cursor.moveToFirst() cursor.getString(columnIndex) } }
2020.10.16 -
[DSL] Duplicate class org.intellij.lang.annotations 에러 해결
configurations { all { exclude(group = "org.jetbrains", module = "annotations") } } 앱 수준 그레이들에 다음과 같은 코드를 추가하면 된다.
2020.10.10