목록2024/01 (7)
Hanbit the Developer
문제 상황 로딩 화면에서 Success.NotEmpty 상태가 되어야 하는데, 중간에 Success.Empty 화면이 아주 짧게 보이는 문제가 발생하였다. 기존 코드 @HiltViewModel class TodoViewModel @Inject constructor( // ... ) : ViewModel() { private val _uiState: MutableStateFlow = MutableStateFlow(TodoUiState.Loading) val uiState = _uiState.asStateFlow() private val activeUserId: StateFlow = getActiveUserIdUseCase() .stateIn(viewModelScope, SharingStarted.While..
안드로이드 애플리케이션은 리눅스 프로세스에서 실행되며, 애플리케이션 코드 일부가 실행되어야 할 때 프로세스가 생성된다. 다른 애플리케이션이 메모리를 필요로 하면서 기존 애플리케이션이 더이상 쓰이지 않으면 종료될 수 있다. 안드로이드의 특이하면서 기본적인 특징은 애플리케이션 프로세스의 라이프타임이 해당 애플리케이션에 의해 결정되지 않고, 시스템에 의해 제어된다는 점이다. 시스템은, 실행 중인 애플리케이션 요소, 사용자에게 얼마나 중요한지, 시스템에서 사용 가능한 전체 메모리의 양을 고려한다. 개발자는 Activity, Service, BroadcastReceiver 같은 컴포넌트들이 애플리케이션 프로세스의 수명에 영향을 어떻게 미치는지를 알아야 한다. 컴포넌트를 올바르게 사용하지 않으면 시스템이 앱을 강제..
The different app startup states 앱을 처음부터 시작하는 cold start를 기준으로 최적화하는 것이 권장된다. 최적화 지표를 위한 지표는 다음과 같다: TTID: time to initial display TTFD: time to fully drawn Cold start 앱이 처음부터 시작하는 것을 의미한다. 기기 부팅된 뒤 앱이 처음으로 시작될 때, 앱이 시스템으로부터 종료된 후 앱이 시작될 때 콜드 스타트가 발생한다. 소요 시간이 가장 긴 유형이다. 콜드 스타트 초기에 시스템은 다음과 같은 작업을 수행한다: 앱 로드 및 시작 앱 시작 후 곧바로 blank starting window 띄움 앱 프로세스 생성 앱 프로세스가 생성되면 프로세스는 다음과 같은 작업을 수행한다: a..
배경Room에 새 테이블로 User를 추가하였더니 아래와 같은 에러가 발생하였다.error: There is a problem with the query: [SQLITE_ERROR] SQL error or missing database (no such table: user)GPT에 의하면 이 경우 DB 버전을 올린 뒤 database에 migration strategy를 제공하라고 하였다:1. Update Database Version@Database(entities = [TaskEntity::class], version = 2)abstract class NnDatabase : RoomDatabase() { abstract fun taskDao(): TaskDao abstract fun use..
ViewModel 생성 방법 ViewModelStore, ViewModelProvider에 대해 알아보기 전에, ViewModel을 어떻게 생성할 수 있는지부터 파악하여 top-down으로 알아보고자 한다. ViewModelProvider를 통한 생성 ViewModelProvider라는 클래스를 생성하고 get 함수를 통해 뷰모델을 얻을 수 있다. 이때 ViewModelProvider.Factory라고 하는, 뷰모델 생성 방식을 정의한 인터페이스를 따로 넣어줄 수도 있다. 지정하지 않으면 디폴트 팩토리를 사용하게 된다. class MyActivity : AppCompatActivity() { private lateinit var myViewModel: MyViewModel override fun onCr..
오버랩 이슈 페이드 인, 페이드 아웃이 진행될 때 새로 나타나는 뷰가 잠시 아래로 밀려있는 이슈가 발생하였다. 기존 코드 AnimatedVisibility(visible = uiState is TodoUiState.Success) { TodoScreenSuccess() } AnimatedVisibility(visible = uiState is TodoUiState.Empty) { TodoScreenEmpty() } 문제 원인 페이드 인과 페이드 아웃이 아래처럼 진행되는데, t0
무엇을 했는가? 1. 면접 경험 3번의 면접 경험을 통해 제게 부족한 점들을 깨달을 수 있었습니다. 그것들 중 가장 치명적이었던 내용은 다음과 같습니다: - Kotlin 언어에 대한 지식 부족: Android 개발에 집중하다 보니 Kotlin에 충분히 신경 쓰지 못했습니다. 이를 극복하기 위해 Kotlin 공식 문서와 'Effective Kotlin' 책을 읽고 블로그에 66개 글을 게시하며 지식을 공유했습니다. - 코드에 대한 깊은 이해 부족: 직접 작성한 코드에 대한 상세한 이해가 부족했습니다. 이를 해결하기 위해, 평소에 아무런 생각 없이 타이핑 했던 모든 코드들에 의문을 갖고 그렇게 했어야 하는 이유를 생각하고자 했고, 공식 문서를 읽거나 코드 레벨로 구현을 살펴보며, 안드로이드 프레임워크를 심층..