본문 바로가기

안드로이드

(35)
Android - Compose 1.2 바뀐 것 1. Chip과 FilterChip 드디어 기존의 Chip에 대응하는 컴포넌트가 Compose에 추가되었다. @ExperimentalMaterialApi @Composable fun Chip( onClick: () -> Unit, modifier: Modifier = Modifier, enabled: Boolean = true, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, shape: Shape = MaterialTheme.shapes.small.copy(CornerSize(percent = 50)), border: BorderStroke? = null, colors: ChipColors = C..
Android - MovableContentOf in Compose 최근 Stable로 올라온 Compose 1.2 버전에서 movableContentOf 와 movableContentWithReceiverOf 라는 새로운 두 함수가 추가되었다. 기존에는 동일한 Content이라도 부모가 바뀌게 되면 기존의 Content 없애고 새로운 Content을 구성하는 형태로 동작하였다. 이제는 movableContentOf 을 사용하여 기존의 Content를 재구성 없이 그대로 이동시킬 수 있고, 재구성에 필요한 불필요한 비용 줄일 수 있다. 사용 방법은 mutableStateOf 와 동일하게 remember 로 감싸주면 되고 내부에 Content를 넣어주면 된다. 1. movableContentOf @Composable fun MovableContentTest() { val ..
Compose 1.1 정리 https://android-developers.googleblog.com/2022/02/jetpack-compose-11-now-stable.html Jetpack Compose 1.1 is now stable! Posted by Florina Muntenescu , Android Developer Relations Engineer Today, we’re releasing version 1.1 of Jetpack Co... android-developers.googleblog.com 1. Image vector caching 벡터 이미지에 대한 캐싱이 추가되었다. Compose 1.0 의 PainterResource 코드 val imageVector = remember(path, id) { loadVe..
compose 넣은 xml 불러오면 에러날 때 java.lang.IllegalStateException: ViewTreeLifecycleOwner not found from androidx.coordinatorlayout.widget.CoordinatorLayout{25a0d04 V.E...... ......ID 0,0-0,0 #7f090122 app:id/common_container} at androidx.compose.ui.platform.WindowRecomposer_androidKt.createLifecycleAwareViewTreeRecomposer(WindowRecomposer.android.kt:244) at androidx.compose.ui.platform.WindowRecomposer_androidKt.access$createLi..
오픈소스 라이선스 만들기 앱을 출시하기 위해선 오픈소스 라이선스를 작성해야한다. ( 앱 몇개 다운받아보니 거의 안쓰는 듯...? ) 직접 다 찾아서 타이핑하기에는 귀찮기도 하고, 뭘 써야하는지 모르겠어서 찾다보니 라이브러리가 있었다. gradle-license-plugin https://github.com/jaredsburrows/gradle-license-plugin jaredsburrows/gradle-license-plugin Gradle plugin that provides a task to generate a HTML license report of your project. - jaredsburrows/gradle-license-plugin github.com 1. 라이브러리 추가 buildscript { ... dep..
Error ) NavigationExtensions - does not have a NavController set 에러 내용 java.lang.RuntimeException: Unable to destroy activity .... does not have a NavController set Caused by: java.lang.IllegalStateException: View androidx.fragment.app.FragmentContainerView{d4cc327 V.E...... ......ID 0,143-1080,1868 #7f0900e0 app:id/main_nav_container} does not have a NavController set 재현 상황 android/architecture-components-samples Samples for Android Architecture Components. ..
Dagger ( Hilt ) 2.31 - 변경된 ViewModel 주입 Hilt 2.31에서 ViewModel 주입 방법이 바뀌었다. 기존 코드 implementation "com.google.dagger:hilt-android:2.30.1-alpha" kapt "com.google.dagger:hilt-android-compiler:2.30.1-alpha" implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha02' kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha02' class StartViewModel @ViewModelInject constructor( @Assisted private val savedStateHandle: SavedStateHandle, private ..
ViewModel - SavedStateHandle ViewModel에서 상태 저장을 위해선 SavedStateHandle를 사용하면 된다. class SampleViewModel @ViewModelInject constructor( @Assisted private val savedStateHandle: SavedStateHandle ){ companion object { const val DATE_TYPE_KEY = "DATE_TYPE_KEY" const val IS_EMPTY_KEY = "IS_EMPTY_KEY" } private val _isEmpty = savedStateHandle.getLiveData(IS_EMPTY_KEY) val isEmpty: LiveData get() = _isEmpty private var dateType: Int? =..